actest

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BatchSize = 1000
View Source
const Concurrency = 10

Variables

This section is empty.

Functions

func AddUserPermissionToDB

func AddUserPermissionToDB(t testing.TB, db db.DB, user *user.SignedInUser)

creates a role, connected it to user and store all permission from the user in database

func ConcurrentBatch

func ConcurrentBatch(workers, count, size int, eachFn func(start, end int) error) error

ConcurrentBatch spawns the requested amount of workers then ask them to run eachFn on chunks of the requested size

Types

type FakeAccessControl

type FakeAccessControl struct {
	ExpectedErr      error
	ExpectedEvaluate bool
}

func (FakeAccessControl) Evaluate

func (f FakeAccessControl) Evaluate(ctx context.Context, user identity.Requester, evaluator accesscontrol.Evaluator) (bool, error)

func (FakeAccessControl) RegisterScopeAttributeResolver

func (f FakeAccessControl) RegisterScopeAttributeResolver(prefix string, resolver accesscontrol.ScopeAttributeResolver)

type FakePermissionsService

type FakePermissionsService struct {
	ExpectedErr          error
	ExpectedPermission   *accesscontrol.ResourcePermission
	ExpectedPermissions  []accesscontrol.ResourcePermission
	ExpectedMappedAction string
}

func (*FakePermissionsService) DeleteResourcePermissions

func (f *FakePermissionsService) DeleteResourcePermissions(ctx context.Context, orgID int64, resourceID string) error

func (*FakePermissionsService) GetPermissions

func (*FakePermissionsService) MapActions

func (*FakePermissionsService) SetBuiltInRolePermission

func (f *FakePermissionsService) SetBuiltInRolePermission(ctx context.Context, orgID int64, builtInRole string, resourceID string, permission string) (*accesscontrol.ResourcePermission, error)

func (*FakePermissionsService) SetPermissions

func (*FakePermissionsService) SetTeamPermission

func (f *FakePermissionsService) SetTeamPermission(ctx context.Context, orgID, teamID int64, resourceID, permission string) (*accesscontrol.ResourcePermission, error)

func (*FakePermissionsService) SetUserPermission

func (f *FakePermissionsService) SetUserPermission(ctx context.Context, orgID int64, user accesscontrol.User, resourceID, permission string) (*accesscontrol.ResourcePermission, error)

type FakeService

type FakeService struct {
	accesscontrol.Service
	ExpectedErr                     error
	ExpectedCachedPermissions       bool
	ExpectedPermissions             []accesscontrol.Permission
	ExpectedFilteredUserPermissions []accesscontrol.Permission
	ExpectedUsersPermissions        map[int64][]accesscontrol.Permission
}

func (FakeService) ClearUserPermissionCache

func (f FakeService) ClearUserPermissionCache(user identity.Requester)

func (FakeService) DeclareFixedRoles

func (f FakeService) DeclareFixedRoles(registrations ...accesscontrol.RoleRegistration) error

func (FakeService) DeleteExternalServiceRole

func (f FakeService) DeleteExternalServiceRole(ctx context.Context, externalServiceID string) error

func (FakeService) DeleteTeamPermissions

func (f FakeService) DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error

func (FakeService) DeleteUserPermissions

func (f FakeService) DeleteUserPermissions(ctx context.Context, orgID, userID int64) error

func (FakeService) GetUsageStats

func (f FakeService) GetUsageStats(ctx context.Context) map[string]any

func (FakeService) GetUserPermissions

func (f FakeService) GetUserPermissions(ctx context.Context, user identity.Requester, options accesscontrol.Options) ([]accesscontrol.Permission, error)

func (FakeService) RegisterFixedRoles

func (f FakeService) RegisterFixedRoles(ctx context.Context) error

func (FakeService) SaveExternalServiceRole

