authtest

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package authtest provides mock implementations of the gas authentication and authorization interfaces for use in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string
	Args   []any
}

Call records a single method invocation on a mock.

type MockAuthenticator

type MockAuthenticator struct {
	// AuthenticateFn is called when Authenticate is invoked. If nil,
	// Authenticate returns (nil, nil).
	AuthenticateFn func(ctx context.Context, r *http.Request) (gas.Principal, error)
	// Calls records every method invocation.
	Calls []Call
	// contains filtered or unexported fields
}

MockAuthenticator is a test double for gas.Authenticator.

func (*MockAuthenticator) Authenticate

func (m *MockAuthenticator) Authenticate(ctx context.Context, r *http.Request) (gas.Principal, error)

Authenticate delegates to AuthenticateFn if set, otherwise returns zero values.

func (*MockAuthenticator) CallCount

func (m *MockAuthenticator) CallCount(method string) int

CallCount returns the number of times the named method was called.

func (*MockAuthenticator) Reset

func (m *MockAuthenticator) Reset()

Reset clears all recorded calls.

type MockAuthorizer

type MockAuthorizer struct {
	// AuthorizeFn is called when Authorize is invoked. If nil, Authorize
	// returns nil.
	AuthorizeFn func(ctx context.Context, principal gas.Principal, action, resource string) error
	// Calls records every method invocation.
	Calls []Call
	// contains filtered or unexported fields
}

MockAuthorizer is a test double for gas.Authorizer.

func (*MockAuthorizer) Authorize

func (m *MockAuthorizer) Authorize(ctx context.Context, principal gas.Principal, action, resource string) error

Authorize delegates to AuthorizeFn if set, otherwise returns nil.

func (*MockAuthorizer) CallCount

func (m *MockAuthorizer) CallCount(method string) int

CallCount returns the number of times the named method was called.

func (*MockAuthorizer) Reset

func (m *MockAuthorizer) Reset()

Reset clears all recorded calls.

type MockRevoker

type MockRevoker struct {
	// RevokeFn is called when Revoke is invoked. If nil, Revoke returns nil.
	RevokeFn func(ctx context.Context, principal gas.Principal) error
	// RevokeAllFn is called when RevokeAll is invoked. If nil, RevokeAll
	// returns nil.
	RevokeAllFn func(ctx context.Context, subject string) error
	// RevokeAllBySchemeFn is called when RevokeAllByScheme is invoked. If
	// nil, RevokeAllByScheme returns nil.
	RevokeAllBySchemeFn func(ctx context.Context, subject, scheme string) error
	// Calls records every method invocation.
	Calls []Call
	// contains filtered or unexported fields
}

MockRevoker is a test double for gas.PrincipalRevoker.

func (*MockRevoker) CallCount

func (m *MockRevoker) CallCount(method string) int

CallCount returns the number of times the named method was called.

func (*MockRevoker) Reset

func (m *MockRevoker) Reset()

Reset clears all recorded calls.

func (*MockRevoker) Revoke

func (m *MockRevoker) Revoke(ctx context.Context, principal gas.Principal) error

Revoke delegates to RevokeFn if set, otherwise returns nil.

func (*MockRevoker) RevokeAll

func (m *MockRevoker) RevokeAll(ctx context.Context, subject string) error

RevokeAll delegates to RevokeAllFn if set, otherwise returns nil.

func (*MockRevoker) RevokeAllByScheme

func (m *MockRevoker) RevokeAllByScheme(ctx context.Context, subject, scheme string) error

RevokeAllByScheme delegates to RevokeAllBySchemeFn if set, otherwise returns nil.

Jump to

Keyboard shortcuts

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