iamtest

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package iamtest provides primitives for unit testing IAM implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCaller added in v0.38.0

func NewCaller(members ...string) *iamv1.Caller

NewCaller creates a new caller for test purposes.

func WithMembers added in v0.38.0

func WithMembers(ctx context.Context, members ...string) context.Context

WithMembers returns a new context with resolved IAM members for test purposes.

Types

type Fixture

type Fixture struct {
	// contains filtered or unexported fields
}

Fixture is a test fixture with helper methods for IAM testing.

func NewFixture

func NewFixture(server *iamspanner.IAMServer) *Fixture

NewFixture creates a new Fixture for the provided iamspanner.IAMServer.

func (*Fixture) AddPolicyBinding

func (fx *Fixture) AddPolicyBinding(t *testing.T, resource, role, member string)

AddPolicyBinding adds the provided policy binding.

type PermissionTester added in v0.38.0

type PermissionTester struct {
	// contains filtered or unexported fields
}

PermissionTester is a mock permission tester.

func NewPermissionTester added in v0.38.0

func NewPermissionTester() *PermissionTester

NewPermissionTester creates a new mock permission tester.

func (*PermissionTester) Allow added in v0.38.0

func (p *PermissionTester) Allow(member, permission string, resources ...string) *PermissionTester

Allow a permission for a member and resource.

func (*PermissionTester) AllowAll added in v0.38.0

func (p *PermissionTester) AllowAll() *PermissionTester

AllowAll allows all testable permissions for all members and all resources.

func (*PermissionTester) Reset added in v0.38.0

func (p *PermissionTester) Reset() *PermissionTester

Reset all allowed permissions.

func (*PermissionTester) TestPermissions added in v0.38.0

func (p *PermissionTester) TestPermissions(
	_ context.Context,
	caller *iamv1.Caller,
	resourcePermissions map[string]string,
) (map[string]bool, error)

TestPermissions implements iamcel.PermissionTester.

Jump to

Keyboard shortcuts

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