MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestHandler_NoToken

Function TestHandler_NoToken

internal/ws/handler_test.go:134–150  ·  view source on GitHub ↗

── Tests ───────────────────────────────────────────────────────

(t *testing.T)

Source from the content-addressed store, hash-verified

132// ── Tests ───────────────────────────────────────────────────────
133
134func TestHandler_NoToken(t *testing.T) {
135 hub := NewHub()
136 defer hub.Close()
137 store := &mockStore{}
138 handler := NewHandler(hub, store)
139 srv := startServer(t, handler)
140
141 resp := doHTTP(t, srv, "bot@agents.e2a.dev", "")
142 defer resp.Body.Close()
143 if resp.StatusCode != http.StatusUnauthorized {
144 t.Fatalf("expected 401, got %d", resp.StatusCode)
145 }
146 body, _ := io.ReadAll(resp.Body)
147 if !strings.Contains(string(body), "Authorization: Bearer") {
148 t.Fatalf("unexpected body: %s", body)
149 }
150}
151
152// TestHandler_QueryTokenRejected pins the cutover: the legacy `?token=<key>`
153// query parameter is no longer accepted — only the Authorization: Bearer header.

Callers

nothing calls this directly

Calls 5

CloseMethod · 0.95
NewHubFunction · 0.85
NewHandlerFunction · 0.85
startServerFunction · 0.85
doHTTPFunction · 0.85

Tested by

no test coverage detected