Révision 01d8a819
Styling to make tests green
spec/classes/snat4_spec.rb | ||
---|---|---|
9 | 9 |
|
10 | 10 |
context 'with snat4' do |
11 | 11 |
let(:pre_condition) do |
12 |
"""
|
|
12 |
'
|
|
13 | 13 |
nftables::rules::snat4{ |
14 |
'static':
|
|
15 |
order => '60',
|
|
16 |
snat => '198.51.100.1',
|
|
17 |
oif => 'eth0';
|
|
18 |
'1_1':
|
|
19 |
order => '61',
|
|
20 |
saddr => '192.0.2.2',
|
|
21 |
snat => '198.51.100.3',
|
|
22 |
oif => 'eth0';
|
|
23 |
'1_1_smtp':
|
|
24 |
saddr => '192.0.2.2',
|
|
25 |
snat => '198.51.100.2',
|
|
26 |
dport => '25';
|
|
27 |
'1_1_wireguard':
|
|
28 |
saddr => '192.0.2.2',
|
|
29 |
snat => '198.51.100.2',
|
|
30 |
proto => 'udp',
|
|
31 |
dport => '51820';
|
|
14 |
\'static\':
|
|
15 |
order => \'60\',
|
|
16 |
snat => \'198.51.100.1\',
|
|
17 |
oif => \'eth0\';
|
|
18 |
\'1_1\':
|
|
19 |
order => \'61\',
|
|
20 |
saddr => \'192.0.2.2\',
|
|
21 |
snat => \'198.51.100.3\',
|
|
22 |
oif => \'eth0\';
|
|
23 |
\'1_1_smtp\':
|
|
24 |
saddr => \'192.0.2.2\',
|
|
25 |
snat => \'198.51.100.2\',
|
|
26 |
dport => \'25\';
|
|
27 |
\'1_1_wireguard\':
|
|
28 |
saddr => \'192.0.2.2\',
|
|
29 |
snat => \'198.51.100.2\',
|
|
30 |
proto => \'udp\',
|
|
31 |
dport => \'51820\';
|
|
32 | 32 |
} |
33 |
"""
|
|
33 |
'
|
|
34 | 34 |
end |
35 | 35 |
|
36 | 36 |
it { is_expected.to compile } |
37 | 37 |
|
38 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with( |
|
39 |
:path => '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
|
40 |
:owner => 'root', |
|
41 |
:group => 'root', |
|
42 |
:mode => '0640', |
|
43 |
:ensure_newline => true, |
|
44 |
)} |
|
45 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with( |
|
46 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
47 |
:content => /^chain POSTROUTING {$/, |
|
48 |
:order => '00', |
|
49 |
)} |
|
50 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with( |
|
51 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
52 |
:content => /^ type nat hook postrouting priority 100$/, |
|
53 |
:order => '01', |
|
54 |
)} |
|
55 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with( |
|
56 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
57 |
:content => /^ policy accept$/, |
|
58 |
:order => '02', |
|
59 |
)} |
|
60 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-static').with( |
|
61 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
62 |
:content => /^ oifname eth0 snat 198\.51\.100\.1$/, |
|
63 |
:order => '60', |
|
64 |
)} |
|
65 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1').with( |
|
66 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
67 |
:content => /^ oifname eth0 ip saddr 192\.0\.2\.2 snat 198\.51\.100\.3$/, |
|
68 |
:order => '61', |
|
69 |
)} |
|
70 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1_smtp').with( |
|
71 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
72 |
:content => /^ ip saddr 192\.0\.2\.2 tcp dport 25 snat 198\.51\.100\.2$/, |
|
73 |
:order => '70', |
|
74 |
)} |
|
75 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1_wireguard').with( |
|
76 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
77 |
:content => /^ ip saddr 192\.0\.2\.2 udp dport 51820 snat 198\.51\.100\.2$/, |
|
78 |
:order => '70', |
|
79 |
)} |
|
80 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with( |
|
81 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
82 |
:content => /^}$/, |
|
83 |
:order => '99', |
|
84 |
)} |
|
38 |
it { |
|
39 |
is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with( |
|
40 |
path: '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
|
41 |
owner: 'root', |
|
42 |
group: 'root', |
|
43 |
mode: '0640', |
|
44 |
ensure_newline: true, |
|
45 |
) |
|
46 |
} |
|
47 |
it { |
|
48 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with( |
|
49 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
50 |
content: %r{^chain POSTROUTING \{$}, |
|
51 |
order: '00', |
|
52 |
) |
|
53 |
} |
|
54 |
it { |
|
55 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with( |
|
56 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
57 |
content: %r{^ type nat hook postrouting priority 100$}, |
|
58 |
order: '01', |
|
59 |
) |
|
60 |
} |
|
61 |
it { |
|
62 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with( |
|
63 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
64 |
content: %r{^ policy accept$}, |
|
65 |
order: '02', |
|
66 |
) |
|
67 |
} |
|
68 |
it { |
|
69 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-static').with( |
|
70 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
71 |
content: %r{^ oifname eth0 snat 198\.51\.100\.1$}, |
|
72 |
order: '60', |
|
73 |
) |
|
74 |
} |
|
75 |
it { |
|
76 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1').with( |
|
77 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
78 |
content: %r{^ oifname eth0 ip saddr 192\.0\.2\.2 snat 198\.51\.100\.3$}, |
|
79 |
order: '61', |
|
80 |
) |
|
81 |
} |
|
82 |
it { |
|
83 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1_smtp').with( |
|
84 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
85 |
content: %r{^ ip saddr 192\.0\.2\.2 tcp dport 25 snat 198\.51\.100\.2$}, |
|
86 |
order: '70', |
|
87 |
) |
|
88 |
} |
|
89 |
it { |
|
90 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1_wireguard').with( |
|
91 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
92 |
content: %r{^ ip saddr 192\.0\.2\.2 udp dport 51820 snat 198\.51\.100\.2$}, |
|
93 |
order: '70', |
|
94 |
) |
|
95 |
} |
|
96 |
it { |
|
97 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with( |
|
98 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
99 |
content: %r{^\}$}, |
|
100 |
order: '99', |
|
101 |
) |
|
102 |
} |
|
85 | 103 |
end |
86 | 104 |
end |
87 | 105 |
end |
Formats disponibles : Unified diff