check / check (push) Waiting to run
script/fmt now runs golines -m 77 after gofmt, repeating golines until it changes nothing, since one pass can leave a line the next splits. script/fmt-check fails when either would change a file. script/bootstrap installs golines v0.13.0 with go install, pinned to its commit, and checks the installed version with go version -m. The tree is reformatted. The longer lines this makes are fixed by hand: nolint directives moved onto their own line above the statement, one string split, and 20 functions over funlen's 80 lines shortened or split, RunWAF and limitPercentages among them. Model: opus-5-5
36 lines
793 B
Go
36 lines
793 B
Go
package waf
|
|
|
|
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{
|
|
decision: decision{
|
|
client: netip.MustParseAddr("203.0.113.9"),
|
|
lookedUp: true,
|
|
},
|
|
h: &handler{config: &config.Config{LookupSource: "geojs"}},
|
|
}
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
t.Errorf(
|
|
"counting the request did work, with every threshold off: %v",
|
|
r,
|
|
)
|
|
}
|
|
}()
|
|
|
|
rq.countAnomalies()
|
|
}
|