Rearranged tests for clarity and added one additional positive test.

This commit is contained in:
Patrick Jones 2021-08-06 15:07:15 -07:00
parent 0925f5e864
commit 57c99ca18a
1 changed files with 6 additions and 4 deletions

View File

@ -102,24 +102,26 @@ func TestValidateURL(t *testing.T) {
pattern []string
result bool
}{
{"https://east.sts.googleapis.com", validTokenURLPatterns, true},
{"https://sts.googleapis.com", validTokenURLPatterns, true},
{"https://sts.asfeasfesef.googleapis.com", validTokenURLPatterns, true},
{"https://us-east-1-sts.googleapis.com", validTokenURLPatterns, true},
{"https://.sts.google.com", validTokenURLPatterns, false},
{"https://badsts.googleapis.com", validTokenURLPatterns, false},
{"https://sts.asfeasfesef.googleapis.com", validTokenURLPatterns, true},
{"https://sts.asfe.asfesef.googleapis.com", validTokenURLPatterns, false},
{"https://sts..googleapis.com", validTokenURLPatterns, false},
{"https://-sts.googleapis.com", validTokenURLPatterns, false},
{"https://us-east-1-sts.googleapis.com", validTokenURLPatterns, true},
{"https://us-ea.st-1-sts.googleapis.com", validTokenURLPatterns, false},
// Repeat for iamcredentials as well
{"https://east.iamcredentials.googleapis.com", validImpersonateURLPatterns, true},
{"https://iamcredentials.googleapis.com", validImpersonateURLPatterns, true},
{"https://iamcredentials.asfeasfesef.googleapis.com", validImpersonateURLPatterns, true},
{"https://us-east-1-iamcredentials.googleapis.com", validImpersonateURLPatterns, true},
{"https://.iamcredentials.googleapis.com", validImpersonateURLPatterns, false},
{"https://badiamcredentials.googleapis.com", validImpersonateURLPatterns, false},
{"https://iamcredentials.asfeasfesef.googleapis.com", validImpersonateURLPatterns, true},
{"https://iamcredentials.asfe.asfesef.googleapis.com", validImpersonateURLPatterns, false},
{"https://iamcredentials..googleapis.com", validImpersonateURLPatterns, false},
{"https://-iamcredentials.googleapis.com", validImpersonateURLPatterns, false},
{"https://us-east-1-iamcredentials.googleapis.com", validImpersonateURLPatterns, true},
{"https://us-ea.st-1-iamcredentials.googleapis.com", validImpersonateURLPatterns, false},
}
for _, tt := range urlValidityTests {