testutils

package
v0.0.0-...-4f221f3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

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

This section is empty.

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 CreateDeployEngineServer

func CreateDeployEngineServer(
	serverConfig *TestServerConfig,
	stubValidationEvents []*manage.Event,
	stubChangeStagingEvents []*manage.Event,
	stubDeploymentEvents []*manage.Event,
	clock core.Clock,
) *httptest.Server

func CreateFailingServer

func CreateFailingServer() *httptest.Server

func CreateOAuthServer

func CreateOAuthServer(
	clientID string, clientSecret string, authType string,
) (*httptest.Server, error)

func NewUnixDomainSocketServer

func NewUnixDomainSocketServer(
	socketPath string,
	handler http.Handler,
) *httptest.Server

Types

type MockClock

type MockClock struct {
	TimeSequence []time.Time
	// contains filtered or unexported fields
}

func (*MockClock) Now

func (c *MockClock) Now() time.Time

func (*MockClock) Since

func (c *MockClock) Since(t time.Time) time.Duration

type TestServerConfig

type TestServerConfig struct {
	AllowedAPIKeys                   []string
	AllowedBearerTokens              []string
	AllowedCeleritySignatureKeyPairs 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
	UseUnixDomainSocket          bool
	UnixDomainSocketPath         string
}

Jump to

Keyboard shortcuts

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