Révision c82b960a
rubocop:auto_correct results
spec/classes/ip_nat_spec.rb | ||
---|---|---|
1 |
# frozen_string_literal: true |
|
2 |
|
|
1 | 3 |
require 'spec_helper' |
2 | 4 |
|
3 | 5 |
describe 'nftables' do |
... | ... | |
10 | 12 |
it { is_expected.to compile } |
11 | 13 |
|
12 | 14 |
it { |
13 |
is_expected.to contain_concat('nftables-ip-nat').with(
|
|
14 |
path: '/etc/nftables/puppet-preflight/ip-nat.nft',
|
|
15 |
expect(subject).to contain_concat('nftables-ip-nat').with(
|
|
16 |
path: '/etc/nftables/puppet-preflight/ip-nat.nft', |
|
15 | 17 |
ensure: 'present', |
16 |
owner: 'root',
|
|
17 |
group: 'root',
|
|
18 |
mode: '0640'
|
|
18 |
owner: 'root', |
|
19 |
group: 'root', |
|
20 |
mode: '0640' |
|
19 | 21 |
) |
20 | 22 |
} |
21 | 23 |
|
22 | 24 |
it { |
23 |
is_expected.to contain_concat__fragment('nftables-ip-nat-header').with(
|
|
24 |
target: 'nftables-ip-nat',
|
|
25 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-header').with(
|
|
26 |
target: 'nftables-ip-nat', |
|
25 | 27 |
content: %r{^table ip nat \{$}, |
26 |
order: '00'
|
|
28 |
order: '00' |
|
27 | 29 |
) |
28 | 30 |
} |
29 | 31 |
|
30 | 32 |
it { |
31 |
is_expected.to contain_concat__fragment('nftables-ip-nat-body').with(
|
|
32 |
target: 'nftables-ip-nat',
|
|
33 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-body').with(
|
|
34 |
target: 'nftables-ip-nat', |
|
33 | 35 |
content: %r{^\s+include "ip-nat-chain-\*\.nft"$}, |
34 |
order: '98'
|
|
36 |
order: '98' |
|
35 | 37 |
) |
36 | 38 |
} |
37 | 39 |
|
38 | 40 |
it { |
39 |
is_expected.to contain_concat__fragment('nftables-ip-nat-footer').with(
|
|
40 |
target: 'nftables-ip-nat',
|
|
41 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-footer').with(
|
|
42 |
target: 'nftables-ip-nat', |
|
41 | 43 |
content: %r{^\}$}, |
42 |
order: '99'
|
|
44 |
order: '99' |
|
43 | 45 |
) |
44 | 46 |
} |
45 | 47 |
|
46 | 48 |
it { |
47 |
is_expected.to contain_concat('nftables-ip6-nat').with(
|
|
48 |
path: '/etc/nftables/puppet-preflight/ip6-nat.nft',
|
|
49 |
expect(subject).to contain_concat('nftables-ip6-nat').with(
|
|
50 |
path: '/etc/nftables/puppet-preflight/ip6-nat.nft', |
|
49 | 51 |
ensure: 'present', |
50 |
owner: 'root',
|
|
51 |
group: 'root',
|
|
52 |
mode: '0640'
|
|
52 |
owner: 'root', |
|
53 |
group: 'root', |
|
54 |
mode: '0640' |
|
53 | 55 |
) |
54 | 56 |
} |
55 | 57 |
|
56 | 58 |
it { |
57 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-header').with(
|
|
58 |
target: 'nftables-ip6-nat',
|
|
59 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-header').with(
|
|
60 |
target: 'nftables-ip6-nat', |
|
59 | 61 |
content: %r{^table ip6 nat \{$}, |
60 |
order: '00'
|
|
62 |
order: '00' |
|
61 | 63 |
) |
62 | 64 |
} |
63 | 65 |
|
64 | 66 |
it { |
65 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-body').with(
|
|
66 |
target: 'nftables-ip6-nat',
|
|
67 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-body').with(
|
|
68 |
target: 'nftables-ip6-nat', |
|
67 | 69 |
content: %r{^\s+include "ip6-nat-chain-\*\.nft"$}, |
68 |
order: '98'
|
|
70 |
order: '98' |
|
69 | 71 |
) |
70 | 72 |
} |
71 | 73 |
|
72 | 74 |
it { |
73 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-footer').with(
|
|
74 |
target: 'nftables-ip6-nat',
|
|
75 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-footer').with(
|
|
76 |
target: 'nftables-ip6-nat', |
|
75 | 77 |
content: %r{^\}$}, |
76 |
order: '99'
|
|
78 |
order: '99' |
|
77 | 79 |
) |
78 | 80 |
} |
79 | 81 |
|
80 | 82 |
context 'table ip nat chain prerouting' do |
81 | 83 |
it { |
82 |
is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
|
|
83 |
path: '/etc/nftables/puppet-preflight/ip-nat-chain-PREROUTING.nft',
|
|
84 |
owner: 'root',
|
|
85 |
group: 'root',
|
|
86 |
mode: '0640',
|
|
84 |
expect(subject).to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
|
|
85 |
path: '/etc/nftables/puppet-preflight/ip-nat-chain-PREROUTING.nft', |
|
86 |
owner: 'root', |
|
87 |
group: 'root', |
|
88 |
mode: '0640', |
|
87 | 89 |
ensure_newline: true |
88 | 90 |
) |
89 | 91 |
} |
92 |
|
|
90 | 93 |
it { |
91 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with(
|
|
92 |
target: 'nftables-ip-nat-chain-PREROUTING',
|
|
94 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with(
|
|
95 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
93 | 96 |
content: %r{^chain PREROUTING \{$}, |
94 |
order: '00'
|
|
97 |
order: '00' |
|
95 | 98 |
) |
96 | 99 |
} |
100 |
|
|
97 | 101 |
it { |
98 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
|
|
99 |
target: 'nftables-ip-nat-chain-PREROUTING',
|
|
102 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
|
|
103 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
100 | 104 |
content: %r{^ type nat hook prerouting priority -100$}, |
101 |
order: '01-nftables-ip-nat-chain-PREROUTING-rule-type-b'
|
|
105 |
order: '01-nftables-ip-nat-chain-PREROUTING-rule-type-b' |
|
102 | 106 |
) |
103 | 107 |
} |
108 |
|
|
104 | 109 |
it { |
105 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
|
|
106 |
target: 'nftables-ip-nat-chain-PREROUTING',
|
|
110 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
|
|
111 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
107 | 112 |
content: %r{^ policy accept$}, |
108 |
order: '02-nftables-ip-nat-chain-PREROUTING-rule-policy-b'
|
|
113 |
order: '02-nftables-ip-nat-chain-PREROUTING-rule-policy-b' |
|
109 | 114 |
) |
110 | 115 |
} |
116 |
|
|
111 | 117 |
it { |
112 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
|
|
113 |
target: 'nftables-ip-nat-chain-PREROUTING',
|
|
118 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
|
|
119 |
target: 'nftables-ip-nat-chain-PREROUTING', |
|
114 | 120 |
content: %r{^\}$}, |
115 |
order: '99'
|
|
121 |
order: '99' |
|
116 | 122 |
) |
117 | 123 |
} |
118 | 124 |
end |
119 | 125 |
|
120 | 126 |
context 'table ip nat chain postrouting' do |
121 | 127 |
it { |
122 |
is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
|
123 |
path: '/etc/nftables/puppet-preflight/ip-nat-chain-POSTROUTING.nft',
|
|
124 |
owner: 'root',
|
|
125 |
group: 'root',
|
|
126 |
mode: '0640',
|
|
128 |
expect(subject).to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
|
129 |
path: '/etc/nftables/puppet-preflight/ip-nat-chain-POSTROUTING.nft', |
|
130 |
owner: 'root', |
|
131 |
group: 'root', |
|
132 |
mode: '0640', |
|
127 | 133 |
ensure_newline: true |
128 | 134 |
) |
129 | 135 |
} |
136 |
|
|
130 | 137 |
it { |
131 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
|
132 |
target: 'nftables-ip-nat-chain-POSTROUTING',
|
|
138 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
|
139 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
133 | 140 |
content: %r{^chain POSTROUTING \{$}, |
134 |
order: '00'
|
|
141 |
order: '00' |
|
135 | 142 |
) |
136 | 143 |
} |
144 |
|
|
137 | 145 |
it { |
138 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
|
139 |
target: 'nftables-ip-nat-chain-POSTROUTING',
|
|
146 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
|
147 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
140 | 148 |
content: %r{^ type nat hook postrouting priority 100$}, |
141 |
order: '01-nftables-ip-nat-chain-POSTROUTING-rule-type-b'
|
|
149 |
order: '01-nftables-ip-nat-chain-POSTROUTING-rule-type-b' |
|
142 | 150 |
) |
143 | 151 |
} |
152 |
|
|
144 | 153 |
it { |
145 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
|
146 |
target: 'nftables-ip-nat-chain-POSTROUTING',
|
|
154 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
|
155 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
147 | 156 |
content: %r{^ policy accept$}, |
148 |
order: '02-nftables-ip-nat-chain-POSTROUTING-rule-policy-b'
|
|
157 |
order: '02-nftables-ip-nat-chain-POSTROUTING-rule-policy-b' |
|
149 | 158 |
) |
150 | 159 |
} |
160 |
|
|
151 | 161 |
it { |
152 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
|
153 |
target: 'nftables-ip-nat-chain-POSTROUTING',
|
|
162 |
expect(subject).to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
|
163 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
|
154 | 164 |
content: %r{^\}$}, |
155 |
order: '99'
|
|
165 |
order: '99' |
|
156 | 166 |
) |
157 | 167 |
} |
158 | 168 |
end |
159 | 169 |
|
160 | 170 |
context 'table ip6 nat chain prerouting' do |
161 | 171 |
it { |
162 |
is_expected.to contain_concat('nftables-ip6-nat-chain-PREROUTING6').with(
|
|
163 |
path: '/etc/nftables/puppet-preflight/ip6-nat-chain-PREROUTING6.nft',
|
|
164 |
owner: 'root',
|
|
165 |
group: 'root',
|
|
166 |
mode: '0640',
|
|
172 |
expect(subject).to contain_concat('nftables-ip6-nat-chain-PREROUTING6').with(
|
|
173 |
path: '/etc/nftables/puppet-preflight/ip6-nat-chain-PREROUTING6.nft', |
|
174 |
owner: 'root', |
|
175 |
group: 'root', |
|
176 |
mode: '0640', |
|
167 | 177 |
ensure_newline: true |
168 | 178 |
) |
169 | 179 |
} |
180 |
|
|
170 | 181 |
it { |
171 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-header').with(
|
|
172 |
target: 'nftables-ip6-nat-chain-PREROUTING6',
|
|
182 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-header').with(
|
|
183 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
|
173 | 184 |
content: %r{^chain PREROUTING6 \{$}, |
174 |
order: '00'
|
|
185 |
order: '00' |
|
175 | 186 |
) |
176 | 187 |
} |
188 |
|
|
177 | 189 |
it { |
178 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-type').with(
|
|
179 |
target: 'nftables-ip6-nat-chain-PREROUTING6',
|
|
190 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-type').with(
|
|
191 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
|
180 | 192 |
content: %r{^ type nat hook prerouting priority -100$}, |
181 |
order: '01-nftables-ip6-nat-chain-PREROUTING6-rule-type-b'
|
|
193 |
order: '01-nftables-ip6-nat-chain-PREROUTING6-rule-type-b' |
|
182 | 194 |
) |
183 | 195 |
} |
196 |
|
|
184 | 197 |
it { |
185 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-policy').with(
|
|
186 |
target: 'nftables-ip6-nat-chain-PREROUTING6',
|
|
198 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-policy').with(
|
|
199 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
|
187 | 200 |
content: %r{^ policy accept$}, |
188 |
order: '02-nftables-ip6-nat-chain-PREROUTING6-rule-policy-b'
|
|
201 |
order: '02-nftables-ip6-nat-chain-PREROUTING6-rule-policy-b' |
|
189 | 202 |
) |
190 | 203 |
} |
204 |
|
|
191 | 205 |
it { |
192 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-footer').with(
|
|
193 |
target: 'nftables-ip6-nat-chain-PREROUTING6',
|
|
206 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-footer').with(
|
|
207 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
|
194 | 208 |
content: %r{^\}$}, |
195 |
order: '99'
|
|
209 |
order: '99' |
|
196 | 210 |
) |
197 | 211 |
} |
198 | 212 |
end |
199 | 213 |
|
200 | 214 |
context 'table ip nat chain postrouting' do |
201 | 215 |
it { |
202 |
is_expected.to contain_concat('nftables-ip6-nat-chain-POSTROUTING6').with(
|
|
203 |
path: '/etc/nftables/puppet-preflight/ip6-nat-chain-POSTROUTING6.nft',
|
|
204 |
owner: 'root',
|
|
205 |
group: 'root',
|
|
206 |
mode: '0640',
|
|
216 |
expect(subject).to contain_concat('nftables-ip6-nat-chain-POSTROUTING6').with(
|
|
217 |
path: '/etc/nftables/puppet-preflight/ip6-nat-chain-POSTROUTING6.nft', |
|
218 |
owner: 'root', |
|
219 |
group: 'root', |
|
220 |
mode: '0640', |
|
207 | 221 |
ensure_newline: true |
208 | 222 |
) |
209 | 223 |
} |
224 |
|
|
210 | 225 |
it { |
211 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-header').with(
|
|
212 |
target: 'nftables-ip6-nat-chain-POSTROUTING6',
|
|
226 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-header').with(
|
|
227 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
|
213 | 228 |
content: %r{^chain POSTROUTING6 \{$}, |
214 |
order: '00'
|
|
229 |
order: '00' |
|
215 | 230 |
) |
216 | 231 |
} |
232 |
|
|
217 | 233 |
it { |
218 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-type').with(
|
|
219 |
target: 'nftables-ip6-nat-chain-POSTROUTING6',
|
|
234 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-type').with(
|
|
235 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
|
220 | 236 |
content: %r{^ type nat hook postrouting priority 100$}, |
221 |
order: '01-nftables-ip6-nat-chain-POSTROUTING6-rule-type-b'
|
|
237 |
order: '01-nftables-ip6-nat-chain-POSTROUTING6-rule-type-b' |
|
222 | 238 |
) |
223 | 239 |
} |
240 |
|
|
224 | 241 |
it { |
225 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-policy').with(
|
|
226 |
target: 'nftables-ip6-nat-chain-POSTROUTING6',
|
|
242 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-policy').with(
|
|
243 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
|
227 | 244 |
content: %r{^ policy accept$}, |
228 |
order: '02-nftables-ip6-nat-chain-POSTROUTING6-rule-policy-b'
|
|
245 |
order: '02-nftables-ip6-nat-chain-POSTROUTING6-rule-policy-b' |
|
229 | 246 |
) |
230 | 247 |
} |
248 |
|
|
231 | 249 |
it { |
232 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-footer').with(
|
|
233 |
target: 'nftables-ip6-nat-chain-POSTROUTING6',
|
|
250 |
expect(subject).to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-footer').with(
|
|
251 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
|
234 | 252 |
content: %r{^\}$}, |
235 |
order: '99'
|
|
253 |
order: '99' |
|
236 | 254 |
) |
237 | 255 |
} |
238 | 256 |
end |
... | ... | |
245 | 263 |
end |
246 | 264 |
|
247 | 265 |
it { is_expected.to compile } |
266 |
|
|
248 | 267 |
it { |
249 |
is_expected.to contain_concat('nftables-ip-mycustomtablename').with(
|
|
250 |
path: '/etc/nftables/puppet-preflight/ip-mycustomtablename.nft',
|
|
268 |
expect(subject).to contain_concat('nftables-ip-mycustomtablename').with(
|
|
269 |
path: '/etc/nftables/puppet-preflight/ip-mycustomtablename.nft', |
|
251 | 270 |
ensure: 'present', |
252 |
owner: 'root',
|
|
253 |
group: 'root',
|
|
254 |
mode: '0640'
|
|
271 |
owner: 'root', |
|
272 |
group: 'root', |
|
273 |
mode: '0640' |
|
255 | 274 |
) |
256 | 275 |
} |
257 | 276 |
end |
Formats disponibles : Unified diff