testutils

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2016 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var External bool

External controls whether or not NewTestCA() will create a TestCA server configured to use an external signer or not.

Functions

This section is empty.

Types

type ExternalSigningServer

type ExternalSigningServer struct {
	NumIssued uint64
	URL       string
	// contains filtered or unexported fields
}

ExternalSigningServer runs an HTTPS server with an endpoint at a specified URL which signs node certificate requests from a swarm manager client.

func NewExternalSigningServer

func NewExternalSigningServer(rootCA ca.RootCA, basedir string) (*ExternalSigningServer, error)

NewExternalSigningServer creates and runs a new ExternalSigningServer which uses the given rootCA to sign node certificates. A server key and cert are generated and saved into the given basedir and then a TLS listener is started on a random available port. On success, an HTTPS server will be running in a separate goroutine. The URL of the singing endpoint is available in the returned *ExternalSignerServer value. Calling the Close() method will stop the server.

func (*ExternalSigningServer) Stop

func (ess *ExternalSigningServer) Stop() error

Stop stops this signing server by closing the underlying TCP/TLS listener.

type TestCA

type TestCA struct {
	RootCA                ca.RootCA
	ExternalSigningServer *ExternalSigningServer
	MemoryStore           *store.MemoryStore
	TempDir, Organization string
	Paths                 *ca.SecurityConfigPaths
	Server                grpc.Server
	CAServer              *ca.Server
	Context               context.Context
	NodeCAClients         []api.NodeCAClient
	CAClients             []api.CAClient
	Conns                 []*grpc.ClientConn
	Picker                *picker.Picker
	WorkerToken           string
	ManagerToken          string
}

TestCA is a structure that encapsulates everything needed to test a CA Server

func NewTestCA

func NewTestCA(t *testing.T) *TestCA

NewTestCA is a helper method that creates a TestCA and a bunch of default connections and security configs.

func (*TestCA) NewNodeConfig

func (tc *TestCA) NewNodeConfig(role string) (*ca.SecurityConfig, error)

NewNodeConfig returns security config for a new node, given a role

func (*TestCA) NewNodeConfigOrg

func (tc *TestCA) NewNodeConfigOrg(role, org string) (*ca.SecurityConfig, error)

NewNodeConfigOrg returns security config for a new node, given a role and an org

func (*TestCA) Stop

func (tc *TestCA) Stop()

Stop cleansup after TestCA

func (*TestCA) WriteNewNodeConfig

func (tc *TestCA) WriteNewNodeConfig(role string) (*ca.SecurityConfig, error)

WriteNewNodeConfig returns security config for a new node, given a role saving the generated key and certificates to disk

func (*TestCA) WriteNewNodeConfigOrg

func (tc *TestCA) WriteNewNodeConfigOrg(role, org string) (*ca.SecurityConfig, error)

WriteNewNodeConfigOrg returns security config for a new node, given a role and an org saving the generated key and certificates to disk

Jump to

Keyboard shortcuts

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