root / spec / classes / router_spec.rb @ 95b1259b
Historique | Voir | Annoter | Télécharger (4,98 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 "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-PREROUTING').with(
|
60 |
:path => '/etc/nftables/puppet/ip-nat-chain-PREROUTING.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-PREROUTING-header').with(
|
67 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
68 |
:content => /^chain PREROUTING {$/, |
69 |
:order => '00', |
70 |
)} |
71 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
|
72 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
73 |
:content => /^ type nat hook prerouting priority -100$/, |
74 |
:order => '01', |
75 |
)} |
76 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
|
77 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
78 |
:content => /^ policy accept$/, |
79 |
:order => '02', |
80 |
)} |
81 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
|
82 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
83 |
:content => /^}$/, |
84 |
:order => '99', |
85 |
)} |
86 |
|
87 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
88 |
:path => '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
89 |
:owner => 'root', |
90 |
:group => 'root', |
91 |
:mode => '0640', |
92 |
:ensure_newline => true, |
93 |
)} |
94 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
95 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
96 |
:content => /^chain POSTROUTING {$/, |
97 |
:order => '00', |
98 |
)} |
99 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
100 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
101 |
:content => /^ type nat hook postrouting priority 100$/, |
102 |
:order => '01', |
103 |
)} |
104 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
105 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
106 |
:content => /^ policy accept$/, |
107 |
:order => '02', |
108 |
)} |
109 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-masquerade').with(
|
110 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
111 |
:content => /^ oifname eth0 masquerade$/, |
112 |
:order => '20', |
113 |
)} |
114 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
115 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
116 |
:content => /^}$/, |
117 |
:order => '99', |
118 |
)} |
119 |
end
|
120 |
end
|
121 |
end
|
122 |
end
|