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

Function test_handshake

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

Source from the content-addressed store, hash-verified

87
88
89def test_handshake(message, transport):
90 hdrs, sec_key = gen_ws_headers()
91
92 message.headers.extend(hdrs)
93 status, headers, parser, writer, protocol = websocket.do_handshake(
94 message.method, message.headers, transport)
95 assert status == 101
96 assert protocol is None
97
98 key = base64.b64encode(
99 hashlib.sha1(sec_key.encode() + websocket.WS_KEY).digest())
100 headers = dict(headers)
101 assert headers['SEC-WEBSOCKET-ACCEPT'] == key.decode()
102
103
104def test_handshake_protocol(message, transport):

Callers

nothing calls this directly

Calls 4

gen_ws_headersFunction · 0.85
extendMethod · 0.80
encodeMethod · 0.80
decodeMethod · 0.80

Tested by

no test coverage detected