Documentation ¶
Overview ¶
Package testutil contains shared test utilities for the Pinniped project.
As of right now, it is more or less a dumping ground for our test utilities.
Index ¶
- func CreateCertificate(notBefore, notAfter time.Time) ([]byte, []byte, error)
- func KubeServerSupportsCertificatesV1API(t *testing.T, discoveryClient discovery.DiscoveryInterface) bool
- func NewDeleteOptionsRecorder(client kubernetes.Interface, opts *[]metav1.DeleteOptions) kubernetes.Interface
- func NewPreconditions(uid types.UID, rv string) metav1.DeleteOptions
- func RequireEqualContentType(t *testing.T, actual string, expected string)
- func RequireNumberOfSecretsMatchingLabelSelector(t *testing.T, secrets v1.SecretInterface, labelSet labels.Set, ...)
- func RequireSecurityHeaders(t *testing.T, response *httptest.ResponseRecorder)
- func RequireTimeInDelta(t *testing.T, t1 time.Time, t2 time.Time, delta time.Duration)
- func SHA256(s string) string
- func TLSTestServer(t *testing.T, handler http.HandlerFunc) (caBundlePEM string, url string)
- func TLSTestServerWithCert(t *testing.T, handler http.HandlerFunc, certificate *tls.Certificate) (url string)
- func TempDir(t *testing.T) string
- func WriteStringToTempFile(t *testing.T, filename string, fileBody string) *os.File
- type ErrorWriter
- type ObservableWithInformerOption
- type ObservableWithInitialEventOption
- type RoundTrip
- func (rt *RoundTrip) MutateRequest(fn func(kubeclient.Object) error)
- func (rt *RoundTrip) MutateResponse(fn func(kubeclient.Object) error)
- func (rt *RoundTrip) Namespace() string
- func (rt *RoundTrip) NamespaceScoped() bool
- func (rt *RoundTrip) Resource() schema.GroupVersionResource
- func (rt *RoundTrip) Subresource() string
- func (rt *RoundTrip) Verb() kubeclient.Verb
- func (rt *RoundTrip) WithNamespace(namespace string) *RoundTrip
- func (rt *RoundTrip) WithResource(resource schema.GroupVersionResource) *RoundTrip
- func (rt *RoundTrip) WithSubresource(subresource string) *RoundTrip
- func (rt *RoundTrip) WithVerb(verb kubeclient.Verb) *RoundTrip
- type TranscriptLogMessage
- type TranscriptLogger
- func (*TranscriptLogger) Enabled() bool
- func (log *TranscriptLogger) Error(_ error, msg string, _ ...interface{})
- func (log *TranscriptLogger) Info(msg string, keysAndValues ...interface{})
- func (log *TranscriptLogger) Transcript() []TranscriptLogMessage
- func (log *TranscriptLogger) V(_ int) logr.Logger
- func (log *TranscriptLogger) WithName(_ string) logr.Logger
- func (log *TranscriptLogger) WithValues(_ ...interface{}) logr.Logger
- type ValidCert
- func (v *ValidCert) RequireCommonName(commonName string)
- func (v *ValidCert) RequireDNSName(expectDNSName string)
- func (v *ValidCert) RequireDNSNames(names []string)
- func (v *ValidCert) RequireEmptyDNSNames()
- func (v *ValidCert) RequireEmptyIPs()
- func (v *ValidCert) RequireIPs(ips []net.IP)
- func (v *ValidCert) RequireLifetime(expectNotBefore time.Time, expectNotAfter time.Time, delta time.Duration)
- func (v *ValidCert) RequireMatchesPrivateKey(keyPEM string)
- func (v *ValidCert) RequireOrganizations(orgs []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCertificate ¶
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 KubeServerSupportsCertificatesV1API ¶ added in v0.12.1
func KubeServerSupportsCertificatesV1API(t *testing.T, discoveryClient discovery.DiscoveryInterface) bool
func NewDeleteOptionsRecorder ¶ added in v0.11.0
func NewDeleteOptionsRecorder(client kubernetes.Interface, opts *[]metav1.DeleteOptions) kubernetes.Interface
func NewPreconditions ¶ added in v0.11.0
func NewPreconditions(uid types.UID, rv string) metav1.DeleteOptions
func RequireEqualContentType ¶ added in v0.3.0
func RequireNumberOfSecretsMatchingLabelSelector ¶ added in v0.3.0
func RequireSecurityHeaders ¶ added in v0.3.0
func RequireSecurityHeaders(t *testing.T, response *httptest.ResponseRecorder)
func RequireTimeInDelta ¶ added in v0.3.0
func SHA256 ¶ added in v0.3.0
SHA256 returns the base64 URL encoding of the SHA256 sum of the provided string.
func TLSTestServer ¶
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 TLSTestServerWithCert ¶ added in v0.9.0
func TLSTestServerWithCert(t *testing.T, handler http.HandlerFunc, certificate *tls.Certificate) (url string)
Types ¶
type ErrorWriter ¶
type ErrorWriter struct {
ReturnError error
}
ErrorWriter implements io.Writer by returning a fixed error.
type ObservableWithInformerOption ¶
type ObservableWithInformerOption struct {
// contains filtered or unexported fields
}
func NewObservableWithInformerOption ¶
func NewObservableWithInformerOption() *ObservableWithInformerOption
func (*ObservableWithInformerOption) GetFilterForInformer ¶
func (i *ObservableWithInformerOption) GetFilterForInformer(getter controllerlib.InformerGetter) controllerlib.Filter
func (*ObservableWithInformerOption) WithInformer ¶
func (i *ObservableWithInformerOption) WithInformer( getter controllerlib.InformerGetter, filter controllerlib.Filter, opt controllerlib.InformerOption, ) controllerlib.Option
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 ¶
func (i *ObservableWithInitialEventOption) WithInitialEvent(key controllerlib.Key) controllerlib.Option
type RoundTrip ¶ added in v0.5.0
type RoundTrip struct {
MutateRequests, MutateResponses []func(kubeclient.Object) error
// contains filtered or unexported fields
}
RoundTrip is an implementation of kubeclient.RoundTrip that is easy to use in tests.
func (*RoundTrip) MutateRequest ¶ added in v0.5.0
func (rt *RoundTrip) MutateRequest(fn func(kubeclient.Object) error)
func (*RoundTrip) MutateResponse ¶ added in v0.5.0
func (rt *RoundTrip) MutateResponse(fn func(kubeclient.Object) error)
func (*RoundTrip) NamespaceScoped ¶ added in v0.5.0
func (*RoundTrip) Resource ¶ added in v0.5.0
func (rt *RoundTrip) Resource() schema.GroupVersionResource
func (*RoundTrip) Subresource ¶ added in v0.5.0
func (*RoundTrip) Verb ¶ added in v0.5.0
func (rt *RoundTrip) Verb() kubeclient.Verb
func (*RoundTrip) WithNamespace ¶ added in v0.5.0
func (*RoundTrip) WithResource ¶ added in v0.5.0
func (rt *RoundTrip) WithResource(resource schema.GroupVersionResource) *RoundTrip
func (*RoundTrip) WithSubresource ¶ added in v0.5.0
type TranscriptLogMessage ¶
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) WithValues ¶
func (log *TranscriptLogger) WithValues(_ ...interface{}) logr.Logger
type ValidCert ¶
type ValidCert struct {
// contains filtered or unexported fields
}
func ValidateClientCertificate ¶ added in v0.7.0
func ValidateServerCertificate ¶ added in v0.7.0
ValidateServerCertificate validates a certificate and provides an object for asserting properties of the certificate.
func (*ValidCert) RequireCommonName ¶
RequireCommonName asserts that the certificate contains the provided commonName.
func (*ValidCert) RequireDNSName ¶
RequireDNSName asserts that the certificate matches the provided DNS name.
func (*ValidCert) RequireDNSNames ¶ added in v0.7.0
func (*ValidCert) RequireEmptyDNSNames ¶ added in v0.7.0
func (v *ValidCert) RequireEmptyDNSNames()
func (*ValidCert) RequireEmptyIPs ¶ added in v0.7.0
func (v *ValidCert) RequireEmptyIPs()
func (*ValidCert) RequireIPs ¶ added in v0.7.0
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 ¶
RequireMatchesPrivateKey asserts that the public key in the certificate matches the provided private key.
func (*ValidCert) RequireOrganizations ¶ added in v0.7.0
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package fakekubeapi contains a *very* simple httptest.Server that can be used to stand in for a real Kube API server in tests.
|
Package fakekubeapi contains a *very* simple httptest.Server that can be used to stand in for a real Kube API server in tests. |
Package testlogger implements a logr.Logger suitable for writing test assertions.
|
Package testlogger implements a logr.Logger suitable for writing test assertions. |