summaryrefslogtreecommitdiff
path: root/modules/logging/filters_test.go
diff options
context:
space:
mode:
authorKévin Dunglas <dunglas@gmail.com>2021-11-23 18:00:20 +0100
committerGitHub <noreply@github.com>2021-11-23 10:00:20 -0700
commit789efa5deef53071b57479d37e4022bf372c4eef (patch)
tree6fd09f809735e2d47dfc361a2617008950630508 /modules/logging/filters_test.go
parent8887adb027982e844965b4707b8595cee5845d54 (diff)
logging: add a regexp filter (#4426)
Diffstat (limited to 'modules/logging/filters_test.go')
-rw-r--r--modules/logging/filters_test.go11
1 files changed, 11 insertions, 0 deletions
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)
+ }
+}