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

This commit is contained in:
hoelee committed 2026-07-16 18:01:00 +08:00
1 parent c8ff35532c
commit 1183a20295
1 file changed
+14
+14
View File
@@ -160,3 +160,17 @@ func TestTrustedProxyHeaderSeparatesClients(t *testing.T) {
t.Fatalf("bad client status = %d, want 403", badResponse.Code)
}
good := httptest.NewRequest(http.MethodGet, "http://wiki.example/", nil)
good.RemoteAddr = "127.0.0.1:1234"
good.Header.Set("X-Forwarded-For", "198.51.100.62")
good.Header.Set("User-Agent", "Mozilla/5.0 Chrome/120.0 AppleWebKit/537.36 Safari/537.36")
goodResponse := httptest.NewRecorder()
handler.ServeHTTP(goodResponse, good)
if goodResponse.Code != http.StatusNoContent {
t.Fatalf("good client status = %d, want 204", goodResponse.Code)
}
if nextCalls != 1 {
t.Fatalf("next handler calls = %d, want 1", nextCalls)
}
}