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

This commit is contained in:
hoelee committed 2026-07-14 18:01:00 +08:00
1 parent e9f86ea78d
commit a9dd87f547
1 file changed
+14
+14
View File
@@ -34,3 +34,17 @@ func TestRequiredHeaderCreatesTemporaryBan(t *testing.T) {
t.Fatal("first response did not include Retry-After")
}
second := httptest.NewRequest(http.MethodGet, "http://wiki.example/", nil)
second.RemoteAddr = "203.0.113.11:54321"
second.Header.Set("Accept", "text/html")
second.Header.Set("User-Agent", "Mozilla/5.0 Chrome/120.0 AppleWebKit/537.36 Safari/537.36")
secondResponse := httptest.NewRecorder()
handler.ServeHTTP(secondResponse, second)
if secondResponse.Code != http.StatusForbidden {
t.Fatalf("second response status = %d, want cached ban", secondResponse.Code)
}
if nextCalls != 0 {
t.Fatalf("next handler calls = %d, want 0", nextCalls)
}
}