(t *testing.T)
| 227 | } |
| 228 | |
| 229 | func TestComputeFirewallDiff_CompleteScenario(t *testing.T) { |
| 230 | run1 := &FirewallAnalysis{ |
| 231 | TotalRequests: 46, |
| 232 | AllowedRequests: 38, |
| 233 | BlockedRequests: 8, |
| 234 | RequestsByDomain: map[string]DomainRequestStats{ |
| 235 | "api.github.com:443": {Allowed: 23, Blocked: 0}, |
| 236 | "old-api.internal.com:443": {Allowed: 8, Blocked: 0}, |
| 237 | "staging.api.com:443": {Allowed: 7, Blocked: 0}, |
| 238 | "blocked.example.com:443": {Allowed: 0, Blocked: 8}, |
| 239 | }, |
| 240 | } |
| 241 | run2 := &FirewallAnalysis{ |
| 242 | TotalRequests: 108, |
| 243 | AllowedRequests: 106, |
| 244 | BlockedRequests: 2, |
| 245 | RequestsByDomain: map[string]DomainRequestStats{ |
| 246 | "api.github.com:443": {Allowed: 89, Blocked: 0}, |
| 247 | "registry.npmjs.org:443": {Allowed: 15, Blocked: 0}, |
| 248 | "telemetry.example.com:443": {Allowed: 0, Blocked: 2}, |
| 249 | "staging.api.com:443": {Allowed: 0, Blocked: 0}, // no requests (edge case) |
| 250 | "blocked.example.com:443": {Allowed: 0, Blocked: 0}, // no longer any requests (edge case) |
| 251 | }, |
| 252 | } |
| 253 | |
| 254 | diff := computeFirewallDiff(12345, 12346, run1, run2) |
| 255 | |
| 256 | // Verify new domains |
| 257 | assert.Len(t, diff.NewDomains, 2, "Should have 2 new domains") |
| 258 | |
| 259 | // Verify removed domains |
| 260 | assert.Len(t, diff.RemovedDomains, 1, "Should have 1 removed domain (old-api.internal.com)") |
| 261 | |
| 262 | // api.github.com: 23 → 89 = +287% |
| 263 | assert.GreaterOrEqual(t, len(diff.VolumeChanges), 1, "Should have at least 1 volume change") |
| 264 | } |
| 265 | |
| 266 | func TestDomainStatus(t *testing.T) { |
| 267 | tests := []struct { |
nothing calls this directly
no test coverage detected