From 2443dfc208eaf528b17abab867f2bc7265e757cd Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sat, 7 Jun 2025 11:36:09 +0100 Subject: [PATCH] test: Support Dovecot 2.4 in the integration tests Dovecot 2.4 has a new configuration format, which is unfortunately backwards-incompatible with Dovecot 2.3. This patch adds a 2.4-compatible config, and selects which one to use based on the Dovecot version in the environment. In the future, once 2.4 becomes more common, we will drop the 2.3 config from the test. Note that we don't change the config used in the Docker image, because that is based on Debian **stable** which is still on 2.3. --- .../{dovecot.conf.in => dovecot.conf-2.3.in} | 0 test/t-11-dovecot/config/dovecot.conf-2.4.in | 48 +++++++++++++++++++ test/t-11-dovecot/run.sh | 18 ++++++- 3 files changed, 65 insertions(+), 1 deletion(-) rename test/t-11-dovecot/config/{dovecot.conf.in => dovecot.conf-2.3.in} (100%) create mode 100644 test/t-11-dovecot/config/dovecot.conf-2.4.in diff --git a/test/t-11-dovecot/config/dovecot.conf.in b/test/t-11-dovecot/config/dovecot.conf-2.3.in similarity index 100% rename from test/t-11-dovecot/config/dovecot.conf.in rename to test/t-11-dovecot/config/dovecot.conf-2.3.in diff --git a/test/t-11-dovecot/config/dovecot.conf-2.4.in b/test/t-11-dovecot/config/dovecot.conf-2.4.in new file mode 100644 index 0000000..857525e --- /dev/null +++ b/test/t-11-dovecot/config/dovecot.conf-2.4.in @@ -0,0 +1,48 @@ +dovecot_config_version = 2.4.0 +dovecot_storage_version = 2.4.0 + +base_dir = $ROOT/run/ +state_dir = $ROOT/lib/ +log_path = $ROOT/dovecot.log +ssl = no + +default_internal_user = $USER +default_internal_group = $USER +default_login_user = $USER + + +# Disable authentication penalty, since we intentionally make failed requests +# and it just slows down tests. +auth_failure_delay = 0 + +passdb passwd-file { + passwd_file_path = $ROOT/passwd + + # Before auth checks, rename "u@d" to "u-x". This exercises that chasquid + # handles well the case where the returned user information does not match the + # requested user. + # We drop the domain, to exercise "naked" auth handling. + auth_username_format = "%{user | username}-x" +} + +userdb passwd-file { + passwd_file_path = $ROOT/passwd + + # Same as for passdb applies here. + # Note we can't change the _global_ variant of this setting, because + # that influences the top-level lookups. + auth_username_format = "%{user | username}-x" +} + +service auth { + unix_listener auth { + mode = 0666 + } +} + +# Turn on debugging information, to help troubleshooting issues. +auth_verbose = yes +log_debug = category=auth +auth_debug_passwords = yes +auth_verbose_passwords = yes +mail_debug = yes diff --git a/test/t-11-dovecot/run.sh b/test/t-11-dovecot/run.sh index 7fda6de..72d2cd1 100755 --- a/test/t-11-dovecot/run.sh +++ b/test/t-11-dovecot/run.sh @@ -25,8 +25,24 @@ export ROOT="/tmp/chasquid-dovecot-test" mkdir -p $ROOT $ROOT/run $ROOT/lib rm -f $ROOT/dovecot.log +# Dovecot 2.4 config is not backwards compatible with 2.3. +# Since for now both are popular, we support testing against either. +# TODO: Remove 2.3 support once 2.4 becomes more common. +case "$(dovecot --version | cut -d . -f 1-2)" in +2.3) + DOVE_VER=2.3 + ;; +2.4) + DOVE_VER=2.4 + ;; +*) + skip "unknown dovecot version $(dovecot --version)" + ;; +esac + + GROUP=$(id -g -n) envsubst \ - < config/dovecot.conf.in > $ROOT/dovecot.conf + < config/dovecot.conf-$DOVE_VER.in > $ROOT/dovecot.conf cp -f config/passwd $ROOT/passwd dovecot -F -c $ROOT/dovecot.conf &