package proxy import ( "net/netip" "testing" "sneak.berlin/go/smallwebwaf/internal/config" ) func TestWithEveryAnomalyThresholdOffARequestIsNotCounted(t *testing.T) { t.Parallel() // A request from a client looked up through GeoJS, with every anomaly // threshold off. Its handler has neither GeoJS's answers nor the // anomaly counters, nor a clock, and the request no response: reading // any of them to count the request panics. rq := &request{ h: &handler{config: &config.Config{LookupSource: "geojs"}}, client: netip.MustParseAddr("203.0.113.9"), lookedUp: true, } defer func() { if r := recover(); r != nil { t.Errorf("counting the request did work, with every threshold off: %v", r) } }() rq.countAnomalies() }