test: close remaining auth bug fix test coverage gaps - #196
AjayThorve merged 2 commits into
Conversation
Greptile SummaryThis PR adds test coverage for auth observability paths introduced in a prior bug-fix: RUM emission on HTTP 401s with Confidence Score: 5/5Test-only PR with no runtime changes; safe to merge. All changes are new or extended test files plus a one-line doc comment edit. No production code is modified, the previously flagged _authenticated_user bug is fixed, and the test assertions align correctly with the implementation in rum.ts, websocket-client.ts, and websocket_reconnect.py. Only P2 suggestions remain. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Backend
A[WebSocket message received] --> B{AuthError?}
B -- Yes --> C[create_websocket_message\ntype=ERROR, message=error_code]
B -- No --> D[logger.exception + return]
end
subgraph Frontend HTTP
E[authenticatedFetch] --> F{status === 401?}
F -- Yes --> G{JSON body?}
G -- Yes --> H[trackAuthEvent\nerrorCode, path]
G -- No --> I[skip silently]
end
subgraph Frontend WS
J[WebSocket onmessage] --> K{type === ERROR?}
K -- Yes --> L{message in authCodes?}
L -- Yes --> M[trackAuthEvent\nmessage, details, source=websocket]
L -- No --> N[onError only]
end
subgraph RUM Routing
H --> O{code in EXPECTED_AUTH_CODES?}
M --> O
O -- token_expired / token_missing --> P[DD_RUM.addAction]
O -- token_invalid / auth_error / other --> Q[DD_RUM.addError]
end
Reviews (4): Last reviewed commit: "test: align auth observability coverage" | Re-trigger Greptile |
Introduce a provider-registration pattern for client-side telemetry that decouples event tracking from any specific vendor (Datadog, Sentry, New Relic, etc.). All functions are no-ops until a deployment overlay registers a concrete provider via registerTelemetryProvider(). This lets external developers plug in their own APM without touching the public UI code. Exports: - TelemetryProvider interface (trackError + trackAction) - registerTelemetryProvider() — call once at app init - trackError() — unexpected failures (error tracking / alerting) - trackAction() — expected lifecycle events (analytics) - trackAuthEvent() — routes auth codes by expected/unexpected severity Includes documented event naming conventions (snake_case, domain-scoped) and 7 unit tests covering registration, routing, and no-op behavior. Follow-up: migrate existing rum.ts call sites to this module after PRs NVIDIA-AI-Blueprints#195/NVIDIA-AI-Blueprints#196 merge, and add the Datadog provider bridge in aiq-bp-internal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover remaining auth test gaps by validating HTTP/WS observability paths, SessionProvider refresh wiring, and websocket auth error propagation behavior. Made-with: Cursor Signed-off-by: Ajay Thorve <athorve@nvidia.com>
Signed-off-by: Ajay Thorve <athorve@nvidia.com>
73af05b to
35b60d2
Compare
…prints#196) * test: add missing auth phase-5 regression coverage Cover remaining auth test gaps by validating HTTP/WS observability paths, SessionProvider refresh wiring, and websocket auth error propagation behavior.
Summary
authenticated-fetch(401token_expired/token_invalidparsing and RUM emission)auth_errorpayloads emit RUM events while non-auth websocket errors do notProviderstests to lockSessionProviderrefresh interval wiring (config.sessionRefreshIntervalSecondswhen auth required,0otherwise)_run_workflowemits typedauth_errorwebsocket messages forAuthErrorTest plan
npm run test:ci -- --run src/adapters/api/authenticated-fetch.spec.ts src/adapters/api/websocket-client.spec.ts src/app/providers.spec.tsxuv run pytest frontends/aiq_api/tests/test_auth.py frontends/aiq_api/tests/test_auth_errors.pyMade with Cursor