Documentation
¶
Overview ¶
Package storagetest holds storage test suites and fixtures shared by the memory and Redis backends.
Index ¶
- Variables
- func ContractChild(signature string) *storage.ExchangeGrant
- func ContractGrant(signature string) *storage.ExchangeGrant
- func ContractIdentity(userID, providerID, subject string) *storage.ProviderIdentity
- func ContractUser(t *testing.T, store storage.UserStorage, id string)
- func DCRCASFixture(key dcrkey.Key, secret string) *storage.DCRCredentials
- func DCRFixtureKey() dcrkey.Key
- func NewConfiguredPrivateKeyJWTClient(t *testing.T, id string) fosite.Client
- func RequireKeyRotationOverwrites(t *testing.T, s storage.Storage)
- func RequireSecretClientShapes(t *testing.T, s storage.Storage)
- func RequireSingleDCRCASWinner(t *testing.T, errs []error)
- func RunDCRCASPerFieldTest(t *testing.T, newStore func(t *testing.T) storage.DCRCredentialStore)
- func RunExchangeGrantStorageContract(t *testing.T, newStore ExchangeGrantStoreFactory)
- func RunUserIdentityStorageContract(t *testing.T, newStore UserIdentityStoreFactory)
- func StoredPrivateKeyJWTClient(id string, keys []jose.JSONWebKey) *fosite.DefaultOpenIDConnectClient
- func StoredPrivateKeyJWTClientCases() []struct{ ... }
- func WaitOrFail(t *testing.T, wg *sync.WaitGroup, msg string)
- type ExchangeGrantStoreFactory
- type ManualClock
- type UserIdentityStoreFactory
Constants ¶
This section is empty.
Variables ¶
var ContractEpoch = time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
ContractEpoch is the instant every contract record is built around. A backend whose clock starts elsewhere must start it here.
Functions ¶
func ContractChild ¶
func ContractChild(signature string) *storage.ExchangeGrant
ContractChild builds a child of the grant whose signature is "parent".
func ContractGrant ¶
func ContractGrant(signature string) *storage.ExchangeGrant
ContractGrant returns a valid exchange grant with signature.
func ContractIdentity ¶
func ContractIdentity(userID, providerID, subject string) *storage.ProviderIdentity
ContractIdentity returns a provider identity linking subject to userID.
func ContractUser ¶
func ContractUser(t *testing.T, store storage.UserStorage, id string)
ContractUser creates the user id in store.
func DCRCASFixture ¶
func DCRCASFixture(key dcrkey.Key, secret string) *storage.DCRCredentials
DCRCASFixture returns a valid DCRCredentials at key whose ClientSecret is secret, for the UpdateDCRCredentialsIfUnchanged tests on every backend.
func DCRFixtureKey ¶
DCRFixtureKey returns a populated DCRKey for use in DCR tests.
func NewConfiguredPrivateKeyJWTClient ¶
NewConfiguredPrivateKeyJWTClient builds a pre-provisioned private_key_jwt client holding a fresh public key.
func RequireKeyRotationOverwrites ¶
RequireKeyRotationOverwrites reconciles two private_key_jwt clients with the same ID but different keys and checks the second replaces the first.
func RequireSecretClientShapes ¶
RequireSecretClientShapes round-trips an unpinned and a client_secret_post pinned delegate client, then reconciles the same ID from unpinned to pinned and checks the stored row switches shape.
func RequireSingleDCRCASWinner ¶
RequireSingleDCRCASWinner asserts that of a set of racing UpdateDCRCredentialsIfUnchanged calls made against the same expected value, exactly one succeeded and every other one was refused with ErrDCRCredentialsChanged.
func RunDCRCASPerFieldTest ¶
RunDCRCASPerFieldTest pins that every persisted field takes part in the UpdateDCRCredentialsIfUnchanged comparison: for each field, an expected that differs from the stored row in only that field is refused with ErrDCRCredentialsChanged and the row is left intact. newStore returns a fresh, empty store per subtest.
func RunExchangeGrantStorageContract ¶
func RunExchangeGrantStorageContract(t *testing.T, newStore ExchangeGrantStoreFactory)
RunExchangeGrantStorageContract checks the ExchangeGrantStorage contract. It is backend-agnostic: memory runs it now and Redis reuses it.
func RunUserIdentityStorageContract ¶
func RunUserIdentityStorageContract(t *testing.T, newStore UserIdentityStoreFactory)
RunUserIdentityStorageContract checks that a (provider, subject) pair links to at most one user, including under concurrent creation.
func StoredPrivateKeyJWTClient ¶
func StoredPrivateKeyJWTClient(id string, keys []jose.JSONWebKey) *fosite.DefaultOpenIDConnectClient
StoredPrivateKeyJWTClient returns a private_key_jwt client with keys.
func StoredPrivateKeyJWTClientCases ¶
func StoredPrivateKeyJWTClientCases() []struct {
Name string
Keys []jose.JSONWebKey
WantErr bool
}
StoredPrivateKeyJWTClientCases are stored clients that GetClient must recheck against the current private_key_jwt key limits. Shared by the memory and Redis backends.
Types ¶
type ExchangeGrantStoreFactory ¶
type ExchangeGrantStoreFactory func(t *testing.T) (storage.ExchangeGrantStorage, func(time.Duration))
ExchangeGrantStoreFactory returns a fresh, empty store and a function that moves the store's clock forward by the given duration. The contract suite measures all time against that clock, so a backend must make expiry follow it.
type ManualClock ¶
type ManualClock struct {
// contains filtered or unexported fields
}
ManualClock is a clock a test advances by hand.
func NewManualClock ¶
func NewManualClock(start time.Time) *ManualClock
NewManualClock returns a ManualClock reading start.
func (*ManualClock) Advance ¶
func (c *ManualClock) Advance(d time.Duration)
Advance moves the clock forward by d.
func (*ManualClock) Now ¶
func (c *ManualClock) Now() time.Time
Now returns the clock's current time.
type UserIdentityStoreFactory ¶
type UserIdentityStoreFactory func(t *testing.T) storage.UserStorage
UserIdentityStoreFactory returns a fresh, empty store.