Documentation
¶
Overview ¶
Package kidstoretest provides a shared, test-only contract suite that every KidStorage backend (in-memory KidStore, FS, GORM, GAE) runs against its own factory, mirroring keystoretest.
<!-- design:start --> This package owns the KidStorage contract: a single, test-only suite that every backend (in-memory KidStore, FS, GORM, GAE) runs against its own factory, mirroring keystoretest. It defines no production code — only the behavioral guarantees each KidStorage must satisfy. A backend supplies a Factory and calls RunAll, which executes every contract test as a named subtest, keeping all implementations in lock-step.
ENTITIES ¶
Factory — function alias producing a fresh keys.KidStorage per test, so one suite can drive every backend without knowing the backend.
RunAll — entry point running the complete contract as named subtests against a factory; one call per backend.
TestAddAndGetByKid — asserts Add then GetKeyByKid round-trips key bytes, algorithm, clientID, and kid.
TestGetByUnknownKid — asserts an unknown kid returns keys.ErrKidNotFound.
TestGetKeyByClientIDAlwaysNotFound — asserts GetKey by clientID always returns keys.ErrKeyNotFound, since a kid-indexed store has no clientID index.
TestOverwriteSameKid — asserts re-Adding the same kid replaces key, algorithm, and clientID (Add is upsert-by-kid).
TestRemoveIdempotent — asserts Remove of an absent kid is nil and Remove of a present kid clears it; Remove is intentionally idempotent, unlike KeyStorage.DeleteKey.
TestExpiredKidNotReturned — asserts a past-expiry kid returns keys.ErrKidNotFound, so reads filter expired entries even before any sweep.
TestZeroExpiryNeverExpires — asserts a zero time.Time expiry means the kid is always retrievable (zero is the no-expiry sentinel).
TestCleanExpired — asserts CleanExpired sweeps only expired kids and physically frees the slot for re-Add, confirming the backing row/file is removed and not merely hidden.
TestAsymmetricKeyRoundTrip — asserts an RSA public-key PEM stored under a computed kid round-trips with RS256, proving PEM bytes are preserved verbatim.
TestPersistence — asserts the store reads back what it wrote within one instance; trivial for in-memory but exercises the real storage layer for FS/GORM/GAE. Cross-restart proof lives in backend-specific tests. <!-- design:end -->
Index ¶
- func RunAll(t *testing.T, factory Factory)
- func TestAddAndGetByKid(t *testing.T, factory Factory)
- func TestAsymmetricKeyRoundTrip(t *testing.T, factory Factory)
- func TestCleanExpired(t *testing.T, factory Factory)
- func TestExpiredKidNotReturned(t *testing.T, factory Factory)
- func TestGetByUnknownKid(t *testing.T, factory Factory)
- func TestGetKeyByClientIDAlwaysNotFound(t *testing.T, factory Factory)
- func TestOverwriteSameKid(t *testing.T, factory Factory)
- func TestPersistence(t *testing.T, factory Factory)
- func TestRemoveIdempotent(t *testing.T, factory Factory)
- func TestZeroExpiryNeverExpires(t *testing.T, factory Factory)
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestAddAndGetByKid ¶
func TestCleanExpired ¶
func TestGetByUnknownKid ¶
func TestGetKeyByClientIDAlwaysNotFound ¶
TestGetKeyByClientIDAlwaysNotFound enforces the documented KidStorage semantic: lookup by clientID is meaningless for a kid-indexed store and must always return ErrKeyNotFound, regardless of whether the client has any kids registered.
func TestOverwriteSameKid ¶
func TestPersistence ¶
TestPersistence verifies the store reads back what it wrote. For persistent backends (FS, GORM, GAE) this exercises the actual storage layer; for in-memory it is trivially true. Cross-instance restart proof is handled in backend-specific tests where reopening makes sense.
func TestRemoveIdempotent ¶
TestRemoveIdempotent enforces that Remove on an absent kid is not an error — KidStorage Remove is intentionally idempotent (differs from KeyStorage.DeleteKey which returns ErrKeyNotFound).