── Tests ───────────────────────────────────────────────────────
(t *testing.T)
| 132 | // ── Tests ─────────────────────────────────────────────────────── |
| 133 | |
| 134 | func 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. |
nothing calls this directly
no test coverage detected