From f3d20a1feaddf360360fa8ba4470d6c2170da86d Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 11 Nov 2025 23:02:45 +0000 Subject: [PATCH] Fix failing backend tests in preflight checks Fixes three test failures that were blocking release workflow: 1. TestApplyDockerReportGeneratesUniqueIDsForCollidingHosts: - Initialize dockerTokenBindings and dockerMetadataStore in test helper - These maps were nil causing panic on first access 2. TestSendGroupedAppriseHTTP & TestSendTestNotificationAppriseHTTP: - Configure allowlist to permit localhost (127.0.0.1) for test servers - SSRF protection was blocking httptest.NewServer() URLs - Tests need to allowlist the test server IP to bypass security checks Related to workflow fix in 5fa78c3e3. --- internal/monitoring/monitor_docker_test.go | 10 ++++++---- internal/notifications/notifications_test.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/monitoring/monitor_docker_test.go b/internal/monitoring/monitor_docker_test.go index ba5288533..33547e213 100644 --- a/internal/monitoring/monitor_docker_test.go +++ b/internal/monitoring/monitor_docker_test.go @@ -14,10 +14,12 @@ func newTestMonitor(t *testing.T) *Monitor { t.Helper() return &Monitor{ - state: models.NewState(), - alertManager: alerts.NewManager(), - removedDockerHosts: make(map[string]time.Time), - rateTracker: NewRateTracker(), + state: models.NewState(), + alertManager: alerts.NewManager(), + removedDockerHosts: make(map[string]time.Time), + rateTracker: NewRateTracker(), + dockerTokenBindings: make(map[string]string), + dockerMetadataStore: config.NewDockerMetadataStore(t.TempDir()), } } diff --git a/internal/notifications/notifications_test.go b/internal/notifications/notifications_test.go index 64589b49a..16cab0d1e 100644 --- a/internal/notifications/notifications_test.go +++ b/internal/notifications/notifications_test.go @@ -251,6 +251,11 @@ func TestSendGroupedAppriseHTTP(t *testing.T) { })) defer server.Close() + // Allow localhost for test server (SSRF protection normally blocks this) + if err := nm.UpdateAllowedPrivateCIDRs("127.0.0.1"); err != nil { + t.Fatalf("failed to configure allowlist: %v", err) + } + nm.SetAppriseConfig(AppriseConfig{ Enabled: true, Mode: AppriseModeHTTP, @@ -592,6 +597,11 @@ func TestSendTestNotificationAppriseHTTP(t *testing.T) { })) defer server.Close() + // Allow localhost for test server (SSRF protection normally blocks this) + if err := nm.UpdateAllowedPrivateCIDRs("127.0.0.1"); err != nil { + t.Fatalf("failed to configure allowlist: %v", err) + } + nm.SetAppriseConfig(AppriseConfig{ Enabled: true, Mode: AppriseModeHTTP,