Documentation
¶
Overview ¶
Package authtest provides mock implementations of the gas authentication and authorization interfaces for use in tests.
Index ¶
- type Call
- type MockAuthenticator
- type MockAuthorizer
- type MockRevoker
- func (m *MockRevoker) CallCount(method string) int
- func (m *MockRevoker) Reset()
- func (m *MockRevoker) Revoke(ctx context.Context, principal gas.Principal) error
- func (m *MockRevoker) RevokeAll(ctx context.Context, subject string) error
- func (m *MockRevoker) RevokeAllByScheme(ctx context.Context, subject, scheme string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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.
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) 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.