gcpiam

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gcpiam provides an in-memory mock implementation of GCP IAM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

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

Mock is an in-memory mock implementation of the GCP IAM service.

func New

func New(opts *config.Options) *Mock

New creates a new GCP IAM mock with the given configuration options.

func (*Mock) AddUserToGroup added in v1.3.2

func (m *Mock) AddUserToGroup(
	_ context.Context, userName, groupName string,
) error

AddUserToGroup adds a user to a group.

func (*Mock) AttachRolePolicy

func (m *Mock) AttachRolePolicy(_ context.Context, roleName, policyARN string) error

AttachRolePolicy binds a policy to a custom role.

func (*Mock) AttachUserPolicy

func (m *Mock) AttachUserPolicy(_ context.Context, userName, policyARN string) error

AttachUserPolicy binds a policy to a service account (user).

func (*Mock) CheckPermission

func (m *Mock) CheckPermission(_ context.Context, principal, action, resource string) (bool, error)

CheckPermission evaluates attached policies to determine if a principal is allowed to perform the given action on the given resource. Explicit Deny wins over Allow.

func (*Mock) CreateAccessKey added in v1.3.2

func (m *Mock) CreateAccessKey(
	_ context.Context, cfg driver.AccessKeyConfig,
) (*driver.AccessKeyInfo, error)

CreateAccessKey creates a new service account key.

func (*Mock) CreateGroup added in v1.3.2

func (m *Mock) CreateGroup(
	_ context.Context, cfg driver.GroupConfig,
) (*driver.GroupInfo, error)

CreateGroup creates a new GCP IAM group.

func (*Mock) CreatePolicy

func (m *Mock) CreatePolicy(_ context.Context, cfg driver.PolicyConfig) (*driver.PolicyInfo, error)

CreatePolicy creates a new IAM policy binding.

func (*Mock) CreateRole

func (m *Mock) CreateRole(_ context.Context, cfg driver.RoleConfig) (*driver.RoleInfo, error)

CreateRole creates a new IAM custom role.

func (*Mock) CreateUser

func (m *Mock) CreateUser(_ context.Context, cfg driver.UserConfig) (*driver.UserInfo, error)

CreateUser creates a new IAM service account (user).

func (*Mock) DeleteAccessKey added in v1.3.2

func (m *Mock) DeleteAccessKey(
	_ context.Context, userName, accessKeyID string,
) error

DeleteAccessKey deletes a service account key.

func (*Mock) DeleteGroup added in v1.3.2

func (m *Mock) DeleteGroup(_ context.Context, name string) error

DeleteGroup deletes the GCP IAM group with the given name.

func (*Mock) DeletePolicy

func (m *Mock) DeletePolicy(_ context.Context, arn string) error

DeletePolicy deletes the IAM policy with the given resource name (ARN).

func (*Mock) DeleteRole

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

DeleteRole deletes the IAM custom role with the given name.

func (*Mock) DeleteUser

func (m *Mock) DeleteUser(_ context.Context, name string) error

DeleteUser deletes the IAM service account with the given name.

func (*Mock) DetachRolePolicy

func (m *Mock) DetachRolePolicy(_ context.Context, roleName, policyARN string) error

DetachRolePolicy removes a policy binding from a custom role.

func (*Mock) DetachUserPolicy

func (m *Mock) DetachUserPolicy(_ context.Context, userName, policyARN string) error

DetachUserPolicy removes a policy binding from a service account (user).

func (*Mock) GetGroup added in v1.3.2

func (m *Mock) GetGroup(
	_ context.Context, name string,
) (*driver.GroupInfo, error)

GetGroup returns the GCP IAM group with the given name.

func (*Mock) GetPolicy

func (m *Mock) GetPolicy(_ context.Context, arn string) (*driver.PolicyInfo, error)

GetPolicy returns the IAM policy with the given resource name (ARN).

func (*Mock) GetRole

func (m *Mock) GetRole(_ context.Context, name string) (*driver.RoleInfo, error)

GetRole returns the IAM custom role with the given name.

func (*Mock) GetUser

func (m *Mock) GetUser(_ context.Context, name string) (*driver.UserInfo, error)

GetUser returns the IAM service account with the given name.

func (*Mock) ListAccessKeys added in v1.3.2

func (m *Mock) ListAccessKeys(
	_ context.Context, userName string,
) ([]driver.AccessKeyInfo, error)

ListAccessKeys returns all keys for the given service account.

func (*Mock) ListAttachedRolePolicies

func (m *Mock) ListAttachedRolePolicies(_ context.Context, roleName string) ([]string, error)

ListAttachedRolePolicies returns the resource names of policies attached to the given role.

func (*Mock) ListAttachedUserPolicies

func (m *Mock) ListAttachedUserPolicies(_ context.Context, userName string) ([]string, error)

ListAttachedUserPolicies returns the resource names of policies attached to the given service account.

func (*Mock) ListGroups added in v1.3.2

func (m *Mock) ListGroups(
	_ context.Context,
) ([]driver.GroupInfo, error)

ListGroups returns all GCP IAM groups.

func (*Mock) ListGroupsForUser added in v1.3.2

func (m *Mock) ListGroupsForUser(
	_ context.Context, userName string,
) ([]driver.GroupInfo, error)

ListGroupsForUser returns all groups a user belongs to.

func (*Mock) ListPolicies

func (m *Mock) ListPolicies(_ context.Context) ([]driver.PolicyInfo, error)

ListPolicies returns all IAM policies.

func (*Mock) ListRoles

func (m *Mock) ListRoles(_ context.Context) ([]driver.RoleInfo, error)

ListRoles returns all IAM custom roles.

func (*Mock) ListUsers

func (m *Mock) ListUsers(_ context.Context) ([]driver.UserInfo, error)

ListUsers returns all IAM service accounts.

func (*Mock) RemoveUserFromGroup added in v1.3.2

func (m *Mock) RemoveUserFromGroup(
	_ context.Context, userName, groupName string,
) error

RemoveUserFromGroup removes a user from a group.

Jump to

Keyboard shortcuts

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