Documentation
¶
Overview ¶
Package mock provides mock implementations of storage interfaces for testing purposes. It includes in-memory implementations with call tracking for verification.
Package mock provides mock implementations of storage interfaces for testing.
Index ¶
- type MockClientStore
- func (m *MockClientStore) CheckIPLimit(ctx context.Context, ip string, maxClientsPerIP int) error
- func (m *MockClientStore) GetClient(ctx context.Context, clientID string) (*storage.Client, error)
- func (m *MockClientStore) ListClients(ctx context.Context) ([]*storage.Client, error)
- func (m *MockClientStore) ResetCallCounts()
- func (m *MockClientStore) SaveClient(ctx context.Context, client *storage.Client) error
- func (m *MockClientStore) ValidateClientSecret(ctx context.Context, clientID, clientSecret string) error
- type MockFlowStore
- func (m *MockFlowStore) AtomicCheckAndMarkAuthCodeUsed(ctx context.Context, code string) (*storage.AuthorizationCode, error)
- func (m *MockFlowStore) DeleteAuthorizationCode(ctx context.Context, code string) error
- func (m *MockFlowStore) DeleteAuthorizationState(ctx context.Context, stateID string) error
- func (m *MockFlowStore) GetAuthorizationCode(ctx context.Context, code string) (*storage.AuthorizationCode, error)
- func (m *MockFlowStore) GetAuthorizationState(ctx context.Context, stateID string) (*storage.AuthorizationState, error)
- func (m *MockFlowStore) GetAuthorizationStateByProviderState(ctx context.Context, providerState string) (*storage.AuthorizationState, error)
- func (m *MockFlowStore) ResetCallCounts()
- func (m *MockFlowStore) SaveAuthorizationCode(ctx context.Context, code *storage.AuthorizationCode) error
- func (m *MockFlowStore) SaveAuthorizationState(ctx context.Context, state *storage.AuthorizationState) error
- type MockTokenStore
- func (m *MockTokenStore) DeleteRefreshToken(ctx context.Context, refreshToken string) error
- func (m *MockTokenStore) DeleteToken(ctx context.Context, userID string) error
- func (m *MockTokenStore) GetRefreshTokenInfo(ctx context.Context, refreshToken string) (string, error)
- func (m *MockTokenStore) GetToken(ctx context.Context, userID string) (*oauth2.Token, error)
- func (m *MockTokenStore) GetUserInfo(ctx context.Context, userID string) (*providers.UserInfo, error)
- func (m *MockTokenStore) ResetCallCounts()
- func (m *MockTokenStore) SaveRefreshToken(ctx context.Context, refreshToken, userID string, expiresAt time.Time) error
- func (m *MockTokenStore) SaveToken(ctx context.Context, userID string, token *oauth2.Token) error
- func (m *MockTokenStore) SaveUserInfo(ctx context.Context, userID string, info *providers.UserInfo) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockClientStore ¶
type MockClientStore struct {
SaveClientFunc func(ctx context.Context, client *storage.Client) error
GetClientFunc func(ctx context.Context, clientID string) (*storage.Client, error)
ValidateSecretFunc func(ctx context.Context, clientID, clientSecret string) error
ListClientsFunc func(ctx context.Context) ([]*storage.Client, error)
CheckIPLimitFunc func(ctx context.Context, ip string, maxClientsPerIP int) error
CallCounts map[string]int
// contains filtered or unexported fields
}
MockClientStore is a mock implementation of ClientStore for testing
func NewMockClientStore ¶
func NewMockClientStore() *MockClientStore
NewMockClientStore creates a new mock client store
func (*MockClientStore) CheckIPLimit ¶
CheckIPLimit checks if an IP has reached the client registration limit
func (*MockClientStore) ListClients ¶
ListClients lists all registered clients
func (*MockClientStore) ResetCallCounts ¶
func (m *MockClientStore) ResetCallCounts()
ResetCallCounts resets all call counters
func (*MockClientStore) SaveClient ¶
SaveClient saves a registered client
func (*MockClientStore) ValidateClientSecret ¶
func (m *MockClientStore) ValidateClientSecret(ctx context.Context, clientID, clientSecret string) error
ValidateClientSecret validates a client's secret
type MockFlowStore ¶
type MockFlowStore struct {
SaveAuthStateFunc func(ctx context.Context, state *storage.AuthorizationState) error
GetAuthStateFunc func(ctx context.Context, stateID string) (*storage.AuthorizationState, error)
GetAuthStateByProviderFunc func(ctx context.Context, providerState string) (*storage.AuthorizationState, error)
DeleteAuthStateFunc func(ctx context.Context, stateID string) error
SaveAuthCodeFunc func(ctx context.Context, code *storage.AuthorizationCode) error
GetAuthCodeFunc func(ctx context.Context, code string) (*storage.AuthorizationCode, error)
DeleteAuthCodeFunc func(ctx context.Context, code string) error
AtomicCheckAndMarkCodeUsedFunc func(ctx context.Context, code string) (*storage.AuthorizationCode, error)
CallCounts map[string]int
// contains filtered or unexported fields
}
MockFlowStore is a mock implementation of FlowStore for testing
func NewMockFlowStore ¶
func NewMockFlowStore() *MockFlowStore
NewMockFlowStore creates a new mock flow store
func (*MockFlowStore) AtomicCheckAndMarkAuthCodeUsed ¶ added in v0.1.29
func (m *MockFlowStore) AtomicCheckAndMarkAuthCodeUsed(ctx context.Context, code string) (*storage.AuthorizationCode, error)
AtomicCheckAndMarkAuthCodeUsed atomically checks if a code is unused and marks it as used
func (*MockFlowStore) DeleteAuthorizationCode ¶
func (m *MockFlowStore) DeleteAuthorizationCode(ctx context.Context, code string) error
DeleteAuthorizationCode removes an authorization code
func (*MockFlowStore) DeleteAuthorizationState ¶
func (m *MockFlowStore) DeleteAuthorizationState(ctx context.Context, stateID string) error
DeleteAuthorizationState removes an authorization state
func (*MockFlowStore) GetAuthorizationCode ¶
func (m *MockFlowStore) GetAuthorizationCode(ctx context.Context, code string) (*storage.AuthorizationCode, error)
GetAuthorizationCode retrieves an authorization code
func (*MockFlowStore) GetAuthorizationState ¶
func (m *MockFlowStore) GetAuthorizationState(ctx context.Context, stateID string) (*storage.AuthorizationState, error)
GetAuthorizationState retrieves an authorization state by client state
func (*MockFlowStore) GetAuthorizationStateByProviderState ¶
func (m *MockFlowStore) GetAuthorizationStateByProviderState(ctx context.Context, providerState string) (*storage.AuthorizationState, error)
GetAuthorizationStateByProviderState retrieves an authorization state by provider state
func (*MockFlowStore) ResetCallCounts ¶
func (m *MockFlowStore) ResetCallCounts()
ResetCallCounts resets all call counters
func (*MockFlowStore) SaveAuthorizationCode ¶
func (m *MockFlowStore) SaveAuthorizationCode(ctx context.Context, code *storage.AuthorizationCode) error
SaveAuthorizationCode saves an issued authorization code
func (*MockFlowStore) SaveAuthorizationState ¶
func (m *MockFlowStore) SaveAuthorizationState(ctx context.Context, state *storage.AuthorizationState) error
SaveAuthorizationState saves the state of an ongoing authorization flow
type MockTokenStore ¶
type MockTokenStore struct {
SaveTokenFunc func(ctx context.Context, userID string, token *oauth2.Token) error
GetTokenFunc func(ctx context.Context, userID string) (*oauth2.Token, error)
DeleteTokenFunc func(ctx context.Context, userID string) error
SaveUserInfoFunc func(ctx context.Context, userID string, info *providers.UserInfo) error
GetUserInfoFunc func(ctx context.Context, userID string) (*providers.UserInfo, error)
SaveRefreshFunc func(ctx context.Context, refreshToken, userID string, expiresAt time.Time) error
GetRefreshFunc func(ctx context.Context, refreshToken string) (string, error)
DeleteRefreshFunc func(ctx context.Context, refreshToken string) error
CallCounts map[string]int
// contains filtered or unexported fields
}
MockTokenStore is a mock implementation of TokenStore for testing
func NewMockTokenStore ¶
func NewMockTokenStore() *MockTokenStore
NewMockTokenStore creates a new mock token store
func (*MockTokenStore) DeleteRefreshToken ¶
func (m *MockTokenStore) DeleteRefreshToken(ctx context.Context, refreshToken string) error
DeleteRefreshToken removes a refresh token
func (*MockTokenStore) DeleteToken ¶
func (m *MockTokenStore) DeleteToken(ctx context.Context, userID string) error
DeleteToken removes a token for a user
func (*MockTokenStore) GetRefreshTokenInfo ¶
func (m *MockTokenStore) GetRefreshTokenInfo(ctx context.Context, refreshToken string) (string, error)
GetRefreshTokenInfo retrieves the user ID for a refresh token
func (*MockTokenStore) GetUserInfo ¶
func (m *MockTokenStore) GetUserInfo(ctx context.Context, userID string) (*providers.UserInfo, error)
GetUserInfo retrieves user information
func (*MockTokenStore) ResetCallCounts ¶
func (m *MockTokenStore) ResetCallCounts()
ResetCallCounts resets all call counters
func (*MockTokenStore) SaveRefreshToken ¶
func (m *MockTokenStore) SaveRefreshToken(ctx context.Context, refreshToken, userID string, expiresAt time.Time) error
SaveRefreshToken saves a refresh token mapping to user ID with expiry
func (*MockTokenStore) SaveUserInfo ¶
func (m *MockTokenStore) SaveUserInfo(ctx context.Context, userID string, info *providers.UserInfo) error
SaveUserInfo saves user information