Documentation
¶
Overview ¶
Package partest provides a shared contract test suite for every core.PushedAuthorizationRequestStore implementation (RFC 9126). Each backend hands this package a Factory closure and calls RunAll, so in-memory and GORM answer the same questions about expiry, consumption and client binding. Mirrors the authcodetest and deviceauthtest precedents.
Why a shared suite: the interesting behavior here is not storage, it is the three states a request_uri moves through (live, consumed, expired) and the fact that a backend must keep them distinguishable. A backend that collapses "consumed" into "gone" passes a naive per-backend test and breaks the error a client is owed.
Index ¶
- func RunAll(t *testing.T, factory Factory)
- func TestCleanupExpired(t *testing.T, factory Factory)
- func TestCollision(t *testing.T, factory Factory)
- func TestConsumeMarksWithoutDeleting(t *testing.T, factory Factory)
- func TestConsumeSucceedsOnce(t *testing.T, factory Factory)
- func TestCreateAndGet(t *testing.T, factory Factory)
- func TestDelete(t *testing.T, factory Factory)
- func TestNotFound(t *testing.T, factory Factory)
- func TestRestartPersists(t *testing.T, factory Factory)
- type Backend
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestCleanupExpired ¶
TestCleanupExpired pins the sweep, including that it takes consumed records with it. Consumed rows are what a store accumulates most of, so a sweep that skipped them would grow without bound.
func TestCollision ¶
TestCollision pins that a repeated request_uri is refused rather than overwritten. Overwriting would let a second push replace the payload behind a reference the first client is about to redirect with.
func TestConsumeMarksWithoutDeleting ¶
TestConsumeMarksWithoutDeleting pins the distinction the interface promises: a consumed reference is still readable and reports Consumed. A backend that deletes on consume makes "already used" indistinguishable from "never existed", and the client gets the wrong error.
func TestConsumeSucceedsOnce ¶ added in v0.1.49
TestConsumeSucceedsOnce pins the single-use gate: Consumed is true for the first call and false for every later one, so of two approvals racing on one pushed request only one issues a code (RFC 9126 §4).
func TestCreateAndGet ¶
TestCreateAndGet pins the round trip, and in particular that the payload survives it unchanged. The payload is the whole point of PAR: a backend that drops or reorders parameters silently changes the authorization request between the push and the redirect. `authorization_details` is in the fixture because RFC 9396 JSON is the payload most likely to be mangled by a serializer.
func TestDelete ¶
func TestNotFound ¶
TestNotFound pins the sentinel. The authorization endpoint maps it to "unknown request_uri"; a generic error would surface as a 500 and tell a client nothing it can act on.
func TestRestartPersists ¶
Types ¶
type Backend ¶
type Backend struct {
Store core.PushedAuthorizationRequestStore
Reopen func() core.PushedAuthorizationRequestStore
}
Backend is the per-scenario fixture. Store is the handle under test; Reopen returns a fresh handle over the same backing storage so RestartPersists can simulate a process restart. In-memory backends return the same instance, where the property holds trivially.