modules/auth/social/socialtest
Package socialtest runs an in-process OpenID Connect provider standing in for Google or Apple in tests: it serves signing keys, a token endpoint and a revocation endpoint, and issues signed ID tokens, authorization codes and Apple notifications. Point a social provider at it with Endpoints.
Types#
type Claims#
type Claims struct {
Subject string
Audience string
Email string
EmailVerified bool
PrivateEmail bool
Nonce string
Name string
// IssuedAt defaults to the server's Now; Issuer to its URL.
IssuedAt time.Time
Issuer string
// Extra adds or replaces claims; a nil value removes one.
Extra map[string]any
}Claims describe an ID token to issue.
type Server#
type Server struct {
// URL is the server's base URL and issuer.
URL string
// Now is the clock for issued tokens. Default: time.Now.
Now func() time.Time
// contains filtered or unexported fields
}Server is a fake provider. It is safe for concurrent use.
func New#
func New(t testing.TB) *ServerNew starts a server, closed when the test ends.
func (*Server) Code#
func (s *Server) Code(c Claims, refreshToken string) stringCode returns a single-use authorization code whose exchange returns an ID token with c's claims and refreshToken (none when empty).
func (*Server) Endpoints#
func (s *Server) Endpoints() social.EndpointsEndpoints returns the server's endpoints for a social provider.
func (*Server) FailRevocations#
func (s *Server) FailRevocations(fail bool)FailRevocations makes the revocation endpoint answer 503 while fail is true, to test retries.
func (*Server) IDToken#
func (s *Server) IDToken(c Claims) stringIDToken returns a signed ID token with c's claims, valid for an hour.
func (*Server) Notification#
func (s *Server) Notification(audience, eventType, subject string) stringNotification returns a signed Apple server-to-server notification.
func (*Server) Revoked#
func (s *Server) Revoked() []stringRevoked returns every token revoked.
func (*Server) TokenRequests#
func (s *Server) TokenRequests() []url.ValuesTokenRequests returns the form of every token request received.