Documentation
¶
Overview ¶
Package storetest is the conformance suite for auth.Store implementations. Every store must pass it:
func TestConformance(t *testing.T) {
storetest.Run(t, func(t *testing.T) auth.Store { return newStore(t) })
}
The factory must return an empty store each time it is called.
Index ¶
- Variables
- func CheckWrapper(t *testing.T, inner, wrapped auth.Store)
- func CrashDuringRotation(t *testing.T, state string, open CrashFunc, setHook func(func()))
- func Run(t *testing.T, newStore Factory)
- func RunDevices(t *testing.T, newStore DeviceFactory)
- func RunEmails(t *testing.T, newStore EmailFactory)
- func RunFactors(t *testing.T, newStore FactorFactory)
- func RunIdentities(t *testing.T, newStore IdentityFactory)
- func RunSignup(t *testing.T, newStore SignupFactory)
- func RunSignupSettings(t *testing.T, newStore func(t *testing.T) auth.Store)
- func RunTransfer(t *testing.T, newStore TransferFactory)
- func RunWrapper(t *testing.T, inner auth.Store, wrap func(auth.Store) auth.Store)
- type CrashFunc
- type DeviceFactory
- type DeviceStore
- type EmailFactory
- type EmailStore
- type FactorFactory
- type Factory
- type FullStore
- type IdentityFactory
- type IdentityStore
- type Optional
- type SignupFactory
- type SignupStore
- type TransferFactory
- type TransferStore
Constants ¶
This section is empty.
Variables ¶
var Optionals = []Optional{ {"auth.FactorStore", has[auth.FactorStore]}, {"auth.DeviceStore", has[auth.DeviceStore]}, {"auth.TransferStore", has[auth.TransferStore]}, {"auth.EmailStore", has[auth.EmailStore]}, {"auth.IdentityStore", has[auth.IdentityStore]}, {"auth.SignupStore", has[auth.SignupStore]}, {"auth.SignupSettingsStore", has[auth.SignupSettingsStore]}, }
Optionals lists every optional store interface that the root package or a factor package checks for with a type assertion.
Functions ¶
func CheckWrapper ¶
CheckWrapper reports each optional interface in Optionals that wrapped and inner don't agree on.
func CrashDuringRotation ¶
CrashDuringRotation checks that a process killed in the middle of SwapToken leaves the rotation undone: the old token is still current, the new token is unknown, and no rotation event was recorded. A half-done rotation could log the user out or leave a token that can't be found.
The test starts a child copy of the test binary that calls SwapToken with setHook installed. The hook must run inside SwapToken's transaction, between its writes; the child kills itself there with SIGKILL, so no deferred rollback runs. The parent then reopens the database and checks its state.
Call it from a top-level test function, and pass the same state each time: for example, a database path or schema name.
func RunDevices ¶
func RunDevices(t *testing.T, newStore DeviceFactory)
RunDevices runs every conformance test for auth.DeviceStore against stores made by newStore.
func RunEmails ¶
func RunEmails(t *testing.T, newStore EmailFactory)
RunEmails runs every conformance test for auth.EmailStore against stores made by newStore.
func RunFactors ¶
func RunFactors(t *testing.T, newStore FactorFactory)
RunFactors runs every conformance test for auth.FactorStore against stores made by newStore.
func RunIdentities ¶
func RunIdentities(t *testing.T, newStore IdentityFactory)
RunIdentities runs every conformance test for auth.IdentityStore against stores made by newStore. Tests that need passkey credentials run only when the store is also an auth.FactorStore.
func RunSignup ¶
func RunSignup(t *testing.T, newStore SignupFactory)
RunSignup runs every conformance test for auth.SignupStore against stores made by newStore.
func RunSignupSettings ¶
RunSignupSettings runs the conformance tests for auth.SignupSettingsStore.
func RunTransfer ¶
func RunTransfer(t *testing.T, newStore TransferFactory)
RunTransfer runs every conformance test for auth.TransferStore against stores made by newStore.
func RunWrapper ¶
RunWrapper checks a store wrapper, such as a cache: wrap(inner) must implement each optional interface in Optionals exactly when inner does. It checks inner, and inner with every optional interface hidden. A wrapper that drops an interface turns off the features that need it, and one that claims an interface inner lacks fails at run time.
Types ¶
type CrashFunc ¶
CrashFunc opens a store for the database identified by state. The crash test calls it in the parent process and in a child process, so it must reach the same database from both.
type DeviceFactory ¶
type DeviceFactory func(t *testing.T) DeviceStore
DeviceFactory returns a new, empty store.
type DeviceStore ¶
type DeviceStore interface {
auth.Store
auth.DeviceStore
}
DeviceStore is a store that also persists device codes.
type EmailFactory ¶
type EmailFactory func(t *testing.T) EmailStore
EmailFactory returns a new, empty store.
type EmailStore ¶
type EmailStore interface {
auth.Store
auth.FactorStore
auth.IdentityStore
auth.EmailStore
}
EmailStore is a store that persists sessions, factors, identities, addresses, and passwords.
type FactorFactory ¶
FactorFactory returns a new, empty store.
type FullStore ¶
type FullStore interface {
auth.Store
auth.FactorStore
}
FullStore is a store that also persists factors.
type IdentityFactory ¶
type IdentityFactory func(t *testing.T) IdentityStore
IdentityFactory returns a new, empty store.
type IdentityStore ¶
type IdentityStore interface {
auth.Store
auth.IdentityStore
}
IdentityStore is a store that also persists external identities.
type Optional ¶
Optional is one optional store interface of the root package, with a check for it, for RunWrapper.
type SignupFactory ¶
type SignupFactory func(t *testing.T) SignupStore
SignupFactory returns a new, empty store.
type SignupStore ¶
type SignupStore interface {
auth.Store
auth.SignupStore
}
SignupStore is a store that also persists self-signed-up agents.
type TransferFactory ¶
type TransferFactory func(t *testing.T) TransferStore
TransferFactory returns a new, empty store.
type TransferStore ¶
type TransferStore interface {
EmailStore
auth.SignupStore
auth.TransferStore
}
TransferStore is a store that persists every sign-in record and exports and imports them.