Documentation
¶
Index ¶
- func OverrideRolesClient(client RolesClient)
- type Executor
- type Mock
- type RolesClient
- type SuperTokensExecutor
- func (s *SuperTokensExecutor) AddPermissions(_ context.Context, role string, perms []string) error
- func (s *SuperTokensExecutor) DeleteRole(_ context.Context, role string) error
- func (s *SuperTokensExecutor) EnsureRole(_ context.Context, role string) error
- func (s *SuperTokensExecutor) RemovePermissions(_ context.Context, role string, perms []string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OverrideRolesClient ¶
func OverrideRolesClient(client RolesClient)
OverrideRolesClient allows tests to substitute a mock client.
Types ¶
type Executor ¶
type Executor interface {
EnsureRole(ctx context.Context, role string) error
DeleteRole(ctx context.Context, role string) error
AddPermissions(ctx context.Context, role string, perms []string) error
RemovePermissions(ctx context.Context, role string, perms []string) error
}
Executor applies role/permission changes against a backend (e.g., SuperTokens).
type Mock ¶
type Mock struct {
RolesEnsured []string
RolesDeleted []string
PermsAdded map[string][]string
PermsRemoved map[string][]string
FailWith error
// contains filtered or unexported fields
}
Mock captures applied actions for testing.
func (*Mock) AddPermissions ¶
type RolesClient ¶
type RolesClient interface {
CreateNewRoleOrAddPermissions(role string, perms []string, ctx supertokens.UserContext) (userrolesmodels.CreateNewRoleOrAddPermissionsResponse, error)
RemovePermissionsFromRole(role string, perms []string, ctx supertokens.UserContext) (userrolesmodels.RemovePermissionsFromRoleResponse, error)
DeleteRole(role string, ctx supertokens.UserContext) (userrolesmodels.DeleteRoleResponse, error)
}
RolesClient abstracts the SuperTokens userroles functions for testability.
type SuperTokensExecutor ¶
type SuperTokensExecutor struct{}
SuperTokensExecutor implements Executor using the SuperTokens roles/permissions API.
func NewSuperTokensExecutor ¶
func NewSuperTokensExecutor() *SuperTokensExecutor
func (*SuperTokensExecutor) AddPermissions ¶
func (*SuperTokensExecutor) DeleteRole ¶
func (s *SuperTokensExecutor) DeleteRole(_ context.Context, role string) error
func (*SuperTokensExecutor) EnsureRole ¶
func (s *SuperTokensExecutor) EnsureRole(_ context.Context, role string) error
func (*SuperTokensExecutor) RemovePermissions ¶
Click to show internal directories.
Click to hide internal directories.