mock

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func (m *MockClientStore) CheckIPLimit(ctx context.Context, ip string, maxClientsPerIP int) error

CheckIPLimit checks if an IP has reached the client registration limit

func (*MockClientStore) GetClient

func (m *MockClientStore) GetClient(ctx context.Context, clientID string) (*storage.Client, error)

GetClient retrieves a client by ID

func (*MockClientStore) ListClients

func (m *MockClientStore) ListClients(ctx context.Context) ([]*storage.Client, error)

ListClients lists all registered clients

func (*MockClientStore) ResetCallCounts

func (m *MockClientStore) ResetCallCounts()

ResetCallCounts resets all call counters

func (*MockClientStore) SaveClient

func (m *MockClientStore) SaveClient(ctx context.Context, client *storage.Client) error

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) GetToken

func (m *MockTokenStore) GetToken(ctx context.Context, userID string) (*oauth2.Token, error)

GetToken retrieves a token for a user

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) SaveToken

func (m *MockTokenStore) SaveToken(ctx context.Context, userID string, token *oauth2.Token) error

SaveToken saves a token for a user

func (*MockTokenStore) SaveUserInfo

func (m *MockTokenStore) SaveUserInfo(ctx context.Context, userID string, info *providers.UserInfo) error

SaveUserInfo saves user information

Jump to

Keyboard shortcuts

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