mock

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PermCounter

type PermCounter struct {
	UserPerms map[int32]map[string]int
}

func NewPermCounter

func NewPermCounter() *PermCounter

func (*PermCounter) GetUser

func (p *PermCounter) GetUser(userId int32) map[string]int

func (*PermCounter) IncUser

func (p *PermCounter) IncUser(userId int32, name string)

type PermsMock

type PermsMock struct {
	perms.Permissions

	Counter *PermCounter

	UserPerms map[int32]map[string]interface{}
	UserRoles map[int32]map[string]interface{}
}

func NewMock

func NewMock() *PermsMock

func (*PermsMock) AddUserPerm

func (p *PermsMock) AddUserPerm(userId int32, perm string)

func (*PermsMock) AddUserToRoles

func (p *PermsMock) AddUserToRoles(ctx context.Context, userId int32, roles ...string) error

func (*PermsMock) Can

func (p *PermsMock) Can(userInfo *userinfo.UserInfo, category perms.Category, name perms.Name) bool

func (*PermsMock) CountRolesForJob

func (p *PermsMock) CountRolesForJob(ctx context.Context, prefix string) (int64, error)

func (*PermsMock) CreatePermission

func (p *PermsMock) CreatePermission(ctx context.Context, category perms.Category, name perms.Name) (uint64, error)

func (*PermsMock) CreateRole

func (p *PermsMock) CreateRole(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error)

func (*PermsMock) DeleteRole

func (p *PermsMock) DeleteRole(ctx context.Context, id uint64) error

func (*PermsMock) GetAllPermissions

func (p *PermsMock) GetAllPermissions(ctx context.Context) ([]*permissions.Permission, error)

func (*PermsMock) GetPermissionsByIDs

func (p *PermsMock) GetPermissionsByIDs(ctx context.Context, ids ...uint64) ([]*permissions.Permission, error)

func (*PermsMock) GetPermissionsOfUser

func (p *PermsMock) GetPermissionsOfUser(userInfo *userinfo.UserInfo) (collections.Permissions, error)

func (*PermsMock) GetRole

func (p *PermsMock) GetRole(ctx context.Context, id uint64) (*model.FivenetRoles, error)

func (*PermsMock) GetRoleByJobAndGrade

func (p *PermsMock) GetRoleByJobAndGrade(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error)

func (*PermsMock) GetRolePermissions

func (p *PermsMock) GetRolePermissions(ctx context.Context, id uint64) ([]*permissions.Permission, error)

func (*PermsMock) GetRoles

func (p *PermsMock) GetRoles(ctx context.Context, prefix string) (collections.Roles, error)

func (*PermsMock) GetUserRoles

func (p *PermsMock) GetUserRoles(userId int32) (collections.Roles, error)

func (*PermsMock) RemovePermissionsFromRole

func (p *PermsMock) RemovePermissionsFromRole(ctx context.Context, id uint64, perms ...uint64) error

func (*PermsMock) RemoveUserFromRoles

func (p *PermsMock) RemoveUserFromRoles(ctx context.Context, userId int32, roles ...string) error

func (*PermsMock) RemoveUserPerm

func (p *PermsMock) RemoveUserPerm(userId int32, perm string)

func (*PermsMock) UpdateRolePermissions

func (p *PermsMock) UpdateRolePermissions(ctx context.Context, id uint64, perms ...perms.AddPerm) error

Jump to

Keyboard shortcuts

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