auth/internal/domain/session.go

42 lines
916 B
Go

package domain
import (
"testing"
"source.toby3d.me/website/indieauth/internal/random"
)
type Session struct {
ClientID *ClientID
Me *Me
RedirectURI *URL
Profile *Profile
CodeChallengeMethod CodeChallengeMethod
Scope Scopes
Code string
CodeChallenge string
}
// TestSession returns valid random generated session for tests.
func TestSession(tb testing.TB) *Session {
tb.Helper()
code, err := random.String(24)
if err != nil {
tb.Fatalf("%+v", err)
}
return &Session{
ClientID: TestClientID(tb),
Code: code,
CodeChallenge: "hackme",
CodeChallengeMethod: CodeChallengeMethodPLAIN,
Me: TestMe(tb, "https://user.example.net/"),
RedirectURI: TestURL(tb, "https://example.com/callback"),
Scope: Scopes{
ScopeEmail,
ScopeProfile,
},
}
}