♻️ Use TestURL in other test domains
This commit is contained in:
parent
c9a76ddbd6
commit
bf7be3c4fa
|
@ -2,8 +2,6 @@ package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client describes the client requesting data about the user.
|
// Client describes the client requesting data about the user.
|
||||||
|
@ -19,29 +17,19 @@ type Client struct {
|
||||||
func TestClient(tb testing.TB) *Client {
|
func TestClient(tb testing.TB) *Client {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
|
|
||||||
url, err := NewURL("https://app.example.com/")
|
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
logo, err := NewURL("https://app.example.com/logo.png")
|
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
redirects := make([]*URL, 0)
|
redirects := make([]*URL, 0)
|
||||||
|
|
||||||
for _, redirect := range []string{
|
for _, redirect := range []string{
|
||||||
"https://app.example.net/redirect",
|
"https://app.example.net/redirect",
|
||||||
"https://app.example.com/redirect",
|
"https://app.example.com/redirect",
|
||||||
} {
|
} {
|
||||||
u, err := NewURL(redirect)
|
redirects = append(redirects, TestURL(tb, redirect))
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
redirects = append(redirects, u)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
ID: TestClientID(tb),
|
ID: TestClientID(tb),
|
||||||
Name: []string{"Example App"},
|
Name: []string{"Example App"},
|
||||||
URL: []*URL{url},
|
URL: []*URL{TestURL(tb, "https://app.example.com/")},
|
||||||
Logo: []*URL{logo},
|
Logo: []*URL{TestURL(tb, "https://app.example.com/logo.png")},
|
||||||
RedirectURI: redirects,
|
RedirectURI: redirects,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Profile describes the data about the user.
|
// Profile describes the data about the user.
|
||||||
|
@ -28,16 +26,10 @@ func NewProfile() *Profile {
|
||||||
func TestProfile(tb testing.TB) *Profile {
|
func TestProfile(tb testing.TB) *Profile {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
|
|
||||||
photo, err := NewURL("https://user.example.net/photo.jpg")
|
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
url, err := NewURL("https://user.example.net/")
|
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
return &Profile{
|
return &Profile{
|
||||||
Email: []Email{"user@example.net"},
|
Email: []Email{"user@example.net"},
|
||||||
Name: []string{"Example User"},
|
Name: []string{"Example User"},
|
||||||
Photo: []*URL{photo},
|
Photo: []*URL{TestURL(tb, "https://user.example.net/photo.jpg")},
|
||||||
URL: []*URL{url},
|
URL: []*URL{TestURL(tb, "https://user.example.net/")},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Ticket struct {
|
type Ticket struct {
|
||||||
|
@ -20,15 +18,9 @@ type Ticket struct {
|
||||||
func TestTicket(tb testing.TB) *Ticket {
|
func TestTicket(tb testing.TB) *Ticket {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
|
|
||||||
subject, err := NewMe("https://bob.example.org/")
|
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
resource, err := NewURL("https://alice.example.com/private/")
|
|
||||||
require.NoError(tb, err)
|
|
||||||
|
|
||||||
return &Ticket{
|
return &Ticket{
|
||||||
|
Resource: TestURL(tb, "https://alice.example.com/private/"),
|
||||||
|
Subject: TestMe(tb),
|
||||||
Ticket: "32985723984723985792834",
|
Ticket: "32985723984723985792834",
|
||||||
Resource: resource,
|
|
||||||
Subject: subject,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue