def test_getExtension_with_duplicated_extensions(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), [], extensions=[TLSExtension().create(0, bytearray(0)), SNIExtension().create(b'localhost')]) with self.assertRaises(TLSInternalError): client_hello.getExtension(0)
def test_getExtension_with_duplicated_extensions(self): client_hello = ClientHello().create( (3, 3), bytearray(1), bytearray(0), [], extensions=[ TLSExtension().create(0, bytearray(0)), SNIExtension().create(b'localhost') ]) with self.assertRaises(TLSInternalError): client_hello.getExtension(0)
def test_getExtension_with_present_id(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), [], extensions=[TLSExtension().create(0, bytearray(0))]) ext = client_hello.getExtension(0) self.assertEqual(ext, TLSExtension().create(0, bytearray(0)))
def test_getExtension(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), [], extensions=[TLSExtension().create(0, bytearray(0))]) ext = client_hello.getExtension(1) self.assertIsNone(ext)
def test_getExtension_with_present_id(self): client_hello = ClientHello().create( (3, 3), bytearray(1), bytearray(0), [], extensions=[TLSExtension().create(0, bytearray(0))]) ext = client_hello.getExtension(0) self.assertEqual(ext, TLSExtension().create(0, bytearray(0)))
def test_getExtension(self): client_hello = ClientHello().create( (3, 3), bytearray(1), bytearray(0), [], extensions=[TLSExtension().create(0, bytearray(0))]) ext = client_hello.getExtension(1) self.assertIsNone(ext)
def test_server_name(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), []) client_hello.server_name = b'example.com' self.assertEqual(client_hello.server_name, b'example.com') client_hello.server_name = b'example.org' self.assertEqual(client_hello.server_name, b'example.org') ext = client_hello.getExtension(ExtensionType.server_name) self.assertIsNotNone(ext)
def test_supports_npn(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), []) self.assertFalse(client_hello.supports_npn) client_hello.supports_npn = True self.assertTrue(client_hello.supports_npn) client_hello.supports_npn = True self.assertTrue(client_hello.supports_npn) ext = client_hello.getExtension(ExtensionType.supports_npn) self.assertIsNotNone(ext) client_hello.supports_npn = False self.assertFalse(client_hello.supports_npn) ext = client_hello.getExtension(ExtensionType.supports_npn) self.assertIsNone(ext)
def test_tack(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), []) self.assertFalse(client_hello.tack) client_hello.tack = True self.assertTrue(client_hello.tack) client_hello.tack = True self.assertTrue(client_hello.tack) ext = client_hello.getExtension(ExtensionType.tack) self.assertIsNotNone(ext) client_hello.tack = False self.assertFalse(client_hello.tack) ext = client_hello.getExtension(ExtensionType.tack) self.assertIsNone(ext)
def test_srp_username(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), []) self.assertIsNone(client_hello.srp_username) client_hello.srp_username = b'my-name' self.assertEqual(client_hello.srp_username, b'my-name') client_hello.srp_username = b'her-name' self.assertEqual(client_hello.srp_username, b'her-name') ext = client_hello.getExtension(ExtensionType.srp) self.assertEqual(ext.identity, b'her-name')
def test_certificate_types(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), []) self.assertEqual(client_hello.certificate_types, [0]) client_hello.certificate_types = [0, 1] self.assertEqual(client_hello.certificate_types, [0, 1]) client_hello.certificate_types = [0, 1, 2] self.assertEqual(client_hello.certificate_types, [0, 1, 2]) ext = client_hello.getExtension(ExtensionType.cert_type) self.assertEqual(ext.certTypes, [0, 1, 2])
def test_certificate_types(self): client_hello = ClientHello().create((3, 3), bytearray(1), bytearray(0), []) self.assertEqual(client_hello.certificate_types, [0]) client_hello.certificate_types = [0, 1] self.assertEqual(client_hello.certificate_types, [0, 1]) client_hello.certificate_types = [0, 1, 2] self.assertEqual(client_hello.certificate_types, [0, 1, 2]) ext = client_hello.getExtension(ExtensionType.cert_type) self.assertEqual(ext.cert_types, [0, 1, 2])