Documentation
¶
Overview ¶
Package consenttest provides the shared contract test suite for every core.ConsentStore implementation. Each backend hands RunAll a Factory, so memory, FS, GORM and GAE answer the same questions about replacing a grant, keeping one grant per user and client, and returning copies. Mirrors the partest and authcodetest precedents.
Index ¶
- func RunAll(t *testing.T, factory Factory)
- func TestExpiredIsReturned(t *testing.T, factory Factory)
- func TestKeyedByUserAndClient(t *testing.T, factory Factory)
- func TestNotFound(t *testing.T, factory Factory)
- func TestRefusesAnEmptyKey(t *testing.T, factory Factory)
- func TestRestartPersists(t *testing.T, factory Factory)
- func TestReturnsCopies(t *testing.T, factory Factory)
- func TestRevokeIsIdempotent(t *testing.T, factory Factory)
- func TestSaveAndGet(t *testing.T, factory Factory)
- func TestSaveReplaces(t *testing.T, factory Factory)
- type Backend
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestExpiredIsReturned ¶
TestExpiredIsReturned: the store returns an expired grant and leaves the decision to Covers.
func TestKeyedByUserAndClient ¶
TestKeyedByUserAndClient: a grant to one client says nothing about another, and one user's grant says nothing about another user.
func TestNotFound ¶
TestNotFound: a user with no grant gets ErrConsentNotFound, not an empty grant, so a backend can't make "never asked" look like "asked for nothing".
func TestRefusesAnEmptyKey ¶
TestRefusesAnEmptyKey: a grant without a subject or client can't be stored, so a caller bug can't create a grant that covers every user or every client.
func TestRestartPersists ¶
TestRestartPersists: a grant survives reopening the store.
func TestReturnsCopies ¶
TestReturnsCopies: changing a grant after saving it, or changing what GetConsent returned, doesn't change the stored grant.
func TestRevokeIsIdempotent ¶
TestRevokeIsIdempotent: revoking removes the grant, and revoking again, or revoking what was never there, is not an error.
func TestSaveAndGet ¶
TestSaveAndGet stores a grant and reads every field back.
func TestSaveReplaces ¶
TestSaveReplaces: a second save for the same user and client replaces the first. The caller merges scopes, not the store.
Types ¶
type Backend ¶
type Backend struct {
Store core.ConsentStore
Reopen func() core.ConsentStore
}
Backend is the per-scenario fixture. Reopen returns a fresh handle over the same storage, so RestartPersists can simulate a process restart. In-memory backends return the same instance.