2 describe 'apt::unattended_upgrades', :type => :class do
3 let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
4 let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
6 it { should contain_package("unattended-upgrades") }
9 should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({
17 should create_file("/etc/apt/apt.conf.d/10periodic").with({
24 describe "with origins => ['ubuntu:precise-security']" do
26 { :origins => ['ubuntu:precise-security'] }
28 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
31 describe "with blacklist => []" do
35 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
38 describe "with update => 2" do
42 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
45 describe "with download => 2" do
49 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
52 describe "with upgrade => 2" do
56 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
59 describe "with autoclean => 2" do
63 it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
66 describe "with auto_fix => false" do
68 { :auto_fix => false }
70 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
73 describe "with minimal_steps => true" do
75 { :minimal_steps => true }
77 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
80 describe "with install_on_shutdown => true" do
82 { :install_on_shutdown => true }
84 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
87 describe "with mail_to => NONE" do
89 { :mail_to => "NONE" }
91 it { should contain_file(file_unattended).with_content(/^\/\/ 'mailx' must be installed.\n$/) }
92 it { should contain_file(file_unattended).with_content(/^\/\/ is to always send a mail if Unattended-Upgrade::Mail is set\n$/) }
95 describe "with mail_to => user@website, mail_only_on_error => true" do
97 { :mail_to => "user@website",
98 :mail_only_on_error => true }
100 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
101 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
104 describe "with remove_unused => false" do
106 { :remove_unused => false }
108 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
111 describe "with auto_reboot => true" do
113 { :auto_reboot => true }
115 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
118 describe "with dl_limit => 70" do
120 { :dl_limit => "70" }
122 it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
125 describe "with enable => 0" do
129 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
132 describe "with backup_interval => 1" do
134 { :backup_interval => "1" }
136 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
139 describe "with backup_level => 0" do
141 { :backup_level => "0" }
143 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
146 describe "with max_age => 1" do
150 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
153 describe "with min_age => 1" do
157 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
160 describe "with max_size => 1" do
164 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
167 describe "with download_delta => 2" do
169 { :download_delta => "2" }
171 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
174 describe "with verbose => 2" do
178 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }