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