1 require 'spec_helper_acceptance'
3 describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
5 it 'should work with no errors' do
8 include apt::unattended_upgrades
11 # Attempted workaround for problems seen on debian with
12 # something holding the package database open.
13 #shell('killall -9 apt-get')
14 #shell('killall -9 dpkg')
15 apply_manifest(pp, :catch_failures => true)
18 describe file('/etc/apt/apt.conf.d/10periodic') do
21 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
27 it 'should work with no errors' do
30 class { 'apt::unattended_upgrades':
31 origins => ['${distro_id}:${distro_codename}-test'],
35 apply_manifest(pp, :catch_failures => true)
38 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
40 it { should contain '${distro_id}:${distro_codename}-test' }
44 context 'blacklist' do
45 it 'should work with no errors' do
48 class { 'apt::unattended_upgrades':
49 blacklist => ['puppet']
53 apply_manifest(pp, :catch_failures => true)
56 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
58 it { should contain 'puppet' }
63 it 'should work with no errors' do
66 class { 'apt::unattended_upgrades':
71 apply_manifest(pp, :catch_failures => true)
74 describe file('/etc/apt/apt.conf.d/10periodic') do
76 it { should contain 'APT::Periodic::Update-Package-Lists "99";' }
81 it 'should work with no errors' do
84 class { 'apt::unattended_upgrades':
89 apply_manifest(pp, :catch_failures => true)
92 describe file('/etc/apt/apt.conf.d/10periodic') do
94 it { should contain 'APT::Periodic::Download-Upgradeable-Packages "99";' }
99 it 'should work with no errors' do
102 class { 'apt::unattended_upgrades':
107 apply_manifest(pp, :catch_failures => true)
110 describe file('/etc/apt/apt.conf.d/10periodic') do
111 it { should be_file }
112 it { should contain 'APT::Periodic::Unattended-Upgrade "99";' }
116 context 'autoclean' do
117 it 'should work with no errors' do
120 class { 'apt::unattended_upgrades':
125 apply_manifest(pp, :catch_failures => true)
128 describe file('/etc/apt/apt.conf.d/10periodic') do
129 it { should be_file }
130 it { should contain 'APT::Periodic::AutocleanInterval "99";' }
134 context 'auto_fix' do
136 it 'should work with no errors' do
139 class { 'apt::unattended_upgrades':
144 apply_manifest(pp, :catch_failures => true)
147 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
148 it { should be_file }
149 it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "true";' }
154 it 'should work with no errors' do
157 class { 'apt::unattended_upgrades':
162 apply_manifest(pp, :catch_failures => true)
165 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
166 it { should be_file }
167 it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "false";' }
172 context 'minimal_steps' do
174 it 'should work with no errors' do
177 class { 'apt::unattended_upgrades':
178 minimal_steps => true
182 apply_manifest(pp, :catch_failures => true)
185 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
186 it { should be_file }
187 it { should contain 'Unattended-Upgrade::MinimalSteps "true";' }
192 it 'should work with no errors' do
195 class { 'apt::unattended_upgrades':
196 minimal_steps => false
200 apply_manifest(pp, :catch_failures => true)
203 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
204 it { should be_file }
205 it { should contain 'Unattended-Upgrade::MinimalSteps "false";' }
210 context 'install_on_shutdown' do
212 it 'should work with no errors' do
215 class { 'apt::unattended_upgrades':
216 install_on_shutdown => true
220 apply_manifest(pp, :catch_failures => true)
223 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
224 it { should be_file }
225 it { should contain 'Unattended-Upgrade::InstallOnShutdown "true";' }
230 it 'should work with no errors' do
233 class { 'apt::unattended_upgrades':
234 install_on_shutdown => false
238 apply_manifest(pp, :catch_failures => true)
241 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
242 it { should be_file }
243 it { should contain 'Unattended-Upgrade::InstallOnShutdown "false";' }
249 it 'should work with no errors' do
252 class { 'apt::unattended_upgrades':
253 mail_to => 'test@example.com'
257 apply_manifest(pp, :catch_failures => true)
260 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
261 it { should be_file }
262 it { should contain 'Unattended-Upgrade::Mail "test@example.com";' }
266 context 'mail_only_on_error' do
268 it 'should work with no errors' do
271 class { 'apt::unattended_upgrades':
272 mail_to => 'test@example.com',
273 mail_only_on_error => true
277 apply_manifest(pp, :catch_failures => true)
280 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
281 it { should be_file }
282 it { should contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
287 it 'should work with no errors' do
290 class { 'apt::unattended_upgrades':
291 mail_to => 'test@example.com',
292 mail_only_on_error => false,
296 apply_manifest(pp, :catch_failures => true)
299 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
300 it { should be_file }
301 it { should contain 'Unattended-Upgrade::MailOnlyOnError "false";' }
305 context 'mail_to missing' do
306 it 'should work with no errors' do
309 class { 'apt::unattended_upgrades':
310 mail_only_on_error => true,
314 apply_manifest(pp, :catch_failures => true)
317 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
318 it { should be_file }
319 it { should_not contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
324 context 'remove_unused' do
326 it 'should work with no errors' do
329 class { 'apt::unattended_upgrades':
330 remove_unused => true
334 apply_manifest(pp, :catch_failures => true)
337 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
338 it { should be_file }
339 it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' }
344 it 'should work with no errors' do
347 class { 'apt::unattended_upgrades':
348 remove_unused => false,
352 apply_manifest(pp, :catch_failures => true)
355 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
356 it { should be_file }
357 it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "false";' }
362 context 'auto_reboot' do
364 it 'should work with no errors' do
367 class { 'apt::unattended_upgrades':
372 apply_manifest(pp, :catch_failures => true)
375 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
376 it { should be_file }
377 it { should contain 'Unattended-Upgrade::Automatic-Reboot "true";' }
382 it 'should work with no errors' do
385 class { 'apt::unattended_upgrades':
386 auto_reboot => false,
390 apply_manifest(pp, :catch_failures => true)
393 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
394 it { should be_file }
395 it { should contain 'Unattended-Upgrade::Automatic-Reboot "false";' }
400 context 'dl_limit' do
401 it 'should work with no errors' do
404 class { 'apt::unattended_upgrades':
409 apply_manifest(pp, :catch_failures => true)
412 describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
413 it { should be_file }
414 it { should contain 'Acquire::http::Dl-Limit "99"' }
419 it 'should work with no errors' do
422 class { 'apt::unattended_upgrades':
427 apply_manifest(pp, :catch_failures => true)
430 describe file('/etc/apt/apt.conf.d/10periodic') do
431 it { should be_file }
432 it { should contain 'APT::Periodic::Enable "2"' }
436 context 'backup_interval' do
437 it 'should work with no errors' do
440 class { 'apt::unattended_upgrades':
441 backup_interval => '2'
445 apply_manifest(pp, :catch_failures => true)
448 describe file('/etc/apt/apt.conf.d/10periodic') do
449 it { should be_file }
450 it { should contain 'APT::Periodic::BackUpArchiveInterval "2";' }
454 context 'backup_level' do
455 it 'should work with no errors' do
458 class { 'apt::unattended_upgrades':
463 apply_manifest(pp, :catch_failures => true)
466 describe file('/etc/apt/apt.conf.d/10periodic') do
467 it { should be_file }
468 it { should contain 'APT::Periodic::BackUpLevel "2";' }
473 it 'should work with no errors' do
476 class { 'apt::unattended_upgrades':
481 apply_manifest(pp, :catch_failures => true)
484 describe file('/etc/apt/apt.conf.d/10periodic') do
485 it { should be_file }
486 it { should contain 'APT::Periodic::MaxAge "2";' }
491 it 'should work with no errors' do
494 class { 'apt::unattended_upgrades':
499 apply_manifest(pp, :catch_failures => true)
502 describe file('/etc/apt/apt.conf.d/10periodic') do
503 it { should be_file }
504 it { should contain 'APT::Periodic::MinAge "2";' }
508 context 'max_size' do
509 it 'should work with no errors' do
512 class { 'apt::unattended_upgrades':
517 apply_manifest(pp, :catch_failures => true)
520 describe file('/etc/apt/apt.conf.d/10periodic') do
521 it { should be_file }
522 it { should contain 'APT::Periodic::MaxSize "2";' }
526 context 'download_delta' do
527 it 'should work with no errors' do
530 class { 'apt::unattended_upgrades':
531 download_delta => '2'
535 apply_manifest(pp, :catch_failures => true)
538 describe file('/etc/apt/apt.conf.d/10periodic') do
539 it { should be_file }
540 it { should contain 'APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";' }
545 it 'should work with no errors' do
548 class { 'apt::unattended_upgrades':
553 apply_manifest(pp, :catch_failures => true)
556 describe file('/etc/apt/apt.conf.d/10periodic') do
557 it { should be_file }
558 it { should contain 'APT::Periodic::Verbose "2";' }