consenttest

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 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 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 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