~samwhited/xmpp

ref: bb3bf8e486439ef6d8109b0d91cb8d2bcb3fec4b xmpp/internal d---------
internal/marshal: use data driven testing

Add tests for all branches using a table driven test to exercise
various error conditions.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/prosody: trust all certs

Adds an option to trust all client certs presented to prosody so that
our self-signed certs will be accepted.
The option works by using the new modules option and the TempFile option
to write out a small lua plugin to do the job.
This opens up a lot more flexibility for customization of prosody, but
also makes it possible that we customize prosody too much and lose the
integrity of our tests, so we should use this approach with caution.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/prosody: allow custom modules

Provides an option for loading custom modules.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: simplify use of ClientCert

This patch lets us promote cmd.ClientCert to a function and use it as a
tls.Config's GetClientCertificate function.
It also requires that we write out the client certs to disk first so
that if we need to debug later we have them and don't have to guess at
what was happening.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/marshal: return existing TokenReaders

Short circuit from marshal.TokenReader if the input is already a
TokenReader to avoid the overhead of re-encoding everything in this
niche special case.

See #38

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: add client cert creation

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: configure S2S negotiator

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: fix panic if S2S is enabled

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: refactor waitSocket

This was written in a weird way originally. A quick refactor makes it
much nicer to read.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: make options more flexible

This pulls some of the defaults out into options and only sets them if
the user does not apply these options. It also allows us to get the JID
directly from the command so that we don't have to create and parse a
JID, set a password, and make a user for every single test.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: add s2s connection support

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/xmpptest: add missing doc comment

Oops, let's make the linter happy. That's what I get for not re-running
CI before merging.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/stream: unmarshal stream errors

Previously we returned an internal server error for all stream errors,
which didn't really make much sense as a placeholder even if we did want
to use a single placeholder error for some reason.

Fixes #72

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/xmpptest: add slice token reader type

Adding a type that lets us use a slice as a token reader will make it
easier to test invalid streams that we can't put through a decoder by
easily constructing a slice of contrived tokens.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/stream: add tests for Reader

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp, internal/xmpptest: new API for ClientServer

Using the functional options pattern like other packages in this module
lets us set more options later and set handlers on the client side of
the connection as well for now.

This also updates the existing tests using xmpptest.ClientServer and
updates the send tests to use it with the new API.

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpptest: add a client/server test mechanism

Hopefully this will allow us to get rid of the various race conditions
in the IQ tests.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/ejabberd: new package

The ejabberd package lets you configure and spin up an instance of the
Ejabberd XMPP server (https://www.ejabberd.im/) for use in integration
tests.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/prosody: new package

The prosody package lets you configure and spin up an instance of the
Prosody XMPP server (https://prosody.im/) for use in integration tests.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: new integration test helpers

The internal/integration package is designed to make it easy to spin up
and configure servers for integration tests.
It is not meant to be used directly, instead it is meant to aid in
writing other packages that spin up specific servers and tools.

Fixes #42

Signed-off-by: Sam Whited <sam@samwhited.com>
all: update BUG comments

Remove inaccurate BUG comments and update existing ones to contain a
link to their relavant issue so that they get removed if the issue is
closed.

Signed-off-by: Sam Whited <sam@samwhited.com>
Next