feat(botfilter): add TestTrustedProxyHeaderSeparatesClients
This commit is contained in:
1 parent
701e9a5432
commit
7781ac4154
1 file changed
+14
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user