authtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package authtest provides test fixtures (stub authenticators, signed JWTs, etc.) that downstream services use to exercise auth-protected HTTP / gRPC handlers without spinning up a real identity provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGrpcAuthenticator

func NewGrpcAuthenticator(opts ...grpcAuthenticatorOption) *grpcAuthenticator

func NewHTTPAuthenticator

func NewHTTPAuthenticator() *httpAuthenticator

func NewMockJWT

func NewMockJWT(accountID uuid.UUID, username string) *mockJWT

NewMockJWT creates a new mock JWT issuer/validator for testing

func NewMockProvider

func NewMockProvider(uid, email string) *mockProvider

NewMockProvider creates a new mock authentication provider for testing

func NewStrictGrpcAuthenticator

func NewStrictGrpcAuthenticator(subject string) *strictGrpcAuthenticator

NewStrictGrpcAuthenticator creates an authenticator that actually validates auth headers

func NewTokenClaims

func NewTokenClaims(subject string) *tokenClaims

func WithGrpcAuthenticatorSubject

func WithGrpcAuthenticatorSubject(subject string) grpcAuthenticatorOption

Types

type ContextInjector

type ContextInjector struct {
	mock.Mock
}

ContextInjector is an autogenerated mock type for the ContextInjector type

func NewContextInjector

func NewContextInjector(t interface {
	mock.TestingT
	Cleanup(func())
}) *ContextInjector

NewContextInjector creates a new instance of ContextInjector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*ContextInjector) EXPECT

func (*ContextInjector) Inject

func (_mock *ContextInjector) Inject(ctx context.Context, token auth.Token) (context.Context, error)

Inject provides a mock function for the type ContextInjector

type ContextInjector_Expecter

type ContextInjector_Expecter struct {
	// contains filtered or unexported fields
}

func (*ContextInjector_Expecter) Inject

func (_e *ContextInjector_Expecter) Inject(ctx interface{}, token interface{}) *ContextInjector_Inject_Call

Inject is a helper method to define mock.On call

  • ctx context.Context
  • token auth.Token

type ContextInjector_Inject_Call

type ContextInjector_Inject_Call struct {
	*mock.Call
}

ContextInjector_Inject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Inject'

func (*ContextInjector_Inject_Call) Return

func (*ContextInjector_Inject_Call) Run

func (*ContextInjector_Inject_Call) RunAndReturn

Jump to

Keyboard shortcuts

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