root / spec / classes / snat4_spec.rb @ e4c32222
Historique | Voir | Annoter | Télécharger (3,58 ko)
1 |
require 'spec_helper'
|
---|---|
2 |
|
3 |
describe 'nftables' do |
4 |
let(:pre_condition) { 'Exec{path => "/bin"}' } |
5 |
|
6 |
on_supported_os.each do |os, os_facts|
|
7 |
context "on #{os}" do |
8 |
let(:facts) { os_facts }
|
9 |
|
10 |
context 'with snat4' do |
11 |
let(:pre_condition) do |
12 |
'
|
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\';
|
32 |
}
|
33 |
'
|
34 |
end
|
35 |
|
36 |
it { is_expected.to compile } |
37 |
|
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 |
} |
103 |
end
|
104 |
end
|
105 |
end
|
106 |
end
|