|
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-inet-filter').with(
|
14 |
|
path: '/etc/nftables/puppet-preflight/inet-filter.nft',
|
|
15 |
expect(subject).to contain_concat('nftables-inet-filter').with(
|
|
16 |
path: '/etc/nftables/puppet-preflight/inet-filter.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-inet-filter-header').with(
|
24 |
|
target: 'nftables-inet-filter',
|
|
25 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-header').with(
|
|
26 |
target: 'nftables-inet-filter',
|
25 |
27 |
content: %r{^table inet filter \{$},
|
26 |
|
order: '00'
|
|
28 |
order: '00'
|
27 |
29 |
)
|
28 |
30 |
}
|
29 |
31 |
|
30 |
32 |
it {
|
31 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-body').with(
|
32 |
|
target: 'nftables-inet-filter',
|
33 |
|
order: '98'
|
|
33 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-body').with(
|
|
34 |
target: 'nftables-inet-filter',
|
|
35 |
order: '98'
|
34 |
36 |
)
|
35 |
37 |
}
|
36 |
38 |
|
37 |
39 |
it {
|
38 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-footer').with(
|
39 |
|
target: 'nftables-inet-filter',
|
|
40 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-footer').with(
|
|
41 |
target: 'nftables-inet-filter',
|
40 |
42 |
content: %r{^\}$},
|
41 |
|
order: '99'
|
|
43 |
order: '99'
|
42 |
44 |
)
|
43 |
45 |
}
|
44 |
46 |
|
45 |
47 |
context 'chain input' do
|
46 |
48 |
it {
|
47 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-INPUT').with(
|
48 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-INPUT.nft',
|
49 |
|
owner: 'root',
|
50 |
|
group: 'root',
|
51 |
|
mode: '0640',
|
|
49 |
expect(subject).to contain_concat('nftables-inet-filter-chain-INPUT').with(
|
|
50 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-INPUT.nft',
|
|
51 |
owner: 'root',
|
|
52 |
group: 'root',
|
|
53 |
mode: '0640',
|
52 |
54 |
ensure_newline: true
|
53 |
55 |
)
|
54 |
56 |
}
|
|
57 |
|
55 |
58 |
it {
|
56 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-header').with(
|
57 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
59 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-header').with(
|
|
60 |
target: 'nftables-inet-filter-chain-INPUT',
|
58 |
61 |
content: %r{^chain INPUT \{$},
|
59 |
|
order: '00'
|
|
62 |
order: '00'
|
60 |
63 |
)
|
61 |
64 |
}
|
|
65 |
|
62 |
66 |
it {
|
63 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-type').with(
|
64 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
67 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-type').with(
|
|
68 |
target: 'nftables-inet-filter-chain-INPUT',
|
65 |
69 |
content: %r{^ type filter hook input priority 0$},
|
66 |
|
order: '01-nftables-inet-filter-chain-INPUT-rule-type-b'
|
|
70 |
order: '01-nftables-inet-filter-chain-INPUT-rule-type-b'
|
67 |
71 |
)
|
68 |
72 |
}
|
|
73 |
|
69 |
74 |
it {
|
70 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-policy').with(
|
71 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
75 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-policy').with(
|
|
76 |
target: 'nftables-inet-filter-chain-INPUT',
|
72 |
77 |
content: %r{^ policy drop$},
|
73 |
|
order: '02-nftables-inet-filter-chain-INPUT-rule-policy-b'
|
|
78 |
order: '02-nftables-inet-filter-chain-INPUT-rule-policy-b'
|
74 |
79 |
)
|
75 |
80 |
}
|
|
81 |
|
76 |
82 |
it {
|
77 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-lo').with(
|
78 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
83 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-lo').with(
|
|
84 |
target: 'nftables-inet-filter-chain-INPUT',
|
79 |
85 |
content: %r{^ iifname lo accept$},
|
80 |
|
order: '03-nftables-inet-filter-chain-INPUT-rule-lo-b'
|
|
86 |
order: '03-nftables-inet-filter-chain-INPUT-rule-lo-b'
|
81 |
87 |
)
|
82 |
88 |
}
|
|
89 |
|
83 |
90 |
it {
|
84 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-jump_global').with(
|
85 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
91 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-jump_global').with(
|
|
92 |
target: 'nftables-inet-filter-chain-INPUT',
|
86 |
93 |
content: %r{^ jump global$},
|
87 |
|
order: '04-nftables-inet-filter-chain-INPUT-rule-jump_global-b'
|
|
94 |
order: '04-nftables-inet-filter-chain-INPUT-rule-jump_global-b'
|
88 |
95 |
)
|
89 |
96 |
}
|
|
97 |
|
90 |
98 |
it {
|
91 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related').with(
|
92 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
99 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related').with(
|
|
100 |
target: 'nftables-inet-filter-chain-INPUT',
|
93 |
101 |
content: %r{^ ct state established,related accept$},
|
94 |
|
order: '05-nftables-inet-filter-chain-INPUT-rule-accept_established_related-b'
|
|
102 |
order: '05-nftables-inet-filter-chain-INPUT-rule-accept_established_related-b'
|
95 |
103 |
)
|
96 |
104 |
}
|
|
105 |
|
97 |
106 |
it {
|
98 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid').with(
|
99 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
107 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid').with(
|
|
108 |
target: 'nftables-inet-filter-chain-INPUT',
|
100 |
109 |
content: %r{^ ct state invalid drop$},
|
101 |
|
order: '06-nftables-inet-filter-chain-INPUT-rule-drop_invalid-b'
|
|
110 |
order: '06-nftables-inet-filter-chain-INPUT-rule-drop_invalid-b'
|
102 |
111 |
)
|
103 |
112 |
}
|
|
113 |
|
104 |
114 |
it {
|
105 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-jump_default_in').with(
|
106 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
115 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-jump_default_in').with(
|
|
116 |
target: 'nftables-inet-filter-chain-INPUT',
|
107 |
117 |
content: %r{^ jump default_in$},
|
108 |
|
order: '10-nftables-inet-filter-chain-INPUT-rule-jump_default_in-b'
|
|
118 |
order: '10-nftables-inet-filter-chain-INPUT-rule-jump_default_in-b'
|
109 |
119 |
)
|
110 |
120 |
}
|
|
121 |
|
111 |
122 |
it {
|
112 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
113 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
114 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \"\[nftables\] INPUT Rejected: \" flags all counter$},
|
115 |
|
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
|
123 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
|
124 |
target: 'nftables-inet-filter-chain-INPUT',
|
|
125 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix "\[nftables\] INPUT Rejected: " flags all counter$},
|
|
126 |
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
116 |
127 |
)
|
117 |
128 |
}
|
|
129 |
|
118 |
130 |
it {
|
119 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-reject').with(
|
120 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
131 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-reject').with(
|
|
132 |
target: 'nftables-inet-filter-chain-INPUT',
|
121 |
133 |
content: %r{^ reject with icmpx type port-unreachable$},
|
122 |
|
order: '98-nftables-inet-filter-chain-INPUT-rule-reject-b'
|
|
134 |
order: '98-nftables-inet-filter-chain-INPUT-rule-reject-b'
|
123 |
135 |
)
|
124 |
136 |
}
|
|
137 |
|
125 |
138 |
it {
|
126 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-footer').with(
|
127 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
139 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-footer').with(
|
|
140 |
target: 'nftables-inet-filter-chain-INPUT',
|
128 |
141 |
content: %r{^\}$},
|
129 |
|
order: '99'
|
|
142 |
order: '99'
|
130 |
143 |
)
|
131 |
144 |
}
|
132 |
145 |
|
133 |
146 |
it {
|
134 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-default_in').with(
|
135 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-default_in.nft',
|
136 |
|
owner: 'root',
|
137 |
|
group: 'root',
|
138 |
|
mode: '0640',
|
|
147 |
expect(subject).to contain_concat('nftables-inet-filter-chain-default_in').with(
|
|
148 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-default_in.nft',
|
|
149 |
owner: 'root',
|
|
150 |
group: 'root',
|
|
151 |
mode: '0640',
|
139 |
152 |
ensure_newline: true
|
140 |
153 |
)
|
141 |
154 |
}
|
|
155 |
|
142 |
156 |
it {
|
143 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_in-header').with(
|
144 |
|
target: 'nftables-inet-filter-chain-default_in',
|
|
157 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_in-header').with(
|
|
158 |
target: 'nftables-inet-filter-chain-default_in',
|
145 |
159 |
content: %r{^chain default_in \{$},
|
146 |
|
order: '00'
|
|
160 |
order: '00'
|
147 |
161 |
)
|
148 |
162 |
}
|
|
163 |
|
149 |
164 |
it {
|
150 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_in-footer').with(
|
151 |
|
target: 'nftables-inet-filter-chain-default_in',
|
|
165 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_in-footer').with(
|
|
166 |
target: 'nftables-inet-filter-chain-default_in',
|
152 |
167 |
content: %r{^\}$},
|
153 |
|
order: '99'
|
|
168 |
order: '99'
|
154 |
169 |
)
|
155 |
170 |
}
|
|
171 |
|
156 |
172 |
it {
|
157 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_in-rule-ssh').with(
|
158 |
|
target: 'nftables-inet-filter-chain-default_in',
|
|
173 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_in-rule-ssh').with(
|
|
174 |
target: 'nftables-inet-filter-chain-default_in',
|
159 |
175 |
content: %r{^ tcp dport \{22\} accept$},
|
160 |
|
order: '50-nftables-inet-filter-chain-default_in-rule-ssh-b'
|
|
176 |
order: '50-nftables-inet-filter-chain-default_in-rule-ssh-b'
|
161 |
177 |
)
|
162 |
178 |
}
|
|
179 |
|
163 |
180 |
it {
|
164 |
|
is_expected.to contain_class('nftables::rules::icmp')
|
|
181 |
expect(subject).to contain_class('nftables::rules::icmp')
|
165 |
182 |
}
|
166 |
183 |
end
|
167 |
184 |
|
168 |
185 |
context 'chain output' do
|
169 |
186 |
it {
|
170 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-OUTPUT').with(
|
171 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-OUTPUT.nft',
|
172 |
|
owner: 'root',
|
173 |
|
group: 'root',
|
174 |
|
mode: '0640',
|
|
187 |
expect(subject).to contain_concat('nftables-inet-filter-chain-OUTPUT').with(
|
|
188 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-OUTPUT.nft',
|
|
189 |
owner: 'root',
|
|
190 |
group: 'root',
|
|
191 |
mode: '0640',
|
175 |
192 |
ensure_newline: true
|
176 |
193 |
)
|
177 |
194 |
}
|
|
195 |
|
178 |
196 |
it {
|
179 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-header').with(
|
180 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
197 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-header').with(
|
|
198 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
181 |
199 |
content: %r{^chain OUTPUT \{$},
|
182 |
|
order: '00'
|
|
200 |
order: '00'
|
183 |
201 |
)
|
184 |
202 |
}
|
|
203 |
|
185 |
204 |
it {
|
186 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-type').with(
|
187 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
205 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-type').with(
|
|
206 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
188 |
207 |
content: %r{^ type filter hook output priority 0$},
|
189 |
|
order: '01-nftables-inet-filter-chain-OUTPUT-rule-type-b'
|
|
208 |
order: '01-nftables-inet-filter-chain-OUTPUT-rule-type-b'
|
190 |
209 |
)
|
191 |
210 |
}
|
|
211 |
|
192 |
212 |
it {
|
193 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-policy').with(
|
194 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
213 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-policy').with(
|
|
214 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
195 |
215 |
content: %r{^ policy drop$},
|
196 |
|
order: '02-nftables-inet-filter-chain-OUTPUT-rule-policy-b'
|
|
216 |
order: '02-nftables-inet-filter-chain-OUTPUT-rule-policy-b'
|
197 |
217 |
)
|
198 |
218 |
}
|
|
219 |
|
199 |
220 |
it {
|
200 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-lo').with(
|
201 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
221 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-lo').with(
|
|
222 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
202 |
223 |
content: %r{^ oifname lo accept$},
|
203 |
|
order: '03-nftables-inet-filter-chain-OUTPUT-rule-lo-b'
|
|
224 |
order: '03-nftables-inet-filter-chain-OUTPUT-rule-lo-b'
|
204 |
225 |
)
|
205 |
226 |
}
|
|
227 |
|
206 |
228 |
it {
|
207 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-jump_global').with(
|
208 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
229 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-jump_global').with(
|
|
230 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
209 |
231 |
content: %r{^ jump global$},
|
210 |
|
order: '04-nftables-inet-filter-chain-OUTPUT-rule-jump_global-b'
|
|
232 |
order: '04-nftables-inet-filter-chain-OUTPUT-rule-jump_global-b'
|
211 |
233 |
)
|
212 |
234 |
}
|
|
235 |
|
213 |
236 |
it {
|
214 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related').with(
|
215 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
237 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related').with(
|
|
238 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
216 |
239 |
content: %r{^ ct state established,related accept$},
|
217 |
|
order: '05-nftables-inet-filter-chain-OUTPUT-rule-accept_established_related-b'
|
|
240 |
order: '05-nftables-inet-filter-chain-OUTPUT-rule-accept_established_related-b'
|
218 |
241 |
)
|
219 |
242 |
}
|
|
243 |
|
220 |
244 |
it {
|
221 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid').with(
|
222 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
245 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid').with(
|
|
246 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
223 |
247 |
content: %r{^ ct state invalid drop$},
|
224 |
|
order: '06-nftables-inet-filter-chain-OUTPUT-rule-drop_invalid-b'
|
|
248 |
order: '06-nftables-inet-filter-chain-OUTPUT-rule-drop_invalid-b'
|
225 |
249 |
)
|
226 |
250 |
}
|
|
251 |
|
227 |
252 |
it {
|
228 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-jump_default_out').with(
|
229 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
253 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-jump_default_out').with(
|
|
254 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
230 |
255 |
content: %r{^ jump default_out$},
|
231 |
|
order: '10-nftables-inet-filter-chain-OUTPUT-rule-jump_default_out-b'
|
|
256 |
order: '10-nftables-inet-filter-chain-OUTPUT-rule-jump_default_out-b'
|
232 |
257 |
)
|
233 |
258 |
}
|
|
259 |
|
234 |
260 |
it {
|
235 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
236 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
237 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \"\[nftables\] OUTPUT Rejected: \" flags all counter$},
|
238 |
|
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
|
261 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
|
262 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
263 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix "\[nftables\] OUTPUT Rejected: " flags all counter$},
|
|
264 |
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
239 |
265 |
)
|
240 |
266 |
}
|
|
267 |
|
241 |
268 |
it {
|
242 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-reject').with(
|
243 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
269 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-reject').with(
|
|
270 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
244 |
271 |
content: %r{^ reject with icmpx type port-unreachable$},
|
245 |
|
order: '98-nftables-inet-filter-chain-OUTPUT-rule-reject-b'
|
|
272 |
order: '98-nftables-inet-filter-chain-OUTPUT-rule-reject-b'
|
246 |
273 |
)
|
247 |
274 |
}
|
|
275 |
|
248 |
276 |
it {
|
249 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-footer').with(
|
250 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
277 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-footer').with(
|
|
278 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
251 |
279 |
content: %r{^\}$},
|
252 |
|
order: '99'
|
|
280 |
order: '99'
|
253 |
281 |
)
|
254 |
282 |
}
|
255 |
283 |
|
256 |
284 |
it {
|
257 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-default_out').with(
|
258 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-default_out.nft',
|
259 |
|
owner: 'root',
|
260 |
|
group: 'root',
|
261 |
|
mode: '0640',
|
|
285 |
expect(subject).to contain_concat('nftables-inet-filter-chain-default_out').with(
|
|
286 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-default_out.nft',
|
|
287 |
owner: 'root',
|
|
288 |
group: 'root',
|
|
289 |
mode: '0640',
|
262 |
290 |
ensure_newline: true
|
263 |
291 |
)
|
264 |
292 |
}
|
|
293 |
|
265 |
294 |
it {
|
266 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-header').with(
|
267 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
295 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-header').with(
|
|
296 |
target: 'nftables-inet-filter-chain-default_out',
|
268 |
297 |
content: %r{^chain default_out \{$},
|
269 |
|
order: '00'
|
|
298 |
order: '00'
|
270 |
299 |
)
|
271 |
300 |
}
|
|
301 |
|
272 |
302 |
it {
|
273 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-footer').with(
|
274 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
303 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-footer').with(
|
|
304 |
target: 'nftables-inet-filter-chain-default_out',
|
275 |
305 |
content: %r{^\}$},
|
276 |
|
order: '99'
|
|
306 |
order: '99'
|
277 |
307 |
)
|
278 |
308 |
}
|
|
309 |
|
279 |
310 |
it {
|
280 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnsudp').with(
|
281 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
311 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnsudp').with(
|
|
312 |
target: 'nftables-inet-filter-chain-default_out',
|
282 |
313 |
content: %r{^ udp dport 53 accept$},
|
283 |
|
order: '50-nftables-inet-filter-chain-default_out-rule-dnsudp-b'
|
|
314 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnsudp-b'
|
284 |
315 |
)
|
285 |
316 |
}
|
|
317 |
|
286 |
318 |
it {
|
287 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnstcp').with(
|
288 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
319 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnstcp').with(
|
|
320 |
target: 'nftables-inet-filter-chain-default_out',
|
289 |
321 |
content: %r{^ tcp dport 53 accept$},
|
290 |
|
order: '50-nftables-inet-filter-chain-default_out-rule-dnstcp-b'
|
|
322 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnstcp-b'
|
291 |
323 |
)
|
292 |
324 |
}
|
|
325 |
|
293 |
326 |
it {
|
294 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-chrony').with(
|
295 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
327 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-chrony').with(
|
|
328 |
target: 'nftables-inet-filter-chain-default_out',
|
296 |
329 |
content: %r{^ udp dport 123 accept$},
|
297 |
|
order: '50-nftables-inet-filter-chain-default_out-rule-chrony-b'
|
|
330 |
order: '50-nftables-inet-filter-chain-default_out-rule-chrony-b'
|
298 |
331 |
)
|
299 |
332 |
}
|
|
333 |
|
300 |
334 |
it {
|
301 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-http').with(
|
302 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
335 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-http').with(
|
|
336 |
target: 'nftables-inet-filter-chain-default_out',
|
303 |
337 |
content: %r{^ tcp dport 80 accept$},
|
304 |
|
order: '50-nftables-inet-filter-chain-default_out-rule-http-b'
|
|
338 |
order: '50-nftables-inet-filter-chain-default_out-rule-http-b'
|
305 |
339 |
)
|
306 |
340 |
}
|
|
341 |
|
307 |
342 |
it {
|
308 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-https').with(
|
309 |
|
target: 'nftables-inet-filter-chain-default_out',
|
|
343 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-https').with(
|
|
344 |
target: 'nftables-inet-filter-chain-default_out',
|
310 |
345 |
content: %r{^ tcp dport 443 accept$},
|
311 |
|
order: '50-nftables-inet-filter-chain-default_out-rule-https-b'
|
|
346 |
order: '50-nftables-inet-filter-chain-default_out-rule-https-b'
|
312 |
347 |
)
|
313 |
348 |
}
|
|
349 |
|
314 |
350 |
it {
|
315 |
|
is_expected.to contain_class('nftables::rules::out::icmp')
|
|
351 |
expect(subject).to contain_class('nftables::rules::out::icmp')
|
316 |
352 |
}
|
317 |
353 |
end
|
318 |
354 |
|
319 |
355 |
context 'chain forward' do
|
320 |
356 |
it {
|
321 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-FORWARD').with(
|
322 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-FORWARD.nft',
|
323 |
|
owner: 'root',
|
324 |
|
group: 'root',
|
325 |
|
mode: '0640',
|
|
357 |
expect(subject).to contain_concat('nftables-inet-filter-chain-FORWARD').with(
|
|
358 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-FORWARD.nft',
|
|
359 |
owner: 'root',
|
|
360 |
group: 'root',
|
|
361 |
mode: '0640',
|
326 |
362 |
ensure_newline: true
|
327 |
363 |
)
|
328 |
364 |
}
|
|
365 |
|
329 |
366 |
it {
|
330 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-header').with(
|
331 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
367 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-header').with(
|
|
368 |
target: 'nftables-inet-filter-chain-FORWARD',
|
332 |
369 |
content: %r{^chain FORWARD \{$},
|
333 |
|
order: '00'
|
|
370 |
order: '00'
|
334 |
371 |
)
|
335 |
372 |
}
|
|
373 |
|
336 |
374 |
it {
|
337 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-type').with(
|
338 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
375 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-type').with(
|
|
376 |
target: 'nftables-inet-filter-chain-FORWARD',
|
339 |
377 |
content: %r{^ type filter hook forward priority 0$},
|
340 |
|
order: '01-nftables-inet-filter-chain-FORWARD-rule-type-b'
|
|
378 |
order: '01-nftables-inet-filter-chain-FORWARD-rule-type-b'
|
341 |
379 |
)
|
342 |
380 |
}
|
|
381 |
|
343 |
382 |
it {
|
344 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-policy').with(
|
345 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
383 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-policy').with(
|
|
384 |
target: 'nftables-inet-filter-chain-FORWARD',
|
346 |
385 |
content: %r{^ policy drop$},
|
347 |
|
order: '02-nftables-inet-filter-chain-FORWARD-rule-policy-b'
|
|
386 |
order: '02-nftables-inet-filter-chain-FORWARD-rule-policy-b'
|
348 |
387 |
)
|
349 |
388 |
}
|
|
389 |
|
350 |
390 |
it {
|
351 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-jump_global').with(
|
352 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
391 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-jump_global').with(
|
|
392 |
target: 'nftables-inet-filter-chain-FORWARD',
|
353 |
393 |
content: %r{^ jump global$},
|
354 |
|
order: '03-nftables-inet-filter-chain-FORWARD-rule-jump_global-b'
|
|
394 |
order: '03-nftables-inet-filter-chain-FORWARD-rule-jump_global-b'
|
355 |
395 |
)
|
356 |
396 |
}
|
|
397 |
|
357 |
398 |
it {
|
358 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related')
|
|
399 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related')
|
359 |
400 |
}
|
|
401 |
|
360 |
402 |
it {
|
361 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid')
|
|
403 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid')
|
362 |
404 |
}
|
|
405 |
|
363 |
406 |
it {
|
364 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-jump_default_fwd').with(
|
365 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
407 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-jump_default_fwd').with(
|
|
408 |
target: 'nftables-inet-filter-chain-FORWARD',
|
366 |
409 |
content: %r{^ jump default_fwd$},
|
367 |
|
order: '10-nftables-inet-filter-chain-FORWARD-rule-jump_default_fwd-b'
|
|
410 |
order: '10-nftables-inet-filter-chain-FORWARD-rule-jump_default_fwd-b'
|
368 |
411 |
)
|
369 |
412 |
}
|
|
413 |
|
370 |
414 |
it {
|
371 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
372 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
373 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \"\[nftables\] FORWARD Rejected: \" flags all counter$},
|
374 |
|
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
|
415 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
|
416 |
target: 'nftables-inet-filter-chain-FORWARD',
|
|
417 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix "\[nftables\] FORWARD Rejected: " flags all counter$},
|
|
418 |
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
375 |
419 |
)
|
376 |
420 |
}
|
|
421 |
|
377 |
422 |
it {
|
378 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-reject').with(
|
379 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
423 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-reject').with(
|
|
424 |
target: 'nftables-inet-filter-chain-FORWARD',
|
380 |
425 |
content: %r{^ reject with icmpx type port-unreachable$},
|
381 |
|
order: '98-nftables-inet-filter-chain-FORWARD-rule-reject-b'
|
|
426 |
order: '98-nftables-inet-filter-chain-FORWARD-rule-reject-b'
|
382 |
427 |
)
|
383 |
428 |
}
|
|
429 |
|
384 |
430 |
it {
|
385 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-footer').with(
|
386 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
431 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-footer').with(
|
|
432 |
target: 'nftables-inet-filter-chain-FORWARD',
|
387 |
433 |
content: %r{^\}$},
|
388 |
|
order: '99'
|
|
434 |
order: '99'
|
389 |
435 |
)
|
390 |
436 |
}
|
391 |
437 |
|
392 |
438 |
it {
|
393 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-default_fwd').with(
|
394 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-default_fwd.nft',
|
395 |
|
owner: 'root',
|
396 |
|
group: 'root',
|
397 |
|
mode: '0640',
|
|
439 |
expect(subject).to contain_concat('nftables-inet-filter-chain-default_fwd').with(
|
|
440 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-default_fwd.nft',
|
|
441 |
owner: 'root',
|
|
442 |
group: 'root',
|
|
443 |
mode: '0640',
|
398 |
444 |
ensure_newline: true
|
399 |
445 |
)
|
400 |
446 |
}
|
|
447 |
|
401 |
448 |
it {
|
402 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-header').with(
|
403 |
|
target: 'nftables-inet-filter-chain-default_fwd',
|
|
449 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-header').with(
|
|
450 |
target: 'nftables-inet-filter-chain-default_fwd',
|
404 |
451 |
content: %r{^chain default_fwd \{$},
|
405 |
|
order: '00'
|
|
452 |
order: '00'
|
406 |
453 |
)
|
407 |
454 |
}
|
|
455 |
|
408 |
456 |
it {
|
409 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-footer').with(
|
410 |
|
target: 'nftables-inet-filter-chain-default_fwd',
|
|
457 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-footer').with(
|
|
458 |
target: 'nftables-inet-filter-chain-default_fwd',
|
411 |
459 |
content: %r{^\}$},
|
412 |
|
order: '99'
|
|
460 |
order: '99'
|
413 |
461 |
)
|
414 |
462 |
}
|
415 |
463 |
end
|
416 |
464 |
|
417 |
465 |
context 'chain global' do
|
418 |
466 |
it {
|
419 |
|
is_expected.to contain_concat('nftables-inet-filter-chain-global').with(
|
420 |
|
path: '/etc/nftables/puppet-preflight/inet-filter-chain-global.nft',
|
421 |
|
owner: 'root',
|
422 |
|
group: 'root',
|
423 |
|
mode: '0640',
|
|
467 |
expect(subject).to contain_concat('nftables-inet-filter-chain-global').with(
|
|
468 |
path: '/etc/nftables/puppet-preflight/inet-filter-chain-global.nft',
|
|
469 |
owner: 'root',
|
|
470 |
group: 'root',
|
|
471 |
mode: '0640',
|
424 |
472 |
ensure_newline: true
|
425 |
473 |
)
|
426 |
474 |
}
|
|
475 |
|
427 |
476 |
it {
|
428 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-global-header').with(
|
429 |
|
target: 'nftables-inet-filter-chain-global',
|
|
477 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-global-header').with(
|
|
478 |
target: 'nftables-inet-filter-chain-global',
|
430 |
479 |
content: %r{^chain global \{$},
|
431 |
|
order: '00'
|
|
480 |
order: '00'
|
432 |
481 |
)
|
433 |
482 |
}
|
434 |
483 |
end
|
... | ... | |
437 |
486 |
let(:pre_condition) { 'class{\'nftables\': log_prefix => "test "}' }
|
438 |
487 |
|
439 |
488 |
it {
|
440 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
441 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
442 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \"test " flags all counter$},
|
443 |
|
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
|
489 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
|
490 |
target: 'nftables-inet-filter-chain-INPUT',
|
|
491 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix "test " flags all counter$},
|
|
492 |
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
444 |
493 |
)
|
445 |
494 |
}
|
|
495 |
|
446 |
496 |
it {
|
447 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
448 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
449 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \"test " flags all counter$},
|
450 |
|
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
|
497 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
|
498 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
499 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix "test " flags all counter$},
|
|
500 |
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
451 |
501 |
)
|
452 |
502 |
}
|
|
503 |
|
453 |
504 |
it {
|
454 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
455 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
456 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \"test " flags all counter$},
|
457 |
|
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
|
505 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
|
506 |
target: 'nftables-inet-filter-chain-FORWARD',
|
|
507 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix "test " flags all counter$},
|
|
508 |
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
458 |
509 |
)
|
459 |
510 |
}
|
460 |
511 |
end
|
... | ... | |
463 |
514 |
let(:pre_condition) { 'class{\'nftables\': log_prefix => " bar [%<chain>s] "}' }
|
464 |
515 |
|
465 |
516 |
it {
|
466 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
467 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
468 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \" bar \[INPUT\] " flags all counter$},
|
469 |
|
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
|
517 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
|
518 |
target: 'nftables-inet-filter-chain-INPUT',
|
|
519 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix " bar \[INPUT\] " flags all counter$},
|
|
520 |
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
470 |
521 |
)
|
471 |
522 |
}
|
|
523 |
|
472 |
524 |
it {
|
473 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
474 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
475 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \" bar \[OUTPUT\] " flags all counter$},
|
476 |
|
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
|
525 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
|
526 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
527 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix " bar \[OUTPUT\] " flags all counter$},
|
|
528 |
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
477 |
529 |
)
|
478 |
530 |
}
|
|
531 |
|
479 |
532 |
it {
|
480 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
481 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
482 |
|
content: %r{^ limit rate 3/minute burst 5 packets log prefix \" bar \[FORWARD\] " flags all counter$},
|
483 |
|
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
|
533 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
|
534 |
target: 'nftables-inet-filter-chain-FORWARD',
|
|
535 |
content: %r{^ limit rate 3/minute burst 5 packets log prefix " bar \[FORWARD\] " flags all counter$},
|
|
536 |
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
484 |
537 |
)
|
485 |
538 |
}
|
486 |
539 |
end
|
... | ... | |
493 |
546 |
end
|
494 |
547 |
|
495 |
548 |
it {
|
496 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
497 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
498 |
|
content: %r{^ log prefix \"\[nftables\] INPUT Rejected: \" flags all counter$},
|
499 |
|
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
|
549 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
|
550 |
target: 'nftables-inet-filter-chain-INPUT',
|
|
551 |
content: %r{^ log prefix "\[nftables\] INPUT Rejected: " flags all counter$},
|
|
552 |
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
500 |
553 |
)
|
501 |
554 |
}
|
|
555 |
|
502 |
556 |
it {
|
503 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
504 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
505 |
|
content: %r{^ log prefix \"\[nftables\] OUTPUT Rejected: \" flags all counter$},
|
506 |
|
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
|
557 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
|
558 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
559 |
content: %r{^ log prefix "\[nftables\] OUTPUT Rejected: " flags all counter$},
|
|
560 |
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
507 |
561 |
)
|
508 |
562 |
}
|
|
563 |
|
509 |
564 |
it {
|
510 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
511 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
512 |
|
content: %r{^ log prefix \"\[nftables\] FORWARD Rejected: \" flags all counter$},
|
513 |
|
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
|
565 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
|
566 |
target: 'nftables-inet-filter-chain-FORWARD',
|
|
567 |
content: %r{^ log prefix "\[nftables\] FORWARD Rejected: " flags all counter$},
|
|
568 |
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
514 |
569 |
)
|
515 |
570 |
}
|
516 |
571 |
end
|
... | ... | |
523 |
578 |
end
|
524 |
579 |
|
525 |
580 |
it {
|
526 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
527 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
528 |
|
content: %r{^ limit rate 5/minute log prefix \"\[nftables\] INPUT Rejected: \" flags all counter$},
|
529 |
|
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
|
581 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded').with(
|
|
582 |
target: 'nftables-inet-filter-chain-INPUT',
|
|
583 |
content: %r{^ limit rate 5/minute log prefix "\[nftables\] INPUT Rejected: " flags all counter$},
|
|
584 |
order: '97-nftables-inet-filter-chain-INPUT-rule-log_discarded-b'
|
530 |
585 |
)
|
531 |
586 |
}
|
|
587 |
|
532 |
588 |
it {
|
533 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
534 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
535 |
|
content: %r{^ limit rate 5/minute log prefix \"\[nftables\] OUTPUT Rejected: \" flags all counter$},
|
536 |
|
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
|
589 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded').with(
|
|
590 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
591 |
content: %r{^ limit rate 5/minute log prefix "\[nftables\] OUTPUT Rejected: " flags all counter$},
|
|
592 |
order: '97-nftables-inet-filter-chain-OUTPUT-rule-log_discarded-b'
|
537 |
593 |
)
|
538 |
594 |
}
|
|
595 |
|
539 |
596 |
it {
|
540 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
541 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
542 |
|
content: %r{^ limit rate 5/minute log prefix \"\[nftables\] FORWARD Rejected: \" flags all counter$},
|
543 |
|
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
|
597 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded').with(
|
|
598 |
target: 'nftables-inet-filter-chain-FORWARD',
|
|
599 |
content: %r{^ limit rate 5/minute log prefix "\[nftables\] FORWARD Rejected: " flags all counter$},
|
|
600 |
order: '97-nftables-inet-filter-chain-FORWARD-rule-log_discarded-b'
|
544 |
601 |
)
|
545 |
602 |
}
|
546 |
603 |
end
|
... | ... | |
553 |
610 |
end
|
554 |
611 |
|
555 |
612 |
it {
|
556 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded')
|
|
613 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-log_discarded')
|
557 |
614 |
}
|
|
615 |
|
558 |
616 |
it {
|
559 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-reject')
|
|
617 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-reject')
|
560 |
618 |
}
|
|
619 |
|
561 |
620 |
it {
|
562 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded')
|
|
621 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-log_discarded')
|
563 |
622 |
}
|
|
623 |
|
564 |
624 |
it {
|
565 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-reject')
|
|
625 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-reject')
|
566 |
626 |
}
|
|
627 |
|
567 |
628 |
it {
|
568 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded')
|
|
629 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-log_discarded')
|
569 |
630 |
}
|
|
631 |
|
570 |
632 |
it {
|
571 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-reject')
|
|
633 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-reject')
|
572 |
634 |
}
|
573 |
635 |
end
|
574 |
636 |
|
... | ... | |
580 |
642 |
end
|
581 |
643 |
|
582 |
644 |
it {
|
583 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-reject').with(
|
584 |
|
target: 'nftables-inet-filter-chain-INPUT',
|
|
645 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-reject').with(
|
|
646 |
target: 'nftables-inet-filter-chain-INPUT',
|
585 |
647 |
content: %r{^ reject with tcp reset$},
|
586 |
|
order: '98-nftables-inet-filter-chain-INPUT-rule-reject-b'
|
|
648 |
order: '98-nftables-inet-filter-chain-INPUT-rule-reject-b'
|
587 |
649 |
)
|
588 |
650 |
}
|
|
651 |
|
589 |
652 |
it {
|
590 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-reject').with(
|
591 |
|
target: 'nftables-inet-filter-chain-OUTPUT',
|
|
653 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-reject').with(
|
|
654 |
target: 'nftables-inet-filter-chain-OUTPUT',
|
592 |
655 |
content: %r{^ reject with tcp reset$},
|
593 |
|
order: '98-nftables-inet-filter-chain-OUTPUT-rule-reject-b'
|
|
656 |
order: '98-nftables-inet-filter-chain-OUTPUT-rule-reject-b'
|
594 |
657 |
)
|
595 |
658 |
}
|
|
659 |
|
596 |
660 |
it {
|
597 |
|
is_expected.to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-reject').with(
|
598 |
|
target: 'nftables-inet-filter-chain-FORWARD',
|
|
661 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-reject').with(
|
|
662 |
target: 'nftables-inet-filter-chain-FORWARD',
|
599 |
663 |
content: %r{^ reject with tcp reset$},
|
600 |
|
order: '98-nftables-inet-filter-chain-FORWARD-rule-reject-b'
|
|
664 |
order: '98-nftables-inet-filter-chain-FORWARD-rule-reject-b'
|
601 |
665 |
)
|
602 |
666 |
}
|
603 |
667 |
end
|
... | ... | |
616 |
680 |
let(:params) do
|
617 |
681 |
{
|
618 |
682 |
'in_out_conntrack' => false,
|
619 |
|
'fwd_conntrack' => false,
|
|
683 |
'fwd_conntrack' => false,
|
620 |
684 |
}
|
621 |
685 |
end
|
622 |
686 |
|
623 |
687 |
it {
|
624 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related')
|
|
688 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related')
|
625 |
689 |
}
|
|
690 |
|
626 |
691 |
it {
|
627 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid')
|
|
692 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid')
|
628 |
693 |
}
|
|
694 |
|
629 |
695 |
it {
|
630 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related')
|
|
696 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related')
|
631 |
697 |
}
|
|
698 |
|
632 |
699 |
it {
|
633 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid')
|
|
700 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid')
|
634 |
701 |
}
|
|
702 |
|
635 |
703 |
it {
|
636 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related')
|
|
704 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related')
|
637 |
705 |
}
|
|
706 |
|
638 |
707 |
it {
|
639 |
|
is_expected.not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid')
|
|
708 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid')
|
640 |
709 |
}
|
641 |
710 |
end
|
642 |
711 |
|
... | ... | |
649 |
718 |
end
|
650 |
719 |
|
651 |
720 |
it {
|
652 |
|
is_expected.not_to contain_class('nftables::rules::icmp')
|
|
721 |
expect(subject).not_to contain_class('nftables::rules::icmp')
|
653 |
722 |
}
|
|
723 |
|
654 |
724 |
it {
|
655 |
|
is_expected.not_to contain_class('nftables::rules::out::icmp')
|
|
725 |
expect(subject).not_to contain_class('nftables::rules::out::icmp')
|
656 |
726 |
}
|
657 |
727 |
end
|
658 |
728 |
end
|