prosody

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package prosody facilitates integration testing against Prosody.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bidi added in v0.18.0

func Bidi() integration.Option

Bidi enables bidirectional S2S connections.

func Component added in v0.18.0

func Component(domain, secret string) integration.Option

Component adds an external component with the given domain and secret to the config file.

func ConfigFile

func ConfigFile(cfg Config) integration.Option

ConfigFile is an option that can be used to write a temporary Prosody config file. This will overwrite the existing config file and make most of the other options in this package noops. This option only exists for the rare occasion that you need complete control over the config file.

func CreateUser

func CreateUser(ctx context.Context, addr, pass string) integration.Option

CreateUser returns an option that calls prosodyctl to create a user. It is equivalent to calling: Ctl(ctx, "register", "localpart", "domainpart", "password") except that it also configures the underlying Cmd to know about the user.

func Ctl

func Ctl(ctx context.Context, args ...string) integration.Option

Ctl returns an option that calls prosodyctl with the provided args. It automatically points prosodyctl at the config file so there is no need to pass the --config option.

func HTTPS added in v0.18.0

func HTTPS() integration.Option

HTTPS configures prosody to listen for HTTP and HTTPS on two randomized ports and configures TLS certificates for localhost:https.

func ListenC2S added in v0.18.0

func ListenC2S() integration.Option

ListenC2S listens for client-to-server (c2s) connections on a random port.

func ListenS2S added in v0.18.0

func ListenS2S() integration.Option

ListenS2S listens for server-to-server (s2s) connections on a random port.

func Modules added in v0.18.0

func Modules(mod ...string) integration.Option

Modules adds custom modules to the enabled modules list.

func New

func New(ctx context.Context, opts ...integration.Option) (*integration.Cmd, error)

New creates a new, unstarted, prosody daemon.

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 Set added in v0.18.0

func Set(key string, v interface{}) integration.Option

Set adds an extra key/value pair to the global section of the config file. If v is a string it will be quoted, otherwise it is marshaled using the %v formatting directive (see the fmt package for details). As a special case, if v is nil the key is written to the file directly with no equals sign.

-- Set("foo", "bar")
foo = "bar"

-- Set("foo", 123)
foo = 123

-- Set(`Component "conference.example.org" "muc"`, nil)
Component "conference.example.org" "muc"

func Test

Test starts a Prosody instance and returns a function that runs subtests using t.Run. Multiple calls to the returned function will result in uniquely named subtests. When all subtests have completed, the daemon is stopped.

func TrustAll added in v0.18.0

func TrustAll() integration.Option

TrustAll configures prosody to trust all certificates presented to it without any verification.

func VHost added in v0.18.0

func VHost(hosts ...string) integration.Option

VHost configures one or more virtual hosts. The default if this option is not provided is to create a single vhost called "localhost" and create a self-signed cert for it (if VHost is specified certs must be manually created).

func WebSocket added in v0.18.0

func WebSocket() integration.Option

WebSocket enables the websocket module. WebSocket implies the HTTPS() option.

Types

type Config

type Config struct {
	C2SPort   int
	S2SPort   int
	CompPort  int
	HTTPPort  int
	HTTPSPort int
	Admins    []string
	Modules   []string
	VHosts    []string
	Options   map[string]interface{}
	Component map[string]string
}

Config contains options that can be written to a Prosody config file.

Jump to

Keyboard shortcuts

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