TestNormalizeAudienceURI tests URI normalization for OAuth2 audience validation
(t *testing.T)
| 56 | |
| 57 | // TestNormalizeAudienceURI tests URI normalization for OAuth2 audience validation |
| 58 | func TestNormalizeAudienceURI(t *testing.T) { |
| 59 | t.Parallel() |
| 60 | |
| 61 | testCases := []struct { |
| 62 | name string |
| 63 | input string |
| 64 | expected string |
| 65 | }{ |
| 66 | { |
| 67 | name: "EmptyString", |
| 68 | input: "", |
| 69 | expected: "", |
| 70 | }, |
| 71 | { |
| 72 | name: "SimpleHTTPWithoutTrailingSlash", |
| 73 | input: "http://example.com", |
| 74 | expected: "http://example.com/", |
| 75 | }, |
| 76 | { |
| 77 | name: "SimpleHTTPWithTrailingSlash", |
| 78 | input: "http://example.com/", |
| 79 | expected: "http://example.com/", |
| 80 | }, |
| 81 | { |
| 82 | name: "HTTPSWithPath", |
| 83 | input: "https://api.example.com/v1/", |
| 84 | expected: "https://api.example.com/v1", |
| 85 | }, |
| 86 | { |
| 87 | name: "CaseNormalization", |
| 88 | input: "HTTPS://API.EXAMPLE.COM/V1/", |
| 89 | expected: "https://api.example.com/V1", |
| 90 | }, |
| 91 | { |
| 92 | name: "DefaultHTTPPort", |
| 93 | input: "http://example.com:80/api/", |
| 94 | expected: "http://example.com/api", |
| 95 | }, |
| 96 | { |
| 97 | name: "DefaultHTTPSPort", |
| 98 | input: "https://example.com:443/api/", |
| 99 | expected: "https://example.com/api", |
| 100 | }, |
| 101 | { |
| 102 | name: "NonDefaultPort", |
| 103 | input: "http://example.com:8080/api/", |
| 104 | expected: "http://example.com:8080/api", |
| 105 | }, |
| 106 | } |
| 107 | |
| 108 | for _, tc := range testCases { |
| 109 | t.Run(tc.name, func(t *testing.T) { |
| 110 | t.Parallel() |
| 111 | result := normalizeAudienceURI(tc.input) |
| 112 | assert.Equal(t, tc.expected, result) |
| 113 | }) |
| 114 | } |
| 115 | } |
nothing calls this directly
no test coverage detected