Documentation
¶
Index ¶
- func NewMockAuthService() port.Authenticator
- func NewResourceWithDefaults(resourceType, id string, data map[string]any, isPublic bool) model.Resource
- type MockAccessControlChecker
- func (m *MockAccessControlChecker) CheckAccess(ctx context.Context, subj string, data []byte, timeout time.Duration) (model.AccessCheckResult, error)
- func (m *MockAccessControlChecker) Close() error
- func (m *MockAccessControlChecker) IsReady(ctx context.Context) error
- func (m *MockAccessControlChecker) ReadTuples(_ context.Context, _ string, _ string, _ time.Duration) ([]string, error)
- func (m *MockAccessControlChecker) SetCheckAccessError(err error)
- func (m *MockAccessControlChecker) SetCheckAccessResponse(response map[string]string)
- func (m *MockAccessControlChecker) SetIsReadyError(err error)
- type MockAuthService
- type MockOrganizationSearcher
- func (m *MockOrganizationSearcher) AddOrganization(org model.Organization)
- func (m *MockOrganizationSearcher) ClearOrganizations()
- func (m *MockOrganizationSearcher) GetAllOrganizations() []model.Organization
- func (m *MockOrganizationSearcher) GetOrganizationByDomain(domain string) *model.Organization
- func (m *MockOrganizationSearcher) GetOrganizationByName(name string) *model.Organization
- func (m *MockOrganizationSearcher) GetOrganizationCount() int
- func (m *MockOrganizationSearcher) IsReady(ctx context.Context) error
- func (m *MockOrganizationSearcher) QueryOrganizations(ctx context.Context, criteria model.OrganizationSearchCriteria) (*model.Organization, error)
- func (m *MockOrganizationSearcher) SuggestOrganizations(ctx context.Context, criteria model.OrganizationSuggestionCriteria) (*model.OrganizationSuggestionsResult, error)
- type MockResourceFilter
- type MockResourceSearcher
- func (m *MockResourceSearcher) AddResource(resource model.Resource)
- func (m *MockResourceSearcher) ClearResources()
- func (m *MockResourceSearcher) GetResourceCount() int
- func (m *MockResourceSearcher) IsReady(ctx context.Context) error
- func (m *MockResourceSearcher) QueryResources(ctx context.Context, criteria model.SearchCriteria) (*model.SearchResult, error)
- func (m *MockResourceSearcher) QueryResourcesCount(ctx context.Context, countCriteria model.SearchCriteria, ...) (*model.CountResult, error)
- func (m *MockResourceSearcher) SetIsReadyError(err error)
- func (m *MockResourceSearcher) SetQueryResourcesCountError(err error)
- func (m *MockResourceSearcher) SetQueryResourcesCountResponse(response *model.CountResult)
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
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 ¶
func (m *MockAccessControlChecker) IsReady(ctx context.Context) error
IsReady implements the AccessControlChecker interface (always ready for mock)
func (*MockAccessControlChecker) ReadTuples ¶ added in v0.4.17
func (m *MockAccessControlChecker) ReadTuples(_ context.Context, _ string, _ string, _ time.Duration) ([]string, error)
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
func (m *MockOrganizationSearcher) IsReady(ctx context.Context) error
IsReady implements the OrganizationSearcher interface (always ready for mock)
func (*MockOrganizationSearcher) QueryOrganizations ¶ added in v0.4.0
func (m *MockOrganizationSearcher) QueryOrganizations(ctx context.Context, criteria model.OrganizationSearchCriteria) (*model.Organization, error)
QueryOrganizations implements the OrganizationSearcher interface with mock data
func (*MockOrganizationSearcher) SuggestOrganizations ¶ added in v0.4.1
func (m *MockOrganizationSearcher) SuggestOrganizations(ctx context.Context, criteria model.OrganizationSuggestionCriteria) (*model.OrganizationSuggestionsResult, error)
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
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