feat(botfilter): add TestTrustedProxyHeaderSeparatesClients

This commit is contained in:
hoelee committed 2026-07-16 12:53:00 +08:00
1 parent 701e9a5432
commit 7781ac4154
1 file changed
+14
+14
View File
@@ -136,3 +136,17 @@ func Test404ScoreBansOnSubsequentRequest(t *testing.T) {
}
}
func TestTrustedProxyHeaderSeparatesClients(t *testing.T) {
cfg := CreateConfig()
cfg.RequireUserAgent = true
cfg.ClientIPHeader = "X-Forwarded-For"
cfg.TrustedProxyCIDRs = []string{"127.0.0.0/8"}
nextCalls := 0
handler, err := New(context.Background(), http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
nextCalls++
rw.WriteHeader(http.StatusNoContent)
}), cfg, "test")
if err != nil {
t.Fatalf("New() error = %v", err)
}