httpext_test

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CACertificate = &x509.Certificate{
	SerialNumber: big.NewInt(1),
	Subject: pkix.Name{
		Organization:  []string{"DB Systel GmbH"},
		Country:       []string{"DE"},
		Province:      []string{"Hesse"},
		Locality:      []string{"Frankfurt am Main"},
		StreetAddress: []string{"Juergen-Ponto-Platz 1"},
		PostalCode:    []string{"60329"},
	},
	NotBefore:             time.Now().AddDate(0, 0, -1),
	NotAfter:              time.Now().AddDate(1, 0, 0),
	IsCA:                  true,
	ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
	KeyUsage:              x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
	BasicConstraintsValid: true,
}

Functions

func TestConfig

func TestConfig() *httpext.Config

TestConfig creates a new httpext.Config for testing

Types

type Fixture

type Fixture struct {
	// Sut is the system under test
	Sut *httpext.Server
	// Test is the TestFacade for testing requests
	Test *TestFacade
}

Fixture is a fixture for testing httpext.Server

func NewFixture

func NewFixture() *Fixture

NewFixture creates a new Fixture for testing httpext.Server

func NewFixtureHTTP

func NewFixtureHTTP() *Fixture

NewFixtureHTTPS creates a new Fixture for testing httpext.Server using HTTPS

type PemFilePair

type PemFilePair interface {
	// PublicKeyPath returns the path to the public part
	PublicKeyPath() string
	// PrivateKeyPath returns the path to the private part
	PrivateKeyPath() string
	// Generate generates the files using the provided x509.Certificate
	Generate(cert *x509.Certificate) error
	// Delete deletes the files
	Delete() error
	// contains filtered or unexported methods
}

PemFilePair denotes a pair of PEM files for a certificate

func MustNewTmpPemFilePair

func MustNewTmpPemFilePair() PemFilePair

MustNewTmpPemFilePair equals NewTmpPemFilePair, but panics in case of an error

func NewPemFilePair

func NewPemFilePair(basePath string) PemFilePair

NewPemFilePair creates a new PemFilePair for the provide base path (adding .pem and .key as extensions)

func NewTmpPemFilePair

func NewTmpPemFilePair() (PemFilePair, error)

NewTmpPemFilePair creates a new PemFilePair generating a name for it and using the

type ResponseRecoverFacade

type ResponseRecoverFacade struct {
	*httptest.ResponseRecorder
}

func (*ResponseRecoverFacade) Bytes

func (f *ResponseRecoverFacade) Bytes() []byte

func (*ResponseRecoverFacade) JSON

func (f *ResponseRecoverFacade) JSON(obj interface{}) interface{}

func (*ResponseRecoverFacade) String

func (f *ResponseRecoverFacade) String() string

type TestFacade

type TestFacade struct {
	*http.ServeMux
}

func (*TestFacade) Healthz

func (f *TestFacade) Healthz() *ResponseRecoverFacade

func (*TestFacade) Metrics

func (f *TestFacade) Metrics() string

func (*TestFacade) RequestBytes

func (f *TestFacade) RequestBytes(method, path string, data []byte) *ResponseRecoverFacade

func (*TestFacade) RequestJSON

func (f *TestFacade) RequestJSON(method, path string, obj interface{}) *ResponseRecoverFacade

Jump to

Keyboard shortcuts

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