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