|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | it 'creates the directory /etc/ssh' do
|
32 |
| - expect(chef_run).to create_directory('/etc/ssh') |
33 |
| - .with(mode: '0755') |
34 |
| - .with(owner: 'root') |
35 |
| - .with(group: 'root') |
| 32 | + expect(chef_run).to create_directory('/etc/ssh'). |
| 33 | + with(mode: '0755'). |
| 34 | + with(owner: 'root'). |
| 35 | + with(group: 'root') |
36 | 36 | end
|
37 | 37 |
|
38 | 38 | it 'creates /etc/ssh/ssh_config' do
|
39 |
| - expect(chef_run).to create_template('/etc/ssh/ssh_config') |
40 |
| - .with(owner: 'root') |
41 |
| - .with(group: 'root') |
42 |
| - .with(mode: '0644') |
| 39 | + expect(chef_run).to create_template('/etc/ssh/ssh_config'). |
| 40 | + with(owner: 'root'). |
| 41 | + with(group: 'root'). |
| 42 | + with(mode: '0644') |
43 | 43 | end
|
44 | 44 |
|
45 | 45 | it 'disables weak hmacs' do
|
46 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
47 |
| - .with_content(/MACs [^#]*\bhmac-sha1\b/) |
| 46 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 47 | + with_content(/MACs [^#]*\bhmac-sha1\b/) |
48 | 48 | end
|
49 | 49 |
|
50 | 50 | it 'disables weak kexs' do
|
51 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
52 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
53 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
54 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
55 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
56 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
| 51 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 52 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
| 53 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 54 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
| 55 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 56 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
57 | 57 | end
|
58 | 58 |
|
59 | 59 | it 'disables cbc ciphers' do
|
60 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
61 |
| - .with_content(/Ciphers [^#]*-cbc\b/) |
| 60 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 61 | + with_content(/Ciphers [^#]*-cbc\b/) |
62 | 62 | end
|
63 | 63 |
|
64 | 64 | it 'enables ctr ciphers' do
|
65 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
66 |
| - .with_content(/Ciphers [^#]*\baes128-ctr\b/) |
67 |
| - .with_content(/Ciphers [^#]*\baes192-ctr\b/) |
68 |
| - .with_content(/Ciphers [^#]*\baes256-ctr\b/) |
| 65 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 66 | + with_content(/Ciphers [^#]*\baes128-ctr\b/). |
| 67 | + with_content(/Ciphers [^#]*\baes192-ctr\b/). |
| 68 | + with_content(/Ciphers [^#]*\baes256-ctr\b/) |
69 | 69 | end
|
70 | 70 |
|
71 | 71 | context 'weak_hmac enabled only for the client' do
|
|
76 | 76 | end
|
77 | 77 |
|
78 | 78 | it 'allows weak hmacs for the client' do
|
79 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
80 |
| - .with_content(/MACs [^#]*\bhmac-sha1\b/) |
| 79 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 80 | + with_content(/MACs [^#]*\bhmac-sha1\b/) |
81 | 81 | end
|
82 | 82 |
|
83 | 83 | it 'does not warn about depreciation' do
|
|
93 | 93 | end
|
94 | 94 |
|
95 | 95 | it 'does not enable weak hmacs on the client' do
|
96 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
97 |
| - .with_content(/MACs [^#]*\bhmac-sha1\b/) |
| 96 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 97 | + with_content(/MACs [^#]*\bhmac-sha1\b/) |
98 | 98 | end
|
99 | 99 | end
|
100 | 100 |
|
|
106 | 106 | end
|
107 | 107 |
|
108 | 108 | it 'allows weak kexs on the client' do
|
109 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
110 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
111 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
112 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
113 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
114 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
| 109 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 110 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
| 111 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 112 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
| 113 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 114 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
115 | 115 | end
|
116 | 116 |
|
117 | 117 | it 'does not warn about depreciation' do
|
|
127 | 127 | end
|
128 | 128 |
|
129 | 129 | it 'does not allow weak kexs on the client' do
|
130 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
131 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
132 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
133 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
134 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
135 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
| 130 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 131 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
| 132 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 133 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
| 134 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 135 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
136 | 136 | end
|
137 | 137 | end
|
138 | 138 |
|
|
144 | 144 | end
|
145 | 145 |
|
146 | 146 | it 'allows cbc ciphers on the client' do
|
147 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
148 |
| - .with_content(/Ciphers [^#]*\baes256-cbc\b/) |
149 |
| - .with_content(/Ciphers [^#]*\baes192-cbc\b/) |
150 |
| - .with_content(/Ciphers [^#]*\baes128-cbc\b/) |
| 147 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 148 | + with_content(/Ciphers [^#]*\baes256-cbc\b/). |
| 149 | + with_content(/Ciphers [^#]*\baes192-cbc\b/). |
| 150 | + with_content(/Ciphers [^#]*\baes128-cbc\b/) |
151 | 151 | end
|
152 | 152 |
|
153 | 153 | it 'does not warn about depreciation' do
|
|
163 | 163 | end
|
164 | 164 |
|
165 | 165 | it 'does not allow cbc ciphers on the client' do
|
166 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
167 |
| - .with_content(/Ciphers [^#]*\b.*-cbc\b/) |
| 166 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 167 | + with_content(/Ciphers [^#]*\b.*-cbc\b/) |
168 | 168 | end
|
169 | 169 | end
|
170 | 170 |
|
|
177 | 177 | end
|
178 | 178 |
|
179 | 179 | it 'allows weak hmacs' do
|
180 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
181 |
| - .with_content(/MACs [^#]*\bhmac-sha1\b/) |
| 180 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 181 | + with_content(/MACs [^#]*\bhmac-sha1\b/) |
182 | 182 | end
|
183 | 183 |
|
184 | 184 | it 'still does not allow weak kexs' do
|
185 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
186 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
187 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
188 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
189 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
190 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
| 185 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 186 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
| 187 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 188 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
| 189 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 190 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
191 | 191 | end
|
192 | 192 |
|
193 | 193 | it 'still doss not allow cbc ciphers' do
|
194 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
195 |
| - .with_content(/Ciphers [^#]*-cbc\b/) |
| 194 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 195 | + with_content(/Ciphers [^#]*-cbc\b/) |
196 | 196 | end
|
197 | 197 |
|
198 | 198 | it 'warns about depreciation' do
|
199 |
| - expect(chef_run).to write_log('deprecated-ssh/weak_hmac_client') |
200 |
| - .with(message: /deprecated/) |
201 |
| - .with(level: :warn) |
| 199 | + expect(chef_run).to write_log('deprecated-ssh/weak_hmac_client'). |
| 200 | + with(message: /deprecated/). |
| 201 | + with(level: :warn) |
202 | 202 | end
|
203 | 203 | end
|
204 | 204 |
|
|
210 | 210 | end
|
211 | 211 |
|
212 | 212 | it 'allows weak kexs on the client' do
|
213 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
214 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
215 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
216 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
217 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
218 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
| 213 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 214 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
| 215 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 216 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
| 217 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 218 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
219 | 219 | end
|
220 | 220 |
|
221 | 221 | it 'still does not allow weak macs' do
|
222 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
223 |
| - .with_content(/MACs [^#]*\bhmac-sha1\b/) |
| 222 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 223 | + with_content(/MACs [^#]*\bhmac-sha1\b/) |
224 | 224 | end
|
225 | 225 |
|
226 | 226 | it 'still does not allow cbc ciphers' do
|
227 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
228 |
| - .with_content(/Ciphers [^#]*-cbc\b/) |
| 227 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 228 | + with_content(/Ciphers [^#]*-cbc\b/) |
229 | 229 | end
|
230 | 230 |
|
231 | 231 | it 'warns about depreciation' do
|
232 |
| - expect(chef_run).to write_log('deprecated-ssh/weak_kex_client') |
233 |
| - .with(message: /deprecated/) |
234 |
| - .with(level: :warn) |
| 232 | + expect(chef_run).to write_log('deprecated-ssh/weak_kex_client'). |
| 233 | + with(message: /deprecated/). |
| 234 | + with(level: :warn) |
235 | 235 | end
|
236 | 236 | end
|
237 | 237 |
|
|
243 | 243 | end
|
244 | 244 |
|
245 | 245 | it 'allows cbc ciphers for the client' do
|
246 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
247 |
| - .with_content(/Ciphers [^#]*\baes256-cbc\b/) |
248 |
| - .with_content(/Ciphers [^#]*\baes192-cbc\b/) |
249 |
| - .with_content(/Ciphers [^#]*\baes128-cbc\b/) |
| 246 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 247 | + with_content(/Ciphers [^#]*\baes256-cbc\b/). |
| 248 | + with_content(/Ciphers [^#]*\baes192-cbc\b/). |
| 249 | + with_content(/Ciphers [^#]*\baes128-cbc\b/) |
250 | 250 | end
|
251 | 251 |
|
252 | 252 | it 'still does not allow weak macs' do
|
253 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
254 |
| - .with_content(/MACs [^#]*\bhmac-sha1\b/) |
| 253 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 254 | + with_content(/MACs [^#]*\bhmac-sha1\b/) |
255 | 255 | end
|
256 | 256 |
|
257 | 257 | it 'still does not allow weak kexs' do
|
258 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
259 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
260 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
261 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
262 |
| - expect(chef_run).not_to render_file('/etc/ssh/ssh_config') |
263 |
| - .with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
| 258 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 259 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/) |
| 260 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 261 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/) |
| 262 | + expect(chef_run).not_to render_file('/etc/ssh/ssh_config'). |
| 263 | + with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/) |
264 | 264 | end
|
265 | 265 |
|
266 | 266 | it 'still enables ctr ciphers' do
|
267 |
| - expect(chef_run).to render_file('/etc/ssh/ssh_config') |
268 |
| - .with_content(/Ciphers [^#]*\baes128-ctr\b/) |
269 |
| - .with_content(/Ciphers [^#]*\baes192-ctr\b/) |
270 |
| - .with_content(/Ciphers [^#]*\baes256-ctr\b/) |
| 267 | + expect(chef_run).to render_file('/etc/ssh/ssh_config'). |
| 268 | + with_content(/Ciphers [^#]*\baes128-ctr\b/). |
| 269 | + with_content(/Ciphers [^#]*\baes192-ctr\b/). |
| 270 | + with_content(/Ciphers [^#]*\baes256-ctr\b/) |
271 | 271 | end
|
272 | 272 |
|
273 | 273 | it 'warns about depreciation' do
|
274 |
| - expect(chef_run).to write_log('deprecated-ssh/cbc_required_client') |
275 |
| - .with(message: /deprecated/) |
276 |
| - .with(level: :warn) |
| 274 | + expect(chef_run).to write_log('deprecated-ssh/cbc_required_client'). |
| 275 | + with(message: /deprecated/). |
| 276 | + with(level: :warn) |
277 | 277 | end
|
278 | 278 | end
|
279 | 279 | end
|
|
291 | 291 | end
|
292 | 292 |
|
293 | 293 | it "warns about ignoring the global #{attr} value for the client" do
|
294 |
| - expect(chef_run).to write_log("ignored-ssh/#{attr}_client") |
295 |
| - .with(message: "Ignoring ssh/#{attr}:true for client") |
296 |
| - .with_level(:warn) |
| 294 | + expect(chef_run).to write_log("ignored-ssh/#{attr}_client"). |
| 295 | + with(message: "Ignoring ssh/#{attr}:true for client"). |
| 296 | + with_level(:warn) |
297 | 297 | end
|
298 | 298 | end
|
299 | 299 |
|
|
308 | 308 | end
|
309 | 309 |
|
310 | 310 | it "does not warn about ignoring the global #{attr}" do
|
311 |
| - expect(chef_run).not_to write_log("ignored-ssh/#{attr}_client") |
312 |
| - .with_level(:warn) |
| 311 | + expect(chef_run).not_to write_log("ignored-ssh/#{attr}_client"). |
| 312 | + with_level(:warn) |
313 | 313 | end
|
314 | 314 | end
|
315 | 315 | end
|
|
0 commit comments