spiffetest

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package spiffetest builds SPIFFE OAuth clients for tests. It must not import package authserver, so in-package tests there can use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticatedClient

func AuthenticatedClient(t *testing.T, opts ...Option) *registration.AuthenticatedSPIFFEClient

AuthenticatedClient returns the SPIFFE client Client would build, bound to a verified SPIFFE ID and method as the client-authentication resolver does. The SPIFFE ID is "spiffe://example.org/workload/test" and the method is JWT unless opts say otherwise.

func Client

func Client(t *testing.T, opts ...Option) *registration.SPIFFEClient

Client returns a valid SPIFFE client with id "spiffe-client", the token-exchange grant, scope "openid", audience "https://api.example.com" and no resources, adjusted by opts.

Types

type Option

type Option func(*config)

Option overrides one field of the client built by Client or AuthenticatedClient.

func WithAudiences

func WithAudiences(audiences ...string) Option

WithAudiences sets the allowed audiences.

func WithAuthMethod

func WithAuthMethod(method spiffeauth.SPIFFEAuthenticationMethod) Option

WithAuthMethod sets the authentication method of the client built by AuthenticatedClient.

func WithGrantTypes

func WithGrantTypes(grants ...string) Option

WithGrantTypes sets the allowed grant types.

func WithID

func WithID(id string) Option

WithID sets the client ID.

func WithResources

func WithResources(resources ...string) Option

WithResources sets the allowed RFC 8707 resources.

func WithSPIFFEID

func WithSPIFFEID(id string) Option

WithSPIFFEID sets the SPIFFE ID of the client built by AuthenticatedClient.

func WithScopes

func WithScopes(scopes ...string) Option

WithScopes sets the allowed scopes.

Jump to

Keyboard shortcuts

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