mocks

package
v0.0.1-13 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type K8sSecrets

type K8sSecrets map[string]k8sSecretData

K8sSecrets represents a collection of Kubernetes Secrets to be populated into the mock Kubernetes client's database. The logical hierarchy represented by this structure is:

  • Each Kubernetes Secret contains a 'Data' field.
  • Each 'Data' field contains one or entries that are key/value pairs.
  • The value in each 'Data' field entry can be a nested set of key/value pairs. In particular, for the entry with the key 'conjur-info', the value is expected to be a mapping of application secret names to the corresponding Conjur variable ID (or policy path) that should be used to retrieve the secret value.

type KubeSecretsClient

type KubeSecretsClient struct {

	// TODO: CanRetrieve and CanUpdate are really just used to assert on the presence of errors
	// 	and should probably just be an optional error.
	CanRetrieve bool
	CanUpdate   bool
	// contains filtered or unexported fields
}

KubeSecretsClient implements a mock Kubernetes client for testing Kubernetes Secrets access by the Secrets Provider. This client provides: - A Kubernetes Secret retrieve function - A Kubernetes Secret update function Kubernetes Secrets are populated for this mock client via the AddSecret method. Retrieval and update errors can be simulated for testing by setting the 'CanRetrieve' and 'CanUpdate' flags (respectively) to false.

func NewKubeSecretsClient

func NewKubeSecretsClient() *KubeSecretsClient

NewKubeSecretsClient creates an instance of a KubeSecretsClient

func (*KubeSecretsClient) AddSecret

func (c *KubeSecretsClient) AddSecret(
	secretName string,
	secretData k8sSecretData,
)

AddSecret adds a Kubernetes Secret to the mock Kubernetes Secrets client's database.

func (*KubeSecretsClient) InspectSecret

func (c *KubeSecretsClient) InspectSecret(secretName string) map[string][]byte

InspectSecret provides a way for unit tests to view the 'Data' field content of a Kubernetes Secret by reading this content directly from the mock client's database.

func (*KubeSecretsClient) RetrieveSecret

func (c *KubeSecretsClient) RetrieveSecret(_ string, secretName string) (*v1.Secret, error)

RetrieveSecret retrieves a Kubernetes Secret from the mock Kubernetes Secrets client's database.

func (*KubeSecretsClient) UpdateSecret

func (c *KubeSecretsClient) UpdateSecret(
	_ string, secretName string,
	originalK8sSecret *v1.Secret,
	stringDataEntriesMap map[string][]byte) error

UpdateSecret updates a Kubernetes Secret in the mock Kubernetes Secrets client's database.

type Logger

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

Logger is used to implement logging functions for testing the Kubernetes Secrets storage provider.

func NewLogger

func NewLogger() *Logger

NewLogger returns a shiny, new Logger

func (*Logger) ClearInfo

func (l *Logger) ClearInfo()

ClearInfo Clears the info messages

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...interface{})

Debug logs a debug message.

func (*Logger) DebugWasLogged

func (l *Logger) DebugWasLogged(debug string) bool

DebugWasLogged determines if a debug string appears in any debug messages that have been logged.

func (*Logger) Error

func (l *Logger) Error(msg string, args ...interface{})

Error logs an error.

func (*Logger) ErrorWasLogged

func (l *Logger) ErrorWasLogged(errStr string) bool

ErrorWasLogged determines if an error string appears in any errors that have been logged.

func (*Logger) Info

func (l *Logger) Info(msg string, args ...interface{})

Info logs an info message.

func (*Logger) InfoWasLogged

func (l *Logger) InfoWasLogged(info string) bool

InfoWasLogged determines if a warning string appears in any info messages that have been logged.

func (*Logger) RecordedError

func (l *Logger) RecordedError(msg string, args ...interface{}) error

RecordedError logs that an error has occurred and returns a new error with the given error message.

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...interface{})

Warn logs a warning.

func (*Logger) WarningWasLogged

func (l *Logger) WarningWasLogged(warning string) bool

WarningWasLogged determines if a warning string appears in any warning messages that have been logged.

Jump to

Keyboard shortcuts

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