mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-07-21 11:38:59 +02:00
* Update CI following latest plugindemo version * disable some linter * Disable some linter * Fix linter in redis, add error logger * 🚨 Fix lint errors in private packages * 🚨 Update lints in package and core code * 🚨 exclude unfixable lint errors * 🚨 update lint at package level and ignore necessary global variable * 🍱 fix lint qnd merge * 🚨 Fix Lint for string * 🚨 Fix lint for bouncer * 🚨 Fix error * Fix weird linter error Co-authored-by: Max Lerebourg <maxlerebourg@gmail.com>
31 lines
614 B
Go
31 lines
614 B
Go
package crowdsec_bouncer_traefik_plugin //nolint:revive,stylecheck
|
|
|
|
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)
|
|
}
|