...

Package test

import "github.com/letsencrypt/boulder/test"
Overview
Index
Subdirectories

Overview ▾

Index ▾

func Assert(t *testing.T, result bool, message string)
func AssertBoxedNil(t *testing.T, obj interface{}, message string)
func AssertByteEquals(t *testing.T, one []byte, two []byte)
func AssertContains(t *testing.T, haystack string, needle string)
func AssertDeepEquals(t *testing.T, one interface{}, two interface{})
func AssertEquals(t *testing.T, one interface{}, two interface{})
func AssertError(t *testing.T, err error, message string)
func AssertErrorIs(t *testing.T, err error, target error)
func AssertErrorWraps(t *testing.T, err error, target interface{})
func AssertImplementsGRPCServer(t *testing.T, impl any, unimpl any)
func AssertMarshaledEquals(t *testing.T, one interface{}, two interface{})
func AssertMetricWithLabelsEquals(t *testing.T, c prometheus.Collector, l prometheus.Labels, expected float64)
func AssertNil(t *testing.T, obj interface{}, message string)
func AssertNotContains(t *testing.T, haystack string, needle string)
func AssertNotEquals(t *testing.T, one interface{}, two interface{})
func AssertNotError(t *testing.T, err error, message string)
func AssertNotNil(t *testing.T, obj interface{}, message string)
func AssertSliceContains[T comparable](t *testing.T, haystack []T, needle T)
func AssertUnmarshaledEquals(t *testing.T, got, expected string)
func LoadSigner(filename string) (crypto.Signer, error)
func ResetBoulderTestDatabase(t testing.TB) func()
func ResetIncidentsTestDatabase(t testing.TB) func()
func ThrowAwayCert(t *testing.T, nameCount int) (string, *x509.Certificate)
func ThrowAwayCertWithSerial(t *testing.T, nameCount int, sn *big.Int, issuer *x509.Certificate) (string, *x509.Certificate)
type CleanUpDB

Package files

asserts.go certs.go db.go

func Assert

func Assert(t *testing.T, result bool, message string)

Assert a boolean

func AssertBoxedNil

func AssertBoxedNil(t *testing.T, obj interface{}, message string)

AssertBoxedNil checks that an inner object is nil. This is intentional for testing purposes only.

func AssertByteEquals

func AssertByteEquals(t *testing.T, one []byte, two []byte)

AssertByteEquals uses bytes.Equal to measure one and two for equality.

func AssertContains

func AssertContains(t *testing.T, haystack string, needle string)

AssertContains determines whether needle can be found in haystack

func AssertDeepEquals

func AssertDeepEquals(t *testing.T, one interface{}, two interface{})

AssertDeepEquals uses the reflect.DeepEqual method to measure one and two

func AssertEquals

func AssertEquals(t *testing.T, one interface{}, two interface{})

AssertEquals uses the equality operator (==) to measure one and two

func AssertError

func AssertError(t *testing.T, err error, message string)

AssertError checks that err is non-nil

func AssertErrorIs

func AssertErrorIs(t *testing.T, err error, target error)

AssertErrorIs checks that err wraps the given error

func AssertErrorWraps

func AssertErrorWraps(t *testing.T, err error, target interface{})

AssertErrorWraps checks that err can be unwrapped into the given target. NOTE: Has the side effect of actually performing that unwrapping.

func AssertImplementsGRPCServer

func AssertImplementsGRPCServer(t *testing.T, impl any, unimpl any)

AssertImplementsGRPCServer guarantees that impl, which must be a pointer to one of our gRPC service implementation types, implements all of the methods expected by unimpl, which must be the auto-generated gRPC type which is embedded by impl. This function incidentally also guarantees that impl does not have any methods with non-pointer receivers.

func AssertMarshaledEquals

func AssertMarshaledEquals(t *testing.T, one interface{}, two interface{})

AssertMarshaledEquals marshals one and two to JSON, and then uses the equality operator to measure them

func AssertMetricWithLabelsEquals

func AssertMetricWithLabelsEquals(t *testing.T, c prometheus.Collector, l prometheus.Labels, expected float64)

AssertMetricWithLabelsEquals determines whether the value held by a prometheus Collector (e.g. Gauge, Counter, CounterVec, etc) is equal to the expected float64. In order to make useful assertions about just a subset of labels (e.g. for a CounterVec with fields "host" and "valid", being able to assert that two "valid": "true" increments occurred, without caring which host was tagged in each), takes a set of labels and ignores any metrics which have different label values. Only works for simple metrics (Counters and Gauges), or for the *count* (not value) of data points in a Histogram.

