From 834549875d0984ef832995b23f26153f73e31434 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 17 Dec 2025 20:09:51 +0000 Subject: [PATCH] test(api): allow printable alert IDs for acknowledge (Related to #852) --- internal/api/router_integration_test.go | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/api/router_integration_test.go b/internal/api/router_integration_test.go index 69b7593..17eac10 100644 --- a/internal/api/router_integration_test.go +++ b/internal/api/router_integration_test.go @@ -169,6 +169,32 @@ func TestVersionEndpointUsesRepoVersion(t *testing.T) { t.Fatalf("expected version to match release %q or runtime %q, got %s", releaseVersion, runtimeVersion, actual) } +func TestAlertAcknowledge_AllowsPrintableAlertIDs(t *testing.T) { + srv := newIntegrationServer(t) + + // This ID includes parentheses which were rejected in v5 RC builds due to overly strict + // validation. The request should make it to the alert manager, which returns 404 because + // the alert does not exist in this test environment. + alertID := "docker(host)-container-unhealthy" + escaped := url.PathEscape(alertID) + + req, err := http.NewRequest(http.MethodPost, srv.server.URL+"/api/alerts/"+escaped+"/acknowledge", nil) + if err != nil { + t.Fatalf("create request: %v", err) + } + + res, err := http.DefaultClient.Do(req) + if err != nil { + t.Fatalf("ack request failed: %v", err) + } + defer res.Body.Close() + + if res.StatusCode != http.StatusNotFound { + body, _ := io.ReadAll(res.Body) + t.Fatalf("unexpected status: got %d want %d, body=%s", res.StatusCode, http.StatusNotFound, string(body)) + } +} + func TestStateEndpointReturnsMockData(t *testing.T) { srv := newIntegrationServer(t)