You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(tests): rewrite tests/test_websocket_auth.py::test_ws_valid_token_not_rejected for ticket-based auth (C-002 / #550) #765
tests/test_websocket_auth.py::TestWebSocketAuthentication::test_ws_valid_token_not_rejected (the integration variant, NOT tests/unit/test_websocket_auth.py) asserts that GET /ws?token=<JWT> does NOT return 403. Today the request correctly returns 403 because C-002 / #550 removed JWT-in-URL support in favor of single-use opaque tickets minted via POST /api/ws/ticket.
The integration test was missed when the unit-tier WebSocket-auth tests were updated for the ticket flow. The current behavior is correct production behavior; the test is misleading anyone running the integration suite into thinking there's a regression.
Context
Discovered via full test suite run on 2026-05-09:
FAILED test_websocket_auth.py::TestWebSocketAuthentication::test_ws_valid_token_not_rejected
E AssertionError: Valid token should not get 403
E assert 403 != 403
architecture.md "WebSocket Security (C-002, #550)" documents the new flow:
Client POST /api/ws/ticket (JWT in Authorization header) → backend mints a 32-byte urlsafe ticket, stores it in Redis with a 30s TTL, returns it.
Client connects to /ws?ticket=<opaque>. Backend atomically GETDELs the Redis key and only then accepts the WebSocket.
JWT never enters the WebSocket URL.
Acceptance Criteria
Test mints a ticket via POST /api/ws/ticket and connects to /ws?ticket=<opaque>.
Asserts the upgrade is accepted (101) or that the server does not reject with 403.
Add a negative test asserting /ws?token=<JWT> returns 403, pinning the new behavior so this regression cannot recur silently.
cd tests &&source .venv/bin/activate
pytest test_websocket_auth.py::TestWebSocketAuthentication::test_ws_valid_token_not_rejected -v
Why this matters
Today this failure looks like a regression to anyone running the suite, but it's actually the correct production behavior. The misleading test is a tax on every test-suite review.
Activity
fix(tests): rewrite /ws integration suite for ticket-based auth (#765) (
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
Release: v0.7.0 (#1319)