testtokenexchange

package
v19.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package testtokenexchange serves a JSON Web Key Set and mints token-exchange JWTs signed with it.

Index

Constants

View Source
const (
	// KeysPath is where GitLab serves the key set it signs token-exchange JWTs with.
	KeysPath = "/-/cloud_connector/keys"
)

Variables

View Source
var OrganizationID = uuid.MustParse("0191f1e2-3a4b-7c8d-9e0f-112233445566")

OrganizationID is the organization the minted tokens are issued for, their gitlab.origin_id claim.

Functions

This section is empty.

Types

type Issuer

type Issuer struct {
	URL string
	// contains filtered or unexported fields
}

Issuer is a fake GitLab instance: URL is its address and the iss claim of the tokens it mints.

func NewIssuer

func NewIssuer(t *testing.T) *Issuer

NewIssuer starts an Issuer that serves its key set at KeysPath; it stops when the test ends.

func (*Issuer) Mint

func (i *Issuer) Mint(t *testing.T, audience string, gitlab map[string]any) string

Mint returns a token shaped like the ones GitLab issues for audience. gitlab replaces claims in the nested gitlab object; a nil value removes the claim.

type Keys

type Keys struct {
	// contains filtered or unexported fields
}

Keys is the signing key of a fake GitLab and the key set it publishes for it.

func NewKeys

func NewKeys(t *testing.T) *Keys

NewKeys generates a fresh RSA key.

func (*Keys) Handler

func (k *Keys) Handler() http.Handler

Handler serves the key set.

func (*Keys) IssuerAt

func (k *Keys) IssuerAt(url string) *Issuer

IssuerAt returns an Issuer that mints tokens with url as their iss claim.

Jump to

Keyboard shortcuts

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