root / spec / classes / snat4_spec.rb @ 3d29a6eb
Historique | Voir | Annoter | Télécharger (3,37 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 { 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 |
)} |
85 |
end
|
86 |
end
|
87 |
end
|
88 |
end
|