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 ¶
- func AuthenticatedClient(t *testing.T, opts ...Option) *registration.AuthenticatedSPIFFEClient
- func Client(t *testing.T, opts ...Option) *registration.SPIFFEClient
- type Option
- func WithAudiences(audiences ...string) Option
- func WithAuthMethod(method spiffeauth.SPIFFEAuthenticationMethod) Option
- func WithGrantTypes(grants ...string) Option
- func WithID(id string) Option
- func WithResources(resources ...string) Option
- func WithSPIFFEID(id string) Option
- func WithScopes(scopes ...string) Option
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 ¶
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 ¶
WithGrantTypes sets the allowed grant types.
func WithResources ¶
WithResources sets the allowed RFC 8707 resources.
func WithSPIFFEID ¶
WithSPIFFEID sets the SPIFFE ID of the client built by AuthenticatedClient.