vtesting

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const RateLimitOutput = "<html><body>Rate Limited</body></html>"

RateLimitOutput is the data that is returned when we similuate a Docker registry call that has been rate limited.

Variables

This section is empty.

Functions

func NewAuth

func NewAuth(server *httptest.Server) voucher.Auth

NewAuth creates a new Auth suitable for testing with.

func NewBadTestReference

func NewBadTestReference(t *testing.T) reference.Canonical

NewBadTestReference creates a new reference to be used throughout the docker tests. The returned reference is assumed to not, and does not have valid configuration or layers.

func NewRateLimitedTestReference added in v1.2.1

func NewRateLimitedTestReference(t *testing.T) reference.Canonical

NewRateLimitedTestReference creates a new reference to be used to test the handling of Rate Limited docker calls. The returned response from calling this reference cannot be parsed by a JSON decoder and should result in an error.

func NewScanner

func NewScanner(t *testing.T, vulnerabilities ...voucher.Vulnerability) voucher.VulnerabilityScanner

NewScanner creates a new Scanner suitable for testing with. The scanner will return all of the vulnerabilities that were passed in, regardless of what FailOn is set to. If the scanner is created with 0 vulnerabilities, Checks that use it will always pass.

func NewTestClairServer added in v1.1.1

func NewTestClairServer(t *testing.T, vulns map[string][]v1.Vulnerability) *httptest.Server

NewTestClairServer creates a mock of Clair with a list of pre-defined clair vulnerabilities

func NewTestDockerServer

func NewTestDockerServer(t *testing.T) *httptest.Server

NewTestDockerServer creates a new mock of the Docker registry

func NewTestImageConfig

func NewTestImageConfig() interface{}

NewTestImageConfig creates a test image Config for our mock Docker API.

func NewTestManifest

func NewTestManifest() schema2.Manifest

NewTestManifest creates a test manifest for our mock Docker API.

func NewTestReference

func NewTestReference(t *testing.T) reference.Canonical

NewTestReference creates a new reference to be used throughout the docker tests. The returned reference is assumed to exist, and is assumed to have valid configuration and layers.

func UpdateClient

func UpdateClient(client *http.Client, server *httptest.Server) error

UpdateClient updates the passed http.Client's Transport to support the passed httptest.Server's server certificate, and to set a new Transport which will override the request's hostname with the testing server's hostname.

Types

type Transport

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

Transport wraps the http.Transport, but overwrites the URL of all requests to point to the same path on the passed hostname. This is to enable us to test connections to httptest.Server without changing the client code to allow us to add ports to registry URLs (illegal in the reference.Reference types in the docker registry library).

func NewTransport

func NewTransport(hostname string, transport *http.Transport) *Transport

NewTransport creates a new Transport which wraps the http.Transport. The purpose of this is to allow us to rewrite URLs to connect to our test server.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper. It executes a HTTP request with the Transport's internal http.Transport, but overrides the hostname before doing so.

Jump to

Keyboard shortcuts

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