Documentation
¶
Overview ¶
Package testkit provides functionalities for testing N26 APIs.
Index ¶
- Variables
- type CredentialsProvider
- type CredentialsProviderMocker
- type Request
- type Server
- func (s *Server) AccessToken() auth.Token
- func (s *Server) BasicAuthorization() string
- func (s *Server) DeviceID() uuid.UUID
- func (s *Server) Expect(method, requestURI string) *Request
- func (s *Server) ExpectDelete(requestURI string) *Request
- func (s *Server) ExpectGet(requestURI string) *Request
- func (s *Server) ExpectHead(requestURI string) *Request
- func (s *Server) ExpectPatch(requestURI string) *Request
- func (s *Server) ExpectPost(requestURI string) *Request
- func (s *Server) ExpectPut(requestURI string) *Request
- func (s *Server) ExpectWithBasicAuth(method, requestURI string) *Request
- func (s *Server) MFAToken() uuid.UUID
- func (s *Server) RefreshToken() auth.Token
- func (s *Server) UserID() uuid.UUID
- func (s *Server) WithAccessToken(token uuid.UUID) *Server
- func (s *Server) WithAuthAuthorization(username, password string) *Server
- func (s *Server) WithDeviceID(deviceID uuid.UUID) *Server
- func (s *Server) WithMFAToken(mfaToken uuid.UUID) *Server
- func (s *Server) WithRefreshToken(token uuid.UUID) *Server
- type ServerMocker
- type ServerOption
- func WithAuthAuthorization(username, password string) ServerOption
- func WithAuthConfirmLoginFailure() ServerOption
- func WithAuthConfirmLoginFailureInvalidToken(times int) ServerOption
- func WithAuthConfirmLoginSuccess() ServerOption
- func WithAuthMFAChallengeFailure() ServerOption
- func WithAuthMFAChallengeFailureInvalidToken() ServerOption
- func WithAuthMFAChallengeSuccess() ServerOption
- func WithAuthPasswordLoginFailure(username, password string, deviceID uuid.UUID) ServerOption
- func WithAuthPasswordLoginFailureTooManyAttempts(username, password string, deviceID uuid.UUID) ServerOption
- func WithAuthPasswordLoginFailureWrongCredentials(username, password string, deviceID uuid.UUID) ServerOption
- func WithAuthPasswordLoginSuccess(username, password string, deviceID uuid.UUID) ServerOption
- func WithAuthPasswordLoginUnexpectedResponse(username, password string, deviceID uuid.UUID) ServerOption
- func WithAuthRefreshTokenFailure() ServerOption
- func WithAuthRefreshTokenFailureInvalidToken() ServerOption
- func WithAuthRefreshTokenSuccess() ServerOption
- func WithAuthSuccess(username, password string, deviceID uuid.UUID) ServerOption
- func WithFindAllTransactionsInRange(from time.Time, to time.Time, pageSize int64, result []transaction.Transaction) ServerOption
- type TestingT
Constants ¶
This section is empty.
Variables ¶
var NoMockCredentialsProvider = MockCredentialsProvider()
NoMockCredentialsProvider is no mock CredentialsProvider.
Functions ¶
This section is empty.
Types ¶
type CredentialsProvider ¶
CredentialsProvider is a CredentialsProvider.
func (*CredentialsProvider) Password ¶
func (c *CredentialsProvider) Password() string
Password satisfies CredentialsProvider.
func (*CredentialsProvider) Username ¶
func (c *CredentialsProvider) Username() string
Username satisfies CredentialsProvider.
type CredentialsProviderMocker ¶
type CredentialsProviderMocker func(tb testing.TB) *CredentialsProvider
CredentialsProviderMocker is CredentialsProvider mocker.
func MockCredentialsProvider ¶
func MockCredentialsProvider(mocks ...func(p *CredentialsProvider)) CredentialsProviderMocker
MockCredentialsProvider creates CredentialsProvider mock with cleanup to ensure all the expectations are met.
type Server ¶
Server is a wrapped httpmock.Server to provide more functionalities for testing N26 APIs.
func (*Server) AccessToken ¶
AccessToken returns the accessToken.
func (*Server) BasicAuthorization ¶
BasicAuthorization returns the credentials for asserting the /oauth/token Authorization.
func (*Server) Expect ¶
Expect expects a request with Bearer Authorization.
Server.Expect(http.MethodGet, "/path").
func (*Server) ExpectDelete ¶
ExpectDelete expects a request with Bearer Authorization.
Server.ExpectDelete("/path")
func (*Server) ExpectGet ¶
ExpectGet expects a request with Bearer Authorization.
Server.ExpectGet("/path")
func (*Server) ExpectHead ¶
ExpectHead expects a request with Bearer Authorization.
Server.ExpectHead("/path")
func (*Server) ExpectPatch ¶
ExpectPatch expects a request with Bearer Authorization.
Server.ExpectPatch("/path")
func (*Server) ExpectPost ¶
ExpectPost expects a request with Bearer Authorization.
Server.ExpectPost("/path")
func (*Server) ExpectPut ¶
ExpectPut expects a request with Bearer Authorization.
Server.ExpectPut("/path")
func (*Server) ExpectWithBasicAuth ¶
ExpectWithBasicAuth expects a request with Basic Authorization.
func (*Server) RefreshToken ¶
RefreshToken returns the refreshToken.
func (*Server) WithAccessToken ¶
WithAccessToken sets the accessToken.
func (*Server) WithAuthAuthorization ¶
WithAuthAuthorization sets Authorization credentials for asserting the /oauth/token request.
func (*Server) WithDeviceID ¶
WithDeviceID sets the deviceID.
func (*Server) WithMFAToken ¶
WithMFAToken sets the mfaToken.
type ServerMocker ¶
ServerMocker is a function that applies expectations to the mocked server.
func MockEmptyServer ¶
func MockEmptyServer(mocks ...ServerOption) ServerMocker
MockEmptyServer mocks a N26 API server.
func MockServer ¶
func MockServer( username, password string, deviceID uuid.UUID, mocks ...ServerOption, ) ServerMocker
MockServer mocks a server with successful authentication workflow.
type ServerOption ¶
type ServerOption = func(s *Server)
ServerOption is an option to configure Server.
func WithAuthAuthorization ¶
func WithAuthAuthorization(username, password string) ServerOption
WithAuthAuthorization sets the Authorization credentials for asserting the /oauth/token request.
func WithAuthConfirmLoginFailure ¶
func WithAuthConfirmLoginFailure() ServerOption
WithAuthConfirmLoginFailure expects a request for Login Confirm and returns a 500.
func WithAuthConfirmLoginFailureInvalidToken ¶
func WithAuthConfirmLoginFailureInvalidToken(times int) ServerOption
WithAuthConfirmLoginFailureInvalidToken expects a request for Login Confirm and returns an Invalid Token error (401).
func WithAuthConfirmLoginSuccess ¶
func WithAuthConfirmLoginSuccess() ServerOption
WithAuthConfirmLoginSuccess expects a request for Login Confirm and returns a success.
func WithAuthMFAChallengeFailure ¶
func WithAuthMFAChallengeFailure() ServerOption
WithAuthMFAChallengeFailure expects a request for MFA Challenge and returns a 500.
func WithAuthMFAChallengeFailureInvalidToken ¶
func WithAuthMFAChallengeFailureInvalidToken() ServerOption
WithAuthMFAChallengeFailureInvalidToken expects a request for MFA Challenge and returns an Invalid Token error (401).
func WithAuthMFAChallengeSuccess ¶
func WithAuthMFAChallengeSuccess() ServerOption
WithAuthMFAChallengeSuccess expects a request for MFA Challenge and returns a success.
func WithAuthPasswordLoginFailure ¶
func WithAuthPasswordLoginFailure(username, password string, deviceID uuid.UUID) ServerOption
WithAuthPasswordLoginFailure expects a request for login and returns a 500.
func WithAuthPasswordLoginFailureTooManyAttempts ¶
func WithAuthPasswordLoginFailureTooManyAttempts(username, password string, deviceID uuid.UUID) ServerOption
WithAuthPasswordLoginFailureTooManyAttempts expects a request for login and returns a too many attempts error (429).
func WithAuthPasswordLoginFailureWrongCredentials ¶
func WithAuthPasswordLoginFailureWrongCredentials(username, password string, deviceID uuid.UUID) ServerOption
WithAuthPasswordLoginFailureWrongCredentials expects a request for login and returns a bad credentials error (400).
func WithAuthPasswordLoginSuccess ¶
func WithAuthPasswordLoginSuccess(username, password string, deviceID uuid.UUID) ServerOption
WithAuthPasswordLoginSuccess expects a request for login and returns a 403 for the MFA Challenge.
func WithAuthPasswordLoginUnexpectedResponse ¶
func WithAuthPasswordLoginUnexpectedResponse(username, password string, deviceID uuid.UUID) ServerOption
WithAuthPasswordLoginUnexpectedResponse expects a request for login and returns a 200 as an unexpected response.
func WithAuthRefreshTokenFailure ¶
func WithAuthRefreshTokenFailure() ServerOption
WithAuthRefreshTokenFailure expects a request for Token Refresh and returns a 500.
func WithAuthRefreshTokenFailureInvalidToken ¶
func WithAuthRefreshTokenFailureInvalidToken() ServerOption
WithAuthRefreshTokenFailureInvalidToken expects a request for Token Refresh and returns an Invalid Token error (401).
func WithAuthRefreshTokenSuccess ¶
func WithAuthRefreshTokenSuccess() ServerOption
WithAuthRefreshTokenSuccess expects a request for Token Refresh and returns a success.
func WithAuthSuccess ¶
func WithAuthSuccess(username, password string, deviceID uuid.UUID) ServerOption
WithAuthSuccess expects a success login workflow.
func WithFindAllTransactionsInRange ¶
func WithFindAllTransactionsInRange( from time.Time, to time.Time, pageSize int64, result []transaction.Transaction, ) ServerOption
WithFindAllTransactionsInRange sets expectations for finding all transactions in a range.
Directories
¶
Path | Synopsis |
---|---|
Package auth provides functionalities for testing N26 authentication.
|
Package auth provides functionalities for testing N26 authentication. |
Package transaction provides functionalities for testing N26 Transaction APIs.
|
Package transaction provides functionalities for testing N26 Transaction APIs. |