testutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: GPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquirePGMigrationLock added in v0.0.4

func AcquirePGMigrationLock(t *testing.T, baseURL string) (release func())

AcquirePGMigrationLock holds a cluster-wide advisory lock on a dedicated single-connection pool until the returned fn runs. Callers must wrap the migration invocation — db.Open via golang-migrate — and any additional CREATE ROLE that targets a cluster-wide role (pg_authid is shared across databases). The lock serializes these against parallel `go test` packages that would otherwise race on the pg_authid unique index (#317).

baseURL is a superuser connection URL (any database works; the lock itself is cluster-scoped).

func AcquirePGMigrationLockMain added in v0.0.4

func AcquirePGMigrationLockMain(baseURL string) (release func())

AcquirePGMigrationLockMain is the TestMain-flavoured variant of AcquirePGMigrationLock. Logs to stderr and os.Exits on failure because TestMain doesn't have a *testing.T.

func AlpineImage added in v0.0.3

func AlpineImage(t *testing.T) string

AlpineImage returns the Alpine image reference from docker/server.Dockerfile. This is the version we ship with, so integration tests should use it.

func ComposeServiceImage added in v0.0.3

func ComposeServiceImage(composeFile, service string) string

ComposeServiceImage extracts the image for a named service from a docker-compose file, relative to the repo root. Panics on error so it can be used in TestMain and package-level vars.

func MakeBundle

func MakeBundle(t *testing.T) []byte

MakeBundle returns a valid tar.gz containing app.R and a DESCRIPTION file. The DESCRIPTION makes the bundle deployable without bare-script preprocessing.

func MakeBundleWithoutEntrypoint

func MakeBundleWithoutEntrypoint(t *testing.T) []byte

MakeBundleWithoutEntrypoint returns a valid tar.gz that has no app.R.

func MakeTraversalBundle

func MakeTraversalBundle(t *testing.T) []byte

MakeTraversalBundle returns a tar.gz with a path traversal entry.

func TOMLDockerImage added in v0.0.3

func TOMLDockerImage(t *testing.T) string

TOMLDockerImage reads the docker.image field from a blockyard.toml file, relative to the repo root.

Types

type MockIdP added in v0.0.2

type MockIdP struct {
	Server *httptest.Server

	// Sub and Groups to include in issued ID tokens.
	Sub    string
	Groups []string

	// Nonce to embed in the next ID token. Tests should set this to the
	// nonce extracted from the login redirect URL before calling /callback.
	Nonce string
	// contains filtered or unexported fields
}

MockIdP is a minimal OIDC-compliant mock identity provider for integration tests. Serves:

GET  /.well-known/openid-configuration
GET  /jwks
POST /token

func NewMockIdP added in v0.0.2

func NewMockIdP() *MockIdP

NewMockIdP starts a mock IdP on a random port. The default sub is "test-sub" with groups ["testers"].

func (*MockIdP) Close added in v0.0.2

func (m *MockIdP) Close()

func (*MockIdP) IssueJWT added in v0.0.2

func (m *MockIdP) IssueJWT(sub string, groups []string) string

IssueJWT creates a JWT for control-plane Bearer auth (client credentials style). Same signing key as ID tokens, different claims structure.

func (*MockIdP) IssuerURL added in v0.0.2

func (m *MockIdP) IssuerURL() string

func (*MockIdP) Kid added in v0.0.2

func (m *MockIdP) Kid() string

Kid returns the key ID used in the JWKS.

func (*MockIdP) PrivateKey added in v0.0.2

func (m *MockIdP) PrivateKey() *rsa.PrivateKey

PrivateKey returns the RSA private key used for signing.

Jump to

Keyboard shortcuts

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