testutil

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package testutil provides shared helpers for isolated test fixtures. Production code must not depend on this package.

Index

Constants

View Source
const RequireSymlinksEnv = "CONTROL_TEST_REQUIRE_SYMLINKS"

RequireSymlinksEnv declares that the test runner has been provisioned for symbolic-link creation. It is not inferred from CI or administrator status.

Variables

This section is empty.

Functions

func Symlink(t testing.TB, target, link string)

Symlink creates a fixture link or ends the current test. Unprovisioned environments skip only recognized missing-capability errors; unexpected errors always fail. A true RequireSymlinksEnv makes every creation error fail. No privileges, Developer Mode or filesystem settings are changed.

func TLSServer added in v0.9.1

func TLSServer(t testing.TB, handler http.Handler, hosts ...string) (*httptest.Server, *x509.CertPool)

TLSServer serves handler with a leaf certificate for hosts, 127.0.0.1, and ::1, issued by a fresh test CA. Callers trust the returned pool explicitly; certificate verification stays enabled.

Types

type ConnectProxy added in v0.9.1

type ConnectProxy struct {
	URL string
	// contains filtered or unexported fields
}

ConnectProxy is a minimal CONNECT-only HTTP proxy for gateway route tests. It forwards only allowlisted targets, resolving them itself, so a child that cannot resolve or reach the gateway can still connect through it.

func NewConnectProxy added in v0.9.1

func NewConnectProxy(t testing.TB, resolve map[string]string) *ConnectProxy

NewConnectProxy maps CONNECT host:port targets to dial addresses. Any other target is refused with 403, like a proxy with a destination allowlist.

func (*ConnectProxy) Close added in v0.9.1

func (p *ConnectProxy) Close()

Close stops the listener and every tunnel, simulating a proxy outage.

func (*ConnectProxy) PlaintextRequests added in v0.9.1

func (p *ConnectProxy) PlaintextRequests() int

PlaintextRequests counts non-CONNECT requests, without retaining their headers or bodies. Gateway credentials must never reach this path.

func (*ConnectProxy) Targets added in v0.9.1

func (p *ConnectProxy) Targets() []string

Targets returns every CONNECT target requested so far, including refused ones.

type ReleaseSigner added in v0.10.0

type ReleaseSigner struct {
	Private ed25519.PrivateKey
	KeyID   string
}

ReleaseSigner uses an ephemeral key, never a production release pin.

func NewReleaseSigner added in v0.10.0

func NewReleaseSigner(t *testing.T) ReleaseSigner

func (ReleaseSigner) PublicKey added in v0.10.0

func (s ReleaseSigner) PublicKey() string

func (ReleaseSigner) Sign added in v0.10.0

func (s ReleaseSigner) Sign(t *testing.T, repository, tag string, manifest []byte) []byte

Sign implements the documented protocol independently of the verifier.

Jump to

Keyboard shortcuts

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