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

      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

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

          RunFeatureTests simulates a stream feature neogtiation and tests the output.

          Types

          type ClientServer

          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

            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

              func (cs *ClientServer) Close() error

                Close calls the client and server sessions' close methods.

                type FeatureTestCase

                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

                  type Option func(*ClientServer)

                    Option is a type for configuring a ClientServer.

                    func ClientHandler

                    func ClientHandler(handler xmpp.Handler) Option

                      ClientHandler sets up the client side of a ClientServer.

                      func ClientHandlerFunc

                      func ClientHandlerFunc(handler xmpp.HandlerFunc) Option

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

                        func ClientState

                        func ClientState(state xmpp.SessionState) Option

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

                          func ServerHandler

                          func ServerHandler(handler xmpp.Handler) Option

                            ServerHandler sets up the server side of a ClientServer.

                            func ServerHandlerFunc

                            func ServerHandlerFunc(handler xmpp.HandlerFunc) Option

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

                              func ServerState

                              func ServerState(state xmpp.SessionState) Option

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

                                type Tokens

                                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

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

                                    Token satisfies the xml.TokenReader interface for Tokens.