tests: Add test coverage for custom parameter support

This commit is contained in:
Brennan Kinney 2024-05-02 17:59:05 +12:00 committed by GitHub
parent d7e92b6953
commit 400b1fd90c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View File

@ -2,3 +2,6 @@ max_idle = 600s
# this is a comment
# this is also a comment
readme_directory = /tmp
# This parameter is referenced by an override in `postfix-master.cf`:
custom_parameter = cidr:{{!172.16.0.42 REJECT}}, permit_sasl_authenticated, reject

View File

@ -1,3 +1,6 @@
submission/inet/smtpd_sasl_security_options=noanonymous
# this is a test comment, please don't delete me :'(
# this is also a test comment, :O
# `postfix-main.cf` must be processed first before this custom parameter is in scope:
submission/inet/smtpd_client_restrictions=$custom_parameter

View File

@ -15,6 +15,9 @@ function setup_file() {
function teardown_file() { _default_teardown ; }
# The `postconf` command can query both `main.cf` and `master.cf` at `/etc/postfix/`.
# Reference: http://www.postfix.org/postconf.1.html
@test "Postfix - 'postfix-main.cf' overrides applied to '/etc/postfix/main.cf'" {
_run_in_container grep -q 'max_idle = 600s' /tmp/docker-mailserver/postfix-main.cf
assert_success
@ -37,6 +40,20 @@ function teardown_file() { _default_teardown ; }
assert_output --partial '-o smtpd_sasl_security_options=noanonymous'
}
# Custom parameter support works correctly:
@test "Postfix - 'postfix-main.cf' should apply before 'postfix-master.cf'" {
# Retrieve the value for this setting, `postfix-master.cf` should have the override set:
_run_in_container postconf -Ph 'submission/inet/smtpd_client_restrictions'
assert_success
asset_output '$custom_parameter'
# As it's a custom parameter ($ prefix), ensure the parameters value is correctly configured:
_run_in_container postconf -Phx 'submission/inet/smtpd_client_restrictions'
assert_success
assert_output 'cidr:{{!172.16.0.42 REJECT}}, permit_sasl_authenticated, reject'
refute_output 'postconf: warning: /etc/postfix/master.cf: undefined parameter: custom_parameter'
}
@test "Dovecot - 'dovecot.cf' overrides applied to '/etc/dovecot/local.conf'" {
_run_in_container grep -q 'mail_max_userip_connections = 69' /tmp/docker-mailserver/dovecot.cf
assert_success