Skip to content

Commit 470519d

Browse files
committed
test: fix capture_ws TestClient host for loopback guard
Follow-up to f15f6d9 (WS loopback guard on /ws/transcribe). The functional tests in tests/test_capture_ws.py constructed TestClient with the Starlette default client=("testclient", 50000), which the guard's _LOOPBACK_HOSTS allow-list rejects. PR #84 established the fix pattern for HTTP tests: explicitly pass client=("127.0.0.1", 50000) to TestClient — same security property, same semantics. Applied here. 3 tests previously failing now pass: - test_eof_text_frame_triggers_final_without_disconnect - test_legacy_disconnect_still_finalizes - test_empty_binary_frame_acts_as_eof
1 parent 282c10a commit 470519d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/test_capture_ws.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ async def fake_full(_chunks):
4545
monkeypatch.setattr(cw, "_transcribe_buffer_full", fake_full)
4646

4747
from main import app
48-
return TestClient(app)
48+
# client=("127.0.0.1", 50000) matches the loopback allow-list in
49+
# backend/api/routers/capture_ws.py:_LOOPBACK_HOSTS. Starlette's default
50+
# TestClient uses client=("testclient", 50000), which the WS guard rejects.
51+
# Matches the pattern PR #84 established for HTTP TestClient fixtures.
52+
return TestClient(app, client=("127.0.0.1", 50000))
4953

5054

5155
def _audio_chunk(n_bytes: int = 20_000) -> bytes:

0 commit comments

Comments
 (0)