Documentation ¶
Overview ¶
Package integration contains helpers for integration testing.
Normally users writing integration tests should not use this package directly, instead they should use the packges in subdirectories of this package.
Index ¶
- type Cmd
- func (cmd *Cmd) C2SAddr() (net.Addr, string)
- func (cmd *Cmd) C2SListen(network, addr string) (net.Listener, error)
- func (cmd *Cmd) C2SPort() string
- func (cmd *Cmd) ClientCert(*tls.CertificateRequestInfo) (*tls.Certificate, error)
- func (cmd *Cmd) Close() error
- func (cmd *Cmd) ComponentAddr() (net.Addr, string)
- func (cmd *Cmd) ComponentConn(ctx context.Context) (net.Conn, error)
- func (cmd *Cmd) ComponentListen(network, addr string) (net.Listener, error)
- func (cmd *Cmd) ConfigDir() string
- func (cmd *Cmd) Conn(ctx context.Context, s2s bool) (net.Conn, error)
- func (cmd *Cmd) DialClient(ctx context.Context, j jid.JID, t *testing.T, features ...xmpp.StreamFeature) (*xmpp.Session, error)
- func (cmd *Cmd) DialServer(ctx context.Context, location, origin jid.JID, t *testing.T, ...) (*xmpp.Session, error)
- func (cmd *Cmd) Done() <-chan error
- func (cmd *Cmd) HTTPConn(ctx context.Context, secure bool) (net.Conn, error)
- func (cmd *Cmd) HTTPListen(network, addr string) (net.Listener, error)
- func (cmd *Cmd) HTTPPort() string
- func (cmd *Cmd) HTTPSListen(network, addr string) (net.Listener, error)
- func (cmd *Cmd) HTTPSPort() string
- func (cmd *Cmd) S2SAddr() (net.Addr, string)
- func (cmd *Cmd) S2SListen(network, addr string) (net.Listener, error)
- func (cmd *Cmd) Start() error
- func (cmd *Cmd) Stdin() io.WriteCloser
- func (cmd *Cmd) User() (jid.JID, string)
- type Option
- func Args(f ...string) Option
- func Cert(name string) Option
- func ClientCert(name string) Option
- func Defer(f func(*Cmd) error) Option
- func Log() Option
- func LogFile(f string, tee io.Writer) Option
- func LogXML() Option
- func Shutdown(f func(*Cmd) error) Option
- func TempFile(cfgFileName string, f func(*Cmd, io.Writer) error) Option
- func User(user jid.JID, pass string) Option
- type SubtestRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct { *exec.Cmd // Config is meant to be used by internal packages like prosody and ejabberd // to store their internal representation of the config before writing it out. Config interface{} // contains filtered or unexported fields }
Cmd is an external command being prepared or run.
A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods.
func New ¶
New creates a new, unstarted, command.
The provided context is used to kill the process (by calling os.Process.Kill) if the context becomes done before the command completes on its own.
func (*Cmd) C2SListen ¶
C2SListen returns a listener with a random port. The listener is created on the first call to C2SListener. Subsequent calls ignore the arguments and return the existing listener.
func (*Cmd) C2SPort ¶ added in v0.18.0
C2SPort returns the port on which the C2S listener is running (if any).
func (*Cmd) ClientCert ¶ added in v0.18.0
func (cmd *Cmd) ClientCert(*tls.CertificateRequestInfo) (*tls.Certificate, error)
ClientCert returns the last configured client certificate. The certificate request info is currently ignored and is only there to make promoting this method to a function and using it as tls.Config.GetClientCertificate possible.
func (*Cmd) Close ¶
Close kills the command if it is still running and cleans up any temporary resources that were created.
func (*Cmd) ComponentAddr ¶ added in v0.18.0
ComponentAddr returns the component address and network.
func (*Cmd) ComponentConn ¶ added in v0.18.0
ComponentConn dials a connection to the component socket and returns it without negotiating a session.
func (*Cmd) ComponentListen ¶ added in v0.18.0
ComponentListen returns a listener with a random port. The listener is created on the first call to ComponentListener. Subsequent calls ignore the arguments and return the existing listener.
func (*Cmd) Conn ¶ added in v0.18.0
Conn dials a connection and returns it without negotiating a session.
func (*Cmd) DialClient ¶ added in v0.18.0
func (cmd *Cmd) DialClient(ctx context.Context, j jid.JID, t *testing.T, features ...xmpp.StreamFeature) (*xmpp.Session, error)
DialClient attempts to connect to the server with a client-to-server (c2s) connection by dialing the address reserved by C2SListen and then negotiating a stream with the location set to the domainpart of j and the origin set to j.
func (*Cmd) DialServer ¶ added in v0.18.0
func (cmd *Cmd) DialServer(ctx context.Context, location, origin jid.JID, t *testing.T, features ...xmpp.StreamFeature) (*xmpp.Session, error)
DialServer attempts to connect to the server with a server-to-server (s2s) connection by dialing the address reserved by S2SListen and then negotiating a stream.
func (*Cmd) Done ¶ added in v0.18.0
Done returns a channel that's closed when the commands process terminates.
func (*Cmd) HTTPConn ¶ added in v0.18.0
HTTPConn dials a connection and returns it without negotiating a session.
func (*Cmd) HTTPListen ¶ added in v0.18.0
HTTPListen returns a listener with a random port (for HTTP). The listener is created on the first call to HTTPListener. Subsequent calls ignore the arguments and return the existing listener.
func (*Cmd) HTTPPort ¶ added in v0.18.0
HTTPPort returns the port on which the HTTP listener is running (if any).
func (*Cmd) HTTPSListen ¶ added in v0.18.0
HTTPSListen returns a listener with a random port (for HTTPS). The listener is created on the first call to HTTPSListener. Subsequent calls ignore the arguments and return the existing listener.
func (*Cmd) HTTPSPort ¶ added in v0.18.0
HTTPSPort returns the port on which the HTTPS listener is running (if any).
func (*Cmd) S2SListen ¶ added in v0.18.0
S2SListen returns a listener with a random port. The listener is created on the first call to S2SListener. Subsequent calls ignore the arguments and return the existing listener.
func (*Cmd) Stdin ¶ added in v0.18.0
func (cmd *Cmd) Stdin() io.WriteCloser
Stdin returns a pipe to the commands standard input.
type Option ¶
Option is used to configure a Cmd.
func ClientCert ¶ added in v0.18.0
ClientCert creates a private key and certificate with the given name that can be used for TLS authentication.
func Defer ¶
Defer is an option that calls f after the command is started. If multiple Defer options are passed they are called in order until an error is encountered.
func Log ¶
func Log() Option
Log configures the command to copy stdout to the current testing.T. This should not be used for CLI or TUI clients.
func LogFile ¶ added in v0.18.0
LogFile reads the provided file into the log in the same way that the Log option reads a commands standard output. It can optionally copy the command to the provided io.Writer (if non-nil) as well similar to the tee(1) command. Normally this should be used by the various server and client packages to read a FIFO which has been configured to be the log by the actual client process so that it functions similar to the tail(1) command.
func LogXML ¶
func LogXML() Option
LogXML configures the command to log sent and received XML to the current testing.T.
func Shutdown ¶
Shutdown is run before the configuration is removed and is meant to gracefully shutdown the application in case it does not handle the kill signal correctly. If multiple shutdown options are used the functions will be run in the order in which they are passed until an error is encountered.
type SubtestRunner ¶
SubtestRunner is the signature of a function that can be used to start subtests.
Directories ¶
Path | Synopsis |
---|---|
Package ejabberd facilitates integration testing against Ejabberd.
|
Package ejabberd facilitates integration testing against Ejabberd. |
Package mcabber facilitates integration testing against Mcabber.
|
Package mcabber facilitates integration testing against Mcabber. |
Package mellium facilitates integration testing against clients.
|
Package mellium facilitates integration testing against clients. |
Package prosody facilitates integration testing against Prosody.
|
Package prosody facilitates integration testing against Prosody. |
Package sendxmpp facilitates integration testing with sendxmpp.
|
Package sendxmpp facilitates integration testing with sendxmpp. |