test_util

package
v0.0.0-...-96ff825 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 1 more Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TLSConfigFromCACerts       = 1
	TLSConfigFromClientCACerts = 2
	TLSConfigFromUnknownCA     = 3
)
View Source
const LocalhostDNS = "localhost.routing.cf-app.com"

Our tests assume that there exists a DNS entry *.localhost.routing.cf-app.com that maps to 127.0.0.1 If that DNS entry does not work, then many, many tests will fail

Variables

This section is empty.

Functions

func CreateCert

func CreateCert(cname string) tls.Certificate

func CreateCertDER

func CreateCertDER(cname string) (*rsa.PrivateKey, []byte)

func CreateECKeyPair

func CreateECKeyPair(cname string) (keyPEM, certPEM []byte)

func CreateKeyPair

func CreateKeyPair(cname string) (keyPEM, certPEM []byte)

func CreateKeyPairFromDER

func CreateKeyPairFromDER(certDER []byte, privKey *rsa.PrivateKey) (keyPEM, certPEM []byte)

func CustomSpecSSLConfig

func CustomSpecSSLConfig(onlyTrustClientCACerts bool, TLSClientConfigOption int, statusPort, statusTLSPort, statusRoutesPort, proxyPort, SSLPort, routeServiceServerPort uint16, natsPorts ...uint16) (*config.Config, *tls.Config)

func NewFakeMetron

func NewFakeMetron() *fakeMetron

func NewRequest

func NewRequest(method, host, rawPath string, body io.Reader) *http.Request

func NewResponse

func NewResponse(status int) *http.Response

func NextAvailPort

func NextAvailPort() uint16

func RegisterAddr

func RegisterAddr(reg *registry.RouteRegistry, path string, addr string, cfg RegisterConfig)

func RegisterConnHandler

func RegisterConnHandler(reg *registry.RouteRegistry, path string, handler connHandler, cfg ...RegisterConfig) net.Listener

func RegisterHTTPHandler

func RegisterHTTPHandler(reg *registry.RouteRegistry, path string, handler http.HandlerFunc, cfg ...RegisterConfig) net.Listener

func RegisterWSHandler

func RegisterWSHandler(reg *registry.RouteRegistry, path string, handler websocket.Handler, cfg ...RegisterConfig) net.Listener

func SpecConfig

func SpecConfig(statusPort, statusTLSPort, statusRoutesPort, proxyPort, routeServiceServerPort uint16, natsPorts ...uint16) *config.Config

func SpecSSLConfig

func SpecSSLConfig(statusPort, statusTLSPort, statusRoutesPort, proxyPort, SSLPort, routeServiceServerPort uint16, natsPorts ...uint16) (*config.Config, *tls.Config)

Types

type CertChain

type CertChain struct {
	CertPEM, CACertPEM       []byte
	PrivKeyPEM, CAPrivKeyPEM []byte

	CACert    *x509.Certificate
	CAPrivKey *rsa.PrivateKey
}

func CreateCertAndAddCA

func CreateCertAndAddCA(cn CertNames, cp *x509.CertPool) CertChain

CreateCertAndAddCA creates a signed cert with a root CA and adds the CA to the specified cert pool

func CreateExpiredSignedCertWithRootCA

func CreateExpiredSignedCertWithRootCA(cert CertNames) CertChain

func CreateSignedCertWithRootCA

func CreateSignedCertWithRootCA(cert CertNames) CertChain

func (*CertChain) AsTLSConfig

func (cc *CertChain) AsTLSConfig() *tls.Config

func (*CertChain) TLSCert

func (c *CertChain) TLSCert() tls.Certificate

func (*CertChain) WriteCACertToDir

func (cc *CertChain) WriteCACertToDir(dir string) string

type CertNames

type CertNames struct {
	CommonName string
	SANs       SubjectAltNames
}

type Event

type Event struct {
	EventType string
	Name      string
	Origin    string
	Value     float64
}

type FailureReporter

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

func NewFailureReporter

func NewFailureReporter(client client.Client) FailureReporter

func (FailureReporter) AfterSuiteDidRun

func (fr FailureReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary)

func (FailureReporter) BeforeSuiteDidRun

func (fr FailureReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary)

func (FailureReporter) SpecDidComplete

func (fr FailureReporter) SpecDidComplete(ss *types.SpecSummary)

func (FailureReporter) SpecSuiteDidEnd

