Documentation ¶
Index ¶
- type Calls
- type Mock
- func New() *Mockdeprecated
- func (m *Mock) ClearUserPermissionCache(usr 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) DeleteUserPermissions(ctx context.Context, orgID, userID int64) error
- func (m *Mock) Evaluate(ctx context.Context, us identity.Requester, evaluator accesscontrol.Evaluator) (bool, error)
- func (m *Mock) GetUsageStats(ctx context.Context) map[string]interface{}
- func (m *Mock) GetUserPermissions(ctx context.Context, usr identity.Requester, opts accesscontrol.Options) ([]accesscontrol.Permission, error)
- func (m *Mock) IsDisabled() bool
- 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) WithBuiltInRoles(builtInRoles []string) *Mock
- func (m *Mock) WithDisabled() *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 *user.SignedInUser, 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{} GetUserPermissions []interface{} ClearUserPermissionCache []interface{} IsDisabled []interface{} DeclareFixedRoles []interface{} DeclarePluginRoles []interface{} GetUserBuiltInRoles []interface{} RegisterFixedRoles []interface{} RegisterAttributeScopeResolver []interface{} DeleteUserPermissions []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, *user.SignedInUser, accesscontrol.Evaluator) (bool, error) GetUserPermissionsFunc func(context.Context, *user.SignedInUser, accesscontrol.Options) ([]accesscontrol.Permission, error) ClearUserPermissionCacheFunc func(*user.SignedInUser) IsDisabledFunc func() bool DeclareFixedRolesFunc func(...accesscontrol.RoleRegistration) error DeclarePluginRolesFunc func(context.Context, string, string, []plugins.RoleRegistration) error GetUserBuiltInRolesFunc func(user *user.SignedInUser) []string RegisterFixedRolesFunc func() error RegisterScopeAttributeResolverFunc func(string, accesscontrol.ScopeAttributeResolver) DeleteUserPermissionsFunc func(context.Context, int64) error SearchUsersPermissionsFunc func(context.Context, *user.SignedInUser, 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 // 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) DeleteUserPermissions ¶
func (*Mock) Evaluate ¶
func (m *Mock) Evaluate(ctx context.Context, us 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) GetUsageStats ¶
func (*Mock) GetUserPermissions ¶
func (m *Mock) GetUserPermissions(ctx context.Context, usr identity.Requester, opts accesscontrol.Options) ([]accesscontrol.Permission, error)
GetUserPermissions returns user permissions. This mock return m.permissions unless an override is provided.
func (*Mock) IsDisabled ¶
Middleware checks if service disabled or not to switch to fallback authorization. This mock return m.disabled 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) WithBuiltInRoles ¶
func (*Mock) WithDisabled ¶
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 *user.SignedInUser, 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)