Documentation ¶
Overview ¶
Package mocks defines implemented interfaces for testing modules
Index ¶
- func Request(method string, postKeyValues ...string) *http.Request
- type AfterCallback
- type ArbValues
- type BodyReader
- type ClientState
- type ClientStateRW
- type Emailer
- type ErrorHandler
- type FailStorer
- type Logger
- type Mailer
- type Redirector
- type Renderer
- type Responder
- type Router
- func (r *Router) Delete(path string, _ http.Handler)
- func (r *Router) Get(path string, _ http.Handler)
- func (r *Router) HasDeletes(deletes ...string) error
- func (r *Router) HasGets(gets ...string) error
- func (r *Router) HasPosts(posts ...string) error
- func (r *Router) Post(path string, _ http.Handler)
- func (Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type ServerStorer
- func (s *ServerStorer) AddRememberToken(ctx context.Context, key, token string) error
- func (s *ServerStorer) Create(ctx context.Context, user authboss.User) error
- func (s *ServerStorer) DelRememberTokens(ctx context.Context, key string) error
- func (s *ServerStorer) Load(ctx context.Context, key string) (authboss.User, error)
- func (s *ServerStorer) LoadByConfirmSelector(ctx context.Context, selector string) (authboss.ConfirmableUser, error)
- func (s *ServerStorer) LoadByRecoverSelector(ctx context.Context, selector string) (authboss.RecoverableUser, error)
- func (s *ServerStorer) New(context.Context) authboss.User
- func (s *ServerStorer) NewFromOAuth2(ctx context.Context, provider string, details map[string]string) (authboss.OAuth2User, error)
- func (s *ServerStorer) Save(ctx context.Context, user authboss.User) error
- func (s *ServerStorer) SaveOAuth2(ctx context.Context, user authboss.OAuth2User) error
- func (s *ServerStorer) UseRememberToken(ctx context.Context, givenKey, token string) (err error)
- type User
- func (u User) GetArbitrary() map[string]string
- func (u User) GetAttemptCount() int
- func (u User) GetConfirmSelector() string
- func (u User) GetConfirmVerifier() string
- func (u User) GetConfirmed() bool
- func (u User) GetEmail() string
- func (u User) GetLastAttempt() time.Time
- func (u User) GetLocked() time.Time
- func (u User) GetOAuth2AccessToken() string
- func (u User) GetOAuth2Expiry() time.Time
- func (u User) GetOAuth2Provider() string
- func (u User) GetOAuth2RefreshToken() string
- func (u User) GetOAuth2UID() string
- func (u User) GetPID() string
- func (u User) GetPassword() string
- func (u User) GetRecoverExpiry() time.Time
- func (u User) GetRecoverSelector() string
- func (u User) GetRecoverVerifier() string
- func (u User) GetUsername() string
- func (u User) IsOAuth2User() bool
- func (u *User) PutArbitrary(arb map[string]string)
- func (u *User) PutAttemptCount(attemptCount int)
- func (u *User) PutConfirmSelector(confirmSelector string)
- func (u *User) PutConfirmVerifier(confirmVerifier string)
- func (u *User) PutConfirmed(confirmed bool)
- func (u *User) PutEmail(email string)
- func (u *User) PutLastAttempt(attemptTime time.Time)
- func (u *User) PutLocked(locked time.Time)
- func (u *User) PutOAuth2AccessToken(token string)
- func (u *User) PutOAuth2Expiry(expiry time.Time)
- func (u *User) PutOAuth2Provider(provider string)
- func (u *User) PutOAuth2RefreshToken(refresh string)
- func (u *User) PutOAuth2UID(uid string)
- func (u *User) PutPID(email string)
- func (u *User) PutPassword(password string)
- func (u *User) PutRecoverExpiry(recoverTokenExpiry time.Time)
- func (u *User) PutRecoverSelector(recoverSelector string)
- func (u *User) PutRecoverVerifier(recoverVerifier string)
- func (u *User) PutUsername(username string)
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AfterCallback ¶
type AfterCallback struct { HasBeenCalled bool Fn authboss.EventHandler }
AfterCallback is a callback that knows if it was called
func NewAfterCallback ¶
func NewAfterCallback() *AfterCallback
NewAfterCallback constructs a new aftercallback.
type ArbValues ¶
ArbValues is arbitrary value storage
func (ArbValues) GetPassword ¶
GetPassword gets the password
type BodyReader ¶
BodyReader reads the body of a request and returns some values
type ClientState ¶
ClientState is used for testing the client stores on context
func NewClientState ¶
func NewClientState(data ...string) *ClientState
NewClientState constructs a ClientStorer
type ClientStateRW ¶
ClientStateRW stores things that would originally go in a session, or a map, in memory!
func NewClientRW ¶
func NewClientRW() *ClientStateRW
NewClientRW takes the data from a client state and returns.
func (*ClientStateRW) ReadState ¶
func (c *ClientStateRW) ReadState(*http.Request) (authboss.ClientState, error)
ReadState from memory
func (*ClientStateRW) WriteState ¶
func (c *ClientStateRW) WriteState(w http.ResponseWriter, cstate authboss.ClientState, cse []authboss.ClientStateEvent) error
WriteState to memory
type ErrorHandler ¶
type ErrorHandler struct {
Error error
}
ErrorHandler just holds the last error
func (*ErrorHandler) Wrap ¶
func (e *ErrorHandler) Wrap(handler func(w http.ResponseWriter, r *http.Request) error) http.Handler
Wrap an http method
type FailStorer ¶
type FailStorer struct {
User
}
FailStorer is used for testing module initialize functions that recover more than the base storer
type Redirector ¶
type Redirector struct {
Options authboss.RedirectOptions
}
Redirector stores the redirect options passed to it and writes the Code to the ResponseWriter.
func (*Redirector) Redirect ¶
func (r *Redirector) Redirect(w http.ResponseWriter, req *http.Request, ro authboss.RedirectOptions) error
Redirect a request
type Renderer ¶
type Renderer struct { Pages []string // Render call variables Context context.Context Page string Data authboss.HTMLData }
Renderer mock
func (*Renderer) HasLoadedViews ¶
HasLoadedViews ensures the views were loaded
type Router ¶
Router records the routes that were registered
func (*Router) HasDeletes ¶
HasDeletes ensures all gets routes are present
type ServerStorer ¶
ServerStorer should be valid for any module storer defined in authboss.
func (*ServerStorer) AddRememberToken ¶
func (s *ServerStorer) AddRememberToken(ctx context.Context, key, token string) error
AddRememberToken for remember me
func (*ServerStorer) DelRememberTokens ¶
func (s *ServerStorer) DelRememberTokens(ctx context.Context, key string) error
DelRememberTokens for a user
func (*ServerStorer) LoadByConfirmSelector ¶
func (s *ServerStorer) LoadByConfirmSelector(ctx context.Context, selector string) (authboss.ConfirmableUser, error)
LoadByConfirmSelector finds a user by his confirm selector
func (*ServerStorer) LoadByRecoverSelector ¶
func (s *ServerStorer) LoadByRecoverSelector(ctx context.Context, selector string) (authboss.RecoverableUser, error)
LoadByRecoverSelector finds a user by his recover token
func (*ServerStorer) New ¶
func (s *ServerStorer) New(context.Context) authboss.User
New constructs a blank user to later be created
func (*ServerStorer) NewFromOAuth2 ¶
func (s *ServerStorer) NewFromOAuth2(ctx context.Context, provider string, details map[string]string) (authboss.OAuth2User, error)
NewFromOAuth2 finds a user with the given details, or returns a new one
func (*ServerStorer) SaveOAuth2 ¶
func (s *ServerStorer) SaveOAuth2(ctx context.Context, user authboss.OAuth2User) error
SaveOAuth2 creates a user if not found, or updates one that exists.
func (*ServerStorer) UseRememberToken ¶
func (s *ServerStorer) UseRememberToken(ctx context.Context, givenKey, token string) (err error)
UseRememberToken if it exists, deleting it in the process
type User ¶
type User struct { Username string Email string Password string RecoverSelector string RecoverVerifier string RecoverTokenExpiry time.Time ConfirmSelector string ConfirmVerifier string Confirmed bool AttemptCount int LastAttempt time.Time Locked time.Time OAuth2UID string OAuth2Provider string OAuth2Token string OAuth2Refresh string OAuth2Expiry time.Time Arbitrary map[string]string }
User represents all possible fields a authboss User may have
func (User) GetConfirmSelector ¶
GetConfirmSelector from user
func (User) GetConfirmVerifier ¶
GetConfirmVerifier from user
func (User) GetOAuth2AccessToken ¶
GetOAuth2AccessToken from user
func (User) GetOAuth2Provider ¶
GetOAuth2Provider from user
func (User) GetOAuth2RefreshToken ¶
GetOAuth2RefreshToken from user
func (User) GetRecoverExpiry ¶
GetRecoverExpiry from user
func (User) GetRecoverSelector ¶
GetRecoverSelector from user
func (User) GetRecoverVerifier ¶
GetRecoverVerifier from user
func (User) IsOAuth2User ¶
IsOAuth2User returns true if the user is an oauth2 user
func (*User) PutArbitrary ¶
PutArbitrary into user
func (*User) PutAttemptCount ¶
PutAttemptCount into user
func (*User) PutConfirmSelector ¶
PutConfirmSelector into user
func (*User) PutConfirmVerifier ¶
PutConfirmVerifier into user
func (*User) PutLastAttempt ¶
PutLastAttempt into user
func (*User) PutOAuth2AccessToken ¶
PutOAuth2AccessToken into user
func (*User) PutOAuth2Expiry ¶
PutOAuth2Expiry into user
func (*User) PutOAuth2Provider ¶
PutOAuth2Provider into user
func (*User) PutOAuth2RefreshToken ¶
PutOAuth2RefreshToken into user
func (*User) PutRecoverExpiry ¶
PutRecoverExpiry into user
func (*User) PutRecoverSelector ¶
PutRecoverSelector into user
func (*User) PutRecoverVerifier ¶
PutRecoverVerifier into user
type Values ¶
Values is returned from the BodyReader
func (Values) GetShouldRemember ¶
GetShouldRemember gets the value that tells the remember module if it should remember the user