storagetest

package
v0.77.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 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.

Documentation

Overview

Package storagetest holds storage test suites and fixtures shared by the memory and Redis backends.

Index

Constants

This section is empty.

Variables

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

func DCRFixtureKey() dcrkey.Key

DCRFixtureKey returns a populated DCRKey for use in DCR tests.

func NewConfiguredPrivateKeyJWTClient

func NewConfiguredPrivateKeyJWTClient(t *testing.T, id string) fosite.Client

NewConfiguredPrivateKeyJWTClient builds a pre-provisioned private_key_jwt client holding a fresh public key.

func RequireKeyRotationOverwrites

func RequireKeyRotationOverwrites(t *testing.T, s storage.Storage)

RequireKeyRotationOverwrites reconciles two private_key_jwt clients with the same ID but different keys and checks the second replaces the first.

func RequireSecretClientShapes

func RequireSecretClientShapes(t *testing.T, s storage.Storage)

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

func RequireSingleDCRCASWinner(t *testing.T, errs []error)

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

func RunDCRCASPerFieldTest(t *testing.T, newStore func(t *testing.T) storage.DCRCredentialStore)

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.

func WaitOrFail

func WaitOrFail(t *testing.T, wg *sync.WaitGroup, msg string)

WaitOrFail waits for wg and fails the test if it does not finish in time, so a stuck goroutine cannot hang the suite.

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.

Jump to

Keyboard shortcuts

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