From 6194bfb81d3fe0dabcd304c35c220a84a398618f Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Tue, 13 Sep 2016 15:03:49 -0400 Subject: [PATCH 1/2] Fix audit_test regex for iso8601 timestamps Signed-off-by: Johnny Bieren --- pkg/apiserver/audit/audit_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/audit/audit_test.go b/pkg/apiserver/audit/audit_test.go index 3131f979d41..b4d989b3797 100644 --- a/pkg/apiserver/audit/audit_test.go +++ b/pkg/apiserver/audit/audit_test.go @@ -95,14 +95,14 @@ func TestAudit(t *testing.T) { if len(line) != 2 { t.Fatalf("Unexpected amount of lines in audit log: %d", len(line)) } - match, err := regexp.MatchString(`[\d\:\-\.\+]+ AUDIT: id="[\w-]+" ip="127.0.0.1" method="GET" user="admin" as="" namespace="default" uri="/api/v1/namespaces/default/pods"`, line[0]) + match, err := regexp.MatchString(`[\d\:\-\.\+,T,Z]+ AUDIT: id="[\w-]+" ip="127.0.0.1" method="GET" user="admin" as="" namespace="default" uri="/api/v1/namespaces/default/pods"`, line[0]) if err != nil { t.Errorf("Unexpected error matching first line: %v", err) } if !match { t.Errorf("Unexpected first line of audit: %s", line[0]) } - match, err = regexp.MatchString(`[\d\:\-\.\+]+ AUDIT: id="[\w-]+" response="200"`, line[1]) + match, err = regexp.MatchString(`[\d\:\-\.\+,T,Z]+ AUDIT: id="[\w-]+" response="200"`, line[1]) if err != nil { t.Errorf("Unexpected error matching second line: %v", err) } From df6299d11066598134b44fd3b747fa86fdc88d3e Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Wed, 14 Sep 2016 14:08:41 -0400 Subject: [PATCH 2/2] Fixed edited regex in audit_test unit test Signed-off-by: Johnny Bieren --- pkg/apiserver/audit/audit_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/audit/audit_test.go b/pkg/apiserver/audit/audit_test.go index b4d989b3797..e7b8809fa8c 100644 --- a/pkg/apiserver/audit/audit_test.go +++ b/pkg/apiserver/audit/audit_test.go @@ -95,14 +95,14 @@ func TestAudit(t *testing.T) { if len(line) != 2 { t.Fatalf("Unexpected amount of lines in audit log: %d", len(line)) } - match, err := regexp.MatchString(`[\d\:\-\.\+,T,Z]+ AUDIT: id="[\w-]+" ip="127.0.0.1" method="GET" user="admin" as="" namespace="default" uri="/api/v1/namespaces/default/pods"`, line[0]) + match, err := regexp.MatchString(`[\d\:\-\.\+TZ]+ AUDIT: id="[\w-]+" ip="127.0.0.1" method="GET" user="admin" as="" namespace="default" uri="/api/v1/namespaces/default/pods"`, line[0]) if err != nil { t.Errorf("Unexpected error matching first line: %v", err) } if !match { t.Errorf("Unexpected first line of audit: %s", line[0]) } - match, err = regexp.MatchString(`[\d\:\-\.\+,T,Z]+ AUDIT: id="[\w-]+" response="200"`, line[1]) + match, err = regexp.MatchString(`[\d\:\-\.\+TZ]+ AUDIT: id="[\w-]+" response="200"`, line[1]) if err != nil { t.Errorf("Unexpected error matching second line: %v", err) }