summaryrefslogtreecommitdiffstats
path: root/internal/handler/websocket/handler_test.go
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-02-15 10:31:06 -0800
committerbndw <ben@bdw.to>2026-02-15 10:31:06 -0800
commitf658ef072394ff9fd28244ad475859c210e8ec16 (patch)
treecc08f5f3e09a1a75dd307a1439f53c5e6a27d0ac /internal/handler/websocket/handler_test.go
parent57bc300fe26812aad568c8119f04d92e94c9ab14 (diff)
feat: track authorized (authenticated + successful) requests
Add 'authorized' status for requests that complete successfully after authentication. This complements the existing 'unauthenticated' (pre-auth) status tracking. Now the dashboard shows: - Authorized: Authenticated requests that succeeded - Unauthorized: Authenticated requests rejected (not in allowlist) - Pre-Auth: Requests sent before authentication This gives full visibility into the auth flow: 1. Challenges: How many clients authenticated 2. Authorized: How many authenticated requests succeeded 3. Unauthorized: How many were rejected despite valid auth 4. Pre-Auth: How many tried before authenticating Updated metrics: - requests_total{status="authorized"} - authenticated successes - requests_total{status="ok"} - unauthenticated successes (when no auth)
Diffstat (limited to 'internal/handler/websocket/handler_test.go')
-rw-r--r--internal/handler/websocket/handler_test.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/handler/websocket/handler_test.go b/internal/handler/websocket/handler_test.go
index 10405b2..604a190 100644
--- a/internal/handler/websocket/handler_test.go
+++ b/internal/handler/websocket/handler_test.go
@@ -305,6 +305,13 @@ func TestAuthRequired(t *testing.T) {
305 t.Errorf("Expected OK true after auth, got false: %v", msg3[3]) 305 t.Errorf("Expected OK true after auth, got false: %v", msg3[3])
306 } 306 }
307 t.Logf("Publish succeeded after auth") 307 t.Logf("Publish succeeded after auth")
308
309 // Verify authorized requests are tracked in metrics
310 authorizedCount := ts.metrics.getRequestCount("EVENT", "authorized")
311 if authorizedCount == 0 {
312 t.Errorf("Expected authorized requests to be tracked in metrics, got 0")
313 }
314 t.Logf("Metrics: %d authorized requests tracked", authorizedCount)
308} 315}
309 316
310// TestAuthNotInAllowlist verifies that pubkeys not in allowlist are rejected 317// TestAuthNotInAllowlist verifies that pubkeys not in allowlist are rejected