docker-mailserver/test
Brennan Kinney 1b1877f025
refactor: letsencrypt implicit location discovery (#2525)
* chore: Extract letsencrypt logic into methods

This allows other scripts to share the functionality to discover the correct letsencrypt folder from the 3 possible locations (where specific order is important).

As these methods should now return a string value, the `return 1` after a panic is now dropped.

* chore: Update comments

The todo is resolved with this PR, `_setup_ssl` will be called by both cert conditional statements with purpose for each better documented to maintainers at the start of the logic block.

* refactor: Defer most logic to helper/ssl.sh

The loop is no longer required, extraction is delegated to `_setup_ssl` now.

For the change event prevention, we retrieve the relevant FQDN via the new helper method, beyond that it's just indentation diff.

`check-for-changes.sh` adjusted to allow locally scoped var declarations by wrapping a function. Presently no loop control flow is needed so this seems fine. Made it clear that `CHANGED` is local and `CHKSUM_FILE` is not.

Panic scope doesn't require `SSL_TYPE` for context, it's clearly`letsencrypt`.

* fix: Correctly match wildcard results

Now that the service configs are properly updated, when the services restart they will return a cert with the SAN `DNS:*.example.test`,  which is valid for `mail.example.test`, however the test function did not properly account for this in the regexp query.

Resolved by truncating the left-most DNS label from FQDN and adding a third check to match a returned wildcard DNS result.

Extracted out the common logic to create the regexp query and renamed the methods to communicate more clearly that they check the FQDN is supported, not necessarily explicitly listed by the cert.

* tests(letsencrypt): Enable remaining tests

These will now pass. Adjusted comments accordingly.

Added an additional test on a fake FQDN that should still be valid to a wildcard cert (SNI validation in a proper setup would reject the connection afterwards).

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2022-04-18 22:52:50 +12:00
..
bats@54e965fa9d Revert "check-for-changes: performance improvements + wait for settle (#2104)" 2021-08-28 19:16:34 -04:00
config firewall: replace iptables with nftables (#2505) 2022-04-05 15:13:59 +02:00
docker-openldap formatting files according to standard (#1619) 2020-09-24 14:54:21 +02:00
linting ${@:+$@} -> ${@} 2022-03-08 18:32:15 -05:00
test-files tests(chore): Adjust supported FQDNs in test certs + add wildcard and acme.json configs (#2284) 2021-11-03 20:25:25 +00:00
test_helper refactor: letsencrypt implicit location discovery (#2525) 2022-04-18 22:52:50 +12:00
default_relay_host.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
dovecot_inet_protocol.bats Introduce DOVECOT_INET_PROTOCOLS env (#2358) 2022-01-06 00:53:18 +01:00
helper-functions.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_changedetector.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_disabled_clamav_spamassassin.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_dnsbl.bats Introduce ENABLE_DNSBL env (#2342) 2022-01-03 22:03:46 +01:00
mail_fail2ban.bats firewall: replace iptables with nftables (#2505) 2022-04-05 15:13:59 +02:00
mail_fetchmail.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_fetchmail_parallel.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_hostname.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_lmtp_ip.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_pop3.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_postfix_inet.bats Catch errors on config duplication command 2020-10-20 09:33:47 +02:00
mail_postscreen.bats tests: remove legacy functions / tests (#2434) 2022-03-02 14:55:17 +01:00
mail_privacy.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_quotas_disabled.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_smtponly.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_spam_bounced.bats PERMIT_DOCKER=none as new default value (#2424) 2022-03-02 16:03:40 +01:00
mail_spam_junk_folder.bats PERMIT_DOCKER=none as new default value (#2424) 2022-03-02 16:03:40 +01:00
mail_special_use_folders.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_ssl_letsencrypt.bats refactor: letsencrypt implicit location discovery (#2525) 2022-04-18 22:52:50 +12:00
mail_ssl_manual.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_time.bats scripts: added TZ environment variable to set timezone (#2530) 2022-04-06 16:48:41 +02:00
mail_tls_dhparams.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_undef_spam_subject.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_imap.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_ldap.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_mdbox.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_postgrey.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_postgrey_disabled_by_default.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_relays.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
mail_with_sdbox.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
no_container.bats setup.sh: docker_container first, then fall back to docker_image (#2134) 2021-09-06 10:13:12 +00:00
open_dkim.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
permit_docker.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
security_tls_cipherlists.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
sedfile.bats scripts: introduce _log to sedfile (#2507) 2022-04-02 15:52:30 +02:00
test_helper.bats Introduce CLAMAV_MESSAGE_SIZE_LIMIT env (#2453) 2022-03-03 16:17:01 +01:00
tests.bats scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00