From 1183a20295221df68ecbb9601e34c616fb0ef023 Mon Sep 17 00:00:00 2001 From: hoelee Date: Thu, 16 Jul 2026 18:01:00 +0800 Subject: [PATCH] feat(botfilter): botfilter_test.go part 8/8 --- botfilter_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/botfilter_test.go b/botfilter_test.go index e03597ac..f67e2797 100644 --- a/botfilter_test.go +++ b/botfilter_test.go @@ -160,3 +160,17 @@ func TestTrustedProxyHeaderSeparatesClients(t *testing.T) { t.Fatalf("bad client status = %d, want 403", badResponse.Code) } + good := httptest.NewRequest(http.MethodGet, "http://wiki.example/", nil) + good.RemoteAddr = "127.0.0.1:1234" + good.Header.Set("X-Forwarded-For", "198.51.100.62") + good.Header.Set("User-Agent", "Mozilla/5.0 Chrome/120.0 AppleWebKit/537.36 Safari/537.36") + goodResponse := httptest.NewRecorder() + handler.ServeHTTP(goodResponse, good) + if goodResponse.Code != http.StatusNoContent { + t.Fatalf("good client status = %d, want 204", goodResponse.Code) + } + if nextCalls != 1 { + t.Fatalf("next handler calls = %d, want 1", nextCalls) + } +} +