consenttest

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 7 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 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(t *testing.T, factory Factory)

RunAll runs the complete contract suite against factory.

func RunLister added in v0.3.12

func RunLister(t *testing.T, factory Factory)

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

func TestExpiredIsReturned(t *testing.T, factory Factory)

TestExpiredIsReturned: the store returns an expired grant and leaves the decision to Covers.

func TestKeyedByUserAndClient

func TestKeyedByUserAndClient(t *testing.T, factory Factory)

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

func TestListAfterRevoke(t *testing.T, factory Factory)

TestListAfterRevoke: a revoked grant leaves the list.

func TestListEmptySubject added in v0.3.12

func TestListEmptySubject(t *testing.T, factory Factory)

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

func TestListIsSorted(t *testing.T, factory Factory)

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

func TestListLeavesOutExpired(t *testing.T, factory Factory)

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

func TestListNoGrants(t *testing.T, factory Factory)

TestListNoGrants: a user who approved nothing gets an empty list and no error.

func TestListPersists added in v0.3.12

func TestListPersists(t *testing.T, factory Factory)

TestListPersists: a reopened store lists what was saved before.

func TestListReturnsCopies added in v0.3.12

func TestListReturnsCopies(t *testing.T, factory Factory)

TestListReturnsCopies: changing a listed grant doesn't change the stored one.

func TestListsOnlyTheSubjectsGrants added in v0.3.12

func TestListsOnlyTheSubjectsGrants(t *testing.T, factory Factory)

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

func TestNotFound(t *testing.T, factory Factory)

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

func TestRefusesAnEmptyKey(t *testing.T, factory Factory)

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

func TestRestartPersists(t *testing.T, factory Factory)

TestRestartPersists: a grant survives reopening the store.

func TestReturnsCopies

func TestReturnsCopies(t *testing.T, factory Factory)

TestReturnsCopies: changing a grant after saving it, or changing what GetConsent returned, doesn't change the stored grant.

func TestRevokeIsIdempotent

func TestRevokeIsIdempotent(t *testing.T, factory Factory)

TestRevokeIsIdempotent: revoking removes the grant, and revoking again, or revoking what was never there, is not an error.

func TestSaveAndGet

func TestSaveAndGet(t *testing.T, factory Factory)

TestSaveAndGet stores a grant and reads every field back.

func TestSaveReplaces

func TestSaveReplaces(t *testing.T, factory Factory)

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.

type Factory

type Factory func(t *testing.T) Backend

Factory creates a Backend per scenario. Persistent backends must close over per-test state (a *gorm.DB, a tempdir, a namespace).

Jump to

Keyboard shortcuts

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