(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestNormalizeOrigin(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | input string |
| 13 | expected string |
| 14 | }{ |
| 15 | {"https with port 443", "https://example.com:443", "example.com"}, |
| 16 | {"http with port 80", "http://example.com:80", "example.com"}, |
| 17 | {"https without port", "https://example.com", "example.com"}, |
| 18 | {"http without port", "http://example.com", "example.com"}, |
| 19 | {"with custom port", "http://localhost:3000", "localhost:3000"}, |
| 20 | {"bare domain", "example.com", "example.com"}, |
| 21 | {"bare domain with port", "localhost:8080", "localhost:8080"}, |
| 22 | {"with path", "https://example.com/callback", "example.com"}, |
| 23 | {"with path and port", "http://localhost:3000/app/login", "localhost:3000"}, |
| 24 | {"subdomain", "https://auth.example.com", "auth.example.com"}, |
| 25 | } |
| 26 | for _, tt := range tests { |
| 27 | t.Run(tt.name, func(t *testing.T) { |
| 28 | assert.Equal(t, tt.expected, normalizeOrigin(tt.input)) |
| 29 | }) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func TestIsValidOrigin(t *testing.T) { |
| 34 | t.Run("wildcard allows everything", func(t *testing.T) { |
nothing calls this directly
no test coverage detected