(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestBearerAuthMiddleware_MissingHeader(t *testing.T) { |
| 87 | cfg := &Config{Host: "127.0.0.1", Port: 8080, AuthToken: "secret"} |
| 88 | next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 89 | t.Error("next handler should not be called with missing header") |
| 90 | }) |
| 91 | |
| 92 | handler := BearerAuthMiddleware(cfg, next) |
| 93 | req := httptest.NewRequest(http.MethodPost, "/mcp", nil) |
| 94 | rr := httptest.NewRecorder() |
| 95 | handler.ServeHTTP(rr, req) |
| 96 | |
| 97 | if rr.Code != http.StatusUnauthorized { |
| 98 | t.Errorf("status = %d, want 401", rr.Code) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | func TestBearerAuthMiddleware_MalformedHeader(t *testing.T) { |
| 103 | cfg := &Config{Host: "127.0.0.1", Port: 8080, AuthToken: "secret"} |
nothing calls this directly
no test coverage detected