Skip to content

Commit 683e35d

Browse files
authored
Merge pull request #114 from Perceptyx/add-map-types-test
feat(maps): add more map types and tests
2 parents d6a0601 + e3970df commit 683e35d

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

postfix/config.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ postfix_{{ domain }}_ssl_key:
117117
{%- if not file_path.startswith('/') %}
118118
{%- set file_path = postfix.config_path ~ '/' ~ file_path %}
119119
{%- endif %}
120-
{%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm", "regexp") %}
120+
{%- if file_type in ("btree", "cdb", "cidr", "dbm", "hash", "pcre", "regexp", "sdbm") %}
121121
{%- set need_postmap = True %}
122122
{%- endif %}
123123
postfix_{{ mapping }}:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
control 'Postfix map types' do
4+
title 'maps types are generated properly'
5+
6+
# CIDR
7+
describe command('postmap -q "192.168.0.0/16" /etc/postfix/check_cidr') do
8+
its('stdout') { should eq "REJECT\n" }
9+
its('exit_status') { should eq 0 }
10+
end
11+
12+
# PCRE
13+
describe command(
14+
'postmap -q "/^(?!owner-)(.*)-outgoing@(.*)/" /etc/postfix/check_pcre'
15+
) do
16+
its('stdout') { should eq "550 Use ${1}@${2} instead\n" }
17+
its('exit_status') { should eq 0 }
18+
end
19+
20+
# REGEXP
21+
describe command('postmap -q "/[%!@].*[%!@]/" /etc/postfix/check_client_access') do
22+
its('stdout') { should eq "550 Sender-specified routing rejected\n" }
23+
its('exit_status') { should eq 0 }
24+
end
25+
end

test/salt/pillar/default.sls

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ postfix:
6060
local_recipient_maps: $virtual_mailbox_maps
6161
transport_maps: hash:/etc/postfix/transport
6262

63+
# Other map types
64+
check_client_access_maps: regexp:/etc/postfix/check_client_access
65+
check_cidr_maps: cidr:/etc/postfix/check_cidr
66+
check_pcre_maps: pcre:/etc/postfix/check_pcre
67+
6368
# SMTP server
6469
smtpd_tls_session_cache_database: btree:${data_directory}/smtpd_scache
6570
smtpd_use_tls: 'yes'
@@ -158,3 +163,21 @@ postfix:
158163
159164
160165
- singlealiasexample: [email protected]
166+
167+
check_client_access_maps:
168+
- '/[%!@].*[%!@]/':
169+
- 550 Sender-specified routing rejected
170+
171+
check_cidr_maps:
172+
- '192.168.1.1':
173+
- OK
174+
- '192.168.0.0/16':
175+
- REJECT
176+
- '2001:db8::1':
177+
- OK
178+
- '2001:db8::/32':
179+
- REJECT
180+
181+
check_pcre_maps:
182+
- '/^(?!owner-)(.*)-outgoing@(.*)/':
183+
- 550 Use ${1}@${2} instead

0 commit comments

Comments
 (0)