예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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())
예제 #4
0
    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())
예제 #5
0
    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)
예제 #6
0
    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)