Registration: TOS and agreement

This commit is contained in:
Jakub Warmuz
2015-03-24 17:07:52 +00:00
parent a6e1c3ed17
commit 2b4b86a41b
2 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -117,7 +117,7 @@ class RegistrationResource(Resource):
:ivar new_authz_uri: URI found in the 'next' Link header
"""
__slots__ = ('body', 'uri', 'new_authz_uri')
__slots__ = ('body', 'uri', 'new_authz_uri', 'terms_of_service')
class Registration(ResourceBody):
@@ -128,6 +128,7 @@ class Registration(ResourceBody):
key = jose.Field('key', omitempty=True, decoder=jose.JWK.from_json)
contact = jose.Field('contact', omitempty=True, default=())
recovery_token = jose.Field('recoveryToken', omitempty=True)
agreement = jose.Field('agreement', omitempty=True)
class ChallengeResource(Resource, jose.JSONObjectWithFields):
+6 -1
View File
@@ -36,14 +36,19 @@ class Network(object):
def register(self, contact=messages2.Registration._fields['contact'].default):
new_reg = messages2.Registration(contact=contact)
response = self._post(self.new_reg_uri, self._wrap_in_jws(new_reg))
assert response.status_code == httplib.CREATED # TODO: handle errors
terms_of_service = (response.links['next']['url']
if 'terms-of-service' in response.links else None)
regr = messages2.RegistrationResource(
body=messages2.Registration.from_json(response.json()),
uri=response.headers['location'],
new_authz_uri=response.links['next']['url'],
)
terms_of_service=terms_of_service)
assert regr.body.key == self.key.public()
return regr
def update_registration(self, regr):