common

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0, BSD-3-Clause, MIT Imports: 39 Imported by: 1

Documentation

Index

Constants

View Source
const BrokerServerPrefix = "broker-"
View Source
const OauthServer = "oauth-server"
View Source
const SMServer = "sm-server"

Variables

This section is empty.

Functions

func Closer

func Closer(s string) io.ReadCloser

func CreateVisibilitiesForAllBrokerPlans added in v0.6.0

func CreateVisibilitiesForAllBrokerPlans(SM *SMExpect, brokerID string)

func DoHTTP

func DoHTTP(reaction *HTTPReaction, checks *HTTPExpectations) func(*http.Request) (*http.Response, error)

func DoHTTPSequence added in v0.6.0

func DoHTTPSequence(sequence []HTTPCouple) func(*http.Request) (*http.Response, error)

func ExtractResourceIDs added in v0.1.8

func ExtractResourceIDs(entities []Object) []string

func GenerateFreeTestPlan added in v0.1.8

func GenerateFreeTestPlan() string

func GeneratePaidTestPlan added in v0.1.8

func GeneratePaidTestPlan() string

func GenerateRandomNotification added in v0.3.0

func GenerateRandomNotification() *types.Notification

func GenerateTestPlan added in v0.1.8

func GenerateTestPlan() string

func GenerateTestPlanFromTemplate added in v0.1.8

func GenerateTestPlanFromTemplate(id, planTemplate string) string

func GenerateTestPlanWithID added in v0.9.0

func GenerateTestPlanWithID(planID string) string

func GenerateTestServiceWithPlans added in v0.1.8

func GenerateTestServiceWithPlans(plans ...string) string

func GenerateTestServiceWithPlansWithID added in v0.9.0

func GenerateTestServiceWithPlansWithID(serviceID string, plans ...string) string

func JSONToMap added in v0.1.2

func JSONToMap(j string) map[string]interface{}

func MapContains

func MapContains(actual Object, expected Object)

func MergeObjects added in v0.1.11

func MergeObjects(target, source Object)

func NewSMListener added in v0.4.1

func NewSMListener() (net.Listener, error)

func Print added in v0.1.8

func Print(message string, args ...interface{})

func RegisterPlatformInSM added in v0.1.2

func RegisterPlatformInSM(platformJSON Object, SM *SMExpect, headers map[string]string) *types.Platform

func RegisterVisibilityForPlanAndPlatform added in v0.6.0

func RegisterVisibilityForPlanAndPlatform(SM *SMExpect, planID, platformID string) string

func RemoveAllBrokers

func RemoveAllBrokers(SM *SMExpect)

func RemoveAllInstances added in v0.9.0

func RemoveAllInstances(repository storage.Repository) error

func RemoveAllNotifications added in v0.9.0

func RemoveAllNotifications(repository storage.Repository) error

func RemoveAllOperations added in v0.9.0

func RemoveAllOperations(repository storage.Repository) error

func RemoveAllPlatforms

func RemoveAllPlatforms(SM *SMExpect)

func RemoveAllVisibilities added in v0.1.6

func RemoveAllVisibilities(SM *SMExpect)

func SetLogOutput added in v0.5.0

func SetLogOutput(set *pflag.FlagSet)

func SetNotificationsCleanerSettings added in v0.3.0

func SetNotificationsCleanerSettings(set *pflag.FlagSet)

func SetResponse added in v0.1.2

func SetResponse(rw http.ResponseWriter, status int, message interface{})

func SetTestFileLocation added in v0.1.2

func SetTestFileLocation(set *pflag.FlagSet)

func TestEnv added in v0.1.2

func TestEnv(additionalFlagFuncs ...func(set *pflag.FlagSet)) env.Environment

Types

type Array

type Array = []interface{}

type BrokerServer added in v0.1.2

type BrokerServer struct {
	*httptest.Server

	CatalogHandler                 http.HandlerFunc // /v2/catalog
	ServiceInstanceHandler         http.HandlerFunc // /v2/service_instances/{instance_id}
	ServiceInstanceLastOpHandler   http.HandlerFunc // /v2/service_instances/{instance_id}/last_operation
	BindingHandler                 http.HandlerFunc // /v2/service_instances/{instance_id}/service_bindings/{binding_id}
	BindingLastOpHandler           http.HandlerFunc // /v2/service_instances/{instance_id}/service_bindings/{binding_id}/last_operation
	BindingAdaptCredentialsHandler http.HandlerFunc // /v2/service_instances/{instance_id}/service_bindings/{binding_id}/adapt_credentials

	Username, Password string
	Catalog            SBCatalog
	LastRequestBody    []byte
	LastRequest        *http.Request

	CatalogEndpointRequests                 []*http.Request
	ServiceInstanceEndpointRequests         []*http.Request
	ServiceInstanceLastOpEndpointRequests   []*http.Request
	BindingEndpointRequests                 []*http.Request
	BindingLastOpEndpointRequests           []*http.Request
	BindingAdaptCredentialsEndpointRequests []*http.Request
	// contains filtered or unexported fields
}

