diff --git a/internal/safemode/example_api_keys.go b/internal/safemode/example_api_keys.go index 066c02d9..8e899755 100644 --- a/internal/safemode/example_api_keys.go +++ b/internal/safemode/example_api_keys.go @@ -73,7 +73,7 @@ func WarningServerURL(cfg *config.Config) string { func NewExampleAPIKeyWarningHandler(configPath string, keys []string) http.Handler { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - if r.URL == nil || r.URL.Path != "/" { + if r.URL == nil || (r.URL.Path != "/" && r.URL.Path != "/management.html") { http.NotFound(w, r) return } diff --git a/internal/safemode/example_api_keys_test.go b/internal/safemode/example_api_keys_test.go index 2aaf5471..6f37b04b 100644 --- a/internal/safemode/example_api_keys_test.go +++ b/internal/safemode/example_api_keys_test.go @@ -59,6 +59,16 @@ func TestExampleAPIKeyWarningHandler(t *testing.T) { } } + req = httptest.NewRequest(http.MethodGet, "/management.html", nil) + w = httptest.NewRecorder() + handler.ServeHTTP(w, req) + if w.Code != http.StatusOK { + t.Fatalf("GET /management.html status = %d, want %d", w.Code, http.StatusOK) + } + if body := w.Body.String(); !strings.Contains(body, "Example API key detected") { + t.Fatalf("GET /management.html body missing warning: %s", body) + } + req = httptest.NewRequest(http.MethodHead, "/", nil) w = httptest.NewRecorder() handler.ServeHTTP(w, req)