def setUp(self): jwk = jose.JWKRSA(key=KEY.publickey()) from acme.messages import Authorization self.msg = Authorization(recovery_token='tok', jwk=jwk, identifier='example.com') self.jmsg = { 'type': 'authorization', 'recoveryToken': 'tok', 'identifier': 'example.com', 'jwk': jwk, }
def setUp(self): from acme.messages import ChallengeBody from acme.messages import STATUS_VALID self.challbs = ( ChallengeBody( uri='http://challb1', status=STATUS_VALID, chall=challenges.SimpleHTTP(token=b'IlirfxKKXAsHtmzK29Pj8A')), ChallengeBody(uri='http://challb2', status=STATUS_VALID, chall=challenges.DNS( token=b'DGyRejmCefe7v4NfDGDKfA')), ChallengeBody(uri='http://challb3', status=STATUS_VALID, chall=challenges.RecoveryContact()), ) combinations = ((0, 2), (1, 2)) from acme.messages import Authorization from acme.messages import Identifier from acme.messages import IDENTIFIER_FQDN identifier = Identifier(typ=IDENTIFIER_FQDN, value='example.com') self.authz = Authorization( identifier=identifier, combinations=combinations, challenges=self.challbs) self.jobj_from = { 'identifier': identifier.to_json(), 'challenges': [challb.to_json() for challb in self.challbs], 'combinations': combinations, }
def test_json_without_optionals(self): del self.jmsg['recoveryToken'] del self.jmsg['identifier'] del self.jmsg['jwk'] from acme.messages import Authorization msg = Authorization.from_json(self.jmsg) self.assertTrue(msg.recovery_token is None) self.assertTrue(msg.identifier is None) self.assertTrue(msg.jwk is None) self.assertEqual(self.jmsg, msg.to_partial_json())
class AuthorizationTest(unittest.TestCase): def setUp(self): jwk = jose.JWKRSA(key=KEY.publickey()) from acme.messages import Authorization self.msg = Authorization(recovery_token='tok', jwk=jwk, identifier='example.com') self.jmsg = { 'type': 'authorization', 'recoveryToken': 'tok', 'identifier': 'example.com', 'jwk': jwk, } def test_to_partial_json(self): self.assertEqual(self.msg.to_partial_json(), self.jmsg) def test_from_json(self): self.jmsg['jwk'] = self.jmsg['jwk'].to_partial_json() from acme.messages import Authorization self.assertEqual(Authorization.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['recoveryToken'] del self.jmsg['identifier'] del self.jmsg['jwk'] from acme.messages import Authorization msg = Authorization.from_json(self.jmsg) self.assertTrue(msg.recovery_token is None) self.assertTrue(msg.identifier is None) self.assertTrue(msg.jwk is None) self.assertEqual(self.jmsg, msg.to_partial_json())
def test_from_json_hashable(self): from acme.messages import Authorization hash(Authorization.from_json(self.jobj_from))
def test_from_json(self): from acme.messages import Authorization Authorization.from_json(self.jobj_from)
def test_from_json(self): self.jmsg['jwk'] = self.jmsg['jwk'].to_partial_json() from acme.messages import Authorization self.assertEqual(Authorization.from_json(self.jmsg), self.msg)