check / check (push) In progress
The command is now `sww waf`, and the package is `internal/waf`. Types, functions, files, tests, comments, docs, the Dockerfile, the runit script, `script/`, compose examples, the log field `waf_line` and the `X-From-Waf` test header follow. No behaviour changes, and no setting changes name: rproxy already finds the waf through `SWRP_WAF_BACKEND`. Done with one `sed -i` (Discriminator and DISCRIMINATOR to WAF, discriminator to waf) over the files `git grep -i discriminator` listed, as sneak allowed for this rename, then `git mv` for the package and files. By hand afterwards: the header's spelling, which the linter requires, and the padding after `waf` in `sww`'s usage text. Model: opus-5-5
33 lines
779 B
Go
33 lines
779 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()
|
|
}
|