docker-mailserver/test/tests/parallel/set3/container_configuration/hostname.bats

259 lines
9 KiB
Plaintext
Raw Normal View History

tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
load "${REPOSITORY_ROOT}/test/helper/common"
load "${REPOSITORY_ROOT}/test/helper/setup"
BATS_TEST_NAME_PREFIX='[Network - Hostname] '
CONTAINER1_NAME='dms-test_hostname_fqdn-with-subdomain'
CONTAINER2_NAME='dms-test_hostname_bare-domain'
CONTAINER3_NAME='dms-test_hostname_env-override-hostname'
CONTAINER4_NAME='dms-test_hostname_with-nis-domain'
CONTAINER5_NAME='dms-test_hostname_env-srs-domainname'
# NOTE: Required until postsrsd package updated:
# `--ulimit` is a workaround for some environments when using ENABLE_SRS=1:
# PR 2730: https://github.com/docker-mailserver/docker-mailserver/commit/672e9cf19a3bb1da309e8cea6ee728e58f905366
function teardown() { _default_teardown ; }
@test "should update configuration correctly (Standard FQDN setup)" {
export CONTAINER_NAME="${CONTAINER1_NAME}"
# Should be using the default `--hostname mail.example.test`
local CUSTOM_SETUP_ARGUMENTS=(
--env ENABLE_AMAVIS=1
--env ENABLE_SRS=1
--env PERMIT_DOCKER='container'
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
)
_init_with_defaults
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
_wait_for_smtp_port_in_container
_should_have_expected_hostname 'mail.example.test'
_should_be_configured_to_domainname 'example.test'
_should_be_configured_to_fqdn 'mail.example.test'
_should_have_correct_mail_headers 'mail.example.test' 'example.test'
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
@test "should update configuration correctly (Bare Domain)" {
export CONTAINER_NAME="${CONTAINER2_NAME}"
tests: Ensure excessive FD limits are avoided (#2730) * tests: Ensure excessive FD limits are avoided Processes that run as daemons (`postsrsd` and `fail2ban-server`) initialize by closing all FDs (File Descriptors). This behaviour queries that maximum limit and iterates through the entire range even if only a few FDs are open. In some environments (Docker, limit configured by distro) this can be a range exceeding 1 billion (from kernel default of 1024 soft, 4096 hard), causing an 8 minute delay with heavy CPU activity. `postsrsd` has since been updated to use `close_range()` syscall, and `fail2ban` will now iterate through `/proc/self/fd` (open FDs) which should resolve the performance hit. Until those updates reach our Docker image, we need to workaround it with `--ulimit` option. NOTE: If `docker.service` on a distro sets `LimitNOFILE=` to approx 1 million or lower, it should not be an issue. On distros such as Fedora 36, it is `LimitNOFILE=infinity` (approx 1 billion) that causes excessive delays. * chore: Use Docker host limits instead Typically on modern distros with systemd, this should equate to 1024 (soft) and 512K (hard) limits. A distro may override the built-in global defaults systemd sets via setting `DefaultLimitNOFILE=` in `/etc/systemd/user.conf` and `/etc/systemd/system.conf`. * tests(fix): Better prevent non-deterministic failures - `no_containers.bats` tests the external script `setup.sh` (without `-c`). It's expected that no existing DMS container is running - otherwise it may attempt to use that container and fail. Detect this and fail early via `setup_file()` step. - `mail_hostname.bats` had a odd timing failure with teardown due to the last tests bringing the containers down earlier (`docker stop` paired with the `docker run --rm`). Adding a moment of delay via `sleep` helps avoid that false positive scenario.
2022-08-22 23:24:23 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
local CUSTOM_SETUP_ARGUMENTS=(
--hostname 'bare-domain.test'
--env ENABLE_AMAVIS=1
--env ENABLE_SRS=1
--env PERMIT_DOCKER='container'
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
)
_init_with_defaults
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
_wait_for_smtp_port_in_container
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_should_have_expected_hostname 'bare-domain.test'
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_should_be_configured_to_domainname 'bare-domain.test'
# Bare domain configured, thus no subdomain:
_should_be_configured_to_fqdn 'bare-domain.test'
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_should_have_correct_mail_headers 'bare-domain.test'
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
@test "should update configuration correctly (ENV OVERRIDE_HOSTNAME)" {
export CONTAINER_NAME="${CONTAINER3_NAME}"
local CUSTOM_SETUP_ARGUMENTS=(
--hostname 'original.example.test'
--env OVERRIDE_HOSTNAME='mail.override.test'
--env ENABLE_AMAVIS=1
--env ENABLE_SRS=1
--env PERMIT_DOCKER='container'
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
)
_init_with_defaults
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
_wait_for_smtp_port_in_container
# Should be the original `--hostname` (`hostname -f`), not `OVERRIDE_HOSTNAME`:
_should_have_expected_hostname 'original.example.test'
_should_be_configured_to_domainname 'override.test'
_should_be_configured_to_fqdn 'mail.override.test'
_should_have_correct_mail_headers 'mail.override.test' 'override.test' 'original.example.test'
# Container hostname should not be found in received mail (due to `OVERRIDE_HOSTNAME`):
_run_in_container grep -R 'original.example.test' /var/mail/localhost.localdomain/user1/new/
assert_failure
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
@test "should update configuration correctly (--hostname + --domainname)" {
export CONTAINER_NAME="${CONTAINER4_NAME}"
local CUSTOM_SETUP_ARGUMENTS=(
--hostname 'mail'
--domainname 'example.test'
--env ENABLE_AMAVIS=1
--env ENABLE_SRS=1
--env PERMIT_DOCKER='container'
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
)
_init_with_defaults
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
_wait_for_smtp_port_in_container
# Differs from the first test case, matches exact `--hostname` value:
_should_have_expected_hostname 'mail'
_should_be_configured_to_domainname 'example.test'
_should_be_configured_to_fqdn 'mail.example.test'
# Likewise `--hostname` value will always match the third parameter:
_should_have_correct_mail_headers 'mail.example.test' 'example.test' 'mail'
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# This test is purely for testing the ENV `SRS_DOMAINNAME` (not relevant to these tests?)
@test "should give priority to ENV in postsrsd config (ENV SRS_DOMAINNAME)" {
export CONTAINER_NAME="${CONTAINER5_NAME}"
local CUSTOM_SETUP_ARGUMENTS=(
--hostname 'mail'
--domainname 'example.test'
--env ENABLE_SRS=1
--env SRS_DOMAINNAME='srs.example.test'
--env PERMIT_DOCKER='container'
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)"
)
_init_with_defaults
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
# PostSRSd should be configured correctly:
_run_in_container grep '^SRS_DOMAIN=' /etc/default/postsrsd
assert_output "SRS_DOMAIN=srs.example.test"
assert_success
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
function _should_have_expected_hostname() {
local EXPECTED_FQDN=${1}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_run_in_container "hostname"
assert_output "${EXPECTED_FQDN}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_run_in_container grep -E "[[:space:]]+${EXPECTED_FQDN}" /etc/hosts
assert_success
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
function _should_be_configured_to_domainname() {
local EXPECTED_DOMAIN=${1}
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# setup-stack.sh:_setup_mailname
_run_in_container cat /etc/mailname
assert_output "${EXPECTED_DOMAIN}"
assert_success
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Postfix
_run_in_container postconf mydomain
assert_output "mydomain = ${EXPECTED_DOMAIN}"
assert_success
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# PostSRSd
_run_in_container grep '^SRS_DOMAIN=' /etc/default/postsrsd
assert_output "SRS_DOMAIN=${EXPECTED_DOMAIN}"
assert_success
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Dovecot
_run_in_container grep '^postmaster_address' /etc/dovecot/conf.d/15-lda.conf
assert_output "postmaster_address = postmaster@${EXPECTED_DOMAIN}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
}
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
function _should_be_configured_to_fqdn() {
local EXPECTED_FQDN=${1}
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Postfix
_run_in_container postconf myhostname
assert_output "myhostname = ${EXPECTED_FQDN}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Postfix HELO message should contain FQDN (hostname)
_run_in_container nc -w 1 0.0.0.0 25
assert_output --partial "220 ${EXPECTED_FQDN} ESMTP"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Dovecot
_run_in_container doveconf hostname
assert_output "hostname = ${EXPECTED_FQDN}"
assert_success
tests(fix): Adjust for local testing conditions (#2606) * tests(fix): Increase some timeouts Running tests locally via a VM these tests would fail sometimes due to the time from being queued and Amavis actually processing being roughly around 30 seconds. There should be no harm in raising this to 60 seconds, other than delaying a failure case which will ripple through other time sensitive tests. It's better to pass when functionality is actually correct but just needs a bit longer to complete. * tests(fix): Don't setup an invalid hostname During container startup `helpers/dns.sh` would panic with `hostname -f` failing. Dropping `--domainname` for this container is fine and does not affect the point of it's test. --- It's unclear why this does not occur in CI. Possibly changes within the docker daemon since as CI runs docker on Ubuntu 20.04? (2020). For clarity, this may be equivalent to setting a hostname of `domain.com.domain.com`, or `--hostname` value truncated the NIS domain (`--domainname`) of the same value. IIRC, it would still fail with both options using different values if `--hostname` was multi-label. I believe I've documented how non-deterministic these options can be across different environments. `--hostname` should be preferred. There doesn't seem to be any reason to actually need `--domainname` (which is NIS domain name, unrelated to the DNS domain name). We still need to properly investigate reworking our ENV support that `dns.sh` manages. --- Containers were also not removing themselves after failures either (missing teardown). Which would cause problems when running tests again. * chore: Normalize white-space Sets a consistent indent size of 2 spaces. Previously this varied a fair bit, sometimes with tabs or mixed tabs and spaces. Some formatting with blank lines. Easier to review with white-space in diff ignored. Some minor edits besides blank lines, but no change in functionality. * fix: `setup.sh` target container under test Some of the `setup.sh` commands did not specify the container which was problematic if another `docker-mailserver` container was running, causing test failures. This probably doesn't help with `test/no_container.bats`, but at least prevents `test/tests.bats` failing at this point.
2022-05-30 00:53:30 +00:00
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# OpenDMARC
_run_in_container grep '^AuthservID' /etc/opendmarc.conf
assert_output --partial " ${EXPECTED_FQDN}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_run_in_container grep '^TrustedAuthservIDs' /etc/opendmarc.conf
assert_output --partial " ${EXPECTED_FQDN}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Amavis
_run_in_container grep '^\$myhostname' /etc/amavis/conf.d/05-node_id
assert_output "\$myhostname = \"${EXPECTED_FQDN}\";"
assert_success
}
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
function _should_have_correct_mail_headers() {
local EXPECTED_FQDN=${1}
# NOTE: The next two params should not differ for bare domains:
local EXPECTED_DOMAINPART=${2:-${EXPECTED_FQDN}}
# Required when EXPECTED_FQDN would not match the container hostname:
# (eg: OVERRIDE_HOSTNAME or `--hostname mail --domainname example.test`)
local EXPECTED_HOSTNAME=${3:-${EXPECTED_FQDN}}
2023-02-24 09:44:18 +00:00
_send_email 'email-templates/existing-user1'
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
_wait_for_empty_mail_queue_in_container
_count_files_in_directory_in_container '/var/mail/localhost.localdomain/user1/new/' '1'
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# MTA hostname (sender?) is used in filename of stored mail:
local MAIL_FILEPATH=$(_exec_in_container find /var/mail/localhost.localdomain/user1/new -maxdepth 1 -type f)
run echo "${MAIL_FILEPATH}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
assert_output --partial ".${EXPECTED_HOSTNAME},"
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
# Mail headers should contain EXPECTED_FQDN for lines Received + by + Message-Id
# For `ENABLE_SRS=1`, EXPECTED_DOMAINPART should match lines Return-Path + envelope-from
_run_in_container cat "${MAIL_FILEPATH}"
assert_success
tests(refactor): `mail_hostname.bats` (#3027) * chore: Use a common method to check domain and fqdn config * chore: Shift other test cases into shared test methods * chore: Add another shared method for checking mail headers * chore: Add another shared method for checking hostname * refactor: Improve quality of shared test methods Based on changes from an earlier closed hostname PR from Oct 2021 with additional revision to use `assert_output` and more thorough checking of values expected in output. * chore: Move clean shutdown test to `process-check-restart.bats` This was originally a single test case in `tests.bats` intended for `supervisord` testing. It seems at some point it got reassigned to a hostname override test container, and then migrated to separate test file for hostname override test by accident. It now belongs in the correct place again, as hostname config should have nothing to do with a graceful shutdown? * chore: Prepare for migrating to use `test/helper/setup.bash` * chore: Rename containers and configured FQDN settings * chore: Convert to using common container setup helpers Wait for SMTP port is left at the end to avoid additional start-up delays. * chore: Use `_run_in_container_bash` helper * chore: Be more specific on matching mail headers - I could do multiple container grep calls instead, but opted to match by lines in file. This better ensures values are being matched to the correct lines. - Renamed the test case descriptions. - Expanded test coverage of the 4th container as it represents another DNS config, while the 3rd is just the 4th container with the `SRS_DOMAINNAME` env added, no value in more coverage there. * chore: Remove redundant test coverage in `tests.bats` These checks are performed in `mail_hostname.bats` with better coverage. * chore: Move each containers setup into it's own test-case instead * chore: Re-arrange container name IDs The original `fqdn-with-subdomain` is now `with-nis-domain` which is more accurate. A new test case will properly cover the default `--hostname` only config that is not a bare domain. * chore: Re-arrange test cases to align with new ID ordering This commit just shifts the test cases, no new changes to any content beyond that. * chore: Add new test case for default config * chore: Review feedback `_run_in_container_bash` to `_run_in_container` Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> * chore: Additional review feedback - Fix a suggested change bug with quote wrapping an interpolated variable. - Convert two other `_bash` methods that were missed from review. - Apply the last two suggested changes from review. * chore: `_exec_in_container_bash` to `_exec_in_container` The `| head -n 1` can be dropped if we know for sure it's only one line, which is what we expect. Quotes can then be dropped too. --------- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-01-29 12:34:14 +00:00
assert_line --index 0 --partial 'Return-Path: <SRS0='
assert_line --index 0 --partial "@${EXPECTED_DOMAINPART}>"
# Passed on from Postfix to Dovecot via LMTP:
assert_line --index 2 --partial "Received: from ${EXPECTED_FQDN}"
assert_line --index 3 --partial "by ${EXPECTED_FQDN} with LMTP"
assert_line --index 5 --partial '(envelope-from <SRS0='
assert_line --index 5 --partial "@${EXPECTED_DOMAINPART}>"
# Arrived via Postfix:
# NOTE: The first `localhost` in this line would actually be `mail.external.tld`,
# but Amavis is changing that. It also changes protocol from SMTP to ESMTP.
assert_line --index 7 --partial 'Received: from localhost (localhost [127.0.0.1])'
assert_line --index 8 --partial "by ${EXPECTED_FQDN} (Postfix) with ESMTP id"
assert_line --index 14 --partial 'Message-Id:'
assert_line --index 14 --partial "@${EXPECTED_FQDN}>"
# Mail contents example:
#
# Return-Path: <SRS0=Smtf=5T=external.tld=user@example.test>
# Delivered-To: user1@localhost.localdomain
# Received: from mail.example.test
# by mail.example.test with LMTP
# id jvJfJk23zGPeBgAAUi6ngw
# (envelope-from <SRS0=Smtf=5T=external.tld=user@example.test>)
# for <user1@localhost.localdomain>; Sun, 22 Jan 2023 04:10:53 +0000
# Received: from localhost (localhost [127.0.0.1])
# by mail.example.test (Postfix) with ESMTP id 8CFC4C30F9C4
# for <user1@localhost.localdomain>; Sun, 22 Jan 2023 04:10:53 +0000 (UTC)
# From: Docker Mail Server <dockermailserver@external.tld>
# To: Existing Local User <user1@localhost.localdomain>
# Date: Sat, 22 May 2010 07:43:25 -0400
# Subject: Test Message existing-user1.txt
# Message-Id: <20230122041053.5A5F1C2F608E@mail.example.test>
#
# This is a test mail.
}