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.
This commit is contained in:
rcourtman 2025-11-11 23:02:45 +00:00
parent c43e893034
commit f3d20a1fea
2 changed files with 16 additions and 4 deletions

View file

@ -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()),
}
}

View file

@ -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,