MCPcopy
hub / github.com/aio-libs/aiohttp / test_protocol_key

Function test_protocol_key

tests/test_websocket_handshake.py:66–86  ·  view source on GitHub ↗
(message, transport)

Source from the content-addressed store, hash-verified

64
65
66def test_protocol_key(message, transport):
67 message.headers.extend([('UPGRADE', 'websocket'),
68 ('CONNECTION', 'upgrade'),
69 ('SEC-WEBSOCKET-VERSION', '13')])
70 with pytest.raises(errors.HttpBadRequest):
71 websocket.do_handshake(message.method, message.headers, transport)
72
73 message.headers.extend([('UPGRADE', 'websocket'),
74 ('CONNECTION', 'upgrade'),
75 ('SEC-WEBSOCKET-VERSION', '13'),
76 ('SEC-WEBSOCKET-KEY', '123')])
77 with pytest.raises(errors.HttpBadRequest):
78 websocket.do_handshake(message.method, message.headers, transport)
79
80 sec_key = base64.b64encode(os.urandom(2))
81 message.headers.extend([('UPGRADE', 'websocket'),
82 ('CONNECTION', 'upgrade'),
83 ('SEC-WEBSOCKET-VERSION', '13'),
84 ('SEC-WEBSOCKET-KEY', sec_key.decode())])
85 with pytest.raises(errors.HttpBadRequest):
86 websocket.do_handshake(message.method, message.headers, transport)
87
88
89def test_handshake(message, transport):

Callers

nothing calls this directly

Calls 2

extendMethod · 0.80
decodeMethod · 0.80

Tested by

no test coverage detected