MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / TestNormalizeOrigin

Function TestNormalizeOrigin

internal/validators/url_test.go:9–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func 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
33func TestIsValidOrigin(t *testing.T) {
34 t.Run("wildcard allows everything", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

normalizeOriginFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected