mock

package
v0.4.23 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockAuthService added in v0.4.3

func NewMockAuthService() port.Authenticator

NewMockAuthService creates a new mock authentication service

func NewResourceWithDefaults

func NewResourceWithDefaults(resourceType, id string, data map[string]any, isPublic bool) model.Resource

NewResourceWithDefaults creates a new resource with proper default access control fields

Types

type MockAccessControlChecker

type MockAccessControlChecker struct {
	// PublicResourcesOnly determines if only public resources should be allowed
	PublicResourcesOnly bool
	// AllowedUserIDs contains user IDs that should be granted access to all resources
	AllowedUserIDs []string
	// DeniedResourceIDs contains resource IDs that should always be denied
	DeniedResourceIDs []string
	// SimulateErrors determines if errors should be simulated
	SimulateErrors bool
	// DefaultResult is the default access result ("allowed" or "denied")
	DefaultResult string

	// MockTupleRefs is the list of object refs returned by ReadTuples
	MockTupleRefs []string
	// SimulateTuplesError determines if ReadTuples should return an error
	SimulateTuplesError bool
	// contains filtered or unexported fields
}

MockAccessControlChecker provides a mock implementation of AccessControlChecker for testing

func NewMockAccessControlChecker

func NewMockAccessControlChecker() *MockAccessControlChecker

NewMockAccessControlChecker creates a new mock access control checker

func NewMockAccessControlCheckerDenyAll

func NewMockAccessControlCheckerDenyAll() *MockAccessControlChecker

NewMockAccessControlCheckerDenyAll creates a mock that denies all access

func NewMockAccessControlCheckerPublicOnly

func NewMockAccessControlCheckerPublicOnly() *MockAccessControlChecker

NewMockAccessControlCheckerPublicOnly creates a mock that only allows public resources

func NewMockAccessControlCheckerWithErrors

func NewMockAccessControlCheckerWithErrors() *MockAccessControlChecker

NewMockAccessControlCheckerWithErrors creates a mock that simulates errors

func (*MockAccessControlChecker) CheckAccess

func (m *MockAccessControlChecker) CheckAccess(ctx context.Context, subj string, data []byte, timeout time.Duration) (model.AccessCheckResult, error)

CheckAccess implements the AccessControlChecker interface with mock behavior

func (*MockAccessControlChecker) Close

func (m *MockAccessControlChecker) Close() error

Close implements the AccessControlChecker interface (no-op for mock)

func (*MockAccessControlChecker) IsReady

IsReady implements the AccessControlChecker interface (always ready for mock)

func (*MockAccessControlChecker) ReadTuples added in v0.4.17

ReadTuples implements the AccessControlChecker interface with mock behavior

func (*MockAccessControlChecker) SetCheckAccessError added in v0.4.5

func (m *MockAccessControlChecker) SetCheckAccessError(err error)

SetCheckAccessError sets the mock error for CheckAccess calls

func (*MockAccessControlChecker) SetCheckAccessResponse added in v0.4.5

func (m *MockAccessControlChecker) SetCheckAccessResponse(response map[string]string)

SetCheckAccessResponse sets the mock response for CheckAccess calls

func (*MockAccessControlChecker) SetIsReadyError added in v0.4.5

func (m *MockAccessControlChecker) SetIsReadyError(err error)

SetIsReadyError sets the mock error for IsReady calls

type MockAuthService added in v0.4.3

type MockAuthService struct{}

MockAuthService provides a mock implementation of the authentication service

func (*MockAuthService) ParsePrincipal added in v0.4.3

func (m *MockAuthService) ParsePrincipal(ctx context.Context, token string, logger *slog.Logger) (string, error)

ParsePrincipal returns a mock principal from environment variable (ignores token parameter)

type MockOrganizationSearcher added in v0.4.0

type MockOrganizationSearcher struct {
	// contains filtered or unexported fields
}

MockOrganizationSearcher is a mock implementation of OrganizationSearcher for testing This demonstrates how the clean architecture allows easy swapping of implementations

func NewMockOrganizationSearcher added in v0.4.0

func NewMockOrganizationSearcher() *MockOrganizationSearcher

NewMockOrganizationSearcher creates a new mock organization searcher with sample data

func (*MockOrganizationSearcher) AddOrganization added in v0.4.0

func (m *MockOrganizationSearcher) AddOrganization(org model.Organization)

AddOrganization adds an organization to the mock data (useful for testing)

func (*MockOrganizationSearcher) ClearOrganizations added in v0.4.0

func (m *MockOrganizationSearcher) ClearOrganizations()

ClearOrganizations clears all organizations (useful for testing)

func (*MockOrganizationSearcher) GetAllOrganizations added in v0.4.0

func (m *MockOrganizationSearcher) GetAllOrganizations() []model.Organization

GetAllOrganizations returns all organizations (for testing purposes)

func (*MockOrganizationSearcher) GetOrganizationByDomain added in v0.4.0

func (m *MockOrganizationSearcher) GetOrganizationByDomain(domain string) *model.Organization

GetOrganizationByDomain returns an organization by domain (for testing purposes)

func (*MockOrganizationSearcher) GetOrganizationByName added in v0.4.0

func (m *MockOrganizationSearcher) GetOrganizationByName(name string) *model.Organization

GetOrganizationByName returns an organization by name (for testing purposes)

func (*MockOrganizationSearcher) GetOrganizationCount added in v0.4.0

func (m *MockOrganizationSearcher) GetOrganizationCount() int

GetOrganizationCount returns the total number of organizations

func (*MockOrganizationSearcher) IsReady added in v0.4.0

IsReady implements the OrganizationSearcher interface (always ready for mock)

func (*MockOrganizationSearcher) QueryOrganizations added in v0.4.0

QueryOrganizations implements the OrganizationSearcher interface with mock data

func (*MockOrganizationSearcher) SuggestOrganizations added in v0.4.1

SuggestOrganizations implements the OrganizationSearcher interface with mock suggestions

type MockResourceFilter added in v0.4.10

type MockResourceFilter struct{}

MockResourceFilter is a mock implementation of ResourceFilter for testing

func NewMockResourceFilter added in v0.4.10

func NewMockResourceFilter() *MockResourceFilter

NewMockResourceFilter creates a new MockResourceFilter

func (*MockResourceFilter) Filter added in v0.4.10

func (m *MockResourceFilter) Filter(ctx context.Context, resources []model.Resource, expression string) ([]model.Resource, error)

Filter returns all resources unfiltered (no-op filter for testing)

type MockResourceSearcher

type MockResourceSearcher struct {
	// contains filtered or unexported fields
}

MockResourceSearcher is a mock implementation of ResourceSearcher for testing This demonstrates how the clean architecture allows easy swapping of implementations

func NewMockResourceSearcher

func NewMockResourceSearcher() *MockResourceSearcher

NewMockResourceSearcher creates a new mock searcher with some sample data

func (*MockResourceSearcher) AddResource

func (m *MockResourceSearcher) AddResource(resource model.Resource)

AddResource adds a resource to the mock data (useful for testing)

func (*MockResourceSearcher) ClearResources

func (m *MockResourceSearcher) ClearResources()

ClearResources clears all resources (useful for testing)

func (*MockResourceSearcher) GetResourceCount

func (m *MockResourceSearcher) GetResourceCount() int

GetResourceCount returns the total number of resources

func (*MockResourceSearcher) IsReady

func (m *MockResourceSearcher) IsReady(ctx context.Context) error

IsReady implements the ResourceSearcher interface (always ready for mock)

func (*MockResourceSearcher) QueryResources

func (m *MockResourceSearcher) QueryResources(ctx context.Context, criteria model.SearchCriteria) (*model.SearchResult, error)

QueryResources implements the ResourceSearcher interface with mock data

func (*MockResourceSearcher) QueryResourcesCount added in v0.4.5

func (m *MockResourceSearcher) QueryResourcesCount(ctx context.Context, countCriteria model.SearchCriteria, aggregationCriteria model.SearchCriteria, publicOnly bool) (*model.CountResult, error)

QueryResourcesCount implements the ResourceSearcher interface with mock data

func (*MockResourceSearcher) SetIsReadyError added in v0.4.5

func (m *MockResourceSearcher) SetIsReadyError(err error)

SetIsReadyError sets the mock error for IsReady calls

func (*MockResourceSearcher) SetQueryResourcesCountError added in v0.4.5

func (m *MockResourceSearcher) SetQueryResourcesCountError(err error)

SetQueryResourcesCountError sets the mock error for QueryResourcesCount calls

func (*MockResourceSearcher) SetQueryResourcesCountResponse added in v0.4.5

func (m *MockResourceSearcher) SetQueryResourcesCountResponse(response *model.CountResult)

SetQueryResourcesCountResponse sets the mock response for QueryResourcesCount calls

Jump to

Keyboard shortcuts

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