From 53f3f19f6dc5e996c97199fda0bb4857a658c087 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Thu, 5 Feb 2015 15:57:10 -0800 Subject: [PATCH] Check invalid cases for pack and unpack functions --- .../client/tests/standalone_authenticator_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/letsencrypt/client/tests/standalone_authenticator_test.py b/letsencrypt/client/tests/standalone_authenticator_test.py index a9bc087b6..7329ad84f 100644 --- a/letsencrypt/client/tests/standalone_authenticator_test.py +++ b/letsencrypt/client/tests/standalone_authenticator_test.py @@ -55,6 +55,18 @@ class PackAndUnpackTests(unittest.TestCase): self.assertEqual(pack_3bytes(0), chr(0)*3) self.assertEqual(pack_3bytes(12345678), chr(0xbc) + "aN") + def test_invalid_pack_and_unpack(self): + from letsencrypt.client.standalone_authenticator import \ + unpack_2bytes, unpack_3bytes, pack_2bytes, pack_3bytes + with self.assertRaises(AssertionError): + pack_2bytes(65537) + with self.assertRaises(AssertionError): + pack_3bytes(500000000) + with self.assertRaises(AssertionError): + unpack_2bytes("foo") + with self.assertRaises(AssertionError): + unpack_3bytes("food") + class TLSParseClientHelloTest(unittest.TestCase): """Test for tls_parse_client_hello() function."""