mock

package
v0.0.79 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mock provides a no-op implementation of the minder the authorization client

Package mock provides a no-op implementation of the minder the authorization client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoopClient

type NoopClient struct {
	// If Authorized is true, all Check calls will return nil
	Authorized bool
}

NoopClient is a no-op implementation of the authz.Client interface, which always returns the same authorization result.

func (*NoopClient) Adopt

func (_ *NoopClient) Adopt(_ context.Context, _, _ uuid.UUID) error

Adopt implements authz.Client

func (*NoopClient) AssignmentsToProject

func (_ *NoopClient) AssignmentsToProject(_ context.Context, _ uuid.UUID) ([]*minderv1.RoleAssignment, error)

AssignmentsToProject implements authz.Client

func (*NoopClient) Check

func (n *NoopClient) Check(ctx context.Context, action string, project uuid.UUID) error

Check implements authz.Client

func (*NoopClient) Delete

func (_ *NoopClient) Delete(_ context.Context, _ string, _ authz.Role, _ uuid.UUID) error

Delete implements authz.Client

func (*NoopClient) DeleteUser

func (_ *NoopClient) DeleteUser(_ context.Context, _ string) error

DeleteUser implements authz.Client

func (*NoopClient) MigrateUp

func (_ *NoopClient) MigrateUp(_ context.Context) error

MigrateUp implements authz.Client

func (*NoopClient) Orphan

func (_ *NoopClient) Orphan(_ context.Context, _, _ uuid.UUID) error

Orphan implements authz.Client

func (*NoopClient) PrepareForRun

func (_ *NoopClient) PrepareForRun(_ context.Context) error

PrepareForRun implements authz.Client

func (*NoopClient) ProjectsForUser

func (_ *NoopClient) ProjectsForUser(_ context.Context, _ string) ([]uuid.UUID, error)

ProjectsForUser implements authz.Client

func (*NoopClient) Write

func (_ *NoopClient) Write(_ context.Context, _ string, _ authz.Role, _ uuid.UUID) error

Write_ implements authz.Client

type SimpleClient

type SimpleClient struct {
	Allowed     []uuid.UUID
	Assignments map[uuid.UUID][]*minderv1.RoleAssignment

	// Adoptions is a map of child project to parent project
	Adoptions map[uuid.UUID]uuid.UUID

	// OrphanCalls is a counter for the number of times Orphan is called
	OrphanCalls atomic.Int32
}

SimpleClient maintains a list of authorized projects, suitable for use in tests.

func (*SimpleClient) Adopt

func (n *SimpleClient) Adopt(_ context.Context, p, c uuid.UUID) error

Adopt implements authz.Client

func (*SimpleClient) AssignmentsToProject

func (n *SimpleClient) AssignmentsToProject(_ context.Context, p uuid.UUID) ([]*minderv1.RoleAssignment, error)

AssignmentsToProject implements authz.Client

func (*SimpleClient) Check

func (n *SimpleClient) Check(_ context.Context, _ string, project uuid.UUID) error

Check implements authz.Client

func (*SimpleClient) Delete

func (n *SimpleClient) Delete(_ context.Context, id string, role authz.Role, project uuid.UUID) error

Delete implements authz.Client

func (*SimpleClient) DeleteUser

func (n *SimpleClient) DeleteUser(_ context.Context, user string) error

DeleteUser implements authz.Client

func (*SimpleClient) MigrateUp

func (_ *SimpleClient) MigrateUp(_ context.Context) error

MigrateUp implements authz.Client

func (*SimpleClient) Orphan

func (n *SimpleClient) Orphan(_ context.Context, _, c uuid.UUID) error

Orphan implements authz.Client

func (*SimpleClient) PrepareForRun

func (_ *SimpleClient) PrepareForRun(_ context.Context) error

PrepareForRun implements authz.Client

func (*SimpleClient) ProjectsForUser

func (n *SimpleClient) ProjectsForUser(_ context.Context, _ string) ([]uuid.UUID, error)

ProjectsForUser implements authz.Client

func (*SimpleClient) Write

func (n *SimpleClient) Write(_ context.Context, id string, role authz.Role, project uuid.UUID) error

Write implements authz.Client

Jump to

Keyboard shortcuts

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