identitytest

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 12 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 identitytest holds the conformance suite of identity.Authenticator and a signer of JWTs.

Index

Constants

View Source
const (
	RepoA = "native:repo_A"
	RepoB = "native:repo_B"
)

RepoA is the repository that the credentials of a fixture cover. RepoB is one that they do not cover.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newFixture func(t *testing.T) Fixture)

Run runs the suite.

Types

type Fixture

type Fixture struct {
	Auth identity.Authenticator
	// Valid carries a credential that gives land on repo.
	Valid func(repo string) *http.Request
	// Expired carries a credential that gave land on repo and has expired.
	Expired func(repo string) *http.Request
	// Forged carries a credential that gives land on repo and is signed by a key that the Authenticator does not trust.
	Forged func(repo string) *http.Request
	// Revoked carries a credential that gave land on repo and was revoked. It is nil for a credential that cannot be revoked.
	Revoked func(repo string) *http.Request
}

Fixture is an Authenticator and the requests that it must judge. Each request func returns a new request.

type Issuer

type Issuer struct {
	Kid string
	Key *rsa.PrivateKey
	// URL is the address of the key set.
	URL string
}

Issuer signs JWTs with a new RSA key and serves the key set of it.

func NewIssuer

func NewIssuer(t testing.TB, kid string) *Issuer

NewIssuer starts a key set server that t stops.

func (*Issuer) Sign

func (i *Issuer) Sign(t testing.TB, claims map[string]any) string

Sign returns an RS256 JWT with the claims, under the kid of the issuer.

Jump to

Keyboard shortcuts

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