🎨 Fromat login domain
This commit is contained in:
parent
1f2e9ba963
commit
72e392ab47
|
@ -2,36 +2,47 @@ package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"source.toby3d.me/website/oauth/internal/random"
|
"source.toby3d.me/website/oauth/internal/random"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Login struct {
|
type Login struct {
|
||||||
ClientID string
|
CreatedAt time.Time
|
||||||
Code string
|
CompletedAt time.Time
|
||||||
CodeChallenge string
|
PKCE
|
||||||
CodeChallengeMethod PKCEMethod
|
Scopes []string
|
||||||
CodeVerifier string
|
ClientID string
|
||||||
Me string
|
RedirectURI string
|
||||||
RedirectURI string
|
MeEntered string
|
||||||
Scopes []string
|
MeResolved string
|
||||||
State string
|
Code string
|
||||||
|
Provider string
|
||||||
|
IsCompleted bool
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: gomnd
|
//nolint: gomnd
|
||||||
func TestLogin(tb testing.TB) *Login {
|
func TestLogin(tb testing.TB) *Login {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
|
|
||||||
|
now := time.Now().UTC()
|
||||||
|
|
||||||
return &Login{
|
return &Login{
|
||||||
ClientID: "http://app.example.com/",
|
CreatedAt: now.Add(-1 * time.Minute),
|
||||||
Code: random.New().String(16),
|
CompletedAt: time.Time{},
|
||||||
CodeChallenge: "OfYAxt8zU2dAPDWQxTAUIteRzMsoj9QBdMIVEDOErUo",
|
PKCE: PKCE{
|
||||||
CodeChallengeMethod: PKCEMethodS256,
|
Method: PKCEMethodS256,
|
||||||
CodeVerifier: "a6128783714cfda1d388e2e98b6ae8221ac31aca31959e59512c59f5",
|
Challenge: "OfYAxt8zU2dAPDWQxTAUIteRzMsoj9QBdMIVEDOErUo",
|
||||||
Me: "http://user.example.net/",
|
Verifier: "a6128783714cfda1d388e2e98b6ae8221ac31aca31959e59512c59f5",
|
||||||
RedirectURI: "http://app.example.com/redirect",
|
},
|
||||||
Scopes: []string{"profile", "create", "update", "delete"},
|
Scopes: []string{"profile", "create", "update", "delete"},
|
||||||
State: "1234567890",
|
ClientID: "https://app.example.com/",
|
||||||
|
RedirectURI: "https://app.example.com/redirect",
|
||||||
|
MeEntered: "user.example.net",
|
||||||
|
MeResolved: "https://user.example.net/",
|
||||||
|
Code: random.New().String(8),
|
||||||
|
Provider: "mastodon",
|
||||||
|
IsCompleted: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,15 +50,23 @@ func TestLogin(tb testing.TB) *Login {
|
||||||
func TestLoginInvalid(tb testing.TB) *Login {
|
func TestLoginInvalid(tb testing.TB) *Login {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
|
|
||||||
|
now := time.Now().UTC()
|
||||||
|
|
||||||
return &Login{
|
return &Login{
|
||||||
ClientID: "whoisit",
|
CreatedAt: now.Add(-1 * time.Hour),
|
||||||
Code: "",
|
CompletedAt: time.Time{},
|
||||||
CodeChallenge: random.New().String(42),
|
PKCE: PKCE{
|
||||||
CodeChallengeMethod: "UNDEFINED",
|
Method: "UNDEFINED",
|
||||||
CodeVerifier: random.New().String(42),
|
Challenge: random.New().String(42),
|
||||||
Me: "whoami",
|
Verifier: random.New().String(64),
|
||||||
RedirectURI: "/redirect",
|
},
|
||||||
Scopes: []string{},
|
Scopes: []string{},
|
||||||
State: "",
|
ClientID: "whoisit",
|
||||||
|
RedirectURI: "redirect",
|
||||||
|
MeEntered: "whoami",
|
||||||
|
MeResolved: "",
|
||||||
|
Code: "",
|
||||||
|
Provider: "",
|
||||||
|
IsCompleted: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue