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
- func CreateTLSCert(dir string) error
- func CreateTLSCertForTest(t *testing.T) (string, func())
- func NewHTTPSClient(msg []byte, address string) ([]byte, error)
- func NewHTTPSClientDefault(msg []byte) ([]byte, error)
- func NewTCPClient(msg []byte, address string) ([]byte, error)
- func NewTCPClientDefault(msg []byte) ([]byte, error)
- func NewUnixClient(msg []byte, address string) ([]byte, error)
- func NewUnixClientDefault(msg []byte) ([]byte, error)
- type ExpectingDirProofResponse
- type ExpectingDirProofsResponse
- type ExpectingSTR
- type HTTPError
Constants ¶
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 ¶
CreateTLSCert generates a new self-signed TLS certificate and stores it in the path given by dir.
func CreateTLSCertForTest ¶
CreateTLSCertForTest generates a temporary self-signed TLS certificate that only lasts for the duration of the test t.
func NewHTTPSClient ¶
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 ¶
NewHTTPSClientDefault creates a basic test client that sends a given request msg to a server listening at the default PublicConnection address.
func NewTCPClient ¶
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 ¶
NewTCPClientDefault creates a basic test client that sends a given request msg to a server listening at the default PublicConnection address.
func NewUnixClient ¶
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 ¶
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
}