Documentation
¶
Overview ¶
Package authtest provides an in-memory implementation of auth.AuthStore for use in consumer tests. It is not intended for production use.
Index ¶
- type MemStore
- func (m *MemStore) AddAPIKey(k *auth.Key)
- func (m *MemStore) AddSession(s *auth.Session)
- func (m *MemStore) AddUser(u *auth.User)
- func (m *MemStore) CreateSession(_ context.Context, s *auth.Session) error
- func (m *MemStore) DeleteSession(_ context.Context, tokenHash string) error
- func (m *MemStore) DeleteUserSessions(_ context.Context, userID int64, exceptHash string) error
- func (m *MemStore) GetAPIKeyByHash(_ context.Context, hash string) (*auth.Key, error)
- func (m *MemStore) GetSessionByHash(_ context.Context, tokenHash string) (*auth.Session, error)
- func (m *MemStore) GetUserByID(_ context.Context, id int64) (*auth.User, error)
- func (m *MemStore) UpdateSessionActivity(_ context.Context, tokenHash string, now time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore is an in-memory implementation of auth interfaces for testing.
func (*MemStore) AddSession ¶
AddSession adds a session to the store.
func (*MemStore) CreateSession ¶
CreateSession stores a copy of s, keyed by its TokenHash.
func (*MemStore) DeleteSession ¶
DeleteSession removes the session stored under tokenHash, if any.
func (*MemStore) DeleteUserSessions ¶
DeleteUserSessions removes every session belonging to userID except the one whose token hash equals exceptHash.
func (*MemStore) GetAPIKeyByHash ¶
GetAPIKeyByHash returns the API key stored under hash, or (nil, nil) if absent.
func (*MemStore) GetSessionByHash ¶
GetSessionByHash returns the session stored under tokenHash, or (nil, nil) if no such session exists.
func (*MemStore) GetUserByID ¶
GetUserByID returns the user with the given id, or (nil, nil) if absent.