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)