mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 02:44:21 +02:00
Spec and Boulder compatibility fixes.
Relevant acme-spec: - https://github.com/letsencrypt/acme-spec/issues/127 - https://github.com/letsencrypt/acme-spec/pull/119 - https://github.com/letsencrypt/acme-spec/issues/98 - https://github.com/letsencrypt/acme-spec/issues/92 Relevant boulder: - https://github.com/letsencrypt/boulder/pull/170 - https://github.com/letsencrypt/boulder/issues/128
This commit is contained in:
@@ -18,11 +18,9 @@ class Error(jose.JSONObjectWithFields, Exception):
|
|||||||
'badCSR': 'The CSR is unacceptable (e.g., due to a short key)',
|
'badCSR': 'The CSR is unacceptable (e.g., due to a short key)',
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Boulder omits 'type' and 'instance', spec requires, boulder#128
|
|
||||||
typ = jose.Field('type', omitempty=True)
|
typ = jose.Field('type', omitempty=True)
|
||||||
title = jose.Field('title', omitempty=True)
|
title = jose.Field('title', omitempty=True)
|
||||||
detail = jose.Field('detail')
|
detail = jose.Field('detail')
|
||||||
instance = jose.Field('instance', omitempty=True)
|
|
||||||
|
|
||||||
@typ.encoder
|
@typ.encoder
|
||||||
def typ(value): # pylint: disable=missing-docstring,no-self-argument
|
def typ(value): # pylint: disable=missing-docstring,no-self-argument
|
||||||
@@ -227,10 +225,6 @@ class Authorization(ResourceBody):
|
|||||||
challenges = jose.Field('challenges', omitempty=True)
|
challenges = jose.Field('challenges', omitempty=True)
|
||||||
combinations = jose.Field('combinations', omitempty=True)
|
combinations = jose.Field('combinations', omitempty=True)
|
||||||
|
|
||||||
# TODO: acme-spec #92, #98
|
|
||||||
key = Registration._fields['key']
|
|
||||||
contact = Registration._fields['contact']
|
|
||||||
|
|
||||||
status = jose.Field('status', omitempty=True, decoder=Status.from_json)
|
status = jose.Field('status', omitempty=True, decoder=Status.from_json)
|
||||||
# TODO: 'expires' is allowed for Authorization Resources in
|
# TODO: 'expires' is allowed for Authorization Resources in
|
||||||
# general, but for Key Authorization '[t]he "expires" field MUST
|
# general, but for Key Authorization '[t]he "expires" field MUST
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ class Network(object):
|
|||||||
|
|
||||||
def _authzr_from_response(self, response, identifier,
|
def _authzr_from_response(self, response, identifier,
|
||||||
uri=None, new_cert_uri=None):
|
uri=None, new_cert_uri=None):
|
||||||
|
# pylint: disable=no-self-use
|
||||||
if new_cert_uri is None:
|
if new_cert_uri is None:
|
||||||
try:
|
try:
|
||||||
new_cert_uri = response.links['next']['url']
|
new_cert_uri = response.links['next']['url']
|
||||||
@@ -258,8 +259,7 @@ class Network(object):
|
|||||||
body=messages2.Authorization.from_json(response.json()),
|
body=messages2.Authorization.from_json(response.json()),
|
||||||
uri=response.headers.get('Location', uri),
|
uri=response.headers.get('Location', uri),
|
||||||
new_cert_uri=new_cert_uri)
|
new_cert_uri=new_cert_uri)
|
||||||
if (authzr.body.key != self.key.public()
|
if authzr.body.identifier != identifier:
|
||||||
or authzr.body.identifier != identifier):
|
|
||||||
raise errors.UnexpectedUpdate(authzr)
|
raise errors.UnexpectedUpdate(authzr)
|
||||||
return authzr
|
return authzr
|
||||||
|
|
||||||
|
|||||||
@@ -276,8 +276,6 @@ class PollChallengesTest(unittest.TestCase):
|
|||||||
identifier=authzr.body.identifier,
|
identifier=authzr.body.identifier,
|
||||||
challenges=new_challbs,
|
challenges=new_challbs,
|
||||||
combinations=authzr.body.combinations,
|
combinations=authzr.body.combinations,
|
||||||
key=authzr.body.key,
|
|
||||||
contact=authzr.body.contact,
|
|
||||||
status=status_,
|
status=status_,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class NetworkTest(unittest.TestCase):
|
|||||||
self.authz = messages2.Authorization(
|
self.authz = messages2.Authorization(
|
||||||
identifier=messages2.Identifier(
|
identifier=messages2.Identifier(
|
||||||
typ=messages2.IDENTIFIER_FQDN, value='example.com'),
|
typ=messages2.IDENTIFIER_FQDN, value='example.com'),
|
||||||
challenges=(challb,), combinations=None, key=KEY.public())
|
challenges=(challb,), combinations=None)
|
||||||
self.authzr = messages2.AuthorizationResource(
|
self.authzr = messages2.AuthorizationResource(
|
||||||
body=self.authz, uri=authzr_uri,
|
body=self.authz, uri=authzr_uri,
|
||||||
new_cert_uri='https://www.letsencrypt-demo.org/acme/new-cert')
|
new_cert_uri='https://www.letsencrypt-demo.org/acme/new-cert')
|
||||||
@@ -258,11 +258,10 @@ class NetworkTest(unittest.TestCase):
|
|||||||
# TODO: test POST call arguments
|
# TODO: test POST call arguments
|
||||||
|
|
||||||
# TODO: split here and separate test
|
# TODO: split here and separate test
|
||||||
authz_wrong_key = self.authz.update(key=KEY2.public())
|
self.response.json.return_value = self.authz.update(
|
||||||
self.response.json.return_value = authz_wrong_key.to_json()
|
identifier=self.identifier.update(value='foo')).to_json()
|
||||||
self.assertRaises(
|
self.assertRaises(errors.UnexpectedUpdate, self.net.request_challenges,
|
||||||
errors.UnexpectedUpdate, self.net.request_challenges,
|
self.identifier, self.authzr.uri)
|
||||||
self.identifier, self.regr)
|
|
||||||
|
|
||||||
def test_request_challenges_missing_next(self):
|
def test_request_challenges_missing_next(self):
|
||||||
self.response.status_code = httplib.CREATED
|
self.response.status_code = httplib.CREATED
|
||||||
@@ -336,6 +335,11 @@ class NetworkTest(unittest.TestCase):
|
|||||||
self.assertEqual((self.authzr, self.response),
|
self.assertEqual((self.authzr, self.response),
|
||||||
self.net.poll(self.authzr))
|
self.net.poll(self.authzr))
|
||||||
|
|
||||||
|
# TODO: split here and separate test
|
||||||
|
self.response.json.return_value = self.authz.update(
|
||||||
|
identifier=self.identifier.update(value='foo')).to_json()
|
||||||
|
self.assertRaises(errors.UnexpectedUpdate, self.net.poll, self.authzr)
|
||||||
|
|
||||||
def test_request_issuance(self):
|
def test_request_issuance(self):
|
||||||
self.response.content = CERT.as_der()
|
self.response.content = CERT.as_der()
|
||||||
self.response.headers['Location'] = self.certr.uri
|
self.response.headers['Location'] = self.certr.uri
|
||||||
|
|||||||
Reference in New Issue
Block a user