testkit

package
v0.0.0-...-a52e8f6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApiRawSpec    = Compact([]byte("{\"name\":\"api\"}"))
	EventsRawSpec = Compact([]byte("{\"asyncapi\":\"2.0.0\",\"info\":{\"title\":\"OneOf example\",\"version\":\"1.0.0\"},\"channels\":{\"test\":{\"publish\":{\"message\":{\"$ref\":\"#/components/messages/testMessages\"}}}},\"components\":{\"messages\":{\"testMessages\":{\"description\":\"test\"}}}}"))

	SwaggerApiSpec = Compact([]byte("{\"swagger\":\"2.0\"}"))
)

Functions

func CheckK8sApplication

func CheckK8sApplication(t *testing.T, app *application.Application, name string, expectedServiceData ServiceData)

func CheckK8sApplicationNotContainsService

func CheckK8sApplicationNotContainsService(t *testing.T, re *application.Application, serviceId string)

func CheckK8sBasicAuthSecret

func CheckK8sBasicAuthSecret(t *testing.T, secret *v1core.Secret, name string, labels Labels, username, password string)

func CheckK8sCertificateGenSecret

func CheckK8sCertificateGenSecret(t *testing.T, secret *v1core.Secret, name string, labels Labels, commonName string)

func CheckK8sIstioHandler

func CheckK8sIstioHandler(t *testing.T, handler *istio.Handler, name string, labels Labels, code int, message string)

func CheckK8sIstioInstance

func CheckK8sIstioInstance(t *testing.T, instance *istio.Instance, name string, labels Labels)

func CheckK8sIstioRule

func CheckK8sIstioRule(t *testing.T, rule *istio.Rule, name, namespace string, labels Labels)

func CheckK8sOAuthSecret

func CheckK8sOAuthSecret(t *testing.T, secret *v1core.Secret, name string, labels Labels, clientId, clientSecret string)

func CheckK8sParamsSecret

func CheckK8sParamsSecret(t *testing.T, secret *v1core.Secret, name string, labels Labels, headerKey, headerValue, queryParameterKey, queryParameterValue string)

func CheckK8sService

func CheckK8sService(t *testing.T, service *v1core.Service, name string, labels Labels, protocol v1core.Protocol, port, targetPort int)

func Compact

func Compact(src []byte) []byte

func CreateParamsSecretName

func CreateParamsSecretName(resourceName string) string

func GenerateIdentifier

func GenerateIdentifier() string

Types

type API

type API struct {
	TargetUrl         string               `json:"targetUrl"`
	Credentials       *Credentials         `json:"credentials,omitempty"`
	Spec              json.RawMessage      `json:"spec,omitempty"`
	SpecificationUrl  string               `json:"specificationUrl,omitempty"`
	ApiType           string               `json:"apiType"`
	RequestParameters *RequestParameters   `json:"requestParameters,omitempty"`
	Headers           *map[string][]string `json:"headers,omitempty"`
	QueryParameters   *map[string][]string `json:"queryParameters,omitempty"`
}

func (*API) WithCSRFInBasic

func (api *API) WithCSRFInBasic(csrfInfo *CSRFInfo) *API

func (*API) WithCSRFInCertificateGen

func (api *API) WithCSRFInCertificateGen(csrfInfo *CSRFInfo) *API

func (*API) WithCSRFInOAuth

func (api *API) WithCSRFInOAuth(csrfInfo *CSRFInfo) *API

func (*API) WithHeadersAndQueryParameters

func (api *API) WithHeadersAndQueryParameters(headers, queryParameters *map[string][]string) *API

func (*API) WithRequestParameters

func (api *API) WithRequestParameters(requestParameters *RequestParameters) *API

func (*API) WithRequestParametersInOAuth

func (api *API) WithRequestParametersInOAuth(requestParameters *RequestParameters) *API

type Basic

type Basic struct {
	Username string    `json:"username"`
	Password string    `json:"password"`
	CSRFInfo *CSRFInfo `json:"csrfInfo,omitempty"`
}

type CSRFInfo

type CSRFInfo struct {
	TokenEndpointURL string `json:"tokenEndpointURL"`
}

type CertificateGen

type CertificateGen struct {
	CommonName  string    `json:"commonName"`
	Certificate string    `json:"certificate"`
	CSRFInfo    *CSRFInfo `json:"csrfInfo,omitempty"`
}

type CreateRequestFunc

type CreateRequestFunc func(data requestData, retry int) (*http.Request, error)

type Credentials

