storetest

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

storetest

Package storetest is the conformance suite for auth.Store implementations. Every store passes storetest.Run, and each optional store interface has its own suite.

The package documentation is in storetest.go. To read it with the API, run go doc ./storetest.

Contents

Name What it holds
storetest.go Run and Factory, and the core cases; the package documentation
factors.go RunFactors, for auth.FactorStore: passkeys, recovery codes, and TOTP
signup.go RunSignup, for agent self-signup
signup_settings.go RunSignupSettings
devices.go RunDevices, for device authorization codes
identities.go RunIdentities, for federated identities
emails.go RunEmails, for email addresses and passwords
transfer.go RunTransfer, for auth.TransferStore: export snapshots and ordering, and all-or-nothing imports
crash.go CrashDuringRotation, which kills a process in the middle of a token rotation
admin.go Cases for what the admin API and the audit chain read
apptokens.go Cases for personal access tokens and OAuth tokens
keys.go Cases for DPoP key bindings
quota.go Cases for agent and token caps

See also

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

Constants

This section is empty.

Variables

View Source
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

func CheckWrapper(t *testing.T, inner, wrapped auth.Store)

CheckWrapper reports each optional interface in Optionals that wrapped and inner don't agree on.

func CrashDuringRotation

func CrashDuringRotation(t *testing.T, state string, open CrashFunc, setHook func(func()))

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 Run

func Run(t *testing.T, newStore Factory)

Run runs every conformance test against stores made by newStore.

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

func RunSignupSettings(t *testing.T, newStore func(t *testing.T) auth.Store)

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

func RunWrapper(t *testing.T, inner auth.Store, wrap func(auth.Store) auth.Store)

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

type CrashFunc func(t *testing.T, state string) auth.Store

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

type FactorFactory func(t *testing.T) FullStore

FactorFactory returns a new, empty store.

type Factory

type Factory func(t *testing.T) auth.Store

Factory returns a new, empty store. Use t.Cleanup to release resources.

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

type Optional struct {
	Name string
	Has  func(auth.Store) bool
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL