Documentation
¶
Overview ¶
Package fake provides an authentication plugin for testing purposes.
This plugin allows server integrations tests to easily authenticate as any identity without requiring actual authentication credentials or external dependencies.
Index ¶
Constants ¶
const ( // PluginName is the name of the fake auth plugin. PluginName = "auth_fake" // ProviderName is the name of the fake auth provider. ProviderName = "fakeauth" )
Variables ¶
This section is empty.
Functions ¶
func MustLogin ¶
func MustLogin(ctx context.Context, authClient auth.AuthServiceClient, options FakeOptions) string
MustLogin is a convenience function for tests that will panic if login fails. This allows for concise test setup.
Types ¶
type FakeAuthOption ¶
type FakeAuthOption func(*FakeAuthPlugin)
FakeAuthOption allows configuration of the FakeAuthPlugin.
func WithDefaultIdentity ¶
func WithDefaultIdentity(id auth.Identity) FakeAuthOption
WithDefaultIdentity sets the default identity to use when no credentials are provided.
func WithIdentityValidator ¶
func WithIdentityValidator(validator IdentityValidator) FakeAuthOption
WithIdentityValidator allows setting a custom validator for login requests. This can be used to restrict which identities can be created.
type FakeAuthPlugin ¶
type FakeAuthPlugin struct {
// contains filtered or unexported fields
}
FakeAuthPlugin provides fake authentication for testing purposes. It allows creating arbitrary identities without real credentials.
func Plugin ¶
func Plugin(opts ...FakeAuthOption) *FakeAuthPlugin
Plugin returns a new FakeAuthPlugin for testing purposes.
type FakeOptions ¶
type FakeOptions struct {
// User identity fields
ID string // Takes precedence over Subject
Subject string // Deprecated: Use ID instead
Email string
Name string
EmailVerified *bool
// Error simulation
ErrorCode codes.Code // If set, simulates an error with this code
ErrorMessage string // Custom error message (defaults to "simulated error")
}
FakeOptions provides a strongly-typed structure for configuring fake auth login. These options are converted to a credentials map when making login requests.