testutil

package
v0.0.0-...-11acf48 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package testutil provides utility functions for writing server tests and generating a test server configuration.

testutil provides functions to create a self-signed TLS certificate which can be used for a test server. It also provides functions to create a basic test client which can send requests to a test server via a TLS socket connection or a Unix socket connection.

Index

Constants

View Source
const (
	// TestDir is the default directory for server tests
	TestDir = "coniksServerTest"
	// PublicConnection is the default address for TCP connections
	PublicConnection = "tcp://127.0.0.1:3000"
	// LocalConnection is the default address for Unix socket connections
	LocalConnection = "unix:///tmp/conikstest.sock"
)

Variables

This section is empty.

Functions

func CreateTLSCert

func CreateTLSCert(dir string) error

CreateTLSCert generates a new self-signed TLS certificate and stores it in the path given by dir.

func CreateTLSCertForTest

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

CreateTLSCertForTest generates a temporary self-signed TLS certificate that only lasts for the duration of the test t.

func NewTCPClient

func NewTCPClient(msg []byte, address string) ([]byte, error)

NewTCPClient creates a basic test client that sends a given request msg to the server listening at the given address via a TCP connection.

func NewTCPClientDefault

func NewTCPClientDefault(msg []byte) ([]byte, error)

NewTCPClientDefault creates a basic test client that sends a given request msg to a server listening at the default PublicConnection address.

func NewUnixClient

func NewUnixClient(msg []byte, address string) ([]byte, error)

NewUnixClient creates a basic test client that sends a given request msg to the server listening at the given address via a Unix socket connection.

func NewUnixClientDefault

func NewUnixClientDefault(msg []byte) ([]byte, error)

NewUnixClientDefault creates a basic test client that sends a given request msg to a server listening at the default LocalConnection address.

Types

type ExpectingDirProofResponse

type ExpectingDirProofResponse struct {
	Error             protocol.ErrorCode
	DirectoryResponse struct {
		AP  []json.RawMessage
		STR []json.RawMessage
		TB  json.RawMessage
	}
}

type ExpectingSTR

type ExpectingSTR struct {
	Epoch uint64
}

Jump to

Keyboard shortcuts

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