From 1487f6a7c4ea8fc714a2473fa4f078161625f634 Mon Sep 17 00:00:00 2001 From: Denny Hoang Date: Thu, 5 May 2022 13:33:18 -0400 Subject: [PATCH] add more glob test Signed-off-by: Denny Hoang --- pkg/apis/config/glob_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/apis/config/glob_test.go b/pkg/apis/config/glob_test.go index a6b147c2a1e..e86d1b32361 100644 --- a/pkg/apis/config/glob_test.go +++ b/pkg/apis/config/glob_test.go @@ -39,6 +39,16 @@ func TestGlobMatch(t *testing.T) { {glob: "repository/*", input: "index.docker.io/repository/image", match: true}, // Testing resolved digest {glob: "image", input: "index.docker.io/library/image", match: true}, // Testing resolved digest and official dockerhub public repository {glob: "[", input: "[", match: false, errString: "syntax error in pattern"}, // Invalid glob pattern + {glob: "gcr.io/projectsigstore/*", input: "gcr.io/projectsigstore/cosign", match: true}, + {glob: "gcr.io/projectsigstore/*", input: "us.gcr.io/projectsigstore/cosign", match: false}, + {glob: "*gcr.io/projectsigstore/*", input: "gcr.io/projectsigstore/cosign", match: true}, + {glob: "*gcr.io/projectsigstore/*", input: "gcr.io/projectsigstore2/cosign", match: false}, + {glob: "*gcr.io/*", input: "us.gcr.io/projectsigstore/cosign", match: false}, // Does not match since '*' only handles until next non-separator character '/' + {glob: "*gcr.io/*/*", input: "us.gcr.io/projectsigstore/cosign", match: true}, // Does match with multiple '*' + {glob: "us.gcr.io/*/*", input: "us.gcr.io/projectsigstore/cosign", match: true}, + {glob: "us.gcr.io/*/*", input: "gcr.io/projectsigstore/cosign", match: false}, + {glob: "*.gcr.io/*/*", input: "asia.gcr.io/projectsigstore/cosign", match: true}, + {glob: "*.gcr.io/*/*", input: "gcr.io/projectsigstore/cosign", match: false}, } for _, tc := range tests { got, err := GlobMatch(tc.glob, tc.input)