Documentation
¶
Overview ¶
Package testkit provides test doubles for authkit consumers.
Index ¶
- type Store
- func (s *Store) AddUser(tb testing.TB, email, name, password string) gouncer.User
- func (s *Store) CreateSession(_ context.Context, sess gouncer.Session) error
- func (s *Store) CreateUser(_ context.Context, u gouncer.User) error
- func (s *Store) DeleteSession(_ context.Context, tokenHash []byte) error
- func (s *Store) ListUsers(_ context.Context) ([]gouncer.User, error)
- func (s *Store) SetUserDisabled(_ context.Context, id uuid.UUID, disabled bool) error
- func (s *Store) UserByEmail(_ context.Context, email string) (gouncer.User, error)
- func (s *Store) UserBySession(_ context.Context, tokenHash []byte, now time.Time) (gouncer.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
Users map[uuid.UUID]gouncer.User
Sessions map[string]gouncer.Session
LookupErr error
SessionErr error
CreateSessionErr error
DeleteErr error
ListUsersErr error
CreateUserErr error
SetDisabledErr error
}
Store is an in-memory user and session store encoding the gouncer contract semantics for tests. Set an Err field to force that method to fail.
func (*Store) CreateSession ¶
CreateSession stores sess.
func (*Store) CreateUser ¶
CreateUser stores u, or returns gouncer.ErrEmailTaken for a known email.
func (*Store) DeleteSession ¶
DeleteSession removes the session. Removing an absent one is not an error.
func (*Store) ListUsers ¶
ListUsers returns every account ordered by name then id, with password hashes stripped.
func (*Store) SetUserDisabled ¶
SetUserDisabled updates whether the account may log in, revoking its sessions on disable.
func (*Store) UserByEmail ¶
UserByEmail returns the user with the normalized email, or gouncer.ErrUserNotFound.