diff --git a/src/ratatoskr/web/server.py b/src/ratatoskr/web/server.py index 80518f2..70269d2 100644 --- a/src/ratatoskr/web/server.py +++ b/src/ratatoskr/web/server.py @@ -572,9 +572,10 @@ async def _session_bifrost_endpoint(request: Request) -> JSONResponse: """GET /api/sessions/{session_id}/bifrost → admin-scoped Bifrost dispatch state (#176). The admin key is SERVER-HELD (app.state.admin_key) and never reaches the - browser (INV-003 precedent — upstream credentials stay server-side); the - wrapper overrides the Authorization header with it. Fail-visible when the - admin key isn't configured (never a silent empty pane).""" + browser (INV-003 precedent — upstream credentials stay server-side); it rides on + the wt client's `admin_auth` (`_wt_client(admin_key=…)`), which the SDK uses for + the `admin.*` routes (NOT a per-call header — slice-6). Fail-visible when the admin + key isn't configured (never a silent empty pane).""" session_id = request.path_params["session_id"] admin_key = request.app.state.admin_key if not admin_key: # PRE-001: fail-visible, never silent diff --git a/tests/test_wt.py b/tests/test_wt.py index 47814f7..cabf3c4 100644 --- a/tests/test_wt.py +++ b/tests/test_wt.py @@ -1212,10 +1212,18 @@ class TestStreamAdminEventsWt: await _drain(stream_admin_events(_wtad(fake))) assert ei.value.status == 502 - async def test_connection_dropped_maps_and_carries_cursor(self) -> None: - # Both a connect-time failure (cursor None) and a mid-stream drop / resumable - # EOF (cursor set) surface as ConnectionDropped → SseConnectionDropped. + async def test_connection_dropped_carries_cursor(self) -> None: + # A mid-stream drop / resumable EOF carries the resume cursor. fake = _FakeAdmin(stream_error=wtsdk.ConnectionDropped("42")) with pytest.raises(SseConnectionDropped) as ei: await _drain(stream_admin_events(_wtad(fake))) assert ei.value.last_seen_sse_id == "42" + + async def test_connection_dropped_none_cursor_connect_time(self) -> None: + # A connect-time transport failure surfaces as ConnectionDropped(None) → + # SseConnectionDropped(last_seen_sse_id=None) (the map's other cursor shape; + # heid-code-review slice-6 test-gap). + fake = _FakeAdmin(stream_error=wtsdk.ConnectionDropped(None)) + with pytest.raises(SseConnectionDropped) as ei: + await _drain(stream_admin_events(_wtad(fake))) + assert ei.value.last_seen_sse_id is None