testutil

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers used across multiple packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRSAKey

func GenerateRSAKey(t *testing.T) (*rsa.PrivateKey, string)

GenerateRSAKey creates a 2048-bit RSA private key and returns both the key object and its PKCS#1 PEM-encoded string. It fails the test on error.

func GenerateRSAKeyObject

func GenerateRSAKeyObject(t *testing.T) *rsa.PrivateKey

GenerateRSAKeyObject creates a 2048-bit RSA private key and returns it. It fails the test on error.

func ValidDeniedEntry

func ValidDeniedEntry() *audit.AuditEntry

ValidDeniedEntry returns an AuditEntry populated with valid denied-outcome fields.

func ValidGrantedEntry

func ValidGrantedEntry() *audit.AuditEntry

ValidGrantedEntry returns an AuditEntry populated with valid granted-outcome fields.

func WriteKeyFile

func WriteKeyFile(t *testing.T, key *rsa.PrivateKey) string

WriteKeyFile writes an RSA private key to a temporary PEM file and returns its path. The file is removed automatically when the test finishes.

Types

type OIDCServer

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

OIDCServer is a minimal OIDC provider for tests. It serves discovery, JWKS, and provides token-signing helpers.

func NewOIDCServer

func NewOIDCServer(t *testing.T, key *rsa.PrivateKey) *OIDCServer

NewOIDCServer creates a mock OIDC provider backed by the given RSA key.

func (*OIDCServer) Close

func (o *OIDCServer) Close()

Close shuts down the mock OIDC provider.

func (*OIDCServer) SignToken

func (o *OIDCServer) SignToken(t *testing.T, audience string) string

SignToken creates a signed JWT with standard claims for the given audience.

func (*OIDCServer) SignTokenWithClaims

func (o *OIDCServer) SignTokenWithClaims(t *testing.T, claims map[string]any) string

SignTokenWithClaims creates a signed JWT with arbitrary claims.

Jump to

Keyboard shortcuts

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