mirror of
https://github.com/certbot/certbot.git
synced 2026-06-06 07:12:54 -04:00
acme/challenge_request handles only 1 domain name
No other functions inside acme/ handle lists, so to keep the class consistent, challenge_request() should only handle a string parameter. Iteration should be moved to the client, which is handling the list of domain names anyway.
This commit is contained in:
parent
90aab1ab7e
commit
ad5c2d0a4d
3 changed files with 35 additions and 7 deletions
|
|
@ -62,21 +62,20 @@ def pretty(json_string):
|
|||
return json.dumps(json.loads(json_string), indent=4)
|
||||
|
||||
|
||||
def challenge_request(names):
|
||||
def challenge_request(name):
|
||||
"""Create ACME "challengeRequest message.
|
||||
|
||||
TODO: Temporarily only enabling one name
|
||||
|
||||
:param names: TODO
|
||||
:type names: list
|
||||
:param name: Domain name
|
||||
:type name: unicode
|
||||
|
||||
:returns: ACME "challengeRequest" message.
|
||||
:rtype: dict
|
||||
|
||||
"""
|
||||
|
||||
return {
|
||||
"type": "challengeRequest",
|
||||
"identifier": names[0],
|
||||
"identifier": name,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Tests for letsencrypt.client.acme."""
|
||||
import unittest
|
||||
|
||||
|
|
@ -53,6 +55,30 @@ class PrettyTest(unittest.TestCase):
|
|||
self._call('{"foo": {"bar": "baz"}}'),
|
||||
'{\n "foo": {\n "bar": "baz"\n }\n}')
|
||||
|
||||
class ChallengeRequestTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.client.acme.challenge_request_test"""
|
||||
|
||||
def test_parameter_becomes_result(self):
|
||||
"""Test parameter is passed to result object unchanged"""
|
||||
from letsencrypt.client.acme import challenge_request
|
||||
self.assertEqual(
|
||||
challenge_request("domainname"),
|
||||
{
|
||||
"type": "challengeRequest",
|
||||
"identifier": "domainname",
|
||||
}
|
||||
)
|
||||
|
||||
def test_supports_unicode(self):
|
||||
"""Test support unicode parameter"""
|
||||
from letsencrypt.client.acme import challenge_request
|
||||
self.assertEqual(
|
||||
challenge_request(u'unicode'),
|
||||
{
|
||||
"type": "challengeRequest",
|
||||
"identifier": u'unicode',
|
||||
}
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -130,12 +130,15 @@ class Client(object):
|
|||
def acme_challenge(self):
|
||||
"""Handle ACME "challenge" phase.
|
||||
|
||||
TODO: Handle more than one domain name in self.names
|
||||
|
||||
:returns: ACME "challenge" message.
|
||||
:rtype: dict
|
||||
|
||||
"""
|
||||
|
||||
return self.send_and_receive_expected(
|
||||
acme.challenge_request(self.names), "challenge")
|
||||
acme.challenge_request(self.names[0]), "challenge")
|
||||
|
||||
def acme_authorization(self, challenge_msg, chal_objs, responses):
|
||||
"""Handle ACME "authorization" phase.
|
||||
|
|
|
|||
Loading…
Reference in a new issue