13 Commits

Author SHA1 Message Date
Alberto Bertogli
21e8d50df6 test: Improve layout of helper binaries
This patch moves the test helper binaries to a "one directory per
helper" layout, and also makes them to be ignored in the coverage build
instead of all builds.

With this change, "go build ./..." will build all binaries including the
test helpers, which helps make sure that module manage automation also
considers them. In particular, this makes "go mod tidy" work fine.
2022-08-27 18:46:54 +01:00
Alberto Bertogli
270a071c1e hooks: Add dkimpy support
This patch adds support in the default hook for using dkimpy for DKIM
signing.

Unfortunately, dkimpy binaries have the same name as driusan/dkim's, so
we need to use --help to disambiguate. It's not pretty but it should
work, and is quite self contained.

Also, for the integration tests, we still need driusan/dkim because
dkimpy lacks the features needed. Specifically, dkimpy's dkimverify
can't be made to use custom DNS, or override the TXT values in any way,
so we can't verify that the generated signature is reasonable.

Thanks to ne9z@github for suggesting this change and providing an
alternative patch in https://github.com/albertito/chasquid/pull/19.
2021-07-21 02:06:20 +01:00
Alberto Bertogli
e7a5a4875c test: Update Dockerfile to the new "go get" restrictions
In Go 1.16, "go get" on non-module paths now require an explicit version
to point to.  Without a specific version, the invocation fails.

See https://golang.org/doc/go1.16#go-command for more details on the
change.

The test Dockerfile uses "go get" to fetch driusan/dkim's binaries, used
for integration testing.

So this patch adjusts the Dockerfile to fetch the latest version.
2021-02-18 02:10:13 +00:00
Alberto Bertogli
e79586a014 Implement HAProxy protocol support
This patch implements support for incoming connections wrapped in the
HAProxy protocol v1.

This is useful when running chasquid behind a HAProxy server, as it
needs the original source IP to perform SPF checks.

This patch is a reimplementation of one originally provided by Denys
Vitali in pull request #15, except the logic for the protocol handling
is moved to a new package, and the smtpsrv.Conn handling of the source
IP is simplified.

It is marked as experimental for now, since we want to give it a bit
more exposure just in case the option/api needs adjustment.

Thanks a lot to Denys Vitali (@denysvitali in github) for sending the
original patch for this, and helping test it!
2020-11-13 20:49:42 +00:00
Alberto Bertogli
9dea372d96 gitlab-ci.yml: Run integration tests against submitted and latest deps
It is useful to run the integration tests both against the submitted
dependencies, based on Go module versions from the repository, as well
as the latest ones, to catch integration problems early.

This patch extends the .gitlab-ci.yml configuration to do that, by
optionally passing a flag to "go get" to update the modules.
2019-10-19 13:06:30 +01:00
Alberto Bertogli
3aa7bb4555 test: Adjust Dockerfile to support modules
When modules are configured, go will now attempt to fetch them on build,
using the proxy.

That causes the integration tests run via Docker to fail, because go
build attempts to contact the proxy within the test environment, which
has the external DNS resolvers disabled.

This patch fixes the problem by adjusting the pre-run fetch to use the
new modules system. We fetch the dependencies to the cache so that when
they're needed within the environment, they are present and there's no
need to use the proxy.
2019-10-19 13:06:26 +01:00
Alberto Bertogli
5102007687 test: Adjust docker test to msmtp being a setgid binary
The golang image has been updated to use Debian buster. In that version,
msmtp is now setgid, which means glibc sanitizes the environment before
forking and $HOSTALIASES will be ignored, which breaks the tests.

This patch works around the problem by removing the setgid bit from
msmtp.
2019-08-04 04:55:01 +01:00
Alberto Bertogli
dd7cfaebf2 test: Use minidns in the Docker tests
The integration tests depend on having a DNS server that resolves
"localhost", which is unfortunate but currently unavoidable given
glibc's limitations ($HOSTALIASES only works on DNS-level aliases, and
does not do lookups in /etc/hosts).

Even under docker, this makes the tests depend on the DNS server, and
whether it resolves localhost or not.

In order to make the docker tests more hermetic and isolated from the
environment, this patch introduces a docker entrypoint that, within the
container, will launch minidns and override /etc/resolv.conf to use it.

This guarantees that the tests will be able to resolve localhost, and
also avoid accidental reliance on external DNS zones.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
57f5a09901 test: Replace dnsmasq with minidns
This commit replaces test/t-14-tls_tracking usage of dnsmasq (an
external test dependency) with our new minidns.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
d0c7c3d40a tests: Reorder Dockerfile statements to allow caching
Docker creates intermediate layers on each command (for most commands),
but the COPY was invalidating them too early, every time it runs it was
generating a different layer.

This patch moves the COPY down to the bottom, and adds a bit more
organization to the commands below.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
4ecc5461d3 Add driusan/dkim integration example and tests
This patch adds DKIM signing using https://github.com/driusan/dkim tools
to the example hook.

It also adds an optional integration test to exercise signing and
verification, and corresponding documentation.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
029bca7013 test: Add TLS tracking integration test
This patch adds a new test, which verifies the TLS tracking.

Because we need to simulate SPF records, and Go does not support fully
intercepting DNS lookups yet, this test relies on dnsmasq to provide a
DNS resolver.

In the future, once Go supports DNS lookup interception, we can get rid
of this additional dependency.
2018-06-02 19:31:28 +01:00
Alberto Bertogli
9ef481633a test: Add Dockerfile
This patch adds a Docker configuration file, to build an image that can
run the integration and stress tests.

It might be used for configuring automated testing infrastructure in
subsequent patches.
2018-03-27 08:37:11 +01:00