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 RunLister(t *testing.T, factory Factory)
- func TestExpiredIsReturned(t *testing.T, factory Factory)
- func TestKeyedByUserAndClient(t *testing.T, factory Factory)
- func TestListAfterRevoke(t *testing.T, factory Factory)
- func TestListEmptySubject(t *testing.T, factory Factory)
- func TestListIsSorted(t *testing.T, factory Factory)
- func TestListLeavesOutExpired(t *testing.T, factory Factory)
- func TestListNoGrants(t *testing.T, factory Factory)
- func TestListPersists(t *testing.T, factory Factory)
- func TestListReturnsCopies(t *testing.T, factory Factory)
- func TestListsOnlyTheSubjectsGrants(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 RunLister ¶ added in v0.3.12
RunLister runs the core.ConsentLister scenarios. RunAll calls it, and it skips a store that doesn't implement the optional interface, so a custom ConsentStore without listing still passes RunAll. Every bundled backend implements it and asserts so at compile time.
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 TestListAfterRevoke ¶ added in v0.3.12
TestListAfterRevoke: a revoked grant leaves the list.
func TestListEmptySubject ¶ added in v0.3.12
TestListEmptySubject: an empty subject lists nothing, so a caller that lost the session's user can't list every user's grants.
func TestListIsSorted ¶ added in v0.3.12
TestListIsSorted: grants come back by client_id whatever order they were saved in, so a page listing them doesn't reorder between loads. Eight clients saved in reverse make an accidental order (by file name hash, Datastore key or insertion) unlikely to pass.
func TestListLeavesOutExpired ¶ added in v0.3.12
TestListLeavesOutExpired: an expired grant no longer skips the consent screen, so it isn't shown as a connected app.
func TestListNoGrants ¶ added in v0.3.12
TestListNoGrants: a user who approved nothing gets an empty list and no error.
func TestListPersists ¶ added in v0.3.12
TestListPersists: a reopened store lists what was saved before.
func TestListReturnsCopies ¶ added in v0.3.12
TestListReturnsCopies: changing a listed grant doesn't change the stored one.
func TestListsOnlyTheSubjectsGrants ¶ added in v0.3.12
TestListsOnlyTheSubjectsGrants: a user's list holds their grants, by client_id, with every field, and nothing another user approved. A grant that never expires is listed.
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.