summaryrefslogtreecommitdiff
path: root/modules/logging/filters_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/logging/filters_test.go')
-rw-r--r--modules/logging/filters_test.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/modules/logging/filters_test.go b/modules/logging/filters_test.go
index 99289c3..ecf1d87 100644
--- a/modules/logging/filters_test.go
+++ b/modules/logging/filters_test.go
@@ -13,14 +13,15 @@ func TestQueryFilter(t *testing.T) {
{replaceAction, "notexist", "REDACTED"},
{deleteAction, "bar", ""},
{deleteAction, "notexist", ""},
+ {hashAction, "hash", ""},
}}
if f.Validate() != nil {
t.Fatalf("the filter must be valid")
}
- out := f.Filter(zapcore.Field{String: "/path?foo=a&foo=b&bar=c&bar=d&baz=e"})
- if out.String != "/path?baz=e&foo=REDACTED&foo=REDACTED" {
+ out := f.Filter(zapcore.Field{String: "/path?foo=a&foo=b&bar=c&bar=d&baz=e&hash=hashed"})
+ if out.String != "/path?baz=e&foo=REDACTED&foo=REDACTED&hash=e3b0c442" {
t.Fatalf("query parameters have not been filtered: %s", out.String)
}
}
@@ -45,10 +46,11 @@ func TestCookieFilter(t *testing.T) {
f := CookieFilter{[]cookieFilterAction{
{replaceAction, "foo", "REDACTED"},
{deleteAction, "bar", ""},
+ {hashAction, "hash", ""},
}}
- out := f.Filter(zapcore.Field{String: "foo=a; foo=b; bar=c; bar=d; baz=e"})
- if out.String != "foo=REDACTED; foo=REDACTED; baz=e" {
+ out := f.Filter(zapcore.Field{String: "foo=a; foo=b; bar=c; bar=d; baz=e; hash=hashed"})
+ if out.String != "foo=REDACTED; foo=REDACTED; baz=e; hash=1a06df82" {
t.Fatalf("cookies have not been filtered: %s", out.String)
}
}
@@ -78,3 +80,12 @@ func TestRegexpFilter(t *testing.T) {
t.Fatalf("field has not been filtered: %s", out.String)
}
}
+
+func TestHashFilter(t *testing.T) {
+ f := HashFilter{}
+
+ out := f.Filter(zapcore.Field{String: "foo"})
+ if out.String != "2c26b46b" {
+ t.Fatalf("field has not been filtered: %s", out.String)
+ }
+}