2022-01-08 10:49:02 +00:00
|
|
|
package domain_test
|
|
|
|
|
|
|
|
import (
|
2023-01-02 01:15:11 +00:00
|
|
|
"net/url"
|
2022-01-08 10:49:02 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-03-13 10:58:34 +00:00
|
|
|
"source.toby3d.me/toby3d/auth/internal/domain"
|
2022-01-08 10:49:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestClient_ValidateRedirectURI(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := domain.TestClient(t)
|
|
|
|
|
2023-01-02 01:15:11 +00:00
|
|
|
for name, in := range map[string]*url.URL{
|
|
|
|
"client_id prefix": client.ID.URL().JoinPath("/callback"),
|
|
|
|
"registered redirect_uri": client.RedirectURI[len(client.RedirectURI)-1],
|
2022-02-01 17:27:48 +00:00
|
|
|
} {
|
2023-01-02 01:15:11 +00:00
|
|
|
name, in := name, in
|
2022-01-08 10:49:02 +00:00
|
|
|
|
2023-01-02 01:15:11 +00:00
|
|
|
t.Run(name, func(t *testing.T) {
|
2022-01-08 10:49:02 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2023-01-02 01:15:11 +00:00
|
|
|
if out := client.ValidateRedirectURI(in); !out {
|
|
|
|
t.Errorf("ValidateRedirectURI(%v) = %t, want %t", in, out, true)
|
2022-01-30 17:49:25 +00:00
|
|
|
}
|
2022-01-08 10:49:02 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-01-30 17:49:25 +00:00
|
|
|
|
|
|
|
func TestClient_GetName(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := domain.TestClient(t)
|
|
|
|
if result := client.GetName(); result != client.Name[0] {
|
|
|
|
t.Errorf("GetName() = %v, want %v", result, client.Name[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClient_GetURL(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := domain.TestClient(t)
|
|
|
|
if result := client.GetURL(); result != client.URL[0] {
|
|
|
|
t.Errorf("GetURL() = %v, want %v", result, client.URL[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClient_GetLogo(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := domain.TestClient(t)
|
|
|
|
if result := client.GetLogo(); result != client.Logo[0] {
|
|
|
|
t.Errorf("GetLogo() = %v, want %v", result, client.Logo[0])
|
|
|
|
}
|
|
|
|
}
|