MCPcopy Index your code
hub / github.com/python-websockets/websockets / test_receive_junk_request

Method test_receive_junk_request

tests/test_server.py:242–258  ·  view source on GitHub ↗

Server receives a junk handshake request.

(self)

Source from the content-addressed store, hash-verified

240 )
241
242 def test_receive_junk_request(self):
243 """Server receives a junk handshake request."""
244 server = ServerProtocol()
245 server.receive_data(b"HELO relay.invalid\r\n")
246 server.receive_data(b"MAIL FROM: <alice@invalid>\r\n")
247 server.receive_data(b"RCPT TO: <bob@invalid>\r\n")
248
249 self.assertIsInstance(server.handshake_exc, InvalidMessage)
250 self.assertEqual(
251 str(server.handshake_exc),
252 "did not receive a valid HTTP request",
253 )
254 self.assertIsInstance(server.handshake_exc.__cause__, ValueError)
255 self.assertEqual(
256 str(server.handshake_exc.__cause__),
257 "invalid HTTP request line: HELO relay.invalid",
258 )
259
260
261class ResponseTests(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

ServerProtocolClass · 0.85
receive_dataMethod · 0.80

Tested by

no test coverage detected