~samwhited/xmpp

xmpp: refactor the stanza encoding wrapper

This doesn't really change anything, but for some reason I had a
convoluted wrapper that involved interfaces and fields on a struct
containing functions that defined all the behavior of the struct and
closures when all it really needed was a struct that overrode one method
of an encoder.

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: update documentation

Fix the stanza creation example to use the newer Wrap method and add an
ID argument to make it more obvious that you have to add IDs to the
stanzas yourself.

See #17

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: update the changelog

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

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/marshal: prevent duplicate xmlns attr

Encoding the output of TokenReader can create multiple xmlns attributes
due to a bug in encoding/xml.
This patch uses RawToken in the decode stage to work around this and can
be reverted after the upstream issue is fixed and in all supported
versions of Go.

Upstream issue: https://golang.org/issue/42807 (golang/go#42807)
Upstream CL: https://golang.org/cl/272806 (golang/go#42808)

Fixes #74

Signed-off-by: Sam Whited <sam@samwhited.com>
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>
xmpp: fix function signature mismatch in docs

Signed-off-by: Sam Whited <sam@samwhited.com>
ping: re-enable Ejabberd integration tests

Issue #68 appears to have been fixed by the recent refactor to the
internal/integration packages. This commit re-enables ejabberd tests on
the ping package which is the last step in marking the issue as
resolved.

Fixes #68

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>
ping: add handler type check in tests

Signed-off-by: Sam Whited <sam@samwhited.com>
mux: remove unnecessary argument names

Signed-off-by: Sam Whited <sam@samwhited.com>
mux: move options into their own file

This is a minor refactor that just oves options out into their own file.
While working on the disco package I decided to move them because its
integration with the mux package was going to add even more options and
they were getting a bit hard to find in the sam file as everything else.
Going ahead and moving them out keeps the diff smaller during that work
and makes it easier to see what has changed.

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