tests

package
v0.0.0-...-c16e2ab Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockClient

type MockClient struct {
	Secrets map[string]map[string]*Secret
}

MockClient mocks a Secret Manager client MockClient.Secrets is a map from <project>, <secret_id> to a Secret object

func (*MockClient) CreateSecret

func (cl *MockClient) CreateSecret(project, id string) error

CreateSecret creates an empty secret specified by project, id. It returns nil if successful, otherwise error.

func (*MockClient) DeleteSecretLabel

func (cl *MockClient) DeleteSecretLabel(project, id, key string) error

DeleteSecretLabel deletes the key-value pair in labels of the secret specified by project, id, key. Returns error if update fails or the secret doesn't exist.

func (*MockClient) DestroySecretVersion

func (cl *MockClient) DestroySecretVersion(project, id, version string) error

DestroySecretVersion changes the state of secret version to DESTROYED returns nil if successful, otherwise error.

func (*MockClient) DisableSecretVersion

func (cl *MockClient) DisableSecretVersion(project, id, version string) error

DisableSecretVersion changes the state of secret version to DISABLED returns nil if successful, otherwise error.

func (*MockClient) EnableSecretVersion

func (cl *MockClient) EnableSecretVersion(project, id, version string) error

EnableSecretVersion changes the state of secret version to ENABLED returns nil if successful, otherwise error.

func (*MockClient) GetCreateTime

func (cl *MockClient) GetCreateTime(project, id, version string) (time.Time, error)

GetCreateTime gets the createTime of the secret version specified by project, id, version. Returns createTime if successful, otherwise error.

func (*MockClient) GetSecretLabels

func (cl *MockClient) GetSecretLabels(project, id string) (map[string]string, error)

GetSecretLabels gets the labels of the secret specified by project, id. Returns secret labels if successful, otherwise error

func (*MockClient) GetSecretVersionData

func (cl *MockClient) GetSecretVersionData(project, id, version string) ([]byte, error)

GetSecretVersionData gets the data of the secret version specified by project, id, version. Returns secret value if successful, otherwise error

func (*MockClient) GetSecretVersionState

func (cl *MockClient) GetSecretVersionState(project, id, version string) (secretmanagerpb.SecretVersion_State, error)

GetSecretVersionState gets the state of the secret version specified by project, id, version. Returns state if successful, otherwise error.

func (*MockClient) UpsertSecret

func (cl *MockClient) UpsertSecret(project, id string, data []byte) (string, error)

UpsertSecret adds a new version to the secret specified by project, id. It inserts a new secret if id doesn't already exist. If successful the latest version will have 'data' as its secret value, and return the latest version number if successful, otherwise returns error

func (*MockClient) UpsertSecretLabel

func (cl *MockClient) UpsertSecretLabel(project, id, key, val string) error

UpsertSecretLabel updates or inserts the key-value pair in labels of the secret specified by project, id, key. Returns error if update fails or the secret doesn't exist.

func (*MockClient) ValidateAndConvertVersion

func (cl *MockClient) ValidateAndConvertVersion(project, id, version string) (string, error)

ValidateAndConvertVersion converts version to the version number if version is `latest` returns the numeric version string if the secret version exists, otherwise error.

func (*MockClient) ValidateProject

func (cl *MockClient) ValidateProject(project string) error

ValidateProject returns nil if the project exists, otherwise error.

func (*MockClient) ValidateSecret

func (cl *MockClient) ValidateSecret(project, id string) error

ValidateSecret returns nil if the secret exists, otherwise error.

func (*MockClient) ValidateSecretVersion

func (cl *MockClient) ValidateSecretVersion(project, id, version string) error

ValidateSecretVersion returns nil if the secret version exists, otherwise error.

type MockSvcProvisioner

type MockSvcProvisioner struct {
	NewSecretID    string
	NewSecretValue []byte
}

func (*MockSvcProvisioner) CreateNew

func (p *MockSvcProvisioner) CreateNew(labels map[string]string) (string, []byte, error)

CreateNew provisions a new service account key, returns the key-id and private-key data of the created key if successful, otherwise returns error

func (*MockSvcProvisioner) Deactivate

func (p *MockSvcProvisioner) Deactivate(labels map[string]string, version string) error

Deactivate deletes an existing service account key specified by labels and version, returns nil if successful, otherwise error

type Secret

type Secret struct {
	Versions map[string]*Version
	Labels   map[string]string
}

Secret mocks a Secret Manager secret, which contains metadata and a list of versions Secret.Versions is a map from <version> to a secret Version object Secret.Labels stores the secret metadata

type Version

type Version struct {
	CreateTime time.Time
	Data       []byte
	State      secretmanagerpb.SecretVersion_State
}

Version mocks a Secret Manager secret version, which contains version CreateTime, secret Data and version State

Jump to

Keyboard shortcuts

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