func NewBrokerServer added in v0.1.2

func NewBrokerServer() *BrokerServer

func NewBrokerServerWithCatalog added in v0.1.6

func NewBrokerServerWithCatalog(catalog SBCatalog) *BrokerServer

func (*BrokerServer) Reset added in v0.1.2

func (b *BrokerServer) Reset()

func (*BrokerServer) ResetCallHistory added in v0.1.2

func (b *BrokerServer) ResetCallHistory()

func (*BrokerServer) ResetHandlers added in v0.1.2

func (b *BrokerServer) ResetHandlers()

func (*BrokerServer) ResetProperties added in v0.1.2

func (b *BrokerServer) ResetProperties()

func (*BrokerServer) URL added in v0.1.9

func (b *BrokerServer) URL() string

type FakeServer added in v0.1.9

type FakeServer interface {
	// contains filtered or unexported methods
}

type FlagValue added in v0.1.2

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

func (FlagValue) Set added in v0.1.2

func (f FlagValue) Set(s string) error

func (FlagValue) String added in v0.1.2

func (f FlagValue) String() string

type HTTPCouple added in v0.6.0

type HTTPCouple struct {
	Expectations *HTTPExpectations
	Reaction     *HTTPReaction
}

type HTTPExpectations

type HTTPExpectations struct {
	URL     string
	Body    string
	Params  map[string]string
	Headers map[string]string
}

type HTTPReaction

type HTTPReaction struct {
	Status int
	Body   string
	Err    error
}

type NopCloser

type NopCloser struct {
	io.Reader
}

func (NopCloser) Close

func (NopCloser) Close() error

type OAuthServer

type OAuthServer struct {
	BaseURL string
	// contains filtered or unexported fields
}

func NewOAuthServer

func NewOAuthServer() *OAuthServer

func (*OAuthServer) Close

func (os *OAuthServer) Close()

func (*OAuthServer) CreateToken

func (os *OAuthServer) CreateToken(payload map[string]interface{}) string

func (*OAuthServer) Start

func (os *OAuthServer) Start()

func (*OAuthServer) URL

func (os *OAuthServer) URL() string

type Object

type Object = map[string]interface{}

func CopyFields added in v0.6.0

func CopyFields(obj Object) Object

func CopyLabels added in v0.6.0

func CopyLabels(obj Object) Object

func CopyObject added in v0.1.8

func CopyObject(obj Object) Object

func GenerateRandomBroker added in v0.1.8

func GenerateRandomBroker() Object

func GenerateRandomPlatform added in v0.1.8

func GenerateRandomPlatform() Object

func MakePlatform

func MakePlatform(id string, name string, atype string, description string) Object

func RegisterBrokerInSM added in v0.1.2

func RegisterBrokerInSM(brokerJSON Object, SM *SMExpect, headers map[string]string) Object

func RemoveNonJSONArgs added in v0.1.8

func RemoveNonJSONArgs(obj Object) Object

func RemoveNonNumericArgs added in v0.1.8

func RemoveNonNumericArgs(obj Object) Object

func RemoveNotNullableFieldAndLabels added in v0.1.8

func RemoveNotNullableFieldAndLabels(obj Object, objithMandatoryFields Object) Object

func RemoveNumericArgs added in v0.1.8

func RemoveNumericArgs(obj Object) Object

type SBCatalog added in v0.1.8

type SBCatalog string

func NewEmptySBCatalog added in v0.1.8

func NewEmptySBCatalog() SBCatalog

NewEmptySBCatalog returns an empty service broker catalog tha contains no services and no plans

func NewRandomSBCatalog added in v0.1.8

func NewRandomSBCatalog() SBCatalog

NewRandomSBCatalog returns a service broker catalog containg one random service with one free and one paid random plans

func (*SBCatalog) AddPlanToService added in v0.1.8

func (sbc *SBCatalog) AddPlanToService(plan string, serviceIndex int)

func (*SBCatalog) AddService added in v0.1.8

func (sbc *SBCatalog) AddService(service string)

func (*SBCatalog) RemovePlan added in v0.1.8

func (sbc *SBCatalog) RemovePlan(serviceIndex, planIndex int) (string, string)

func (*SBCatalog) RemoveService added in v0.1.8

func (sbc *SBCatalog) RemoveService(index int) (string, string)

type SMExpect added in v0.6.0

type SMExpect struct {
	*httpexpect.Expect
}

func (*SMExpect) List added in v0.6.0

func (expect *SMExpect) List(path string) *httpexpect.Array

func (*SMExpect) ListWithQuery added in v0.6.0

func (expect *SMExpect) ListWithQuery(path string, query string) *httpexpect.Array

type TestContext

