executor

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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 NewMock

func NewMock() *Mock

func (*Mock) AddPermissions

func (m *Mock) AddPermissions(_ context.Context, role string, perms []string) error

func (*Mock) DeleteRole

func (m *Mock) DeleteRole(_ context.Context, role string) error

func (*Mock) EnsureRole

func (m *Mock) EnsureRole(_ context.Context, role string) error

func (*Mock) RemovePermissions

func (m *Mock) RemovePermissions(_ context.Context, role string, perms []string) error

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 (s *SuperTokensExecutor) AddPermissions(_ context.Context, role string, perms []string) error

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

func (s *SuperTokensExecutor) RemovePermissions(_ context.Context, role string, perms []string) error

Jump to

Keyboard shortcuts

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