diff --git a/botfilter_test.go b/botfilter_test.go index ed2ee428..67c947c3 100644 --- a/botfilter_test.go +++ b/botfilter_test.go @@ -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) + } +} +