Documentation
¶
Overview ¶
Package netxtest holds loopback test wiring for code that talks through internal/netx: a throwaway certificate authority, TLS test servers whose leaf certificates name any host, and a CONNECT-only proxy. It imports only the standard library and never reaches the real network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTLSServer ¶
NewTLSServer starts a TLS server for handler with a leaf for hosts signed by ca. The server is closed when the test ends.
func NewTLSServerConfig ¶
func NewTLSServerConfig(t testing.TB, ca *CA, handler http.Handler, tweak func(*tls.Config), hosts ...string) *httptest.Server
NewTLSServerConfig is NewTLSServer with tweak applied to the server TLS config before start (for example to set MaxVersion). A nil tweak changes nothing.
Types ¶
type CA ¶
type CA struct {
// contains filtered or unexported fields
}
CA is a test certificate authority with an ECDSA P-256 key.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a CONNECT-only test proxy. It records every CONNECT target and every Proxy-Authorization value it receives, answers 407 when wantAuth is set and does not match, and tunnels to the target (mapped through dialAddrs) otherwise. A strict proxy (NewStrictProxy) answers 502 for a target dialAddrs does not map.
func NewProxy ¶
NewProxy starts a CONNECT proxy on loopback, closed when the test ends. dialAddrs maps a CONNECT target "host:port" to the loopback address to dial; wantAuth is the exact Proxy-Authorization value required ("" accepts any).
func NewStrictProxy ¶ added in v0.2.0
NewStrictProxy is NewProxy that never dials a target missing from dialAddrs: it answers 502 Bad Gateway instead, so a test whose code may reach any host (every verify host of the registry) stays on loopback.