From 789efa5deef53071b57479d37e4022bf372c4eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 23 Nov 2021 18:00:20 +0100 Subject: logging: add a regexp filter (#4426) --- modules/logging/filters_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/logging/filters_test.go') diff --git a/modules/logging/filters_test.go b/modules/logging/filters_test.go index 6871bea..99289c3 100644 --- a/modules/logging/filters_test.go +++ b/modules/logging/filters_test.go @@ -3,6 +3,7 @@ package logging import ( "testing" + "github.com/caddyserver/caddy/v2" "go.uber.org/zap/zapcore" ) @@ -67,3 +68,13 @@ func TestValidateCookieFilter(t *testing.T) { t.Fatalf("unknown action type must be invalid") } } + +func TestRegexpFilter(t *testing.T) { + f := RegexpFilter{RawRegexp: `secret`, Value: "REDACTED"} + f.Provision(caddy.Context{}) + + out := f.Filter(zapcore.Field{String: "foo-secret-bar"}) + if out.String != "foo-REDACTED-bar" { + t.Fatalf("field has not been filtered: %s", out.String) + } +} -- cgit v1.2.3