Merge pull request #114 from Perceptyx/add-map-types-test

feat(maps): add more map types and tests
This commit is contained in:
Imran Iqbal 2020-07-20 09:51:20 +01:00 committed by GitHub
commit 683e35d6ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 1 deletions

View File

@ -117,7 +117,7 @@ postfix_{{ domain }}_ssl_key:
{%- if not file_path.startswith('/') %} {%- if not file_path.startswith('/') %}
{%- set file_path = postfix.config_path ~ '/' ~ file_path %} {%- set file_path = postfix.config_path ~ '/' ~ file_path %}
{%- endif %} {%- 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 %} {%- set need_postmap = True %}
{%- endif %} {%- endif %}
postfix_{{ mapping }}: postfix_{{ mapping }}:

View File

@ -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

View File

@ -60,6 +60,11 @@ postfix:
local_recipient_maps: $virtual_mailbox_maps local_recipient_maps: $virtual_mailbox_maps
transport_maps: hash:/etc/postfix/transport 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 # SMTP server
smtpd_tls_session_cache_database: btree:${data_directory}/smtpd_scache smtpd_tls_session_cache_database: btree:${data_directory}/smtpd_scache
smtpd_use_tls: 'yes' smtpd_use_tls: 'yes'
@ -158,3 +163,21 @@ postfix:
- someuser_1@example.com - someuser_1@example.com
- someuser_2@example.com - someuser_2@example.com
- singlealiasexample: someuser_3@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