Documentation ¶
Index ¶
- type Calls
- type Mock
- func New() *Mockdeprecated
- func (m *Mock) ClearUserPermissionCache(user identity.Requester)
- func (m *Mock) DeclareFixedRoles(registrations ...accesscontrol.RoleRegistration) error
- func (m *Mock) DeclarePluginRoles(ctx context.Context, ID, name string, regs []plugins.RoleRegistration) error
- func (m *Mock) DeleteExternalServiceRole(ctx context.Context, externalServiceID string) error
- func (m *Mock) DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error
- func (m *Mock) DeleteUserPermissions(ctx context.Context, orgID, userID int64) error
- func (m *Mock) Evaluate(ctx context.Context, usr identity.Requester, evaluator accesscontrol.Evaluator) (bool, error)
- func (m *Mock) GetRoleByName(ctx context.Context, orgID int64, roleName string) (*accesscontrol.RoleDTO, error)
- func (m *Mock) GetUsageStats(ctx context.Context) map[string]interface{}
- func (m *Mock) GetUserPermissions(ctx context.Context, user identity.Requester, opts accesscontrol.Options) ([]accesscontrol.Permission, error)
- func (m *Mock) RegisterFixedRoles(ctx context.Context) error
- func (m *Mock) RegisterScopeAttributeResolver(scopePrefix string, resolver accesscontrol.ScopeAttributeResolver)
- func (m *Mock) SaveExternalServiceRole(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error
- func (m *Mock) SearchUserPermissions(ctx context.Context, orgID int64, searchOptions accesscontrol.SearchOptions) ([]accesscontrol.Permission, error)
- func (m *Mock) SearchUsersPermissions(ctx context.Context, usr identity.Requester, ...) (map[int64][]accesscontrol.Permission, error)
- func (m *Mock) SyncUserRoles(ctx context.Context, orgID int64, cmd accesscontrol.SyncUserRolesCommand) error
- func (m *Mock) WithBuiltInRoles(builtInRoles []string) *Mock
- func (m *Mock) WithPermissions(permissions []accesscontrol.Permission) *Mock
- type MockPermissionsService
- func (m *MockPermissionsService) DeleteResourcePermissions(ctx context.Context, orgID int64, resourceID string) error
- func (m *MockPermissionsService) GetPermissions(ctx context.Context, user identity.Requester, resourceID string) ([]accesscontrol.ResourcePermission, error)
- func (m *MockPermissionsService) MapActions(permission accesscontrol.ResourcePermission) string
- func (m *MockPermissionsService) SetBuiltInRolePermission(ctx context.Context, orgID int64, builtInRole, resourceID, permission string) (*accesscontrol.ResourcePermission, error)
- func (m *MockPermissionsService) SetPermissions(ctx context.Context, orgID int64, resourceID string, ...) ([]accesscontrol.ResourcePermission, error)
- func (m *MockPermissionsService) SetTeamPermission(ctx context.Context, orgID, teamID int64, resourceID, permission string) (*accesscontrol.ResourcePermission, error)
- func (m *MockPermissionsService) SetUserPermission(ctx context.Context, orgID int64, user accesscontrol.User, ...) (*accesscontrol.ResourcePermission, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calls ¶
type Calls struct { Evaluate []interface{} GetRoleByName []interface{} GetUserPermissions []interface{} ClearUserPermissionCache []interface{} DeclareFixedRoles []interface{} DeclarePluginRoles []interface{} GetUserBuiltInRoles []interface{} RegisterFixedRoles []interface{} RegisterAttributeScopeResolver []interface{} DeleteUserPermissions []interface{} DeleteTeamPermissions []interface{} SearchUsersPermissions []interface{} SearchUserPermissions []interface{} SaveExternalServiceRole []interface{} DeleteExternalServiceRole []interface{} }
type Mock ¶
type Mock struct { // Track the list of calls Calls Calls // Override functions EvaluateFunc func(context.Context, identity.Requester, accesscontrol.Evaluator) (bool, error) GetRoleByNameFunc func(context.Context, int64, string) (*accesscontrol.RoleDTO, error) GetUserPermissionsFunc func(context.Context, identity.Requester, accesscontrol.Options) ([]accesscontrol.Permission, error) ClearUserPermissionCacheFunc func(identity.Requester) DeclareFixedRolesFunc func(...accesscontrol.RoleRegistration) error DeclarePluginRolesFunc func(context.Context, string, string, []plugins.RoleRegistration) error GetUserBuiltInRolesFunc func(user identity.Requester) []string RegisterFixedRolesFunc func() error RegisterScopeAttributeResolverFunc func(string, accesscontrol.ScopeAttributeResolver) DeleteUserPermissionsFunc func(context.Context, int64) error DeleteTeamPermissionsFunc func(context.Context, int64) error SearchUsersPermissionsFunc func(context.Context, identity.Requester, int64, accesscontrol.SearchOptions) (map[int64][]accesscontrol.Permission, error) SearchUserPermissionsFunc func(ctx context.Context, orgID int64, searchOptions accesscontrol.SearchOptions) ([]accesscontrol.Permission, error) SaveExternalServiceRoleFunc func(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error DeleteExternalServiceRoleFunc func(ctx context.Context, externalServiceID string) error SyncUserRolesFunc func(ctx context.Context, orgID int64, cmd accesscontrol.SyncUserRolesCommand) error // contains filtered or unexported fields }
func (*Mock) ClearUserPermissionCache ¶
func (*Mock) DeclareFixedRoles ¶
func (m *Mock) DeclareFixedRoles(registrations ...accesscontrol.RoleRegistration) error
DeclareFixedRoles allow the caller to declare, to the service, fixed roles and their assignments to organization roles ("Viewer", "Editor", "Admin") or "Grafana Admin" This mock returns no error unless an override is provided.
func (*Mock) DeclarePluginRoles ¶
func (m *Mock) DeclarePluginRoles(ctx context.Context, ID, name string, regs []plugins.RoleRegistration) error
DeclarePluginRoles allow the caller to declare, to the service, plugin roles and their assignments to organization roles ("Viewer", "Editor", "Admin") or "Grafana Admin" This mock returns no error unless an override is provided.
func (*Mock) DeleteExternalServiceRole ¶
func (*Mock) DeleteTeamPermissions ¶
func (*Mock) DeleteUserPermissions ¶
func (*Mock) Evaluate ¶
func (m *Mock) Evaluate(ctx context.Context, usr identity.Requester, evaluator accesscontrol.Evaluator) (bool, error)
Evaluate evaluates access to the given resource. This mock uses GetUserPermissions to then call the evaluator Evaluate function.
func (*Mock) GetRoleByName ¶
func (*Mock) GetUsageStats ¶
func (*Mock) GetUserPermissions ¶
func (m *Mock) GetUserPermissions(ctx context.Context, user identity.Requester, opts accesscontrol.Options) ([]accesscontrol.Permission, error)
GetUserPermissions returns user permissions. This mock return m.permissions unless an override is provided.
func (*Mock) RegisterFixedRoles ¶
RegisterFixedRoles registers all roles declared to AccessControl This mock returns no error unless an override is provided.
func (*Mock) RegisterScopeAttributeResolver ¶
func (m *Mock) RegisterScopeAttributeResolver(scopePrefix string, resolver accesscontrol.ScopeAttributeResolver)
func (*Mock) SaveExternalServiceRole ¶
func (m *Mock) SaveExternalServiceRole(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error
func (*Mock) SearchUserPermissions ¶
func (m *Mock) SearchUserPermissions(ctx context.Context, orgID int64, searchOptions accesscontrol.SearchOptions) ([]accesscontrol.Permission, error)
func (*Mock) SearchUsersPermissions ¶
func (m *Mock) SearchUsersPermissions(ctx context.Context, usr identity.Requester, options accesscontrol.SearchOptions) (map[int64][]accesscontrol.Permission, error)
SearchUsersPermissions returns all users' permissions filtered by an action prefix
func (*Mock) SyncUserRoles ¶
func (m *Mock) SyncUserRoles(ctx context.Context, orgID int64, cmd accesscontrol.SyncUserRolesCommand) error
func (*Mock) WithBuiltInRoles ¶
func (*Mock) WithPermissions ¶
func (m *Mock) WithPermissions(permissions []accesscontrol.Permission) *Mock
type MockPermissionsService ¶
func NewMockedPermissionsService ¶
func NewMockedPermissionsService() *MockPermissionsService
func (*MockPermissionsService) DeleteResourcePermissions ¶
func (*MockPermissionsService) GetPermissions ¶
func (m *MockPermissionsService) GetPermissions(ctx context.Context, user identity.Requester, resourceID string) ([]accesscontrol.ResourcePermission, error)
func (*MockPermissionsService) MapActions ¶
func (m *MockPermissionsService) MapActions(permission accesscontrol.ResourcePermission) string
func (*MockPermissionsService) SetBuiltInRolePermission ¶
func (m *MockPermissionsService) SetBuiltInRolePermission(ctx context.Context, orgID int64, builtInRole, resourceID, permission string) (*accesscontrol.ResourcePermission, error)
func (*MockPermissionsService) SetPermissions ¶
func (m *MockPermissionsService) SetPermissions(ctx context.Context, orgID int64, resourceID string, commands ...accesscontrol.SetResourcePermissionCommand) ([]accesscontrol.ResourcePermission, error)
func (*MockPermissionsService) SetTeamPermission ¶
func (m *MockPermissionsService) SetTeamPermission(ctx context.Context, orgID, teamID int64, resourceID, permission string) (*accesscontrol.ResourcePermission, error)
func (*MockPermissionsService) SetUserPermission ¶
func (m *MockPermissionsService) SetUserPermission(ctx context.Context, orgID int64, user accesscontrol.User, resourceID, permission string) (*accesscontrol.ResourcePermission, error)