testenv

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package testenv provides functions for creating test servers for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTestServer

func MakeTestServer(t *testing.T, opts ...TestServerOptFunc) (process *service.TeleportProcess)

MakeTestServer creates a Teleport Server for testing.

func NewTCPListener

func NewTCPListener(t *testing.T, lt service.ListenerType, fds *[]*servicecfg.FileDescriptor) string

NewTCPListener creates a new TCP listener on 127.0.0.1:0, adds it to the FileDescriptor slice (with the specified type) and returns its actual local address as a string (for use in configuration). Takes a pointer to the slice so that it's convenient to call in the middle of a FileConfig or Config struct literal.

func WithInsecureDevMode

func WithInsecureDevMode(t *testing.T, mode bool)

WithInsecureDevMode is a test helper that sets insecure dev mode and resets it in test cleanup. It is NOT SAFE to use in parallel tests, because it modifies a global. To run insecure dev mode tests in parallel, group them together under a parent test and then run them as parallel subtests. and call WithInsecureDevMode before running all the tests in parallel.

func WithResyncInterval

func WithResyncInterval(t *testing.T, interval time.Duration)

WithResyncInterval is a test helper that sets the tunnel resync interval and resets it in test cleanup. Useful to substantially speedup test cluster setup - passing 0 for the interval selects a reasonably fast default of 100ms. It is NOT SAFE to use in parallel tests, because it modifies a global.

Types

type TestServerOptFunc

type TestServerOptFunc func(o *TestServersOpts)

func WithAuthConfig

func WithAuthConfig(fn func(*servicecfg.AuthConfig)) TestServerOptFunc

func WithAuthPreference

func WithAuthPreference(authPref types.AuthPreference) TestServerOptFunc

func WithBootstrap

func WithBootstrap(bootstrap ...types.Resource) TestServerOptFunc

func WithClusterName

func WithClusterName(t *testing.T, n string) TestServerOptFunc

func WithConfig

func WithConfig(fn func(cfg *servicecfg.Config)) TestServerOptFunc

func WithHostname

func WithHostname(hostname string) TestServerOptFunc

func WithSSHLabel

func WithSSHLabel(key, value string) TestServerOptFunc

func WithSSHPublicAddrs

func WithSSHPublicAddrs(addrs ...string) TestServerOptFunc

type TestServersOpts

type TestServersOpts struct {
	Bootstrap   []types.Resource
	ConfigFuncs []func(cfg *servicecfg.Config)
}

Jump to

Keyboard shortcuts

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