func (f FakeService) SaveExternalServiceRole(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error

func (FakeService) SearchUserPermissions

func (f FakeService) SearchUserPermissions(ctx context.Context, orgID int64, searchOptions accesscontrol.SearchOptions) ([]accesscontrol.Permission, error)

func (FakeService) SearchUsersPermissions

func (f FakeService) SearchUsersPermissions(ctx context.Context, user identity.Requester, options accesscontrol.SearchOptions) (map[int64][]accesscontrol.Permission, error)

type FakeStore

type FakeStore struct {
	ExpectedUserPermissions       []accesscontrol.Permission
	ExpectedBasicRolesPermissions []accesscontrol.Permission
	ExpectedTeamsPermissions      map[int64][]accesscontrol.Permission
	ExpectedUsersPermissions      map[int64][]accesscontrol.Permission
	ExpectedUsersRoles            map[int64][]string
	ExpectedErr                   error
}

func (FakeStore) DeleteExternalServiceRole

func (f FakeStore) DeleteExternalServiceRole(ctx context.Context, externalServiceID string) error

func (FakeStore) DeleteTeamPermissions

func (f FakeStore) DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error

func (FakeStore) DeleteUserPermissions

func (f FakeStore) DeleteUserPermissions(ctx context.Context, orgID, userID int64) error

func (FakeStore) GetBasicRolesPermissions

func (f FakeStore) GetBasicRolesPermissions(ctx context.Context, query accesscontrol.GetUserPermissionsQuery) ([]accesscontrol.Permission, error)

func (FakeStore) GetTeamsPermissions

func (FakeStore) GetUserPermissions

func (FakeStore) GetUsersBasicRoles

func (f FakeStore) GetUsersBasicRoles(ctx context.Context, userFilter []int64, orgID int64) (map[int64][]string, error)

func (FakeStore) SaveExternalServiceRole

func (f FakeStore) SaveExternalServiceRole(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error

func (FakeStore) SearchUsersPermissions

func (f FakeStore) SearchUsersPermissions(ctx context.Context, orgID int64, options accesscontrol.SearchOptions) (map[int64][]accesscontrol.Permission, error)

type MockStore

type MockStore struct {
	mock.Mock
}

MockStore is an autogenerated mock type for the Store type

func NewMockStore

func NewMockStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStore

NewMockStore creates a new instance of MockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockStore) DeleteExternalServiceRole

func (_m *MockStore) DeleteExternalServiceRole(ctx context.Context, externalServiceID string) error

DeleteExternalServiceRole provides a mock function with given fields: ctx, externalServiceID

func (*MockStore) DeleteTeamPermissions

func (_m *MockStore) DeleteTeamPermissions(ctx context.Context, orgID int64, teamID int64) error

DeleteTeamPermissions provides a mock function with given fields: ctx, orgID, teamID

func (*MockStore) DeleteUserPermissions

func (_m *MockStore) DeleteUserPermissions(ctx context.Context, orgID int64, userID int64) error

DeleteUserPermissions provides a mock function with given fields: ctx, orgID, userID

func (*MockStore) GetBasicRolesPermissions

func (_m *MockStore) GetBasicRolesPermissions(ctx context.Context, query accesscontrol.GetUserPermissionsQuery) ([]accesscontrol.Permission, error)

GetBasicRolesPermissions provides a mock function with given fields: ctx, query

func (*MockStore) GetTeamsPermissions

func (_m *MockStore) GetTeamsPermissions(ctx context.Context, query accesscontrol.GetUserPermissionsQuery) (map[int64][]accesscontrol.Permission, error)

GetTeamsPermissions provides a mock function with given fields: ctx, query

func (*MockStore) GetUserPermissions

GetUserPermissions provides a mock function with given fields: ctx, query

func (*MockStore) GetUsersBasicRoles

func (_m *MockStore) GetUsersBasicRoles(ctx context.Context, userFilter []int64, orgID int64) (map[int64][]string, error)

GetUsersBasicRoles provides a mock function with given fields: ctx, userFilter, orgID

func (*MockStore) SaveExternalServiceRole

func (_m *MockStore) SaveExternalServiceRole(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error

SaveExternalServiceRole provides a mock function with given fields: ctx, cmd

func (*MockStore) SearchUsersPermissions

func (_m *MockStore) SearchUsersPermissions(ctx context.Context, orgID int64, options accesscontrol.SearchOptions) (map[int64][]accesscontrol.Permission, error)

SearchUsersPermissions provides a mock function with given fields: ctx, orgID, options

Jump to

Keyboard shortcuts

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