pomerium/pkg/webauthnutil/webauthnutil_test.go
2022-11-17 19:27:48 -07:00

31 lines
715 B
Go

package webauthnutil
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetEffectiveDomain(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
in string
expect string
}{
{"https://www.example.com/some/path", "example.com"},
{"https://www.example.com:8080/some/path", "example.com"},
{"https://www.subdomain.example.com/some/path", "example.com"},
{"https://example.com/some/path", "example.com"},
} {
tc := tc
t.Run(tc.expect, func(t *testing.T) {
t.Parallel()
r, err := http.NewRequest(http.MethodGet, tc.in, nil)
require.NoError(t, err)
assert.Equal(t, tc.expect, GetEffectiveDomain(r))
})
}
}