func AssertNil

func AssertNil(t *testing.T, obj interface{}, message string)

AssertNil checks that an object is nil. Being a "boxed nil" (a nil value wrapped in a non-nil interface type) is not good enough.

func AssertNotContains

func AssertNotContains(t *testing.T, haystack string, needle string)

AssertNotContains determines if needle is not found in haystack

func AssertNotEquals

func AssertNotEquals(t *testing.T, one interface{}, two interface{})

AssertNotEquals uses the equality operator to measure that one and two are different

func AssertNotError

func AssertNotError(t *testing.T, err error, message string)

AssertNotError checks that err is nil

func AssertNotNil

func AssertNotNil(t *testing.T, obj interface{}, message string)

AssertNotNil checks an object to be non-nil. Being a "boxed nil" (a nil value wrapped in a non-nil interface type) is not good enough. Note that there is a gap between AssertNil and AssertNotNil. Both fail when called with a boxed nil. This is intentional: we want to avoid boxed nils.

func AssertSliceContains

func AssertSliceContains[T comparable](t *testing.T, haystack []T, needle T)

AssertSliceContains determines if needle can be found in haystack

func AssertUnmarshaledEquals

func AssertUnmarshaledEquals(t *testing.T, got, expected string)

AssertUnmarshaledEquals unmarshals two JSON strings (got and expected) to a map[string]interface{} and then uses reflect.DeepEqual to check they are the same

func LoadSigner

func LoadSigner(filename string) (crypto.Signer, error)

LoadSigner loads a PEM private key specified by filename or returns an error. Can be paired with issuance.LoadCertificate to get both a CA cert and its associated private key for use in signing throwaway test certs.

func ResetBoulderTestDatabase

func ResetBoulderTestDatabase(t testing.TB) func()

ResetBoulderTestDatabase returns a cleanup function which deletes all rows in all tables of the 'boulder_sa_test' database. Omits the 'gorp_migrations' table as this is used by sql-migrate (https://github.com/rubenv/sql-migrate) to track migrations. If it encounters an error it fails the tests.

func ResetIncidentsTestDatabase

func ResetIncidentsTestDatabase(t testing.TB) func()

ResetIncidentsTestDatabase returns a cleanup function which deletes all rows in all tables of the 'incidents_sa_test' database. Omits the 'gorp_migrations' table as this is used by sql-migrate (https://github.com/rubenv/sql-migrate) to track migrations. If it encounters an error it fails the tests.

func ThrowAwayCert

func ThrowAwayCert(t *testing.T, nameCount int) (string, *x509.Certificate)

ThrowAwayCert is a small test helper function that creates a self-signed certificate for nameCount random example.com subdomains and returns the parsed certificate and the random serial in string form or aborts the test. The certificate returned from this function is the bare minimum needed for most tests and isn't a robust example of a complete end entity certificate.

func ThrowAwayCertWithSerial

func ThrowAwayCertWithSerial(t *testing.T, nameCount int, sn *big.Int, issuer *x509.Certificate) (string, *x509.Certificate)

ThrowAwayCertWithSerial is a small test helper function that creates a certificate for nameCount random example.com subdomains and returns the parsed certificate and the serial in string form or aborts the test. The new throwaway certificate is always self-signed (with a random key), but will appear to be issued from issuer if provided. The certificate returned from this function is the bare minimum needed for most tests and isn't a robust example of a complete end entity certificate.

type CleanUpDB

CleanUpDB is an interface with only what is needed to delete all rows in all tables in a database plus close the database connection. It is satisfied by *sql.DB.

type CleanUpDB interface {
    BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
    ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
    QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)

    io.Closer
}

Subdirectories

Name Synopsis
..
akamai-test-srv
block-a-key block-a-key is a small utility for creating key blocklist entries.
cert-ceremonies generate.go is a helper utility for integration tests.
ct-test-srv This is a test server that implements the subset of RFC6962 APIs needed to run Boulder's CT log submission code.
health-checker
inmem
nonce
ra
sa
integration
load-generator
acme Package acme provides ACME client functionality tailored to the needs of the load-generator.
mail-test-srv
ocsp
checkari
checkocsp
helper
ocsp_forever
s3-test-srv
vars