Documentation
¶
Index ¶
- func DeriveTestCSRFToken(rawSessionToken string) string
- func TestCSRFKey() []byte
- func TestPasswordHash(t testing.TB, password string) string
- type MockEmailSender
- type MockStore
- func (m *MockStore) AdminExists(ctx context.Context) (bool, error)
- func (m *MockStore) ClaimMFALoginTokenAttempt(ctx context.Context, tokenHash string, maxAttempts int) (*auth.MFALoginToken, error)
- func (m *MockStore) ClaimTOTPCounter(ctx context.Context, userID string, counter int64) (bool, error)
- func (m *MockStore) CleanupExpiredSessions(ctx context.Context) error
- func (m *MockStore) ClearPendingMFASecret(ctx context.Context, userID string) error
- func (m *MockStore) CompletePasswordReset(ctx context.Context, user *auth.User, readResetToken, readPasswordHash string) error
- func (m *MockStore) ConsumeMFALoginToken(ctx context.Context, tokenHash string) (bool, error)
- func (m *MockStore) ConsumeMFARecoveryCode(ctx context.Context, userID string, readCodes, remaining []string) error
- func (m *MockStore) ConsumePasswordResetToken(ctx context.Context, userID, readResetToken string) error
- func (m *MockStore) CountGroupMembers(ctx context.Context, groupID string) (int, error)
- func (m *MockStore) CreateAPIKey(ctx context.Context, key *auth.UserAPIKey) error
- func (m *MockStore) CreateAdminIfNone(ctx context.Context, user *auth.User) (bool, error)
- func (m *MockStore) CreateGroup(ctx context.Context, group *auth.Group) error
- func (m *MockStore) CreateMFALoginToken(ctx context.Context, tokenHash, userID string, passwordVersion int64, ...) (time.Time, error)
- func (m *MockStore) CreateSession(ctx context.Context, session *auth.Session) error
- func (m *MockStore) CreateUser(ctx context.Context, user *auth.User) error
- func (m *MockStore) DeleteAPIKey(ctx context.Context, keyID string) error
- func (m *MockStore) DeleteGroup(ctx context.Context, groupID string) error
- func (m *MockStore) DeleteSession(ctx context.Context, token string) error
- func (m *MockStore) DeleteUser(ctx context.Context, userID string) error
- func (m *MockStore) DeleteUserSessions(ctx context.Context, userID string) error
- func (m *MockStore) DisableMFA(ctx context.Context, userID, readSecret string, readCodes []string) error
- func (m *MockStore) EnableMFA(ctx context.Context, userID, pendingSecret string, totpCounter int64, ...) error
- func (m *MockStore) GetAPIKeyByHash(ctx context.Context, keyHash string) (*auth.UserAPIKey, error)
- func (m *MockStore) GetAPIKeyByID(ctx context.Context, keyID string) (*auth.UserAPIKey, error)
- func (m *MockStore) GetGroup(ctx context.Context, groupID string) (*auth.Group, error)
- func (m *MockStore) GetSession(ctx context.Context, token string) (*auth.Session, error)
- func (m *MockStore) GetUserByEmail(ctx context.Context, email string) (*auth.User, error)
- func (m *MockStore) GetUserByID(ctx context.Context, userID string) (*auth.User, error)
- func (m *MockStore) GetUserByResetToken(ctx context.Context, token string) (*auth.User, error)
- func (m *MockStore) ListAPIKeysByUser(ctx context.Context, userID string) ([]*auth.UserAPIKey, error)
- func (m *MockStore) ListGroups(ctx context.Context) ([]auth.Group, error)
- func (m *MockStore) ListUsers(ctx context.Context) ([]auth.User, error)
- func (m *MockStore) Ping(ctx context.Context) error
- func (m *MockStore) RecordAPIKeyUsage(ctx context.Context, keyID string, delta int64) error
- func (m *MockStore) RecordFailedLogin(ctx context.Context, userID string) error
- func (m *MockStore) RecordSuccessfulLogin(ctx context.Context, userID string) error
- func (m *MockStore) ReplaceMFARecoveryCodes(ctx context.Context, userID, readSecret string, readCodes, newHashes []string) error
- func (m *MockStore) SetPasswordResetToken(ctx context.Context, user *auth.User, readExpiry *time.Time) error
- func (m *MockStore) SetPendingMFASecret(ctx context.Context, userID, secret string, expiresAt time.Time) error
- func (m *MockStore) UpdateAPIKey(ctx context.Context, key *auth.UserAPIKey) error
- func (m *MockStore) UpdateGroup(ctx context.Context, group *auth.Group) error
- func (m *MockStore) UpdateUserAdminFields(ctx context.Context, user *auth.User, readEmail string, readGroupIDs []string, ...) error
- func (m *MockStore) UpdateUserCredentials(ctx context.Context, user *auth.User, readEmail, readPasswordHash string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveTestCSRFToken ¶
DeriveTestCSRFToken returns the CSRF token a service configured with TestCSRFKey expects for rawSessionToken: hex(HMAC-SHA256(key, token)). It re-derives the value independently, so a change to the production derivation fails the tests that use it.
func TestCSRFKey ¶
func TestCSRFKey() []byte
TestCSRFKey returns the fixed 32-byte CSRF key shared by test services. Pass it as auth.ServiceConfig.CSRFKey so a service built via auth.NewService derives CSRF tokens deterministically, letting tests reproduce the expected token with DeriveTestCSRFToken.
Types ¶
type MockEmailSender ¶
MockEmailSender is a mock implementation of the email sender for testing.
func (*MockEmailSender) SendPasswordResetEmail ¶
func (m *MockEmailSender) SendPasswordResetEmail(ctx context.Context, email, resetURL string) error
func (*MockEmailSender) SendUserInviteEmail ¶
func (m *MockEmailSender) SendUserInviteEmail(ctx context.Context, email, setupURL string) error
type MockStore ¶
MockStore is a testify mock of auth.StoreInterface for tests outside package auth. Tests inside package auth use their own copy in test_helpers_test.go (importing this package from there would be an import cycle), so a new store method must be added to both.
func (*MockStore) ClaimMFALoginTokenAttempt ¶
func (*MockStore) ClaimTOTPCounter ¶
func (*MockStore) CleanupExpiredSessions ¶
func (*MockStore) ClearPendingMFASecret ¶
func (*MockStore) CompletePasswordReset ¶
func (*MockStore) ConsumeMFALoginToken ¶
func (*MockStore) ConsumeMFARecoveryCode ¶
func (*MockStore) ConsumePasswordResetToken ¶
func (*MockStore) CountGroupMembers ¶
func (*MockStore) CreateAPIKey ¶
API Key operations.