本文整理匯總了Python中acme.challenges.HTTP01屬性的典型用法代碼示例。如果您正苦於以下問題:Python challenges.HTTP01屬性的具體用法?Python challenges.HTTP01怎麽用?Python challenges.HTTP01使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類acme.challenges
的用法示例。
在下文中一共展示了challenges.HTTP01屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: supported_challb
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def supported_challb(authorization):
"""Find supported challenge body.
This plugin supports only `http-01`, so CA must offer it as a
single-element combo. If this is not the case this function returns
`None`.
Returns:
`acme.messages.ChallengeBody` with `http-01` challenge or `None`.
"""
for combo in authorization.body.combinations:
first_challb = authorization.body.challenges[combo[0]]
if len(combo) == 1 and isinstance(
first_challb.chall, challenges.HTTP01):
return first_challb
return None
示例2: supported_challb
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def supported_challb(authorization):
"""Find supported challenge body.
This plugin supports only `http-01`, so CA must offer it as a
single-element combo. If this is not the case this function returns
`None`.
Returns:
`acme.messages.ChallengeBody` with `http-01` challenge or `None`.
"""
if authorization.body.combinations is None:
for challenge in authorization.body.challenges:
if isinstance(challenge.chall, challenges.HTTP01):
return challenge
else:
for combo in authorization.body.combinations:
first_challb = authorization.body.challenges[combo[0]]
if len(combo) == 1 and isinstance(
first_challb.chall, challenges.HTTP01):
return first_challb
return None
示例3: get_chall_pref
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def get_chall_pref(self, domain):
# pylint: disable=missing-docstring,no-self-use,unused-argument
return [challenges.HTTP01]
示例4: test_start_responding
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def test_start_responding(self, token):
"""
Calling ``start_responding`` makes an appropriate resource available.
"""
challenge = challenges.HTTP01(token=token)
response = challenge.response(RSA_KEY_512)
responder = HTTP01Responder()
challenge_resource = Resource()
challenge_resource.putChild(b'acme-challenge', responder.resource)
root = Resource()
root.putChild(b'.well-known', challenge_resource)
client = StubTreq(root)
encoded_token = challenge.encode('token')
challenge_url = URL(host=u'example.com', path=[
u'.well-known', u'acme-challenge', encoded_token]).asText()
self.assertThat(client.get(challenge_url),
succeeded(MatchesStructure(code=Equals(404))))
responder.start_responding(u'example.com', challenge, response)
self.assertThat(client.get(challenge_url), succeeded(MatchesAll(
MatchesStructure(
code=Equals(200),
headers=AfterPreprocessing(
methodcaller('getRawHeaders', b'content-type'),
Equals([b'text/plain']))),
AfterPreprocessing(methodcaller('content'), succeeded(
Equals(response.key_authorization.encode('utf-8'))))
)))
# Starting twice before stopping doesn't break things
responder.start_responding(u'example.com', challenge, response)
self.assertThat(client.get(challenge_url),
succeeded(MatchesStructure(code=Equals(200))))
responder.stop_responding(u'example.com', challenge, response)
self.assertThat(client.get(challenge_url),
succeeded(MatchesStructure(code=Equals(404))))
示例5: get_chall_pref
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def get_chall_pref(self, unused_domain): # pylint: disable=no-self-use
"""Return list of challenge preferences."""
return [challenges.HTTP01]
示例6: get_chall_pref
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def get_chall_pref(self, domain):
return [challenges.HTTP01]
示例7: test_answer_challenge
# 需要導入模塊: from acme import challenges [as 別名]
# 或者: from acme.challenges import HTTP01 [as 別名]
def test_answer_challenge(self):
"""
`~txacme.client.Client.answer_challenge` responds to a challenge and
returns the updated challenge.
"""
key_authorization = u'blahblahblah'
uri = u'https://example.org/acme/authz/1/0'
sequence = RequestSequence(
[_nonce_response(
u'https://example.org/acme/authz/1/0',
b'Nonce'),
(MatchesListwise([
Equals(b'POST'),
Equals(uri),
Equals({}),
ContainsDict({b'Content-Type': Equals([JSON_CONTENT_TYPE])}),
on_jws(Equals({
u'resource': u'challenge',
u'type': u'http-01',
}))]),
(http.OK,
{b'content-type': JSON_CONTENT_TYPE,
b'replay-nonce': b64encode(b'Nonce2'),
b'link': b'<https://example.org/acme/authz/1>;rel="up"',
},
_json_dumps({
u'uri': uri,
u'type': u'http-01',
u'status': u'processing',
u'token': u'DGyRejmCefe7v4NfDGDKfA',
})))],
self.expectThat)
client = self.useFixture(
ClientFixture(sequence, key=RSA_KEY_512)).client
with sequence.consume(self.fail):
self.assertThat(
client.answer_challenge(
messages.ChallengeBody(
uri=uri,
chall=challenges.HTTP01(token=b'blahblah'),
status=messages.STATUS_PENDING),
challenges.HTTP01Response(
key_authorization=key_authorization)),
succeeded(MatchesStructure(
body=MatchesStructure(),
authzr_uri=Equals(
u'https://example.org/acme/authz/1'),
)))