feat(botfilter): botfilter_test.go part 6/8
This commit is contained in:
1 parent
1b22e8e907
commit
0f070d783a
1 file changed
+14
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user