From 0f070d783a0d5e3dffba7b9024a7e13f6724ee34 Mon Sep 17 00:00:00 2001 From: hoelee Date: Tue, 14 Jul 2026 18:01:00 +0800 Subject: [PATCH] feat(botfilter): botfilter_test.go part 6/8 --- botfilter_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/botfilter_test.go b/botfilter_test.go index c4490c4c..110f78bc 100644 --- a/botfilter_test.go +++ b/botfilter_test.go @@ -122,3 +122,17 @@ func Test404ScoreBansOnSubsequentRequest(t *testing.T) { t.Fatalf("first response status = %d, want 404", firstResponse.Code) } + second := httptest.NewRequest(http.MethodGet, "http://wiki.example/another-miss", nil) + second.RemoteAddr = "198.51.100.23:1234" + second.Header.Set("User-Agent", "Mozilla/5.0 Chrome/120.0 AppleWebKit/537.36 Safari/537.36") + second.Header.Set("Accept", "text/html") + secondResponse := httptest.NewRecorder() + handler.ServeHTTP(secondResponse, second) + if secondResponse.Code != http.StatusForbidden { + t.Fatalf("second response status = %d, want cached ban after two 404s", secondResponse.Code) + } + if nextCalls != 1 { + t.Fatalf("next handler calls = %d, want 1", nextCalls) + } +} +