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

Method test_no_origin

tests/test_server.py:550–562  ·  view source on GitHub ↗

Handshake fails when checking origin and the Origin header is missing.

(self)

Source from the content-addressed store, hash-verified

548 self.assertEqual(server.origin, "https://example.com")
549
550 def test_no_origin(self):
551 """Handshake fails when checking origin and the Origin header is missing."""
552 server = ServerProtocol(origins=["https://example.com"])
553 request = make_request()
554 response = server.accept(request)
555 server.send_response(response)
556
557 self.assertEqual(response.status_code, 403)
558 self.assertHandshakeError(
559 server,
560 InvalidOrigin,
561 "missing Origin header",
562 )
563
564 def test_unexpected_origin(self):
565 """Handshake fails when checking origin and the Origin header is unexpected."""

Callers

nothing calls this directly

Calls 5

acceptMethod · 0.95
send_responseMethod · 0.95
assertHandshakeErrorMethod · 0.95
ServerProtocolClass · 0.85
make_requestFunction · 0.85

Tested by

no test coverage detected