Documentation
¶
Overview ¶
Provides a stub implementation of a Deploy Engine server. This allows for thorough testing of the client including client streaming behaviour and the various authentication methods supported by the Deploy Engine v1 API.
Index ¶
- Constants
- func CreateDefaultTransport(transport *http.Transport) http.RoundTripper
- func CreateDeployEngineServer(serverConfig *TestServerConfig, stubValidationEvents []*manage.Event, ...) *httptest.Server
- func CreateFailingServer() *httptest.Server
- func CreateOAuthServer(clientID string, clientSecret string, authType string) (*httptest.Server, error)
- func NewInstanceState(id string, name string, status core.InstanceStatus) *state.InstanceState
- func NewUnixDomainSocketServer(socketPath string, handler http.Handler) *httptest.Server
- type MockClock
- type TestServerConfig
Constants ¶
const ( // StubAuditRecordID is the ID of the first audit record the stub server holds, // the only one it serves by ID. StubAuditRecordID = "test-audit-record-id-1" // StubSecondAuditRecordID is the ID of the second audit record the stub server holds. StubSecondAuditRecordID = "test-audit-record-id-2" // StubMissingCursorAction is an action filter that makes the stub server answer a // query with a page that reports more records but carries no cursor. StubMissingCursorAction = "test.missing-cursor" )
const ( // StubTakenInstanceName is an instance name that the stub server answers a create // with as already in use, held by StubNameHolderInstanceID. StubTakenInstanceName = "test-taken-instance-name" // StubNameHolderInstanceID is the instance that holds StubTakenInstanceName. StubNameHolderInstanceID = "test-name-holder-instance-id" // StubTakenNameHolderGoneInstanceName is an instance name that the stub server // answers a create with as in use, without the holder's ID, as the engine does when // the holder is removed before it can be looked up. StubTakenNameHolderGoneInstanceName = "test-taken-instance-name-holder-gone" // StubOtherInstanceChangesetID is a change set the stub server reports as staged for // StubChangesetInstanceID when a create or destroy uses it. StubOtherInstanceChangesetID = "test-other-instance-changeset-id" // StubChangesetInstanceID is the instance StubOtherInstanceChangesetID was staged for. StubChangesetInstanceID = "test-changeset-instance-id" // StubNewInstanceChangesetID is a change set the stub server reports as staged for a // new instance when an update uses it. StubNewInstanceChangesetID = "test-new-instance-changeset-id" // StubDriftBlockedChangesetID is a change set the stub server answers an update with // as blocked by drift. StubDriftBlockedChangesetID = "test-drift-blocked-changeset-id" )
Variables ¶
This section is empty.
Functions ¶
func CreateDefaultTransport ¶
func CreateDefaultTransport(transport *http.Transport) http.RoundTripper
CreateDefaultTransport provides a function that overrides the default transport configured for a deploy engine client with the Go default HTTP transport.
func CreateFailingServer ¶
func CreateOAuthServer ¶
func NewInstanceState ¶ added in v0.6.0
func NewInstanceState(id string, name string, status core.InstanceStatus) *state.InstanceState
NewInstanceState creates the instance the stub engine responds with. Its maps are empty rather than nil, as the deploy engine sends them.
Types ¶
type TestServerConfig ¶
type TestServerConfig struct {
AllowedAPIKeys []string
AllowedBearerTokens []string
AllowedBluelinkSignatureKeyPairs map[string]*sigv1.KeyPair
// A string that will be present in some part of the request
// to the server that will trigger behaviour to simulate
// an internal server error.
InternalServerErrorTrigger string
NetworkErrorTrigger string
DeserialiseErrorTrigger string
InternalServerErrorTriggerID string
NetworkErrorTriggerID string
DeserialiseErrorTriggerID string
FailingStreamTriggerID string
DriftDetectedChangesetID string
UseUnixDomainSocket bool
UnixDomainSocketPath string
// Called with the query parameters of each audit trail query the server receives,
// so tests can check how a client encoded its filters.
AuditQueryRecorder func(query url.Values)
}