testenv

package
v2.0.330 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 7 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

Overview

Package testenv gates tests that need external fixtures, such as the local-kms emulator or the SoftHSM token (XPKI-100).

A fixture that is not reachable skips the test, unless XPKI_INTEGRATION is "required" (the Makefile exports it, so make test/covtest and CI fail instead). A reachable fixture always runs the test, so a present but broken fixture fails. Unit tests must not call it.

func TestKMS(t *testing.T) {
	testenv.RequireTCP(t, "local-kms", "localhost:14556")
	// ...
}

RequireFile does the same for a fixture identified by a file, such as the SoftHSM token configuration.

Index

Constants

View Source
const (
	// IntegrationEnv is the environment variable that selects whether a
	// missing fixture skips or fails a test.
	IntegrationEnv = "XPKI_INTEGRATION"
	// Required is the IntegrationEnv value that makes a missing fixture fail.
	Required = "required"
)

Variables

This section is empty.

Functions

func IntegrationRequired

func IntegrationRequired() bool

IntegrationRequired reports whether a missing fixture must fail the test.

func RequireFile

func RequireFile(t testing.TB, name, path string)

RequireFile gates t on the fixture name whose file is at path, such as the SoftHSM token configuration. It returns when path exists. Otherwise it fails t when IntegrationRequired, and skips t when not. Any stat error other than a missing file fails t, since the fixture is present but broken.

func RequireTCP

func RequireTCP(t testing.TB, name, addr string)

RequireTCP gates t on the fixture name listening at addr ("host:port"). It returns when addr accepts a TCP connection. Otherwise it fails t when IntegrationRequired, and skips t when not.

func SoftHSMConfig

func SoftHSMConfig() string

SoftHSMConfig returns the path of the SoftHSM token configuration that `make hsmconfig` writes. It is under the home directory and not the shared /tmp, because it names the PKCS#11 module the tests load (XPKI-128).

Types

This section is empty.

Jump to

Keyboard shortcuts

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