mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 19:02:52 +02:00
Merge branch 'test-add_dns01_challenge' into add_dns01_challenge
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
"""ACME Identifier Validation Challenges."""
|
"""ACME Identifier Validation Challenges."""
|
||||||
import abc
|
import abc
|
||||||
import base64
|
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
import dns.exception
|
import dns.exception
|
||||||
import functools
|
import functools
|
||||||
@@ -283,8 +282,7 @@ class DNS01(KeyAuthorizationChallenge):
|
|||||||
LABEL = "_acme-challenge"
|
LABEL = "_acme-challenge"
|
||||||
"""Label clients prepend to the domain name being validated."""
|
"""Label clients prepend to the domain name being validated."""
|
||||||
|
|
||||||
# FIXME: Remove extra parameter once #2052 is integrated
|
def validation(self, account_key, **unused_kwargs):
|
||||||
def validation(self, account_key, dns01_hexdigit_response=True, **unused_kwargs):
|
|
||||||
"""Generate validation.
|
"""Generate validation.
|
||||||
|
|
||||||
:param JWK account_key:
|
:param JWK account_key:
|
||||||
@@ -292,9 +290,7 @@ class DNS01(KeyAuthorizationChallenge):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
key_authorization = self.key_authorization(account_key)
|
key_authorization = self.key_authorization(account_key)
|
||||||
if dns01_hexdigit_response:
|
return jose.b64encode(hashlib.sha256(key_authorization).digest())
|
||||||
return hashlib.sha256(key_authorization).hexdigest()
|
|
||||||
return base64.urlsafe_b64encode(hashlib.sha256(key_authorization).digest())
|
|
||||||
|
|
||||||
def validation_domain_name(self, name):
|
def validation_domain_name(self, name):
|
||||||
"""Domain name for TXT validation record.
|
"""Domain name for TXT validation record.
|
||||||
|
|||||||
@@ -168,17 +168,10 @@ class DNS01Test(unittest.TestCase):
|
|||||||
self.assertEqual('_acme-challenge.www.example.com',
|
self.assertEqual('_acme-challenge.www.example.com',
|
||||||
self.msg.validation_domain_name('www.example.com'))
|
self.msg.validation_domain_name('www.example.com'))
|
||||||
|
|
||||||
# FIXME: Remove extra parameter once #2052 is integrated
|
|
||||||
def test_validation(self):
|
def test_validation(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"rAa7iIg4K2y63fvUhCfy8dP1Xl7wEhmQq0oChTcE3Zk=",
|
"rAa7iIg4K2y63fvUhCfy8dP1Xl7wEhmQq0oChTcE3Zk",
|
||||||
self.msg.validation(KEY, dns01_hexdigit_response=False))
|
self.msg.validation(KEY))
|
||||||
|
|
||||||
# FIXME: Remove this once #2052 is integrated
|
|
||||||
def test_validation_for_server_with_hexdigit_response(self):
|
|
||||||
self.assertEqual(
|
|
||||||
"ac06bb8888382b6cbaddfbd48427f2f1d3f55e5ef0121990ab4a02853704dd99",
|
|
||||||
self.msg.validation(KEY, dns01_hexdigit_response=True))
|
|
||||||
|
|
||||||
def test_to_partial_json(self):
|
def test_to_partial_json(self):
|
||||||
self.assertEqual(self.jmsg, self.msg.to_partial_json())
|
self.assertEqual(self.jmsg, self.msg.to_partial_json())
|
||||||
|
|||||||
Reference in New Issue
Block a user