Version: v1.14.6 Latest Latest

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

Go to latest
Published: Aug 16, 2019 License: Apache-2.0, Apache-2.0 Imports: 25 Imported by: 0




This section is empty.


This section is empty.


func NewAttribute

func NewAttribute(namespace string, labels map[string]string, dryRun bool) admission.Attributes

NewAttribute returns static admission Attributes for testing.

func NewAttributeUnstructured

func NewAttributeUnstructured(namespace string, labels map[string]string, dryRun bool) admission.Attributes

NewAttributeUnstructured returns static admission Attributes for testing with custom resources.

func NewAuthenticationInfoResolver

func NewAuthenticationInfoResolver(cacheMisses *int32) webhook.AuthenticationInfoResolver

NewAuthenticationInfoResolver creates a fake AuthenticationInfoResolver that counts cache misses on every call to its methods.

func NewFakeDataSource

func NewFakeDataSource(name string, webhooks []registrationv1beta1.Webhook, mutating bool, stopCh <-chan struct{}) (clientset kubernetes.Interface, factory informers.SharedInformerFactory)

NewFakeDataSource returns a mock client and informer returning the given webhooks.

func NewObjectInterfacesForTest added in v1.14.0

func NewObjectInterfacesForTest() admission.ObjectInterfaces

NewObjectInterfacesForTest returns an ObjectInterfaces appropriate for test cases in this file.

func NewServiceResolver

func NewServiceResolver(base url.URL) webhook.ServiceResolver

NewServiceResolver returns a static service resolve that return the given URL or an error for the failResolve namespace.

func NewTestServer

func NewTestServer(t *testing.T) *httptest.Server

NewTestServer returns a webhook test HTTPS server with fixed webhook test certs.

func Wrapper

Wrapper turns an AuthenticationInfoResolver into a AuthenticationInfoResolverWrapper that unconditionally returns the given AuthenticationInfoResolver.


type CachedTest

type CachedTest struct {
	Name            string
	Webhooks        []registrationv1beta1.Webhook
	ExpectAllow     bool
	ExpectCacheMiss bool

CachedTest is a test case for the client manager.

func NewCachedClientTestcases

func NewCachedClientTestcases(url *url.URL) []CachedTest

NewCachedClientTestcases returns a set of client manager test cases.

type FakeAttributes added in v1.12.0

type FakeAttributes struct {
	// contains filtered or unexported fields

FakeAttributes decorate admission.Attributes. It's used to trace the added annotations.

func (*FakeAttributes) AddAnnotation added in v1.12.0

func (f *FakeAttributes) AddAnnotation(k, v string) error

AddAnnotation adds an annotation key value pair to FakeAttributes

func (*FakeAttributes) GetAnnotations added in v1.12.0

func (f *FakeAttributes) GetAnnotations() map[string]string

GetAnnotations reads annotations from FakeAttributes

type Test

type Test struct {
	Name              string
	Webhooks          []registrationv1beta1.Webhook
	Path              string
	IsCRD             bool
	IsDryRun          bool
	AdditionalLabels  map[string]string
	ExpectLabels      map[string]string
	ExpectAllow       bool
	ErrorContains     string
	ExpectAnnotations map[string]string

Test is a webhook test case.

func NewMutatingTestCases added in v1.12.0

func NewMutatingTestCases(url *url.URL) []Test

NewMutatingTestCases returns test cases with a given base url. All test cases in NewMutatingTestCases have Patch set in AdmissionResponse. The test cases are only used by both MutatingAdmissionWebhook.

func NewNonMutatingTestCases added in v1.12.0

func NewNonMutatingTestCases(url *url.URL) []Test

NewNonMutatingTestCases returns test cases with a given base url. All test cases in NewNonMutatingTestCases have no Patch set in AdmissionResponse. The test cases are used by both MutatingAdmissionWebhook and ValidatingAdmissionWebhook.

Jump to

Keyboard shortcuts

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