Documentation ¶
Overview ¶
Package util provides common test utility functions.
Index ¶
- Constants
- Variables
- func Assert(t *testing.T, condition bool)
- func CreateServiceInstanceQuery() *url.Values
- func DefaultClient() (*http.Client, error)
- func DefaultRequest(method, path string) (*http.Request, error)
- func DefaultRequestWithBody(method, path string, body io.Reader) (*http.Request, error)
- func Delete(path string, statusCode int, response interface{}) error
- func DeleteAndError(path string, statusCode int, apiError api.ErrorType) error
- func DeleteServiceBindingQuery(req *api.CreateServiceBindingRequest) *url.Values
- func DeleteServiceInstanceQuery(req *api.CreateServiceInstanceRequest) *url.Values
- func DoRequest(client *http.Client, request *http.Request) (*http.Response, error)
- func Get(path string, statusCode int, response interface{}) error
- func GetAndError(path string, statusCode int, apiError api.ErrorType) error
- func MatchHeader(response *http.Response, name, value string) error
- func MustBasicRequest(t *testing.T, method, path string) *http.Request
- func MustCreateServiceBinding(t *testing.T, instance, binding string, req *api.CreateServiceBindingRequest)
- func MustCreateServiceBrokerConfig(t *testing.T, clients client.Clients, config *v1.ServiceBrokerConfig)
- func MustCreateServiceInstance(t *testing.T, name string, req *api.CreateServiceInstanceRequest) *api.CreateServiceInstanceResponse
- func MustCreateServiceInstanceSuccessfully(t *testing.T, name string, req *api.CreateServiceInstanceRequest)
- func MustDefaultClient(t *testing.T) *http.Client
- func MustDefaultRequest(t *testing.T, method, path string) *http.Request
- func MustDefaultRequestWithBody(t *testing.T, method, path string, body io.Reader) *http.Request
- func MustDelete(t *testing.T, path string, statusCode int, response interface{})
- func MustDeleteAndError(t *testing.T, path string, statusCode int, apiError api.ErrorType)
- func MustDeleteServiceBinding(t *testing.T, instance, binding string, req *api.CreateServiceBindingRequest)
- func MustDeleteServiceBrokerConfig(t *testing.T, clients client.Clients)
- func MustDeleteServiceInstance(t *testing.T, name string, req *api.CreateServiceInstanceRequest) *api.CreateServiceInstanceResponse
- func MustDeleteServiceInstanceSuccessfully(t *testing.T, name string, req *api.CreateServiceInstanceRequest)
- func MustDoRequest(t *testing.T, client *http.Client, request *http.Request) *http.Response
- func MustGet(t *testing.T, path string, statusCode int, response interface{})
- func MustGetAndError(t *testing.T, path string, statusCode int, apiError api.ErrorType)
- func MustGetRegistryEntry(t *testing.T, clients client.Clients, rt registry.Type, name string) *corev1.Secret
- func MustHaveRegistryEntriesTLS(t *testing.T, entry *corev1.Secret, key, cert registry.Key)
- func MustHaveRegistryEntriesTLSAndVerify(t *testing.T, entry *corev1.Secret, caCert, key, cert registry.Key, ...)
- func MustHaveRegistryEntryPassword(t *testing.T, entry *corev1.Secret, key registry.Key, length int, ...)
- func MustHaveRegistryEntryWithValue(t *testing.T, entry *corev1.Secret, key registry.Key, value string)
- func MustNotDoRequest(t *testing.T, client *http.Client, request *http.Request)
- func MustNotHaveRegistryEntry(t *testing.T, entry *corev1.Secret, key registry.Key)
- func MustPatch(t *testing.T, path string, statusCode int, request, response interface{})
- func MustPatchAndError(t *testing.T, path string, statusCode int, request interface{}, ...)
- func MustPollServiceInstanceForCompletion(t *testing.T, name string, rsp *api.CreateServiceInstanceResponse)
- func MustPollServiceInstanceForDeletion(t *testing.T, name string, rsp *api.CreateServiceInstanceResponse)
- func MustPut(t *testing.T, path string, statusCode int, request, response interface{})
- func MustPutAndError(t *testing.T, path string, statusCode int, request interface{}, ...)
- func MustReplaceBrokerConfig(t *testing.T, clients client.Clients, spec *v1.ServiceBrokerConfigSpec)
- func MustReplaceBrokerConfigWithInvalidCondition(t *testing.T, clients client.Clients, spec *v1.ServiceBrokerConfigSpec)
- func MustResetDynamicClient(t *testing.T, clients client.Clients)
- func MustUpdateBrokerConfig(t *testing.T, clients client.Clients, callback func(*v1.ServiceBrokerConfig))
- func MustUpdateServiceInstance(t *testing.T, name string, req *api.UpdateServiceInstanceRequest) *api.CreateServiceInstanceResponse
- func MustUpdateServiceInstanceSuccessfully(t *testing.T, name string, req *api.UpdateServiceInstanceRequest)
- func MustVerifyStatusCode(t *testing.T, response *http.Response, statusCode int)
- func MustWaitFor(t *testing.T, f util.WaitFunc, timeout time.Duration)
- func NewClients() (client.Clients, error)
- func Patch(path string, statusCode int, request, response interface{}) error
- func PatchAndError(path string, statusCode int, request interface{}, apiError api.ErrorType) error
- func PollServiceInstanceQuery(req *api.CreateServiceInstanceRequest, rsp *api.CreateServiceInstanceResponse) *url.Values
- func Put(path string, statusCode int, request, response interface{}) error
- func PutAndError(path string, statusCode int, request interface{}, apiError api.ErrorType) error
- func ReadServiceInstanceQuery(req *api.CreateServiceInstanceRequest) *url.Values
- func ResetClients(clients client.Clients) error
- func ServerRunning() error
- func ServiceBindingURI(instance, binding string, query *url.Values) string
- func ServiceInstancePollURI(instance string, query *url.Values) string
- func ServiceInstanceURI(instance string, query *url.Values) string
- func UpdateServiceInstanceQuery() *url.Values
- func VerifyStatusCode(response *http.Response, statusCode int) error
- func WaitFor(f util.WaitFunc, timeout time.Duration) error
Constants ¶
const ( // QueryServiceID is the service ID identifier used in a query. QueryServiceID = "service_id" // QueryPlanID is the plan ID identifier used in a query. QueryPlanID = "plan_id" // QueryOperation is the operation ID identifier used in a query. QueryOperation = "operation" )
const ( // CA is the CA for the server certificate. CA = `` /* 1203-byte string literal not displayed */ // Cert is a valid for "DNS:localhost" until 2022-05-26. Cert = `` /* 1244-byte string literal not displayed */ // Key is the private key for cert. Key = `` /* 1703-byte string literal not displayed */ // Token is the default OAuth bearer token. Token = "HeMan" // Namespace is the default namespace, that isn't default. Namespace = "Skeletor" )
Variables ¶
var ( // DefaultBrokerConfig is a minimal service broker config to allow initialization. DefaultBrokerConfig = &v1.ServiceBrokerConfig{ ObjectMeta: metav1.ObjectMeta{ Name: "couchbase-service-broker", Namespace: Namespace, }, } )
Functions ¶
func CreateServiceInstanceQuery ¶
CreateServiceInstanceQuery creates a query string for use with the service instance creation.
func DefaultClient ¶
DefaultClient creates a HTTP client for use against the service broker. It applies known good configuration to provide connectivity with the broker for the common case.
func DefaultRequest ¶
DefaultRequest creates a HTTP request object for the requested method on a path. It applies known good configuration to provide connectivity with the broker for the common case.
func DefaultRequestWithBody ¶
DefaultRequestWithBody creates a HTTP request object for the requested method on a path. It applies known good configuration to provide connectivity with the broker for the common case.
func DeleteAndError ¶
DeleteAndError does a DELETE API call and expects a certain response with a valid JSON error.
func DeleteServiceBindingQuery ¶
func DeleteServiceBindingQuery(req *api.CreateServiceBindingRequest) *url.Values
DeleteServiceBindingQuery creates a query string for use with the service binding deletion API. It is generated from the original service binding creation request.
func DeleteServiceInstanceQuery ¶
func DeleteServiceInstanceQuery(req *api.CreateServiceInstanceRequest) *url.Values
DeleteServiceInstanceQuery creates a query string for use with the service instance deletion API. It is generated from the original service instance creation request.
func DoRequest ¶
DoRequest performs a requests against the broker API with the provided client. This call will cause test failure if the network transport fails.
func GetAndError ¶
GetAndError does a GET API call and expects a certain response with a valid JSON error.
func MatchHeader ¶
MatchHeader checks if the header exists with the specified value.
func MustBasicRequest ¶
MustBasicRequest creates a HTTP request object for the requested method on a path. It applies no additional headers.
func MustCreateServiceBinding ¶
func MustCreateServiceBinding(t *testing.T, instance, binding string, req *api.CreateServiceBindingRequest)
MustCreateServiceBinding wraps up service binding creation.
func MustCreateServiceBrokerConfig ¶
func MustCreateServiceBrokerConfig(t *testing.T, clients client.Clients, config *v1.ServiceBrokerConfig)
MustCreateServiceBrokerConfig creates the service broker configuration file with a user specified one.
func MustCreateServiceInstance ¶
func MustCreateServiceInstance(t *testing.T, name string, req *api.CreateServiceInstanceRequest) *api.CreateServiceInstanceResponse
MustCreateServiceInstance wraps up service instance creation.
func MustCreateServiceInstanceSuccessfully ¶
func MustCreateServiceInstanceSuccessfully(t *testing.T, name string, req *api.CreateServiceInstanceRequest)
MustCreateServiceInstanceSuccessfully wraps up service instance creation and polling.
func MustDefaultClient ¶
MustDefaultClient creates a HTTP client for use against the service broker. It applies known good configuration to provide connectivity with the broker for the common case.
func MustDefaultRequest ¶
MustDefaultRequest creates a HTTP request object for the requested method on a path. It applies known good configuration to provide connectivity with the broker for the common case.
func MustDefaultRequestWithBody ¶
MustDefaultRequestWithBody creates a HTTP request object for the requested method on a path. It applies known good configuration to provide connectivity with the broker for the common case.
func MustDelete ¶
MustDelete does a DELETE API call and expects a certain response.
func MustDeleteAndError ¶
MustDeleteAndError does a DELETE API call and expects a certain response with a valid JSON error.
func MustDeleteServiceBinding ¶
func MustDeleteServiceBinding(t *testing.T, instance, binding string, req *api.CreateServiceBindingRequest)
MustDeleteServiceBinding wraps up service binding deletion.
func MustDeleteServiceBrokerConfig ¶
MustDeleteServiceBrokerConfig deletes the service broker configuration file.
func MustDeleteServiceInstance ¶
func MustDeleteServiceInstance(t *testing.T, name string, req *api.CreateServiceInstanceRequest) *api.CreateServiceInstanceResponse
MustDeleteServiceInstance wraps up service instance deletion.
func MustDeleteServiceInstanceSuccessfully ¶
func MustDeleteServiceInstanceSuccessfully(t *testing.T, name string, req *api.CreateServiceInstanceRequest)
MustDeleteServiceInstanceSuccessfully wraps up service instance deletion and polling.
func MustDoRequest ¶
MustDoRequest performs a requests against the broker API with the provided client. This call will cause test failure if the network transport fails.
func MustGetAndError ¶
MustGetAndError does a GET API call and expects a certain response with a valid JSON error.
func MustGetRegistryEntry ¶
func MustGetRegistryEntry(t *testing.T, clients client.Clients, rt registry.Type, name string) *corev1.Secret
MustGetRegistryEntry returns the registry entry for a service instance.
func MustHaveRegistryEntriesTLS ¶
MustHaveRegistryEntriesTLS checks that the requested entries corresponding to a certificate and key pair exist and they are valid.
func MustHaveRegistryEntriesTLSAndVerify ¶
func MustHaveRegistryEntriesTLSAndVerify(t *testing.T, entry *corev1.Secret, caCert, key, cert registry.Key, usage x509.ExtKeyUsage)
MustHaveRegistryEntriesTLSAndVerify checks that the requested entries corresponding to a certificate and key pair exist and they are valid against a CA.
func MustHaveRegistryEntryPassword ¶
func MustHaveRegistryEntryPassword(t *testing.T, entry *corev1.Secret, key registry.Key, length int, dictionary string)
MustHaveRegistryEntryPassword checks a registry entry exists and is valid for a password.
func MustHaveRegistryEntryWithValue ¶
func MustHaveRegistryEntryWithValue(t *testing.T, entry *corev1.Secret, key registry.Key, value string)
MustHaveRegistryEntryWithValue checks a registry entry exists.
func MustNotDoRequest ¶
MustNotDoRequest performs a requests against the broker API with the provided client. This call will cause test failure if the network transport succeeds.
func MustNotHaveRegistryEntry ¶
MustNotHaveRegistryEntry checks a registry entry doesn't exist.
func MustPatchAndError ¶
func MustPatchAndError(t *testing.T, path string, statusCode int, request interface{}, apiError api.ErrorType)
MustPatchAndError does a PATCH API call and expects a certain response with a valid JSON error.
func MustPollServiceInstanceForCompletion ¶
func MustPollServiceInstanceForCompletion(t *testing.T, name string, rsp *api.CreateServiceInstanceResponse)
MustPollServiceInstanceForCompletion wraps up service instance poll.
func MustPollServiceInstanceForDeletion ¶
func MustPollServiceInstanceForDeletion(t *testing.T, name string, rsp *api.CreateServiceInstanceResponse)
MustPollServiceInstanceForDeletion wraps up polling for an aysnc deletion.
func MustPutAndError ¶
func MustPutAndError(t *testing.T, path string, statusCode int, request interface{}, apiError api.ErrorType)
MustPutAndError does a PUT API call and expects a certain response with a valid JSON error.
func MustReplaceBrokerConfig ¶
func MustReplaceBrokerConfig(t *testing.T, clients client.Clients, spec *v1.ServiceBrokerConfigSpec)
MustReplaceBrokerConfig updates the service broker configuration and waits for the broker to acquire the write lock and update the configuration to make it live.
func MustReplaceBrokerConfigWithInvalidCondition ¶
func MustReplaceBrokerConfigWithInvalidCondition(t *testing.T, clients client.Clients, spec *v1.ServiceBrokerConfigSpec)
MustReplaceBrokerConfigWithInvalidCondition will updata the configuration and then ensure that the broker has registered it is invalid.
func MustResetDynamicClient ¶
ResetDynamicClient deletes any objects created by template rendering. This simulates garbage collection when a registry item is deleted.
func MustUpdateBrokerConfig ¶
func MustUpdateBrokerConfig(t *testing.T, clients client.Clients, callback func(*v1.ServiceBrokerConfig))
MustUpdateBrokerConfig updates the service broker configuration with a typesafe callback.
func MustUpdateServiceInstance ¶
func MustUpdateServiceInstance(t *testing.T, name string, req *api.UpdateServiceInstanceRequest) *api.CreateServiceInstanceResponse
MustUpdateServiceInstance wraps up service instance creation.
func MustUpdateServiceInstanceSuccessfully ¶
func MustUpdateServiceInstanceSuccessfully(t *testing.T, name string, req *api.UpdateServiceInstanceRequest)
MustUpdateServiceInstanceSuccessfully wraps up service instance update and polling.
func MustVerifyStatusCode ¶
MustVerifyStatusCode verifies the HTTP status code is as expected. This call will cause test failure if the HTTP status code does not match.
func MustWaitFor ¶
MustWaitFor waits until a condition is nil.
func NewClients ¶
NewClients creates a new set of fake clients for use by testing.
func PatchAndError ¶
PatchAndError does a PATCH API call and expects a certain response with a valid JSON error.
func PollServiceInstanceQuery ¶
func PollServiceInstanceQuery(req *api.CreateServiceInstanceRequest, rsp *api.CreateServiceInstanceResponse) *url.Values
PollServiceInstanceQuery creates a query string for use with the service instance polling API. It is generated from the original service instance creation request and the response containing the operation ID.
func PutAndError ¶
PutAndError does a PUT API call and expects a certain response with a valid JSON error.
func ReadServiceInstanceQuery ¶
func ReadServiceInstanceQuery(req *api.CreateServiceInstanceRequest) *url.Values
ReadServiceInstanceQuery creates a query string for use with the service instance get API. It is generated from the original service instance creation request.
func ResetClients ¶
ResetClients resets clients back to a pristine state. The kubernetes and dynamic clients have their own object caches, therefore objects created with the kubernetes client cannot be cleaned up using the dynamic client. This also has implications for the service broker as a whole. Clients are reset by just overwriting them, therefore at any one time only the top level clients interface is valid. Objects contained within must not be cached e.g. references to the kubernetes client for example.
func ServerRunning ¶
func ServerRunning() error
ServerRunning is a wait function that checks the server is accepting TCP traffic, and responding with a good status to the readiness check endpoint.
func ServiceBindingURI ¶
ServiceBindingURI generates a URI (path + query) to operate on a service binding.
func ServiceInstancePollURI ¶
ServiceInstancePollURI generates a URI (path + query) to operate on a service instance polling.
func ServiceInstanceURI ¶
ServiceInstanceURI generates a URI (path + query) to operate on a service instance.
func UpdateServiceInstanceQuery ¶
UpdateServiceInstanceQuery creates a query string for use with the service instance update.
func VerifyStatusCode ¶
VerifyStatusCode verifies the HTTP status code is as expected. This call will cause test failure if the HTTP status code does not match.
Types ¶
This section is empty.