From b14575145ff8edf9ce1cd1257122e41fb2502c87 Mon Sep 17 00:00:00 2001 From: hoelee Date: Mon, 20 Jul 2026 18:01:00 +0800 Subject: [PATCH] feat(botfilter): botfilter_test.go part 7/8 --- botfilter_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/botfilter_test.go b/botfilter_test.go index edcabe7b..e03597ac 100644 --- a/botfilter_test.go +++ b/botfilter_test.go @@ -150,3 +150,13 @@ func TestTrustedProxyHeaderSeparatesClients(t *testing.T) { t.Fatalf("New() error = %v", err) } + bad := httptest.NewRequest(http.MethodGet, "http://wiki.example/", nil) + bad.RemoteAddr = "127.0.0.1:1234" + bad.Header.Set("X-Forwarded-For", "198.51.100.61") + bad.Header.Del("User-Agent") + badResponse := httptest.NewRecorder() + handler.ServeHTTP(badResponse, bad) + if badResponse.Code != http.StatusForbidden { + t.Fatalf("bad client status = %d, want 403", badResponse.Code) + } +