testutil

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCertificate

func CreateCertificate(notBefore, notAfter time.Time) ([]byte, []byte, error)

CreateCertificate creates a certificate with the provided time bounds, and returns the PEM representation of the certificate and its private key. The returned certificate is capable of signing child certificates.

func RequireEqualContentType added in v0.3.0

func RequireEqualContentType(t *testing.T, actual string, expected string)

func RequireNumberOfSecretsMatchingLabelSelector added in v0.3.0

func RequireNumberOfSecretsMatchingLabelSelector(t *testing.T, secrets v1.SecretInterface, labelSet labels.Set, expectedNumberOfSecrets int)

func RequireSecurityHeaders added in v0.3.0

func RequireSecurityHeaders(t *testing.T, response *httptest.ResponseRecorder)

func RequireTimeInDelta added in v0.3.0

func RequireTimeInDelta(t *testing.T, t1 time.Time, t2 time.Time, delta time.Duration)

func SHA256 added in v0.3.0

func SHA256(s string) string

SHA256 returns the base64 URL encoding of the SHA256 sum of the provided string.

func TLSTestServer

func TLSTestServer(t *testing.T, handler http.HandlerFunc) (caBundlePEM string, url string)

TLSTestServer starts a test server listening on a local port using a test CA. It returns the PEM CA bundle and the URL of the listening server. The lifetime of the server is bound to the provided *testing.T.

func TempDir added in v0.3.0

func TempDir(t *testing.T) string

Types

type ErrorWriter

type ErrorWriter struct {
	ReturnError error
}

ErrorWriter implements io.Writer by returning a fixed error.

func (*ErrorWriter) Write

func (e *ErrorWriter) Write([]byte) (int, error)

type ObservableWithInformerOption

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

func NewObservableWithInformerOption

func NewObservableWithInformerOption() *ObservableWithInformerOption

func (*ObservableWithInformerOption) GetFilterForInformer

func (*ObservableWithInformerOption) WithInformer

type ObservableWithInitialEventOption

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

func NewObservableWithInitialEventOption

func NewObservableWithInitialEventOption() *ObservableWithInitialEventOption

func (*ObservableWithInitialEventOption) GetInitialEventKey

func (i *ObservableWithInitialEventOption) GetInitialEventKey() *controllerlib.Key

func (*ObservableWithInitialEventOption) WithInitialEvent

type TranscriptLogMessage

type TranscriptLogMessage struct {
	Level   string
	Message string
}

type TranscriptLogger

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

func NewTranscriptLogger

func NewTranscriptLogger(t *testing.T) *TranscriptLogger

func (*TranscriptLogger) Enabled

func (*TranscriptLogger) Enabled() bool

func (*TranscriptLogger) Error

func (log *TranscriptLogger) Error(_ error, msg string, _ ...interface{})

func (*TranscriptLogger) Info

func (log *TranscriptLogger) Info(msg string, keysAndValues ...interface{})

func (*TranscriptLogger) Transcript

func (log *TranscriptLogger) Transcript() []TranscriptLogMessage

func (*TranscriptLogger) V

func (log *TranscriptLogger) V(_ int) logr.Logger

func (*TranscriptLogger) WithName

func (log *TranscriptLogger) WithName(_ string) logr.Logger

func (*TranscriptLogger) WithValues

func (log *TranscriptLogger) WithValues(_ ...interface{}) logr.Logger

type ValidCert

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

func ValidateCertificate

func ValidateCertificate(t *testing.T, caPEM string, certPEM string) *ValidCert

ValidateCertificate validates a certificate and provides an object for asserting properties of the certificate.

func (*ValidCert) RequireCommonName

func (v *ValidCert) RequireCommonName(commonName string)

RequireCommonName asserts that the certificate contains the provided commonName.

func (*ValidCert) RequireDNSName

func (v *ValidCert) RequireDNSName(expectDNSName string)

RequireDNSName asserts that the certificate matches the provided DNS name.

func (*ValidCert) RequireLifetime

func (v *ValidCert) RequireLifetime(expectNotBefore time.Time, expectNotAfter time.Time, delta time.Duration)

RequireLifetime asserts that the lifetime of the certificate matches the expected timestamps.

func (*ValidCert) RequireMatchesPrivateKey

func (v *ValidCert) RequireMatchesPrivateKey(keyPEM string)

RequireMatchesPrivateKey asserts that the public key in the certificate matches the provided private key.

Directories

Path Synopsis
Package testlogger implements a logr.Logger suitable for writing test assertions.
Package testlogger implements a logr.Logger suitable for writing test assertions.

Jump to

Keyboard shortcuts

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