def test_create(self): npn_extension = NPNExtension() npn_extension = npn_extension.create() self.assertEqual(None, npn_extension.protocols) self.assertEqual(13172, npn_extension.ext_type) self.assertEqual(bytearray(0), npn_extension.ext_data)
def test_create(self): npn_extension = NPNExtension() npn_extension = npn_extension.create() self.assertIsNone(npn_extension.protocols) self.assertEqual(13172, npn_extension.extType) self.assertEqual(bytearray(0), npn_extension.extData)
def test_write_with_list(self): npn_extension = NPNExtension() npn_extensnio = npn_extension.create([ bytearray(b'http/1.1'), bytearray(b'spdy/3')]) self.assertEqual(bytearray( b'\x33\x74' + # type of extension - NPN b'\x00\x10' + # length of extension b'\x08' + # length of name of protocol # utf-8 encoding of "http/1.1" b'\x68\x74\x74\x70\x2f\x31\x2e\x31' + b'\x06' + # length of name of protocol # utf-8 encoding of "spdy/3" b'\x73\x70\x64\x79\x2f\x33' ), npn_extension.write())
def test_write_with_list(self): npn_extension = NPNExtension() npn_extensnio = npn_extension.create( [bytearray(b'http/1.1'), bytearray(b'spdy/3')]) self.assertEqual( bytearray(b'\x33\x74' + # type of extension - NPN b'\x00\x10' + # length of extension b'\x08' + # length of name of protocol # utf-8 encoding of "http/1.1" b'\x68\x74\x74\x70\x2f\x31\x2e\x31' + b'\x06' + # length of name of protocol # utf-8 encoding of "spdy/3" b'\x73\x70\x64\x79\x2f\x33'), npn_extension.write())
def test_create_with_list_of_protocols(self): npn_extension = NPNExtension() npn_extension = npn_extension.create( [bytearray(b'http/1.1'), bytearray(b'spdy/3')]) self.assertEqual([bytearray(b'http/1.1'), bytearray(b'spdy/3')], npn_extension.protocols) self.assertEqual( bytearray(b'\x08' + # length of name of protocol # utf-8 encoding of "http/1.1" b'\x68\x74\x74\x70\x2f\x31\x2e\x31' + b'\x06' + # length of name of protocol # utf-8 encoding of "http/1.1" b'\x73\x70\x64\x79\x2f\x33'), npn_extension.extData)
def test_create_with_list_of_protocols(self): npn_extension = NPNExtension() npn_extension = npn_extension.create([ bytearray(b'http/1.1'), bytearray(b'spdy/3')]) self.assertEqual([ bytearray(b'http/1.1'), bytearray(b'spdy/3')], npn_extension.protocols) self.assertEqual(bytearray( b'\x08' + # length of name of protocol # utf-8 encoding of "http/1.1" b'\x68\x74\x74\x70\x2f\x31\x2e\x31' + b'\x06' + # length of name of protocol # utf-8 encoding of "http/1.1" b'\x73\x70\x64\x79\x2f\x33' ), npn_extension.ext_data)