From 29decd6650795cbab93a8c4c8548df143aa31e8c Mon Sep 17 00:00:00 2001 From: hoelee Date: Tue, 23 Jun 2026 11:46:00 +0800 Subject: [PATCH] feat(botfilter): add TestRequiredHeaderCreatesTemporaryBan --- botfilter_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 botfilter_test.go diff --git a/botfilter_test.go b/botfilter_test.go new file mode 100644 index 00000000..f9f9c9e2 --- /dev/null +++ b/botfilter_test.go @@ -0,0 +1,23 @@ +package botfilter + +import ( + "context" + "net/http" + "net/http/httptest" + "testing" +) + +func TestRequiredHeaderCreatesTemporaryBan(t *testing.T) { + cfg := CreateConfig() + cfg.RequireUserAgent = true + cfg.RequireAccept = true + cfg.RequireHost = true + nextCalls := 0 + handler, err := New(context.Background(), http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { + nextCalls++ + rw.WriteHeader(http.StatusOK) + }), cfg, "test") + if err != nil { + t.Fatalf("New() error = %v", err) + } +