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) (key *auth.Key, found bool, err error)
- func (m *MemStore) GetSessionByHash(_ context.Context, tokenHash string) (sess *auth.Session, found bool, err error)
- func (m *MemStore) GetUserByID(_ context.Context, id int64) (user *auth.User, found bool, err 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 ¶
func (m *MemStore) GetAPIKeyByHash(_ context.Context, hash string) (key *auth.Key, found bool, err error)
GetAPIKeyByHash returns the API key stored under hash. found is false when the key is absent; err is always nil.
func (*MemStore) GetSessionByHash ¶
func (m *MemStore) GetSessionByHash(_ context.Context, tokenHash string) (sess *auth.Session, found bool, err error)
GetSessionByHash returns the session stored under tokenHash. found is false when no such session exists; err is always nil.