Révision 01d8a819
Styling to make tests green
spec/classes/router_spec.rb | ||
---|---|---|
9 | 9 |
|
10 | 10 |
context 'as router' do |
11 | 11 |
let(:pre_condition) do |
12 |
"""
|
|
12 |
'
|
|
13 | 13 |
# inet-filter-chain-default_fwd |
14 | 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';
|
|
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 | 21 |
} |
22 | 22 |
|
23 | 23 |
nftables::rules::masquerade{ |
24 |
'masquerade':
|
|
25 |
order => '20',
|
|
26 |
oif => 'eth0';
|
|
24 |
\'masquerade\':
|
|
25 |
order => \'20\',
|
|
26 |
oif => \'eth0\';
|
|
27 | 27 |
} |
28 |
"""
|
|
28 |
'
|
|
29 | 29 |
end |
30 | 30 |
|
31 | 31 |
it { is_expected.to compile } |
32 | 32 |
|
33 |
it { is_expected.to contain_concat('nftables-inet-filter-chain-default_fwd').with( |
|
34 |
:path => '/etc/nftables/puppet/inet-filter-chain-default_fwd.nft', |
|
35 |
:owner => 'root', |
|
36 |
:group => 'root', |
|
37 |
:mode => '0640', |
|
38 |
:ensure_newline => true, |
|
39 |
)} |
|
40 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-header').with( |
|
41 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
42 |
:content => /^chain default_fwd {$/, |
|
43 |
:order => '00', |
|
44 |
)} |
|
45 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-out').with( |
|
46 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
47 |
:content => /^ iifname eth1 oifname eth0 accept$/, |
|
48 |
:order => '20', |
|
49 |
)} |
|
50 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-drop').with( |
|
51 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
52 |
:content => /^ iifname eth0 drop$/, |
|
53 |
:order => '90', |
|
54 |
)} |
|
55 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-footer').with( |
|
56 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
57 |
:content => /^}$/, |
|
58 |
:order => '99', |
|
59 |
)} |
|
33 |
it { |
|
34 |
is_expected.to contain_concat('nftables-inet-filter-chain-default_fwd').with( |
|
35 |
path: '/etc/nftables/puppet/inet-filter-chain-default_fwd.nft', |
|
36 |
owner: 'root', |
|
37 |
group: 'root', |
|
38 |
mode: '0640', |
|
39 |
ensure_newline: true, |
|
40 |
) |
|
41 |
} |
|
42 |
it { |
|
43 |
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-header').with( |
|
44 |
target: 'nftables-inet-filter-chain-default_fwd', |
|
45 |
content: %r{^chain default_fwd \{$}, |
|
46 |
order: '00', |
|
47 |
) |
|
48 |
} |
|
49 |
it { |
|
50 |
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-out').with( |
|
51 |
target: 'nftables-inet-filter-chain-default_fwd', |
|
52 |
content: %r{^ iifname eth1 oifname eth0 accept$}, |
|
53 |
order: '20', |
|
54 |
) |
|
55 |
} |
|
56 |
it { |
|
57 |
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-drop').with( |
|
58 |
target: 'nftables-inet-filter-chain-default_fwd', |
|
59 |
content: %r{^ iifname eth0 drop$}, |
|
60 |
order: '90', |
|
61 |
) |
|
62 |
} |
|
63 |
it { |
|
64 |
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-footer').with( |
|
65 |
target: 'nftables-inet-filter-chain-default_fwd', |
|
66 |
content: %r{^\}$}, |
|
67 |
order: '99', |
|
68 |
) |
|
69 |
} |
|
60 | 70 |
|
61 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with( |
|
62 |
:path => '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft', |
|
63 |
:owner => 'root', |
|
64 |
:group => 'root', |
|
65 |
:mode => '0640', |
|
66 |
:ensure_newline => true, |
|
67 |
)} |
|
68 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with( |
|
69 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
70 |
:content => /^chain PREROUTING {$/, |
|
71 |
:order => '00', |
|
72 |
)} |
|
73 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with( |
|
74 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
75 |
:content => /^ type nat hook prerouting priority -100$/, |
|
76 |
:order => '01', |
|
77 |
)} |
|
78 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with( |
|
79 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
80 |
:content => /^ policy accept$/, |
|
81 |
:order => '02', |
|
82 |
)} |
|
83 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with( |
|
84 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
85 |
:content => /^}$/, |
|
86 |
:order => '99', |
|
87 |
)} |
|
71 |
it { |
|
72 |
is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with( |
|
73 |
path: '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft', |
|
74 |
owner: 'root', |
|
75 |
group: 'root', |
|
76 |
mode: '0640', |
|
77 |
ensure_newline: true, |
|
78 |
) |
|
79 |
} |
|
80 |
it { |
|
81 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with( |
|
82 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
83 |
content: %r{^chain PREROUTING \{$}, |
|
84 |
order: '00', |
|
85 |
) |
|
86 |
} |
|
87 |
it { |
|
88 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with( |
|
89 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
90 |
content: %r{^ type nat hook prerouting priority -100$}, |
|
91 |
order: '01', |
|
92 |
) |
|
93 |
} |
|
94 |
it { |
|
95 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with( |
|
96 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
97 |
content: %r{^ policy accept$}, |
|
98 |
order: '02', |
|
99 |
) |
|
100 |
} |
|
101 |
it { |
|
102 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with( |
|
103 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
104 |
content: %r{^\}$}, |
|
105 |
order: '99', |
|
106 |
) |
|
107 |
} |
|
88 | 108 |
|
89 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with( |
|
90 |
:path => '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
|
91 |
:owner => 'root', |
|
92 |
:group => 'root', |
|
93 |
:mode => '0640', |
|
94 |
:ensure_newline => true, |
|
95 |
)} |
|
96 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with( |
|
97 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
98 |
:content => /^chain POSTROUTING {$/, |
|
99 |
:order => '00', |
|
100 |
)} |
|
101 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with( |
|
102 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
103 |
:content => /^ type nat hook postrouting priority 100$/, |
|
104 |
:order => '01', |
|
105 |
)} |
|
106 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with( |
|
107 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
108 |
:content => /^ policy accept$/, |
|
109 |
:order => '02', |
|
110 |
)} |
|
111 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-masquerade').with( |
|
112 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
113 |
:content => /^ oifname eth0 masquerade$/, |
|
114 |
:order => '20', |
|
115 |
)} |
|
116 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with( |
|
117 |
:target => 'nftables-ip-nat-chain-POSTROUTING', |
|
118 |
:content => /^}$/, |
|
119 |
:order => '99', |
|
120 |
)} |
|
109 |
it { |
|
110 |
is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with( |
|
111 |
path: '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
|
112 |
owner: 'root', |
|
113 |
group: 'root', |
|
114 |
mode: '0640', |
|
115 |
ensure_newline: true, |
|
116 |
) |
|
117 |
} |
|
118 |
it { |
|
119 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with( |
|
120 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
121 |
content: %r{^chain POSTROUTING \{$}, |
|
122 |
order: '00', |
|
123 |
) |
|
124 |
} |
|
125 |
it { |
|
126 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with( |
|
127 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
128 |
content: %r{^ type nat hook postrouting priority 100$}, |
|
129 |
order: '01', |
|
130 |
) |
|
131 |
} |
|
132 |
it { |
|
133 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with( |
|
134 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
135 |
content: %r{^ policy accept$}, |
|
136 |
order: '02', |
|
137 |
) |
|
138 |
} |
|
139 |
it { |
|
140 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-masquerade').with( |
|
141 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
142 |
content: %r{^ oifname eth0 masquerade$}, |
|
143 |
order: '20', |
|
144 |
) |
|
145 |
} |
|
146 |
it { |
|
147 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with( |
|
148 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
149 |
content: %r{^\}$}, |
|
150 |
order: '99', |
|
151 |
) |
|
152 |
} |
|
121 | 153 |
end |
122 | 154 |
end |
123 | 155 |
end |
Formats disponibles : Unified diff