Documentation
¶
Overview ¶
Package authtest provides an in-memory auth.Store for tests.
Index ¶
- type MemStore
- func (m *MemStore) APIKeyByHash(_ context.Context, hash string) (auth.APIKey, error)
- func (m *MemStore) AcquireLoginLock(_ context.Context, key, owner string, now, until time.Time) (bool, error)
- func (m *MemStore) AddEraseCount(_ context.Context, jobID, key string, n int64) error
- func (m *MemStore) AddRoles(_ context.Context, userID string, roles []string, now time.Time) error
- func (m *MemStore) AddStorageUsage(_ context.Context, owner string, bytes, files int64) error
- func (m *MemStore) AppendAudit(_ context.Context, rec auth.AuditRecord) error
- func (m *MemStore) AuditRecords() []auth.AuditRecord
- func (m *MemStore) CancelJob(_ context.Context, id string, result auth.JobResult, steps []auth.Step, ...) (bool, error)
- func (m *MemStore) ClaimDirectUpload(_ context.Context, id, tokenHash string, now time.Time) (auth.FileJournalEntry, error)
- func (m *MemStore) ClaimFileDeletions(_ context.Context, now, lease time.Time, limit int) ([]auth.FileDeletion, error)
- func (m *MemStore) ClaimIdempotency(_ context.Context, rec auth.IdempotencyRecord) (auth.IdempotencyRecord, bool, error)
- func (m *MemStore) ClaimInvitation(_ context.Context, hash string, now time.Time) (auth.Invitation, error)
- func (m *MemStore) ClaimInvitationByID(_ context.Context, id string, now time.Time) (auth.Invitation, error)
- func (m *MemStore) ClaimJob(_ context.Context, workerID string, at time.Time, margin time.Duration) (auth.Job, bool, error)
- func (m *MemStore) ClaimPendingUpload(_ context.Context, id, tokenHash, documentID string, now time.Time) (auth.FileJournalEntry, error)
- func (m *MemStore) ClearEraseEmail(_ context.Context, jobID string) error
- func (m *MemStore) ClearLoginAttempts(_ context.Context, key string) error
- func (m *MemStore) CompleteFileDeletion(_ context.Context, key string) error
- func (m *MemStore) CompleteIdempotency(_ context.Context, id string, result *auth.JobResult, jobID string, ...) error
- func (m *MemStore) CompleteJob(_ context.Context, id string, result auth.JobResult, ...) error
- func (m *MemStore) CompletePendingUpload(_ context.Context, id, name, contentType, sha256sum string, size int64, ...) error
- func (m *MemStore) CountOpenPendingUploads(_ context.Context, callerKey string, now time.Time) (int, error)
- func (m *MemStore) CounterKeys() []string
- func (m *MemStore) CreateAPIKey(_ context.Context, k auth.APIKey) error
- func (m *MemStore) CreateEmailToken(_ context.Context, t auth.EmailToken) error
- func (m *MemStore) CreateInvitation(_ context.Context, inv auth.Invitation) error
- func (m *MemStore) CreateSession(_ context.Context, s auth.Session) error
- func (m *MemStore) CreateUser(_ context.Context, u auth.User) error
- func (m *MemStore) DeleteAPIKey(_ context.Context, name string) error
- func (m *MemStore) DeleteEmailJobsOfUser(_ context.Context, userID string) error
- func (m *MemStore) DeleteEmailTokensOfUser(_ context.Context, userID string) error
- func (m *MemStore) DeleteInvitation(_ context.Context, id string) error
- func (m *MemStore) DeleteOtherSessions(_ context.Context, userID, keepID string) (int64, error)
- func (m *MemStore) DeleteSecret(_ context.Context, database, name string) error
- func (m *MemStore) DeleteSession(_ context.Context, userID, id string) error
- func (m *MemStore) DeleteSessions(_ context.Context, userID string) (int64, error)
- func (m *MemStore) DeleteUser(_ context.Context, id string) error
- func (m *MemStore) Deletions() []auth.FileDeletion
- func (m *MemStore) EmailTokens() []auth.EmailToken
- func (m *MemStore) EnqueueJob(_ context.Context, j auth.Job) error
- func (m *MemStore) EraseUser(_ context.Context, id, placeholderEmail string, now time.Time) error
- func (m *MemStore) FileDeletionStats(_ context.Context) (auth.FileDeletionStats, error)
- func (m *MemStore) FileJournalEntry(_ context.Context, id string) (auth.FileJournalEntry, error)
- func (m *MemStore) GetCheckReport(_ context.Context, database, collection string) (auth.CheckReport, bool, error)
- func (m *MemStore) GetEmailToken(_ context.Context, hash string) (auth.EmailToken, error)
- func (m *MemStore) GetJob(_ context.Context, id string) (auth.Job, bool, error)
- func (m *MemStore) Identity(_ context.Context, provider, subject string) (auth.Identity, error)
- func (m *MemStore) ImageDeclarations(_ context.Context) (map[string]string, error)
- func (m *MemStore) IncrementCounter(_ context.Context, key string, at, expires time.Time) (int, time.Time, error)
- func (m *MemStore) InvalidateEmailTokens(_ context.Context, userID, purpose string, now time.Time) error
- func (m *MemStore) JournalEntry(id string) (auth.FileJournalEntry, bool)
- func (m *MemStore) JournalFile(_ context.Context, e auth.FileJournalEntry) error
- func (m *MemStore) ListAPIKeys(context.Context) ([]auth.APIKey, error)
- func (m *MemStore) ListAudit(_ context.Context, f auth.AuditFilter) ([]auth.AuditRecord, bool, error)
- func (m *MemStore) ListCheckReports(_ context.Context, documents bool) ([]auth.CheckReport, error)
- func (m *MemStore) ListInvitations(context.Context) ([]auth.Invitation, error)
- func (m *MemStore) ListInvocations(_ context.Context, f auth.InvocationFilter) ([]auth.InvocationRecord, bool, error)
- func (m *MemStore) ListJobs(_ context.Context, f auth.JobFilter) ([]auth.Job, bool, error)
- func (m *MemStore) ListScheduleStates(context.Context) ([]auth.ScheduleState, error)
- func (m *MemStore) ListSecrets(context.Context) ([]auth.Secret, error)
- func (m *MemStore) ListSessions(_ context.Context, userID string) ([]auth.Session, error)
- func (m *MemStore) ListUnverifiedUsers(_ context.Context, before time.Time, limit int) ([]auth.User, error)
- func (m *MemStore) ListUsers(context.Context) ([]auth.User, error)
- func (m *MemStore) ListUsersPage(ctx context.Context, contains, after string, skip, limit int) ([]auth.User, bool, error)
- func (m *MemStore) LoginAttempts(_ context.Context, key string) (auth.Attempts, error)
- func (m *MemStore) PutIdentity(_ context.Context, id auth.Identity) error
- func (m *MemStore) QueueFileDeletion(_ context.Context, d auth.FileDeletion) error
- func (m *MemStore) RecordInvocation(_ context.Context, r auth.InvocationRecord) error
- func (m *MemStore) RecordLoginFailure(_ context.Context, key string, at, expires time.Time) error
- func (m *MemStore) RedeemEmailToken(_ context.Context, hash, purpose string, now time.Time) (auth.EmailToken, error)
- func (m *MemStore) ReleaseIdempotency(_ context.Context, id string) error
- func (m *MemStore) ReleaseLoginLock(_ context.Context, key, owner string) error
- func (m *MemStore) ReleaseUpload(_ context.Context, id, status string, at time.Time) error
- func (m *MemStore) RemoveRole(_ context.Context, userID, role string, now time.Time) error
- func (m *MemStore) RenewJobLease(_ context.Context, id string, attempt int, until time.Time) (bool, error)
- func (m *MemStore) ReopenJob(_ context.Context, id string, expiresAt time.Time) (bool, error)
- func (m *MemStore) RetryFileDeletion(_ context.Context, key string, notBefore time.Time) error
- func (m *MemStore) RetryJob(_ context.Context, id string, notBefore time.Time) error
- func (m *MemStore) SecretByScope(_ context.Context, database, name string) (auth.Secret, error)
- func (m *MemStore) Session(id string) (auth.Session, bool)
- func (m *MemStore) SessionByTokenHash(_ context.Context, hash string) (auth.Session, auth.User, error)
- func (m *MemStore) SessionCount(userID string) int
- func (m *MemStore) SetCheckReport(_ context.Context, r auth.CheckReport) error
- func (m *MemStore) SetFileJournalStatus(_ context.Context, id, status, documentID string, at, expiresAt time.Time) error
- func (m *MemStore) SetImageDeclaration(_ context.Context, key, fingerprint string) error
- func (m *MemStore) SetJobSteps(_ context.Context, id string, attempt int, steps []auth.Step, omitted int) (bool, error)
- func (m *MemStore) SetScheduleState(_ context.Context, st auth.ScheduleState) error
- func (m *MemStore) StaleFileJournal(_ context.Context, before, now time.Time, limit int) ([]auth.FileJournalEntry, error)
- func (m *MemStore) StorageUsage(_ context.Context, limit int) (auth.StorageUsage, error)
- func (m *MemStore) StorageUsageOf(_ context.Context, owner string) (auth.StorageUsageTotals, auth.StorageUsageTotals, error)
- func (m *MemStore) TouchAPIKey(_ context.Context, hash string, at time.Time) error
- func (m *MemStore) TouchSession(_ context.Context, id string, lastUsed, expires time.Time) error
- func (m *MemStore) UpdateUser(_ context.Context, id string, upd auth.UserUpdate, now time.Time) error
- func (m *MemStore) UpsertSecret(_ context.Context, s auth.Secret) error
- func (m *MemStore) UserByEmail(_ context.Context, email string) (auth.User, error)
- func (m *MemStore) UserByID(_ context.Context, id string) (auth.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemStore ¶
type MemStore struct {
// FailPutIdentity, when set, is returned by PutIdentity.
FailPutIdentity error
// contains filtered or unexported fields
}
MemStore is an in-memory auth.Store. The zero value is not usable; use NewMemStore.
func (*MemStore) APIKeyByHash ¶
func (*MemStore) AcquireLoginLock ¶ added in v0.5.0
func (m *MemStore) AcquireLoginLock(_ context.Context, key, owner string, now, until time.Time) (bool, error)
AcquireLoginLock and ReleaseLoginLock keep the locks apart from the counters.
func (*MemStore) AddEraseCount ¶ added in v0.4.0
func (*MemStore) AddStorageUsage ¶ added in v0.8.0
func (*MemStore) AppendAudit ¶
func (*MemStore) AuditRecords ¶
func (m *MemStore) AuditRecords() []auth.AuditRecord
AuditRecords returns every stored audit record, oldest first.
func (*MemStore) ClaimDirectUpload ¶ added in v0.8.0
func (*MemStore) ClaimFileDeletions ¶ added in v0.8.0
func (*MemStore) ClaimIdempotency ¶
func (m *MemStore) ClaimIdempotency(_ context.Context, rec auth.IdempotencyRecord) (auth.IdempotencyRecord, bool, error)
ClaimIdempotency inserts rec if its id isn't already used, mirroring the MongoDB store's insert-or-fetch-existing atomicity (a single mutex makes this trivially atomic here).
func (*MemStore) ClaimInvitation ¶
func (*MemStore) ClaimInvitationByID ¶ added in v0.4.0
func (*MemStore) ClaimJob ¶
func (m *MemStore) ClaimJob(_ context.Context, workerID string, at time.Time, margin time.Duration) (auth.Job, bool, error)
ClaimJob picks the oldest job that's never been claimed, or whose lease has expired, the same rule the MongoDB store's query applies.
func (*MemStore) ClaimPendingUpload ¶ added in v0.8.0
func (*MemStore) ClearEraseEmail ¶ added in v0.4.0
func (*MemStore) ClearLoginAttempts ¶
func (*MemStore) CompleteFileDeletion ¶ added in v0.8.0
func (*MemStore) CompleteIdempotency ¶
func (*MemStore) CompleteJob ¶
func (*MemStore) CompletePendingUpload ¶ added in v0.8.0
func (*MemStore) CountOpenPendingUploads ¶ added in v0.8.0
func (*MemStore) CounterKeys ¶ added in v0.4.0
CounterKeys returns the keys of every counter, for tests.
func (*MemStore) CreateAPIKey ¶
func (*MemStore) CreateEmailToken ¶ added in v0.4.0
func (*MemStore) CreateInvitation ¶
func (*MemStore) CreateSession ¶
func (*MemStore) DeleteAPIKey ¶
func (*MemStore) DeleteEmailJobsOfUser ¶ added in v0.4.0
func (*MemStore) DeleteEmailTokensOfUser ¶ added in v0.4.0
func (*MemStore) DeleteInvitation ¶
func (*MemStore) DeleteOtherSessions ¶
func (*MemStore) DeleteSecret ¶
func (*MemStore) DeleteSession ¶
func (*MemStore) DeleteSessions ¶
func (*MemStore) Deletions ¶ added in v0.8.0
func (m *MemStore) Deletions() []auth.FileDeletion
Deletions returns the queued deletions, for tests.
func (*MemStore) EmailTokens ¶ added in v0.4.0
func (m *MemStore) EmailTokens() []auth.EmailToken
EmailTokens returns every stored token record, for tests.
func (*MemStore) FileDeletionStats ¶ added in v0.8.0
func (*MemStore) FileJournalEntry ¶ added in v0.8.0
func (*MemStore) GetCheckReport ¶ added in v0.8.0
func (*MemStore) GetEmailToken ¶ added in v0.4.0
func (*MemStore) ImageDeclarations ¶ added in v0.8.1
func (*MemStore) IncrementCounter ¶
func (m *MemStore) IncrementCounter(_ context.Context, key string, at, expires time.Time) (int, time.Time, error)
IncrementCounter is a fixed window, unlike RecordLoginFailure's sliding cleanup deadline: expires (and so the reset) only moves once the current window has actually ended, or a steady stream of calls would push the deadline forward forever and never reset the count.
func (*MemStore) InvalidateEmailTokens ¶ added in v0.4.0
func (*MemStore) JournalEntry ¶ added in v0.8.0
func (m *MemStore) JournalEntry(id string) (auth.FileJournalEntry, bool)
JournalEntry returns an upload's record, for tests.
func (*MemStore) JournalFile ¶ added in v0.8.0
func (*MemStore) ListAPIKeys ¶
func (*MemStore) ListAudit ¶
func (m *MemStore) ListAudit(_ context.Context, f auth.AuditFilter) ([]auth.AuditRecord, bool, error)
ListAudit filters like the MongoDB store, newest first. Expired records are kept, as before MongoDB's TTL monitor removes them.
func (*MemStore) ListCheckReports ¶ added in v0.8.0
func (*MemStore) ListInvitations ¶
func (*MemStore) ListInvocations ¶
func (m *MemStore) ListInvocations(_ context.Context, f auth.InvocationFilter) ([]auth.InvocationRecord, bool, error)
ListInvocations filters like the MongoDB store, newest first. Expired records are kept, as before MongoDB's TTL monitor removes them.
func (*MemStore) ListScheduleStates ¶ added in v0.8.0
func (*MemStore) ListSecrets ¶
func (*MemStore) ListSessions ¶
func (*MemStore) ListUnverifiedUsers ¶ added in v0.4.0
func (*MemStore) ListUsersPage ¶ added in v0.5.0
func (*MemStore) LoginAttempts ¶
LoginAttempts returns the counter even past its expiry, like MongoDB before its TTL monitor deletes it; a failure after expiry restarts it.
func (*MemStore) PutIdentity ¶
func (*MemStore) QueueFileDeletion ¶ added in v0.8.0
func (*MemStore) RecordInvocation ¶
func (*MemStore) RecordLoginFailure ¶
func (*MemStore) RedeemEmailToken ¶ added in v0.4.0
func (*MemStore) ReleaseIdempotency ¶
func (*MemStore) ReleaseLoginLock ¶ added in v0.5.0
func (*MemStore) ReleaseUpload ¶ added in v0.8.0
func (*MemStore) RemoveRole ¶
func (*MemStore) RenewJobLease ¶ added in v0.8.0
func (*MemStore) RetryFileDeletion ¶ added in v0.8.0
func (*MemStore) SecretByScope ¶
func (*MemStore) SessionByTokenHash ¶
func (*MemStore) SessionCount ¶
SessionCount returns how many sessions the user has, expired or not.
func (*MemStore) SetCheckReport ¶ added in v0.8.0
func (*MemStore) SetFileJournalStatus ¶ added in v0.8.0
func (*MemStore) SetImageDeclaration ¶ added in v0.8.1
func (*MemStore) SetJobSteps ¶ added in v0.8.0
func (*MemStore) SetScheduleState ¶ added in v0.8.0
func (*MemStore) StaleFileJournal ¶ added in v0.8.0
func (*MemStore) StorageUsage ¶ added in v0.8.0
func (*MemStore) StorageUsageOf ¶ added in v0.8.1
func (m *MemStore) StorageUsageOf(_ context.Context, owner string) (auth.StorageUsageTotals, auth.StorageUsageTotals, error)