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