type TestContext struct {
	SM          *SMExpect
	SMWithOAuth *SMExpect
	// Requests a token the the "multitenant" oauth client - then token issued by this client contains
	// the "multitenant" client id behind the specified token claim in the api config
	// the token also contains a "tenant identifier" behind the configured tenant_indentifier claim that
	// will be compared with the value of the label specified in the "label key" configuration
	// In the end requesting brokers with this
	SMWithOAuthForTenant *SMExpect
	SMWithBasic          *SMExpect
	SMRepository         storage.TransactionalRepository

	TestPlatform *types.Platform

	Servers map[string]FakeServer
	// contains filtered or unexported fields
}

func DefaultTestContext added in v0.1.9

func DefaultTestContext() *TestContext

DefaultTestContext sets up a test context with default values

func (*TestContext) Cleanup

func (ctx *TestContext) Cleanup()

func (*TestContext) CleanupAdditionalResources added in v0.1.8

func (ctx *TestContext) CleanupAdditionalResources()

func (*TestContext) CleanupBroker

func (ctx *TestContext) CleanupBroker(id string)

func (*TestContext) CloseWebSocket added in v0.3.3

func (ctx *TestContext) CloseWebSocket(conn *websocket.Conn)

func (*TestContext) ConnectWebSocket added in v0.3.3

func (ctx *TestContext) ConnectWebSocket(platform *types.Platform, queryParams map[string]string) (*websocket.Conn, *http.Response, error)

func (*TestContext) RegisterBroker

func (ctx *TestContext) RegisterBroker() (string, Object, *BrokerServer)

func (*TestContext) RegisterBrokerWithCatalog added in v0.1.6

func (ctx *TestContext) RegisterBrokerWithCatalog(catalog SBCatalog) (string, Object, *BrokerServer)

func (*TestContext) RegisterBrokerWithCatalogAndLabels added in v0.1.8

func (ctx *TestContext) RegisterBrokerWithCatalogAndLabels(catalog SBCatalog, brokerData Object) (string, Object, *BrokerServer)

func (*TestContext) RegisterBrokerWithCatalogAndLabelsExpect added in v0.4.2

func (ctx *TestContext) RegisterBrokerWithCatalogAndLabelsExpect(catalog SBCatalog, brokerData Object, expect *SMExpect) (string, Object, *BrokerServer)

func (*TestContext) RegisterPlatform added in v0.1.6

func (ctx *TestContext) RegisterPlatform() *types.Platform

type TestContextBuilder added in v0.1.9

type TestContextBuilder struct {
	Environment func(f ...func(set *pflag.FlagSet)) env.Environment
	Servers     map[string]FakeServer
	HttpClient  *http.Client
	// contains filtered or unexported fields
}

func NewTestContextBuilder added in v0.1.9

func NewTestContextBuilder() *TestContextBuilder

NewTestContextBuilder sets up a builder with default values

func NewTestContextBuilderWithSecurity added in v0.9.7

func NewTestContextBuilderWithSecurity() *TestContextBuilder

func (*TestContextBuilder) Build added in v0.1.9

func (tcb *TestContextBuilder) Build() *TestContext

func (*TestContextBuilder) BuildWithListener added in v0.4.1

func (tcb *TestContextBuilder) BuildWithListener(listener net.Listener) *TestContext

func (*TestContextBuilder) SkipBasicAuthClientSetup added in v0.1.9

func (tcb *TestContextBuilder) SkipBasicAuthClientSetup(shouldSkip bool) *TestContextBuilder

func (*TestContextBuilder) WithAdditionalFakeServers added in v0.1.9

func (tcb *TestContextBuilder) WithAdditionalFakeServers(additionalFakeServers map[string]FakeServer) *TestContextBuilder

func (*TestContextBuilder) WithDefaultEnv added in v0.1.9

func (tcb *TestContextBuilder) WithDefaultEnv(envCreateFunc func(f ...func(set *pflag.FlagSet)) env.Environment) *TestContextBuilder

func (*TestContextBuilder) WithDefaultTokenClaims added in v0.1.9

func (tcb *TestContextBuilder) WithDefaultTokenClaims(defaultTokenClaims map[string]interface{}) *TestContextBuilder

func (*TestContextBuilder) WithEnvPostExtensions added in v0.1.9

func (tcb *TestContextBuilder) WithEnvPostExtensions(fs ...func(e env.Environment, servers map[string]FakeServer)) *TestContextBuilder

func (*TestContextBuilder) WithEnvPreExtensions added in v0.1.9

func (tcb *TestContextBuilder) WithEnvPreExtensions(fs ...func(set *pflag.FlagSet)) *TestContextBuilder

func (*TestContextBuilder) WithSMExtensions added in v0.1.9

func (tcb *TestContextBuilder) WithSMExtensions(fs ...func(ctx context.Context, smb *sm.ServiceManagerBuilder, e env.Environment) error) *TestContextBuilder

func (*TestContextBuilder) WithTenantTokenClaims added in v0.4.1

func (tcb *TestContextBuilder) WithTenantTokenClaims(tenantTokenClaims map[string]interface{}) *TestContextBuilder

Jump to

Keyboard shortcuts

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