Documentation
¶
Overview ¶
Package testoauth is a fake OAuth 2.0 authorization and token server for tests, with a stand-in for the user's browser.
Index ¶
- Constants
- type Callback
- type Server
- func (s *Server) Browse(t *testing.T, authURL, email string) Callback
- func (s *Server) Config(scopes ...string) auth.OAuthConfig
- func (s *Server) Deny(deny bool)
- func (s *Server) Hang(t *testing.T) (release func())
- func (s *Server) OmitExpiry(on bool)
- func (s *Server) RespondNext(status int, body string)
- func (s *Server) RevokeAccess()
- func (s *Server) RevokeAll()
- func (s *Server) RotateRefresh(on bool)
- func (s *Server) S256Requested() bool
- func (s *Server) SetEmail(email string)
- func (s *Server) TokenRequests() int
- func (s *Server) ValidAccess(token string) bool
- func (s *Server) VerifierChecked() bool
Constants ¶
const ClientID = "godwit-test"
ClientID is the only client the server knows.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
AuthURL, TokenURL string
// contains filtered or unexported fields
}
Server issues codes, tokens and unsigned id_tokens. Refresh tokens do not rotate unless RotateRefresh(true).
func (*Server) Browse ¶
Browse plays the user's browser: it opens authURL, signs in as email and follows the server's redirect to the loopback address.
func (*Server) Config ¶
func (s *Server) Config(scopes ...string) auth.OAuthConfig
Config is an OAuthConfig for this server.
func (*Server) Deny ¶
Deny makes the user refuse consent: the server redirects with error=access_denied.
func (*Server) Hang ¶
Hang makes token requests wait, without an answer, until release is called or the client goes away. release also runs when the test ends.
func (*Server) OmitExpiry ¶
OmitExpiry makes token responses leave out expires_in.
func (*Server) RespondNext ¶
RespondNext makes the token endpoint answer its next request with status and a JSON body, whatever was asked.
func (*Server) RevokeAccess ¶
func (s *Server) RevokeAccess()
RevokeAccess invalidates every access token issued so far; refresh tokens still work.
func (*Server) RevokeAll ¶
func (s *Server) RevokeAll()
RevokeAll invalidates every refresh and access token issued so far.
func (*Server) RotateRefresh ¶
RotateRefresh makes each refresh issue a new refresh token. The old one stays valid, as Microsoft's do until they expire.
func (*Server) S256Requested ¶
S256Requested reports whether every authorization request so far asked for code_challenge_method=S256 (false before the first).
func (*Server) SetEmail ¶
SetEmail makes later id_tokens name email whoever signed in; "" undoes it.
func (*Server) TokenRequests ¶
TokenRequests is how many requests the token endpoint has received.
func (*Server) ValidAccess ¶
ValidAccess reports whether token is a live access token.
func (*Server) VerifierChecked ¶
VerifierChecked reports whether every code exchange so far sent a code_verifier matching its challenge (false before the first).