testutil

package
v0.0.0-...-f4f6315 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 21 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"
	// PublicHTTPSConnection is the default address for HTTPS connections
	PublicHTTPSConnection = "https://127.0.0.1:4430"
	// 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 NewHTTPSClient

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

NewHTTPSClient creates a basic test client that sends a given request msg to the server listening at the given address via an HTTPS connection.

func NewHTTPSClientDefault

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

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

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 ExpectingDirProofsResponse

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

type ExpectingSTR

type ExpectingSTR struct {
	Epoch uint64
}

type HTTPError

type HTTPError struct {
	Status string
	Body   string
}

func (HTTPError) Error

func (e HTTPError) Error() string

Jump to

Keyboard shortcuts

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