Skip to content

Commit

Permalink
Test for invalid IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Oct 5, 2022
1 parent 415be6f commit 00a028f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/logging/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func TestIPMaskSingleValue(t *testing.T) {
if out.String != "ffff:ffff::" {
t.Fatalf("field has not been filtered: %s", out.String)
}

out = f.Filter(zapcore.Field{String: "not-an-ip"})
if out.String != "not-an-ip" {
t.Fatalf("field has been filtered: %s", out.String)
}
}

func TestIPMaskCommaValue(t *testing.T) {
Expand All @@ -36,6 +41,11 @@ func TestIPMaskCommaValue(t *testing.T) {
if out.String != "ffff:ffff::, ff00:ffff::" {
t.Fatalf("field has not been filtered: %s", out.String)
}

out = f.Filter(zapcore.Field{String: "not-an-ip, 255.255.255.255"})
if out.String != "not-an-ip, 255.255.0.0" {
t.Fatalf("field has not been filtered: %s", out.String)
}
}

func TestIPMaskMultiValue(t *testing.T) {
Expand Down

0 comments on commit 00a028f

Please sign in to comment.