test

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 12 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 test runs certificate manager tests against PostgreSQL in a container: the manager's own tests, and the tests of what's built on it.

Index

Constants

View Source
const (
	// PassphraseVersion and Passphrase are registered with the shared
	// manager, so that private keys can be encrypted
	PassphraseVersion = 1
	Passphrase        = "test passphrase"

	// RootCommonName and RootOrganization are the shared manager's root
	// certificate's subject
	RootCommonName   = "Test Root CA"
	RootOrganization = "Test"
)

Variables

This section is empty.

Functions

func Begin

func Begin(t *testing.T) (*manager.Manager, context.Context)

Begin returns the shared test manager and a per-test context, which is cancelled when the test ends.

func End

func End(t *testing.T)

End releases the per-test context created by Begin.

func IsolatedManager

func IsolatedManager(t *testing.T, opts ...manager.Opt) *manager.Manager

IsolatedManager returns a new manager on a new, empty database schema, with only the options, so that a test sets its own passphrases and root, and can make assertions about every certificate. The schema is dropped when the test ends.

func IsolatedSchema

func IsolatedSchema(t *testing.T) string

IsolatedSchema returns the name of a new, empty database schema, so that a test can create managers on it with its own options. The schema is dropped when the test ends.

func Main

func Main(m *testing.M, setup func(*manager.Manager) (func(), error), opts ...manager.Opt)

Main is the test main function for certificate manager tests. It starts a PostgreSQL container, creates a manager on it, with the test passphrase and a new root certificate, and runs the tests, which get the manager with Begin. The setup function, when it's set, is called with the manager before the tests run, and the teardown it returns after.

func NewRoot

func NewRoot(commonName, organization string) (*cert.Cert, string, error)

NewRoot returns a new root certificate, valid for a day, and it with its private key, PEM encoded, as manager.WithRoot and InsertRootCert take it

func NewSchemaManager

func NewSchemaManager(schemaName string, opts ...manager.Opt) (*manager.Manager, error)

NewSchemaManager is SchemaManager, returning its error, for tests of the manager's options

func Pool

func Pool() pg.PoolConn

Pool returns the shared test connection pool, such as for a manager of a test's own

func Schema

func Schema() string

Schema returns the database schema used by the shared test manager, for tests which need to refer to its tables directly

func SchemaManager

func SchemaManager(t *testing.T, schemaName string, opts ...manager.Opt) *manager.Manager

SchemaManager returns a new manager on the schema, with the options. The manager isn't closed, as it shares the pool with the other managers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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