Add unit tests for subdomain match in keyring

This ensures that the amount of subdomains should always match the
glob+dot (`*.`) pattern.

Refers to https://github.com/kubernetes/kubernetes/issues/119941

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
Sascha Grunert 2023-08-15 12:17:26 +02:00
parent 6e0cb243d5
commit 3edae95e5a
No known key found for this signature in database
GPG Key ID: 09D97D153EF94D93

View File

@ -88,6 +88,22 @@ func TestURLsMatch(t *testing.T) {
targetURL: "kubernetes.io",
matchExpected: false,
},
{
globURL: "*kubernetes.io",
targetURL: "a.kubernetes.io",
matchExpected: false,
},
// match when number of parts match
{
globURL: "*kubernetes.io",
targetURL: "kubernetes.io",
matchExpected: true,
},
{
globURL: "*.*.*.kubernetes.io",
targetURL: "a.b.c.kubernetes.io",
matchExpected: true,
},
// no match when some parts mismatch
{
globURL: "kubernetes.io",