TestComputeFirewallDiff_RemovedDeniedDomain verifies that a domain which was denied in the base run but is absent from the comparison run is flagged as an anomaly. This covers the false-red scenario where awmg-mcpg:8080 is blocked in the failed run but is simply absent (no traffic) in the green run
(t *testing.T)
| 86 | // covers the false-red scenario where awmg-mcpg:8080 is blocked in the failed run but |
| 87 | // is simply absent (no traffic) in the green run — the block should still be surfaced. |
| 88 | func TestComputeFirewallDiff_RemovedDeniedDomain(t *testing.T) { |
| 89 | run1 := &FirewallAnalysis{ |
| 90 | RequestsByDomain: map[string]DomainRequestStats{ |
| 91 | "api.github.com:443": {Allowed: 10, Blocked: 0}, |
| 92 | "awmg-mcpg:8080": {Allowed: 0, Blocked: 1}, |
| 93 | }, |
| 94 | } |
| 95 | run2 := &FirewallAnalysis{ |
| 96 | RequestsByDomain: map[string]DomainRequestStats{ |
| 97 | "api.github.com:443": {Allowed: 10, Blocked: 0}, |
| 98 | }, |
| 99 | } |
| 100 | |
| 101 | diff := computeFirewallDiff(100, 200, run1, run2) |
| 102 | |
| 103 | assert.Len(t, diff.RemovedDomains, 1, "Should have 1 removed domain") |
| 104 | entry := diff.RemovedDomains[0] |
| 105 | assert.Equal(t, "awmg-mcpg:8080", entry.Domain) |
| 106 | assert.Equal(t, "removed", entry.Status) |
| 107 | assert.Equal(t, "denied", entry.Run1Status, "Domain was denied in run 1") |
| 108 | assert.Equal(t, 1, entry.Run1Blocked, "Domain had 1 blocked request") |
| 109 | assert.True(t, entry.IsAnomaly, "Denied removed domain should be an anomaly") |
| 110 | assert.NotEmpty(t, entry.AnomalyNote, "Anomaly note should be set") |
| 111 | assert.True(t, diff.Summary.HasAnomalies, "Summary should report anomalies") |
| 112 | assert.Equal(t, 1, diff.Summary.AnomalyCount, "Should have 1 anomaly") |
| 113 | } |
| 114 | |
| 115 | func TestComputeFirewallDiff_StatusChanges(t *testing.T) { |
| 116 | run1 := &FirewallAnalysis{ |
nothing calls this directly
no test coverage detected