Files
crowdsec-bouncer-traefik-pl…/bouncer_test.go
T
2022-10-11 19:56:14 +02:00

31 lines
587 B
Go

package crowdsec_bouncer_traefik_plugin
import (
"context"
"net/http"
"net/http/httptest"
"testing"
)
func TestCrowdSec(t *testing.T) {
cfg := CreateConfig()
cfg.CrowdsecLapiKey = "test"
ctx := context.Background()
next := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {})
handler, err := New(ctx, next, cfg, "demo-plugin")
if err != nil {
t.Fatal(err)
}
recorder := httptest.NewRecorder()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost", nil)
if err != nil {
t.Fatal(err)
}
handler.ServeHTTP(recorder, req)
}