Documentation ¶
Index ¶
- func AddMockTransport()
- func AddrMock() string
- func AddrTestIPC() string
- func AddrTestInp() string
- func AddrTestTCP() string
- func AddrTestTLS() string
- func AddrTestWS() string
- func AddrTestWSS() string
- func CannotRecv(t *testing.T, f func() (mangos.Socket, error))
- func CannotSend(t *testing.T, f func() (mangos.Socket, error))
- func ConnectPair(t *testing.T, s1 mangos.Socket, s2 mangos.Socket)
- func ConnectPairVia(t *testing.T, addr string, s1, s2 mangos.Socket, o1, o2 map[string]interface{})
- func GetMockSocket() protocol.Socket
- func GetMockSocketEx(proto uint16, name string) protocol.Socket
- func GetMockSocketRaw(proto, peer uint16, name, peerName string, raw interface{}, err error) protocol.Socket
- func GetSocket(t *testing.T, f func() (mangos.Socket, error)) mangos.Socket
- func GetTLSConfig(t *testing.T, server bool) *tls.Config
- func MockAddPipe(t *testing.T, s mangos.Socket, c MockCreator, p MockPipe) mangos.Pipe
- func MockMustRecvStr(t *testing.T, p MockPipe, str string, d time.Duration)
- func MockMustSend(t *testing.T, p MockPipe, data []byte, d time.Duration)
- func MockMustSendMsg(t *testing.T, p MockPipe, m *mangos.Message, d time.Duration)
- func MockMustSendStr(t *testing.T, p MockPipe, str string, d time.Duration)
- func MustBeError(t *testing.T, e error, compare error)
- func MustBeFalse(t *testing.T, b bool)
- func MustBeNil(t *testing.T, v interface{})
- func MustBeTrue(t *testing.T, b bool)
- func MustClose(t *testing.T, s mangos.Socket)
- func MustFail(t *testing.T, e error)
- func MustGetInfo(t *testing.T, f func() (mangos.Socket, error)) mangos.ProtocolInfo
- func MustNotBeNil(t *testing.T, v interface{})
- func MustNotRecv(t *testing.T, s mangos.Socket, err error)
- func MustRecv(t *testing.T, s mangos.Socket) []byte
- func MustRecvMsg(t *testing.T, s mangos.Socket) *mangos.Message
- func MustRecvString(t *testing.T, s mangos.Socket, m string)
- func MustSend(t *testing.T, s mangos.Socket, b []byte)
- func MustSendMsg(t *testing.T, s mangos.Socket, m *mangos.Message)
- func MustSendString(t *testing.T, s mangos.Socket, m string)
- func MustSucceed(t *testing.T, e error)
- func NewMockSocket() (protocol.Socket, error)
- func NextPort() uint32
- func SetTTL(t *testing.T, f func() (mangos.Socket, error))
- func SetTTLNegative(t *testing.T, f func() (mangos.Socket, error))
- func SetTTLNotInt(t *testing.T, f func() (mangos.Socket, error))
- func SetTTLTooBig(t *testing.T, f func() (mangos.Socket, error))
- func SetTTLZero(t *testing.T, f func() (mangos.Socket, error))
- func TTLDropTest(t *testing.T, cli func() (mangos.Socket, error), ...)
- func TranConnHandshake(t *testing.T, c net.Conn, proto uint16)
- func TranSendBadMessages(t *testing.T, proto uint16, isipc bool, dial func() (net.Conn, error))
- func TranSendConnBadHandshakes(t *testing.T, dial func() (net.Conn, error))
- func TranVerifyAcceptWithoutListen(t *testing.T, tran transport.Transport)
- func TranVerifyAnonymousPort(t *testing.T, addr string, dOpts, lOpts map[string]interface{})
- func TranVerifyBadAddress(t *testing.T, addr string, dOpts, lOpts map[string]interface{})
- func TranVerifyBadLocalAddress(t *testing.T, addr string, opts map[string]interface{})
- func TranVerifyBadRemoteAddress(t *testing.T, addr string, opts map[string]interface{})
- func TranVerifyBoolOption(t *testing.T, tran transport.Transport, name string)
- func TranVerifyConnectionRefused(t *testing.T, tran transport.Transport, opts map[string]interface{})
- func TranVerifyDialInsecure(t *testing.T, tran transport.Transport)
- func TranVerifyDialNoCert(t *testing.T, tran transport.Transport)
- func TranVerifyDuplicateListen(t *testing.T, tran transport.Transport, opts map[string]interface{})
- func TranVerifyDurationOption(t *testing.T, tran transport.Transport, name string)
- func TranVerifyHandshakeFail(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyIntOption(t *testing.T, tran transport.Transport, name string)
- func TranVerifyInvalidOption(t *testing.T, tran transport.Transport)
- func TranVerifyKeepAliveOption(t *testing.T, tran transport.Transport)
- func TranVerifyListenAndAccept(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyListenerClosed(t *testing.T, tran transport.Transport, opts map[string]interface{})
- func TranVerifyMaxRecvSize(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyMessageHeader(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyMessageSizes(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyNoDelayOption(t *testing.T, tran transport.Transport)
- func TranVerifyPipeAddresses(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyPipeOptions(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyPipeOptions2(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyScheme(t *testing.T, tran transport.Transport)
- func TranVerifySendRecv(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
- func TranVerifyTLSConfigOption(t *testing.T, tran transport.Transport)
- func VerifyClosedAddPipe(t *testing.T, f func() (mangos.Socket, error))
- func VerifyClosedClose(t *testing.T, f func() (mangos.Socket, error))
- func VerifyClosedContext(t *testing.T, f func() (mangos.Socket, error))
- func VerifyClosedDial(t *testing.T, f func() (mangos.Socket, error))
- func VerifyClosedListen(t *testing.T, f func() (mangos.Socket, error))
- func VerifyClosedRecv(t *testing.T, f func() (mangos.Socket, error))
- func VerifyClosedSend(t *testing.T, f func() (mangos.Socket, error))
- func VerifyCooked(t *testing.T, f func() (mangos.Socket, error))
- func VerifyInvalidOption(t *testing.T, f func() (mangos.Socket, error))
- func VerifyMaxRx(t *testing.T, addr string, makePair func() (mangos.Socket, error))
- func VerifyOptionBool(t *testing.T, f func() (mangos.Socket, error), option string)
- func VerifyOptionDuration(t *testing.T, f func() (mangos.Socket, error), option string)
- func VerifyOptionInt(t *testing.T, f func() (mangos.Socket, error), option string)
- func VerifyOptionMaxRecvSize(t *testing.T, f func() (mangos.Socket, error))
- func VerifyOptionQLen(t *testing.T, f func() (mangos.Socket, error), option string)
- func VerifyOptionTTL(t *testing.T, f func() (mangos.Socket, error))
- func VerifyRaw(t *testing.T, f func() (mangos.Socket, error))
- type KeyPair
- type Keys
- type MockCreator
- type MockPipe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddrTestIPC ¶
func AddrTestIPC() string
AddrTestIPC returns a test IPC address. It will be in the temporary directory.
func CannotRecv ¶
CannotRecv verifies that the socket cannot recv.
func CannotSend ¶
CannotSend verifies that the socket cannot send.
func ConnectPair ¶
ConnectPair is like ConnectPairVia but uses inproc.
func ConnectPairVia ¶
ConnectPairVia connects two sockets using the given address. The pipe event hook is used for this operation, and the function does not return until both sockets have seen the connection.
func GetMockSocketEx ¶
GetMockSocketEx returns a socket for a specific protocol.
func GetMockSocketRaw ¶
func GetMockSocketRaw(proto, peer uint16, name, peerName string, raw interface{}, err error) protocol.Socket
GetMockSocketRaw is an extended form to get a mocked socket, with particular properties set (including the response to GetOption() for Raw.)
func GetTLSConfig ¶
GetTLSConfig is like NewTLSConfig, but it caches to avoid regenerating key material pointlessly.
func MockAddPipe ¶
func MockAddPipe(t *testing.T, s mangos.Socket, c MockCreator, p MockPipe) mangos.Pipe
MockAddPipe simulates adding a pipe.
func MockMustRecvStr ¶
MockMustRecvStr ensures that the pipe receives a message with the payload equal to the string.
func MockMustSend ¶
MockMustSend ensures that the pipe sends a message with the body given.
func MockMustSendMsg ¶
MockMustSendMsg ensures that the pipe sends a message.
func MockMustSendStr ¶
MockMustSendStr ensures that the pipe sends a message with a payload containing the given string.
func MustBeError ¶
MustBeError verifies that a value is a specific error.
func MustBeFalse ¶
MustBeFalse verifies that the condition is true.
func MustBeTrue ¶
MustBeTrue verifies that the condition is true.
func MustFail ¶
MustFail verifies that the error is not nil. If it is nil, the test is a fatal failure.
func MustGetInfo ¶
MustGetInfo returns the Info for the socket.
func MustNotBeNil ¶
MustNotBeNil verifies that the provided value is not nil
func MustNotRecv ¶
func MustRecvMsg ¶
func MustRecvString ¶
func MustSendMsg ¶
func MustSendString ¶
func MustSucceed ¶
MustSucceed verifies that that the supplied error is nil. If it is not nil, we call t.Fatalf() to fail the test immediately.
func NewMockSocket ¶
NewMockSocket returns a mock socket, and nil.
func SetTTLNegative ¶
SetTTLNegative tests that a given socket fails to set a negative TTL.
func SetTTLNotInt ¶
SetTTLNotInt tests that a given socket fails to set a non-integer TTL.
func SetTTLTooBig ¶
SetTTLTooBig tests that a given socket fails to set a very large TTL.
func SetTTLZero ¶
SetTTLZero tests that a given socket fails to set a TTL of zero.
func TTLDropTest ¶
func TTLDropTest(t *testing.T, cli func() (mangos.Socket, error), srv func() (mangos.Socket, error), rawcli func() (mangos.Socket, error), rawsrv func() (mangos.Socket, error))
TTLDropTest is a generic test for dropping based on TTL expiration. F1 makes the Client socket, f2 makes the Server socket.
func TranConnHandshake ¶
TranConnHandshake just performs the handshake, the conn should be connected.
func TranSendBadMessages ¶
TranSendBadMessages opens new connections and sends garbage to them.
func TranSendConnBadHandshakes ¶
TranSendConnBadHandshakes just sends garbage handshakes.
func TranVerifyAcceptWithoutListen ¶
TranVerifyAcceptWithoutListen verifies that we can't call accept if we did not first call listen.
func TranVerifyAnonymousPort ¶
TranVerifyAnonymousPort is used by TCP based transports to verify that using a wild card port address works. The addr is an address using a wild card port (usually port 0).
func TranVerifyBadAddress ¶
TranVerifyBadAddress is used to verify that certain addresses are invalid and cannot be used for dialing or listening. This is useful, for example, when checking that DNS failures are handled properly.
func TranVerifyBadLocalAddress ¶
TranVerifyBadLocalAddress is used to verify that a given address cannot be listened to. This could be for an address that we cannot resolve a name for, or an address that we do not have an IP address for. The failure can occur at either listener allocation time, or when trying to bind.
func TranVerifyBadRemoteAddress ¶
TranVerifyBadRemoteAddress is used to verify that a given address cannot be dialed to. This could be for an address that we cannot resolve a name for, or an address is known to be otherwise impossible or invalid.
func TranVerifyBoolOption ¶
TranVerifyBoolOption verifies that a bool option behaves properly.
func TranVerifyConnectionRefused ¶
func TranVerifyConnectionRefused(t *testing.T, tran transport.Transport, opts map[string]interface{})
TranVerifyConnectionRefused verifies that connection is refused if no listener.
func TranVerifyDialInsecure ¶
TranVerifyDialInsecure verifies InsecureSkipVerify.
func TranVerifyDialNoCert ¶
TranVerifyDialNoCert verifies that we fail to dial if we lack a Server cert.
func TranVerifyDuplicateListen ¶
TranVerifyDuplicateListen verifies that we can't bind to the same address twice.
func TranVerifyDurationOption ¶
TranVerifyDurationOption verifies that a time.Duration option behaves properly.
func TranVerifyHandshakeFail ¶
func TranVerifyHandshakeFail(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyHandshakeFail verifies that we fail if the protocols mismatch.
func TranVerifyIntOption ¶
TranVerifyIntOption verifies that an int option behaves properly.
func TranVerifyInvalidOption ¶
TranVerifyInvalidOption verifies that an invalid option behaves properly.
func TranVerifyKeepAliveOption ¶
TranVerifyKeepAliveOption verifies that keep alive options work.
func TranVerifyListenAndAccept ¶
func TranVerifyListenAndAccept(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyListenAndAccept verifies that we can establish the connection.
func TranVerifyListenerClosed ¶
TranVerifyListenerClosed verifies that the listener behaves after closed.
func TranVerifyMaxRecvSize ¶
func TranVerifyMaxRecvSize(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyMaxRecvSize verifies the transport handles maximum receive size properly.
func TranVerifyMessageHeader ¶
func TranVerifyMessageHeader(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyMessageHeader verifies that message headers are transmitted.
func TranVerifyMessageSizes ¶
func TranVerifyMessageSizes(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyMessageSizes verifies we can transport a variety of message sizes
func TranVerifyNoDelayOption ¶
TranVerifyNoDelayOption verifies that NoDelay is always true.
func TranVerifyPipeAddresses ¶
func TranVerifyPipeAddresses(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyPipeAddresses performs basic validation of pipe address options.
func TranVerifyPipeOptions ¶
func TranVerifyPipeOptions(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyPipeOptions verifies that the LocalAddr, RemoteAddr and invalid options all behave as we expect.
func TranVerifyPipeOptions2 ¶
func TranVerifyPipeOptions2(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifyPipeOptions2 verifies standard pipe Options.
func TranVerifyScheme ¶
TranVerifyScheme verifies that we get the right scheme. It also tries an invalid scheme.
func TranVerifySendRecv ¶
func TranVerifySendRecv(t *testing.T, tran transport.Transport, dOpts, lOpts map[string]interface{})
TranVerifySendRecv just verifies basic send and receive.
func TranVerifyTLSConfigOption ¶
TranVerifyTLSConfigOption verifies that OptionTLSConfig works properly.
func VerifyClosedAddPipe ¶
func VerifyClosedClose ¶
VerifyClosedClose verifies that Close on an already closed socket returns protocol.ErrClosed.
func VerifyClosedContext ¶
func VerifyClosedDial ¶
VerifyClosedDial verifies that Dial returns protocol.ErrClosed on a closed socket.
func VerifyClosedListen ¶
VerifyClosedListen verifies that Listen returns protocol.ErrClosed on a closed socket.
func VerifyClosedRecv ¶
VerifyClosedRecv verifies that Recv on the socket created returns protocol.ErrClosed if it is closed.
func VerifyClosedSend ¶
VerifyClosedSend verifies that Send on the socket created returns protocol.ErrClosed if it is closed.
func VerifyCooked ¶
VerifyCooked verifies that the socket created is cooked, and cannot be changed to raw.
func VerifyInvalidOption ¶
VerifyInvalidOption verifies that invalid options fail.
func VerifyMaxRx ¶
VerifyMaxRx is used to test that the transport enforces the maximum receive size. In order to avoid challenges, this has to be pair.
func VerifyOptionBool ¶
VerifyOptionBool validates bool options.
func VerifyOptionDuration ¶
VerifyOptionDuration validates time.Duration options
func VerifyOptionInt ¶
VerifyOptionInt validates integer options.
func VerifyOptionMaxRecvSize ¶
VerifyOptionMaxRecvSize validates OptionMaxRecvSize.
func VerifyOptionQLen ¶
VerifyOptionQLen validates queue length options.
func VerifyOptionTTL ¶
VerifyOptionTTL validates OptionTTL.
Types ¶
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair is a single public key pair
type Keys ¶
type Keys struct { Root KeyPair // Root CA key pair Server KeyPair // Server key pair Client KeyPair // Client key pair }
Keys is a set of the Root, Server, and Client keys for a test config.
func GetTLSConfigKeys ¶
GetTLSConfigKeys is like NewTLSConfig, but it caches to avoid regenerating key material pointlessly. It also returns the Keys.
type MockCreator ¶
type MockCreator interface { // NewPipe creates a Pipe, but does not add it. The pipe will // use the assigned peer protocol. NewPipe(peer uint16) MockPipe // AddPipe adds the given pipe, returning an error if there is // no room to do so in the pipeQ. AddPipe(pipe MockPipe) error // DeferClose is used to defer close operations. If Close() // is called, and deferring is false, then the close // will happen immediately. DeferClose(deferring bool) // Close is used to close the creator. Close() error // Dial simulates dialing Dial() (transport.Pipe, error) // Listen simulates listening Listen() error // Accept simulates accepting. Accept() (transport.Pipe, error) // GetOption simulates getting an option. GetOption(string) (interface{}, error) // SetOption simulates setting an option. SetOption(string, interface{}) error // Address returns the address. Address() string // InjectError is used to inject a single error. InjectError(error) }
MockCreator is an abstraction of both dialers and listeners, which allows us to test various transport failure conditions.
func GetMockDialer ¶
func GetMockDialer(t *testing.T, s mangos.Socket) (mangos.Dialer, MockCreator)
GetMockDialer returns a dialer that creates mock pipes.
func GetMockListener ¶
func GetMockListener(t *testing.T, s mangos.Socket) (mangos.Listener, MockCreator)
GetMockListener returns a listener that creates mock pipes.
type MockPipe ¶
type MockPipe interface { // SendQ obtains the send queue. Test code can read from this // to get messages sent by the socket. SendQ() <-chan *protocol.Message // RecvQ obtains the recv queue. Test code can write to this // to send message to the socket. RecvQ() chan<- *protocol.Message // InjectSendError is used to inject an error that will be seen // by the next Send() operation. InjectSendError(error) // InjectRecvError is used to inject an error that will be seen // by the next Recv() operation. InjectRecvError(error) // DeferClose defers closing. DeferClose(deferring bool) // MockSendMsg lets us inject a message into the queue. MockSendMsg(*protocol.Message, time.Duration) error // MockRecvMsg lets us attempt to receive a message. MockRecvMsg(time.Duration) (*protocol.Message, error) transport.Pipe }
MockPipe is a mocked transport pipe.
func MockConnect ¶
MockConnect simulates connecting a pipe.
func NewMockPipe ¶
NewMockPipe creates a mocked transport pipe.