testsupport

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 15 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

View Source
var FlagUpdate = flag.Bool("update", false, "update golden files")

FlagUpdate signals that the tests should update their golden files. Note that not all golden files used throughout the package end in .golden. Especially key files have a different extension which is more practical.

Functions

func CreateTmpDir

func CreateTmpDir(t *testing.T) (string, func())

CreateTmpDir creates a temporary directory.

It returns the path to the created temporary directory an a clean-up function which allows to delete it.

func Retry

func Retry(t *testing.T, n int, d time.Duration, op func() error)

Retry retries op at most n times before it fails t. It sleeps for d after the first failure and then increases d by the next power of itself.

func SetLegoCACertificates

func SetLegoCACertificates(t *testing.T, certPath string) func()

SetLegoCACertificates sets the LEGO_CA_CERTIFICATES environment variable to certPath. This makes all new instances of the lego ACME client use the certificate located at certPath when connecting to the ACME server.

SetLegoCACertificates returns a function which reverts any changes this made to the environment. Always use it in the following way:

reset := SetLegoCACertificates(t, somePath)
defer reset()
... test code ...

func SkipIfPebbleDisabled

func SkipIfPebbleDisabled(t *testing.T) bool

SkipIfPebbleDisabled checks whether the test should be skipped because pebble is not available.

At least the ACMEPROXY_PEBBLE_DIR environment variable has to be set, otherwise the test is skipped.

Types

type Pebble

type Pebble struct {
	TestCert string
	// contains filtered or unexported fields
}

Pebble represents an instance of the pebble test server used for testing ACME protocol clients.

For more information about pebble see https://github.com/letsencrypt/pebble

func NewPebble

func NewPebble(t *testing.T, configJSON, dnsPort string) *Pebble

NewPebble creates a new Pebble instance by reading the necessary configuration settings from environment variables or using defaults.

func (*Pebble) AccountURLPrefix

func (p *Pebble) AccountURLPrefix() string

AccountURLPrefix returns the prefix of all account URLs belonging to accounts issued by this instance of pebble.

func (*Pebble) AssertIssuedByPebble

func (p *Pebble) AssertIssuedByPebble(t *testing.T, domain string, certificate []byte)

AssertIssuedByPebble asserts that the passed PEM encoded certificate is a valid certificate issued by this instance of pebble.

func (*Pebble) DirectoryURL

func (p *Pebble) DirectoryURL() string

DirectoryURL returns the directory URL of the pebble instance.

func (*Pebble) HTTPPort

func (p *Pebble) HTTPPort() int

HTTPPort returns the port pebble uses to solve HTTP01 challenges.

func (*Pebble) Start

func (p *Pebble) Start(t *testing.T)

Start starts the pebble server for the test.

func (*Pebble) Stop

func (p *Pebble) Stop(t *testing.T)

Stop stops the pebble server after the test.

func (*Pebble) WaitReady

func (p *Pebble) WaitReady(t *testing.T)

WaitReady waits for pebble to become ready.

Jump to

Keyboard shortcuts

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