feat(botfilter): botfilter_test.go part 6/8

This commit is contained in:
hoelee committed 2026-07-15 18:01:00 +08:00
1 parent 6f860cabd1
commit 701e9a5432
1 file changed
+14
+14
View File
@@ -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)
}
}