class ChallengeTest(unittest.TestCase): def setUp(self): challs = ( challenges.SimpleHTTPS(token='IlirfxKKXAsHtmzK29Pj8A'), challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA'), challenges.RecoveryToken(), ) combinations = ((0, 2), (1, 2)) from letsencrypt.acme.messages import Challenge self.msg = Challenge( session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', challenges=challs, combinations=combinations) self.jmsg_to = { 'type': 'challenge', 'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4', 'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ', 'challenges': challs, 'combinations': combinations, } self.jmsg_from = { 'type': 'challenge', 'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4', 'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ', 'challenges': [chall.fully_serialize() for chall in challs], 'combinations': [[0, 2], [1, 2]], # TODO array tuples } def test_resolved_combinations(self): self.assertEqual(self.msg.resolved_combinations, ( ( challenges.SimpleHTTPS(token='IlirfxKKXAsHtmzK29Pj8A'), challenges.RecoveryToken() ), ( challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA'), challenges.RecoveryToken(), ) )) def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg_to) def test_from_json(self): from letsencrypt.acme.messages import Challenge self.assertEqual(Challenge.from_json(self.jmsg_from), self.msg) def test_json_without_optionals(self): del self.jmsg_from['combinations'] del self.jmsg_to['combinations'] from letsencrypt.acme.messages import Challenge msg = Challenge.from_json(self.jmsg_from) self.assertEqual(msg.combinations, ()) self.assertEqual(msg.to_json(), self.jmsg_to)
class ChallengeTest(unittest.TestCase): def setUp(self): challs = ( challenges.SimpleHTTPS(token='IlirfxKKXAsHtmzK29Pj8A'), challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA'), challenges.RecoveryToken(), ) combinations = ((0, 2), (1, 2)) from letsencrypt.acme.messages import Challenge self.msg = Challenge( session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', challenges=challs, combinations=combinations) self.jmsg_to = { 'type': 'challenge', 'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4', 'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ', 'challenges': challs, 'combinations': combinations, } self.jmsg_from = { 'type': 'challenge', 'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4', 'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ', 'challenges': [chall.fully_serialize() for chall in challs], 'combinations': [[0, 2], [1, 2]], # TODO array tuples } def test_resolved_combinations(self): self.assertEqual(self.msg.resolved_combinations, ( ( challenges.SimpleHTTPS(token='IlirfxKKXAsHtmzK29Pj8A'), challenges.RecoveryToken() ), ( challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA'), challenges.RecoveryToken(), ) )) def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg_to) def test_from_json(self): from letsencrypt.acme.messages import Challenge self.assertEqual(Challenge.from_json(self.jmsg_from), self.msg) def test_json_without_optionals(self): del self.jmsg_from['combinations'] del self.jmsg_to['combinations'] from letsencrypt.acme.messages import Challenge msg = Challenge.from_json(self.jmsg_from) self.assertEqual(msg.combinations, ()) self.assertEqual(msg.to_json(), self.jmsg_to)
class ChallengeTest(unittest.TestCase): def setUp(self): challenges = [ { 'type': 'simpleHttps', 'token': 'IlirfxKKXAsHtmzK29Pj8A' }, { 'type': 'dns', 'token': 'DGyRejmCefe7v4NfDGDKfA' }, { 'type': 'recoveryToken' }, ] combinations = [[0, 2], [1, 2]] from letsencrypt.acme.messages import Challenge self.msg = Challenge( session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', challenges=challenges, combinations=combinations) self.jmsg = { 'type': 'challenge', 'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4', 'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ', 'challenges': challenges, 'combinations': combinations, } def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg) def test_from_json(self): from letsencrypt.acme.messages import Challenge self.assertEqual(Challenge.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['combinations'] from letsencrypt.acme.messages import Challenge msg = Challenge.from_json(self.jmsg) self.assertEqual(msg.combinations, []) self.assertEqual(msg.to_json(), self.jmsg)
class ChallengeTest(unittest.TestCase): def setUp(self): challenges = [ {'type': 'simpleHttps', 'token': 'IlirfxKKXAsHtmzK29Pj8A'}, {'type': 'dns', 'token': 'DGyRejmCefe7v4NfDGDKfA'}, {'type': 'recoveryToken'}, ] combinations = [[0, 2], [1, 2]] from letsencrypt.acme.messages import Challenge self.msg = Challenge( session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', challenges=challenges, combinations=combinations) self.jmsg = { 'type': 'challenge', 'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4', 'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ', 'challenges': challenges, 'combinations': combinations, } def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg) def test_from_json(self): from letsencrypt.acme.messages import Challenge self.assertEqual(Challenge.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['combinations'] from letsencrypt.acme.messages import Challenge msg = Challenge.from_json(self.jmsg) self.assertEqual(msg.combinations, []) self.assertEqual(msg.to_json(), self.jmsg)