Documentation
¶
Overview ¶
Package wif provides federated identity token acquisition for Azure workload identity login.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcquireOption ¶
type AcquireOption func(*AcquireOptions)
AcquireOption configures the behavior of Provider.AcquireToken.
func WithForceRefresh ¶
func WithForceRefresh() AcquireOption
WithForceRefresh bypasses any cached token and forces a fresh acquisition flow.
type AcquireOptions ¶
type AcquireOptions struct {
ForceRefresh bool
}
AcquireOptions holds the resolved option values for Provider.AcquireToken.
func ApplyOptions ¶
func ApplyOptions(opts []AcquireOption) AcquireOptions
ApplyOptions applies the given options to a default AcquireOptions.
type Provider ¶
type Provider interface {
// AcquireToken acquires and returns a federated identity token.
// The cached return value indicates whether the token was served from cache.
// Options such as [WithForceRefresh] control caching behavior.
AcquireToken(ctx context.Context, opts ...AcquireOption) (token string, cached bool, err error)
}
Provider acquires a federated identity token for workload identity login.
type ProviderMock ¶
type ProviderMock struct {
// AcquireTokenFunc mocks the AcquireToken method.
AcquireTokenFunc func(ctx context.Context, opts ...AcquireOption) (string, bool, error)
// contains filtered or unexported fields
}
ProviderMock is a mock implementation of Provider.
func TestSomethingThatUsesProvider(t *testing.T) {
// make and configure a mocked Provider
mockedProvider := &ProviderMock{
AcquireTokenFunc: func(ctx context.Context, opts ...AcquireOption) (string, bool, error) {
panic("mock out the AcquireToken method")
},
}
// use mockedProvider in code that requires Provider
// and then make assertions.
}
func (*ProviderMock) AcquireToken ¶
func (mock *ProviderMock) AcquireToken(ctx context.Context, opts ...AcquireOption) (string, bool, error)
AcquireToken calls AcquireTokenFunc.
func (*ProviderMock) AcquireTokenCalls ¶
func (mock *ProviderMock) AcquireTokenCalls() []struct { Ctx context.Context Opts []AcquireOption }
AcquireTokenCalls gets all the calls that were made to AcquireToken. Check the length with:
len(mockedProvider.AcquireTokenCalls())