func (fr FailureReporter) SpecSuiteDidEnd(summary *types.SuiteSummary)

func (FailureReporter) SpecSuiteWillBegin

func (fr FailureReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)

func (FailureReporter) SpecWillRun

func (fr FailureReporter) SpecWillRun(specSummary *types.SpecSummary)

func (FailureReporter) SuiteDidEnd

func (fr FailureReporter) SuiteDidEnd(summary *types.SuiteSummary)

func (FailureReporter) SuiteWillBegin

func (fr FailureReporter) SuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)

type FakeFile

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

func (*FakeFile) Read

func (f *FakeFile) Read(data *[]byte) (int, error)

func (*FakeFile) Write

func (f *FakeFile) Write(data []byte) (int, error)

type FakeMetron

type FakeMetron interface {
	AllEvents() []Event

	Address() string
	Close() error
	Port() int
}

type HangingReadCloser

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

func (*HangingReadCloser) Close

func (h *HangingReadCloser) Close() error

func (*HangingReadCloser) Read

func (h *HangingReadCloser) Read(p []byte) (n int, err error)

type HttpConn

type HttpConn struct {
	net.Conn

	Reader *bufio.Reader
	Writer *bufio.Writer
}

func NewHttpConn

func NewHttpConn(x net.Conn) *HttpConn

func (*HttpConn) CheckLine

func (x *HttpConn) CheckLine(expected string)

func (*HttpConn) CheckLines

func (x *HttpConn) CheckLines(expected []string)

func (*HttpConn) ReadRequest

func (x *HttpConn) ReadRequest() (*http.Request, string)

func (*HttpConn) ReadResponse

func (x *HttpConn) ReadResponse() (*http.Response, string)

func (*HttpConn) WriteLine

func (x *HttpConn) WriteLine(line string)

func (*HttpConn) WriteLines

func (x *HttpConn) WriteLines(lines []string)

func (*HttpConn) WriteRequest

func (x *HttpConn) WriteRequest(req *http.Request)

func (*HttpConn) WriteResponse

func (x *HttpConn) WriteResponse(resp *http.Response)

type NATSRunner

type NATSRunner struct {
	MessageBus *nats.Conn
	// contains filtered or unexported fields
}

func NewNATSRunner

func NewNATSRunner(port int) *NATSRunner

func (*NATSRunner) KillWithFire

func (runner *NATSRunner) KillWithFire()

func (*NATSRunner) Start

func (runner *NATSRunner) Start()

func (*NATSRunner) Stop

func (runner *NATSRunner) Stop()

type Nats

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

func NewNats

func NewNats(port uint16) *Nats

func (*Nats) Port

func (n *Nats) Port() uint16

func (*Nats) Start

func (n *Nats) Start()

func (*Nats) Stop

func (n *Nats) Stop()

type RegisterConfig

type RegisterConfig struct {
	RouteServiceUrl     string
	ServerCertDomainSAN string
	InstanceId          string
	InstanceIndex       string
	AppId               string
	StaleThreshold      int
	TLSConfig           *tls.Config
	IgnoreTLSConfig     bool
	Protocol            string
}

type SlowReadCloser

type SlowReadCloser struct {
	SleepDuration time.Duration
	// contains filtered or unexported fields
}

func (*SlowReadCloser) Close

func (h *SlowReadCloser) Close() error

func (*SlowReadCloser) Read

func (h *SlowReadCloser) Read(p []byte) (n int, err error)

type SubjectAltNames

type SubjectAltNames struct {
	DNS string
	IP  string
}

type TestZapLogger

type TestZapLogger struct {
	logger.Logger
	*TestZapSink
}

TestZapLogger implements a zap logger that can be used with Ginkgo tests

func NewTestZapLogger

func NewTestZapLogger(component string) *TestZapLogger

NewTestZapLogger returns a new test logger using zap

func (*TestZapLogger) Buffer

func (z *TestZapLogger) Buffer() *gbytes.Buffer

Buffer returns the gbytes buffer that was used as the sink

func (*TestZapLogger) Lines

func (z *TestZapLogger) Lines(level zap.Level) []string

type TestZapSink

type TestZapSink struct {
	*gbytes.Buffer
}

Taken from github.com/uber-go/zap

func (*TestZapSink) Lines

func (s *TestZapSink) Lines() []string

func (*TestZapSink) Sync

func (s *TestZapSink) Sync() error

Directories

Path Synopsis
rss

Jump to

Keyboard shortcuts

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