xmpptest

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package xmpptest provides utilities for XMPP testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSession

func NewSession(finalState xmpp.SessionState, rw io.ReadWriter) *xmpp.Session

NewSession returns a new client-to-client XMPP session with the state bits set to finalState|xmpp.Ready, the origin JID set to "test@example.net" and the location JID set to "example.net".

NewSession panics on error for ease of use in testing, where a panic is acceptable.

func NopNegotiator added in v0.7.1

func NopNegotiator(state xmpp.SessionState) xmpp.Negotiator

NopNegotiator marks the state as ready (by returning state|xmpp.Ready) and pops the first token (likely <stream:stream>) but does not perform any validation on the token, transmit any data over the wire, or perform any other session negotiation.

func RunFeatureTests added in v0.18.0

func RunFeatureTests(t *testing.T, tcs []FeatureTestCase)

RunFeatureTests simulates a stream feature neogtiation and tests the output.

Types

type ClientServer added in v0.17.1

type ClientServer struct {
	Client *xmpp.Session
	Server *xmpp.Session
	// contains filtered or unexported fields
}

ClientServer is two coupled xmpp.Session's that can respond to one another in tests.

func NewClientServer added in v0.17.1

func NewClientServer(opts ...Option) *ClientServer

NewClientServer returns a ClientServer with the client and server goroutines started. Both serve goroutines are started when NewClientServer is called and shut down when the ClientServer is closed.

func (*ClientServer) Close added in v0.17.1

func (cs *ClientServer) Close() error

Close calls the client and server sessions' close methods.

type FeatureTestCase added in v0.18.0

type FeatureTestCase struct {
	State      xmpp.SessionState
	Feature    xmpp.StreamFeature
	In         string
	Out        string
	FinalState xmpp.SessionState
	Err        error
}

FeatureTestCase is a data driven test for stream feature negotiation.

type Option added in v0.17.1

type Option func(*ClientServer)

Option is a type for configuring a ClientServer.

func ClientHandler added in v0.17.1

func ClientHandler(handler xmpp.Handler) Option

ClientHandler sets up the client side of a ClientServer.

func ClientHandlerFunc added in v0.17.1

func ClientHandlerFunc(handler xmpp.HandlerFunc) Option

ClientHandlerFunc sets up the client side of a ClientServer using an xmpp.HandlerFunc.

func ClientState added in v0.17.1

func ClientState(state xmpp.SessionState) Option

ClientState configures extra state bits to add to the client session.

func ServerHandler added in v0.17.1

func ServerHandler(handler xmpp.Handler) Option

ServerHandler sets up the server side of a ClientServer.

func ServerHandlerFunc added in v0.17.1

func ServerHandlerFunc(handler xmpp.HandlerFunc) Option

ServerHandlerFunc sets up the server side of a ClientServer using an xmpp.HandlerFunc.

func ServerState added in v0.17.1

func ServerState(state xmpp.SessionState) Option

ServerState configures extra state bits to add to the server session.

type Tokens added in v0.18.0

type Tokens []xml.Token

Tokens is a slice of XML tokens that can also act as an xml.TokenReader by popping tokens from itself. This is useful for testing contrived scenarios where the tokens cannot be constructed using an xml.Decoder because the stream to be tested violates the well-formedness rules of XML or otherwise would result in an error from the decoder.

func (*Tokens) Token added in v0.18.0

func (r *Tokens) Token() (xml.Token, error)

Token satisfies the xml.TokenReader interface for Tokens.

Jump to

Keyboard shortcuts

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