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

This commit is contained in:
hoelee committed 2026-06-24 18:01:00 +08:00
1 parent 29decd6650
commit 4232ce2e71
1 file changed
+13
+13
View File
@@ -21,3 +21,16 @@ func TestRequiredHeaderCreatesTemporaryBan(t *testing.T) {
t.Fatalf("New() error = %v", err)
}
first := httptest.NewRequest(http.MethodGet, "http://wiki.example/content/article", nil)
first.RemoteAddr = "203.0.113.11:54321"
first.Header.Set("Accept", "text/html")
first.Header.Del("User-Agent")
firstResponse := httptest.NewRecorder()
handler.ServeHTTP(firstResponse, first)
if firstResponse.Code != http.StatusForbidden {
t.Fatalf("first response status = %d, want %d", firstResponse.Code, http.StatusForbidden)
}
if firstResponse.Header().Get("Retry-After") == "" {
t.Fatal("first response did not include Retry-After")
}