Documentation ¶
Overview ¶
Package prosody facilitates integration testing against Prosody.
Index ¶
- func Bidi() integration.Option
- func Channel(domain string, c ...ChannelConfig) integration.Option
- func Component(domain, secret, name string, modules ...string) integration.Option
- func ConfigFile(cfg Config) integration.Option
- func CreateUser(ctx context.Context, addr, pass string) integration.Option
- func Ctl(ctx context.Context, args ...string) integration.Option
- func HTTPS() integration.Option
- func ListenC2S() integration.Option
- func ListenS2S() integration.Option
- func MUC(domain string, modules ...string) integration.Option
- func Modules(mod ...string) integration.Option
- func New(ctx context.Context, opts ...integration.Option) (*integration.Cmd, error)
- func Set(key string, v interface{}) integration.Option
- func Test(ctx context.Context, t *testing.T, opts ...integration.Option) integration.SubtestRunner
- func TrustAll() integration.Option
- func VHost(hosts ...string) integration.Option
- func WebSocket() integration.Option
- type ChannelConfig
- type Config
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 Channel ¶ added in v0.20.0
func Channel(domain string, c ...ChannelConfig) integration.Option
Channel configures the MUC component (if loaded) with a default channel or channels.
func Component ¶ added in v0.18.0
func Component(domain, secret, name string, modules ...string) integration.Option
Component adds an component with the given domain and secret to the config file. If a name is provided the component must be a builtin.
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 MUC ¶ added in v0.20.0
func MUC(domain string, modules ...string) integration.Option
MUC launches prosody with the built-in multi-user chat component enabled. It is the same as Component(domain, "", "muc", modules).
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 ¶
func Test(ctx context.Context, t *testing.T, opts ...integration.Option) integration.SubtestRunner
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 ChannelConfig ¶ added in v0.20.0
type ChannelConfig struct { Localpart string Admins []string Owners []string Visitors []string Name string Desc string AllowMemberInvites bool ChangeSubject bool HistoryLen int Lang string Pass string Logging bool MembersOnly bool Moderated bool Persistent bool Public bool PublicJIDs bool }
ChannelConfig configures a Multi-User Chat channel.
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]struct { Name string Secret string Modules []string MUCDefaults []ChannelConfig } }
Config contains options that can be written to a Prosody config file.