partest

package
v0.3.15 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: 9 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 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

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 the provided factory.

func TestCleanupExpired

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

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

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

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 TestConcurrentConsumeOneWins added in v0.3.7

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

TestConcurrentConsumeOneWins races eight approvals of one pushed request. Exactly one may see Consumed true, or two approvals both issue a code for a single-use request_uri. None may fail with a backend conflict error.

See: https://www.rfc-editor.org/rfc/rfc9126#section-4 See: https://cwe.mitre.org/data/definitions/367.html

func TestConsumeMarksWithoutDeleting

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

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

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

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

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

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 TestDelete(t *testing.T, factory Factory)

func TestNotFound

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

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

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

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.

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) so Store and Reopen resolve to the same storage within one scenario.

Jump to

Keyboard shortcuts

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