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) + } +} +