type Credentials struct {
	Oauth          *Oauth          `json:"oauth,omitempty"`
	Basic          *Basic          `json:"basic,omitempty"`
	CertificateGen *CertificateGen `json:"certificateGen,omitempty"`
}

type DocsObject

type DocsObject struct {
	Title  string `json:"title"`
	Type   string `json:"type"`
	Source string `json:"source"`
}

type Documentation

type Documentation struct {
	DisplayName string       `json:"displayName"`
	Description string       `json:"description"`
	Type        string       `json:"type"`
	Tags        []string     `json:"tags,omitempty"`
	Docs        []DocsObject `json:"docs,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

type Events

type Events struct {
	Spec json.RawMessage `json:"spec,omitempty"`
}

type K8sResourcesClient

type K8sResourcesClient interface {
	GetService(name string, options v1.GetOptions) (*v1core.Service, error)
	GetSecret(name string, options v1.GetOptions) (*v1core.Secret, error)
	GetHandler(name string, options v1.GetOptions) (*v1alpha2.Handler, error)
	GetRule(name string, options v1.GetOptions) (*v1alpha2.Rule, error)
	GetInstance(name string, options v1.GetOptions) (*v1alpha2.Instance, error)
	GetApplicationServices(name string, options v1.GetOptions) (*v1alpha1.Application, error)
	CreateDummyApplication(namePrefix string, options v1.GetOptions, skipInstallation bool) (*v1alpha1.Application, error)
	DeleteApplication(name string, options *v1.DeleteOptions) error
}

func NewK8sInClusterResourcesClient

func NewK8sInClusterResourcesClient(namespace string) (K8sResourcesClient, error)

type Labels

type Labels map[string]string

type MetadataServiceClient

type MetadataServiceClient interface {
	CreateService(t *testing.T, serviceDetails ServiceDetails) (int, *PostServiceResponse, error)
	UpdateService(t *testing.T, idToUpdate string, updatedServiceDetails ServiceDetails) (int, error)
	DeleteService(t *testing.T, idToDelete string) (int, error)
	GetService(t *testing.T, serviceId string) (int, *ServiceDetails, error)
	GetAllServices(t *testing.T) (int, []Service, error)
}

func NewMetadataServiceClient

func NewMetadataServiceClient(url string) MetadataServiceClient

type Oauth

type Oauth struct {
	URL               string             `json:"url"`
	ClientID          string             `json:"clientId"`
	ClientSecret      string             `json:"clientSecret"`
	CSRFInfo          *CSRFInfo          `json:"csrfInfo,omitempty"`
	RequestParameters *RequestParameters `json:"requestParameters,omitempty"`
}

type PostServiceResponse

type PostServiceResponse struct {
	ID string `json:"id"`
}

type Predicate

type Predicate func(response *http.Response, err error) bool

type RequestParameters

type RequestParameters struct {
	Headers         *map[string][]string `json:"headers,omitempty"`
	QueryParameters *map[string][]string `json:"queryParameters,omitempty"`
}

type Service

type Service struct {
	ID               string            `json:"id"`
	Provider         string            `json:"provider"`
	Name             string            `json:"name"`
	Description      string            `json:"description"`
	ShortDescription string            `json:"shortDescription,omitempty"`
	Identifier       string            `json:"identifier,omitempty"`
	Labels           map[string]string `json:"labels,omitempty"`
}

type ServiceData

type ServiceData struct {
	ServiceId            string
	DisplayName          string
	ProviderDisplayName  string
	LongDescription      string
	HasAPI               bool
	TargetUrl            string
	OauthUrl             string
	GatewayUrl           string
	AccessLabel          string
	HasEvents            bool
	CSRFTokenEndpointURL string
}

type ServiceDetails

type ServiceDetails struct {
	Provider         string            `json:"provider"`
	Name             string            `json:"name"`
	Description      string            `json:"description"`
	ShortDescription string            `json:"shortDescription,omitempty"`
	Identifier       string            `json:"identifier,omitempty"`
	Labels           map[string]string `json:"labels,omitempty"`
	Api              *API              `json:"api,omitempty"`
	Events           *Events           `json:"events,omitempty"`
	Documentation    *Documentation    `json:"documentation,omitempty"`
}

func (ServiceDetails) WithAPI

func (sd ServiceDetails) WithAPI(api *API) ServiceDetails

type TestConfig

type TestConfig struct {
	MetadataServiceUrl string
	Namespace          string
}

func ReadConfig

func ReadConfig() (TestConfig, error)

Jump to

Keyboard shortcuts

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