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