diff --git a/postfix/config.sls b/postfix/config.sls index 64ad2f8..6c522fc 100644 --- a/postfix/config.sls +++ b/postfix/config.sls @@ -117,7 +117,7 @@ postfix_{{ domain }}_ssl_key: {%- if not file_path.startswith('/') %} {%- set file_path = postfix.config_path ~ '/' ~ file_path %} {%- endif %} - {%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm", "regexp") %} + {%- if file_type in ("btree", "cdb", "cidr", "dbm", "hash", "pcre", "regexp", "sdbm") %} {%- set need_postmap = True %} {%- endif %} postfix_{{ mapping }}: diff --git a/test/integration/default/controls/postfix_maps_type_spec.rb b/test/integration/default/controls/postfix_maps_type_spec.rb new file mode 100644 index 0000000..edfee69 --- /dev/null +++ b/test/integration/default/controls/postfix_maps_type_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +control 'Postfix map types' do + title 'maps types are generated properly' + + # CIDR + describe command('postmap -q "192.168.0.0/16" /etc/postfix/check_cidr') do + its('stdout') { should eq "REJECT\n" } + its('exit_status') { should eq 0 } + end + + # PCRE + describe command( + 'postmap -q "/^(?!owner-)(.*)-outgoing@(.*)/" /etc/postfix/check_pcre' + ) do + its('stdout') { should eq "550 Use ${1}@${2} instead\n" } + its('exit_status') { should eq 0 } + end + + # REGEXP + describe command('postmap -q "/[%!@].*[%!@]/" /etc/postfix/check_client_access') do + its('stdout') { should eq "550 Sender-specified routing rejected\n" } + its('exit_status') { should eq 0 } + end +end diff --git a/test/salt/pillar/default.sls b/test/salt/pillar/default.sls index 997e736..26fe152 100644 --- a/test/salt/pillar/default.sls +++ b/test/salt/pillar/default.sls @@ -60,6 +60,11 @@ postfix: local_recipient_maps: $virtual_mailbox_maps transport_maps: hash:/etc/postfix/transport + # Other map types + check_client_access_maps: regexp:/etc/postfix/check_client_access + check_cidr_maps: cidr:/etc/postfix/check_cidr + check_pcre_maps: pcre:/etc/postfix/check_pcre + # SMTP server smtpd_tls_session_cache_database: btree:${data_directory}/smtpd_scache smtpd_use_tls: 'yes' @@ -158,3 +163,21 @@ postfix: - someuser_1@example.com - someuser_2@example.com - singlealiasexample: someuser_3@example.com + + check_client_access_maps: + - '/[%!@].*[%!@]/': + - 550 Sender-specified routing rejected + + check_cidr_maps: + - '192.168.1.1': + - OK + - '192.168.0.0/16': + - REJECT + - '2001:db8::1': + - OK + - '2001:db8::/32': + - REJECT + + check_pcre_maps: + - '/^(?!owner-)(.*)-outgoing@(.*)/': + - 550 Use ${1}@${2} instead