Révision d78c1613
Add spec tests for router functionality
spec/classes/router_spec.rb | ||
---|---|---|
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 "as router" do |
|
11 |
let(:pre_condition) { |
|
12 |
""" |
|
13 |
# inet-filter-chain-default_fwd |
|
14 |
nftables::rule{ |
|
15 |
'default_fwd-out': |
|
16 |
order => '20', |
|
17 |
content => 'iifname eth1 oifname eth0 accept'; |
|
18 |
'default_fwd-drop': |
|
19 |
order => '90', |
|
20 |
content => 'iifname eth0 drop'; |
|
21 |
'POSTROUTING-masquerade': |
|
22 |
table => 'ip-nat', |
|
23 |
order => '20', |
|
24 |
content => 'oifname eth0 masquerade'; |
|
25 |
} |
|
26 |
""" |
|
27 |
} |
|
28 |
|
|
29 |
it { is_expected.to compile } |
|
30 |
|
|
31 |
it { is_expected.to contain_concat('nftables-inet-filter-chain-default_fwd').with( |
|
32 |
:path => '/etc/nftables/puppet/inet-filter-chain-default_fwd.nft', |
|
33 |
:owner => 'root', |
|
34 |
:group => 'root', |
|
35 |
:mode => '0640', |
|
36 |
:ensure_newline => true, |
|
37 |
)} |
|
38 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-header').with( |
|
39 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
40 |
:content => /^chain default_fwd {$/, |
|
41 |
:order => '00', |
|
42 |
)} |
|
43 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-out').with( |
|
44 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
45 |
:content => /^ iifname eth1 oifname eth0 accept$/, |
|
46 |
:order => '20', |
|
47 |
)} |
|
48 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-drop').with( |
|
49 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
50 |
:content => /^ iifname eth0 drop$/, |
|
51 |
:order => '90', |
|
52 |
)} |
|
53 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-footer').with( |
|
54 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
55 |
:content => /^}$/, |
|
56 |
:order => '99', |
|
57 |
)} |
|
58 |
|
|
59 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with( |
|
60 |
:path => '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
|
61 |
:owner => 'root', |
|
62 |
:group => 'root', |
|
63 |
:mode => '0640', |
|
64 |
:ensure_newline => true, |
|
65 |
)} |
|
66 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with( |
|
67 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
68 |
:content => /^chain POSTROUTING {$/, |
|
69 |
:order => '00', |
|
70 |
)} |
|
71 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with( |
|
72 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
73 |
:content => /^ type nat hook postrouting priority 100$/, |
|
74 |
:order => '01', |
|
75 |
)} |
|
76 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with( |
|
77 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
78 |
:content => /^ policy accept$/, |
|
79 |
:order => '02', |
|
80 |
)} |
|
81 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-masquerade').with( |
|
82 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
83 |
:content => /^ oifname eth0 masquerade$/, |
|
84 |
:order => '20', |
|
85 |
)} |
|
86 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with( |
|
87 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
88 |
:content => /^}$/, |
|
89 |
:order => '99', |
|
90 |
)} |
|
91 |
end |
|
92 |
end |
|
93 |
end |
|
94 |
end |
Formats disponibles : Unified diff