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:
parent
5fa78c3e36
commit
515987cc8b
2 changed files with 16 additions and 4 deletions
|
|
@ -14,10 +14,12 @@ func newTestMonitor(t *testing.T) *Monitor {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
return &Monitor{
|
return &Monitor{
|
||||||
state: models.NewState(),
|
state: models.NewState(),
|
||||||
alertManager: alerts.NewManager(),
|
alertManager: alerts.NewManager(),
|
||||||
removedDockerHosts: make(map[string]time.Time),
|
removedDockerHosts: make(map[string]time.Time),
|
||||||
rateTracker: NewRateTracker(),
|
rateTracker: NewRateTracker(),
|
||||||
|
dockerTokenBindings: make(map[string]string),
|
||||||
|
dockerMetadataStore: config.NewDockerMetadataStore(t.TempDir()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,11 @@ func TestSendGroupedAppriseHTTP(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
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{
|
nm.SetAppriseConfig(AppriseConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Mode: AppriseModeHTTP,
|
Mode: AppriseModeHTTP,
|
||||||
|
|
@ -592,6 +597,11 @@ func TestSendTestNotificationAppriseHTTP(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
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{
|
nm.SetAppriseConfig(AppriseConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Mode: AppriseModeHTTP,
|
Mode: AppriseModeHTTP,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue