def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate(certificate=CERT, chain=[CERT], refresh=refresh) self.jmsg = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': [jose.b64encode(CERT.as_der())], 'refresh': refresh, }
def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate( certificate=CERT, chain=(CERT,), refresh=refresh) self.jmsg_to = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': (jose.b64encode(CERT.as_der()),), 'refresh': refresh, } self.jmsg_from = self.jmsg_to.copy() # TODO: schema validation array tuples self.jmsg_from['chain'] = list(self.jmsg_from['chain'])
class CertificateTest(unittest.TestCase): def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate( certificate=CERT, chain=[CERT], refresh=refresh) self.jmsg = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': [jose.b64encode(CERT.as_der())], 'refresh': refresh, } def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg) def test_from_json(self): from letsencrypt.acme.messages import Certificate self.assertEqual(Certificate.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['chain'] del self.jmsg['refresh'] from letsencrypt.acme.messages import Certificate msg = Certificate.from_json(self.jmsg) self.assertEqual(msg.chain, []) self.assertTrue(msg.refresh is None) self.assertEqual(self.jmsg, msg.to_json())
class CertificateTest(unittest.TestCase): def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate(certificate=CERT, chain=[CERT], refresh=refresh) self.jmsg = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': [jose.b64encode(CERT.as_der())], 'refresh': refresh, } def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg) def test_from_json(self): from letsencrypt.acme.messages import Certificate self.assertEqual(Certificate.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['chain'] del self.jmsg['refresh'] from letsencrypt.acme.messages import Certificate msg = Certificate.from_json(self.jmsg) self.assertEqual(msg.chain, []) self.assertTrue(msg.refresh is None) self.assertEqual(self.jmsg, msg.to_json())
def test_json_without_optionals(self): del self.jmsg['chain'] del self.jmsg['refresh'] from letsencrypt.acme.messages import Certificate msg = Certificate.from_json(self.jmsg) self.assertEqual(msg.chain, []) self.assertTrue(msg.refresh is None) self.assertEqual(self.jmsg, msg.to_json())
def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate( certificate=CERT, chain=[CERT], refresh=refresh) self.jmsg = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': [jose.b64encode(CERT.as_der())], 'refresh': refresh, }
class CertificateTest(unittest.TestCase): def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate( certificate=CERT, chain=(CERT,), refresh=refresh) self.jmsg_to = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': (jose.b64encode(CERT.as_der()),), 'refresh': refresh, } self.jmsg_from = self.jmsg_to.copy() # TODO: schema validation array tuples self.jmsg_from['chain'] = list(self.jmsg_from['chain']) def test_to_json(self): self.assertEqual(self.msg.to_json(), self.jmsg_to) def test_from_json(self): from letsencrypt.acme.messages import Certificate self.assertEqual(Certificate.from_json(self.jmsg_from), self.msg) def test_json_without_optionals(self): del self.jmsg_from['chain'] del self.jmsg_from['refresh'] del self.jmsg_to['chain'] del self.jmsg_to['refresh'] from letsencrypt.acme.messages import Certificate msg = Certificate.from_json(self.jmsg_from) self.assertEqual(msg.chain, ()) self.assertTrue(msg.refresh is None) self.assertEqual(self.jmsg_to, msg.to_json())
class CertificateTest(unittest.TestCase): def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' from letsencrypt.acme.messages import Certificate self.msg = Certificate( certificate=CERT, chain=(CERT,), refresh=refresh) self.jmsg_to = { 'type': 'certificate', 'certificate': jose.b64encode(CERT.as_der()), 'chain': (jose.b64encode(CERT.as_der()),), 'refresh': refresh, } self.jmsg_from = self.jmsg_to.copy() # TODO: schema validation array tuples self.jmsg_from['chain'] = list(self.jmsg_from['chain']) def test_to_partial_json(self): self.assertEqual(self.msg.to_partial_json(), self.jmsg_to) def test_from_json(self): from letsencrypt.acme.messages import Certificate self.assertEqual(Certificate.from_json(self.jmsg_from), self.msg) def test_json_without_optionals(self): del self.jmsg_from['chain'] del self.jmsg_from['refresh'] del self.jmsg_to['chain'] del self.jmsg_to['refresh'] from letsencrypt.acme.messages import Certificate msg = Certificate.from_json(self.jmsg_from) self.assertEqual(msg.chain, ()) self.assertTrue(msg.refresh is None) self.assertEqual(self.jmsg_to, msg.to_partial_json())
def test_from_json(self): from letsencrypt.acme.messages import Certificate self.assertEqual(Certificate.from_json(self.jmsg_from), self.msg)