Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remediate rubocop offenses #43

Merged
merged 1 commit into from
Jan 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 58 additions & 49 deletions spec/classes/unattended_upgrades_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@
context 'with defaults on Debian' do
it { should contain_package('unattended-upgrades') }

it { should contain_apt__conf('unattended-upgrades').with({
'require' => 'Package[unattended-upgrades]',
})
it {
should contain_apt__conf('unattended-upgrades').with(
'require' => 'Package[unattended-upgrades]',
)
}

it { should contain_apt__conf('periodic').with({
'require' => 'Package[unattended-upgrades]',
})
it {
should contain_apt__conf('periodic').with(
'require' => 'Package[unattended-upgrades]',
)
}

it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
/Unattended-Upgrade::Origins-Pattern {/
).with_content(
/Unattended-Upgrade::Package-Blacklist {\n};/
Expand All @@ -55,11 +57,11 @@
}

it {
should create_file(file_periodic).with({
should create_file(file_periodic).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
/APT::Periodic::Enable "1";/
).with_content(
/APT::Periodic::BackupArchiveInterval "0";/
Expand All @@ -86,9 +88,9 @@
)
}

it { should contain_apt__conf('auto-upgrades').with({
it { should contain_apt__conf('auto-upgrades').with(
'ensure' => 'absent',
})
)
}
end

Expand All @@ -100,18 +102,19 @@
:lsbdistrelease => '6.0.10',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This section varies for different releases
/\Unattended-Upgrade::Allowed-Origins\ {\n
\t"\${distro_id}\ oldoldstable";\n
\t"\${distro_id}\ \${distro_codename}-security";\n
\t"\${distro_id}\ \${distro_codename}-lts";\n
};/x
)}
)
}
end

context 'with defaults on Debian 7 Wheezy' do
Expand All @@ -122,17 +125,18 @@
:lsbdistrelease => '7.1',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This section varies for different releases
/\Unattended-Upgrade::Origins-Pattern\ {\n
\t"origin=Debian,archive=stable,label=Debian-Security";\n
\t"origin=Debian,archive=oldstable,label=Debian-Security";\n
};/x
)}
)
}
end

context 'with defaults on Debian 8 Jessie' do
Expand All @@ -143,16 +147,17 @@
:lsbdistrelease => '8.2',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This section varies for different releases
/\Unattended-Upgrade::Origins-Pattern\ {\n
\t"origin=Debian,codename=\${distro_codename},label=Debian-Security";\n
};/x
)}
)
}
end

context 'with defaults on Ubuntu 12.04LTS Precise Pangolin' do
Expand All @@ -163,16 +168,17 @@
:lsbrelease => '12.04',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This is the only section that's different for Ubuntu compared to Debian
/\Unattended-Upgrade::Allowed-Origins\ {\n
\t"\${distro_id}\:\${distro_codename}-security";\n
};/x
)}
)
}
end

context 'with defaults on Ubuntu 14.04LTS Trusty Tahr' do
Expand All @@ -183,16 +189,17 @@
:lsbrelease => '14.04',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This is the only section that's different for Ubuntu compared to Debian
/\Unattended-Upgrade::Allowed-Origins\ {\n
\t"\${distro_id}\:\${distro_codename}-security";\n
};/x
)}
)
}
end

context 'with defaults on Ubuntu 15.04 Vivid Vervet' do
Expand All @@ -203,16 +210,17 @@
:lsbrelease => '15.04',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This is the only section that's different for Ubuntu compared to Debian
/\Unattended-Upgrade::Allowed-Origins\ {\n
\t"\${distro_id}\:\${distro_codename}-security";\n
};/x
)}
)
}
end

context 'with defaults on Ubuntu 15.10 Wily Werewolf' do
Expand All @@ -223,16 +231,17 @@
:lsbrelease => '15.10',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
# This is the only section that's different for Ubuntu compared to Debian
/\Unattended-Upgrade::Allowed-Origins\ {\n
\t"\${distro_id}\:\${distro_codename}-security";\n
};/x
)}
)
}
end

context 'with defaults on Raspbian' do
Expand All @@ -243,11 +252,11 @@
:lsbrelease => '8.0',
} }
it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
)
}
end

Expand All @@ -270,8 +279,8 @@
},
:verbose => 1,
:legacy_origin => true,
:origins => [ 'bananas' ],
:blacklist => [ 'foo', 'bar' ],
:origins => %w(bananas),
:blacklist => %w(foo bar),
:minimal_steps => false,
:install_on_shutdown => true,
:mail => {
Expand All @@ -284,22 +293,22 @@
end
it { should contain_package('unattended-upgrades') }

it { should contain_apt__conf('unattended-upgrades').with({
it { should contain_apt__conf('unattended-upgrades').with(
'require' => 'Package[unattended-upgrades]',
})
)
}

it { should contain_apt__conf('periodic').with({
it { should contain_apt__conf('periodic').with(
'require' => 'Package[unattended-upgrades]',
})
)
}

it {
should create_file(file_unattended).with({
should create_file(file_unattended).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
/Unattended-Upgrade::Allowed-Origins {\n\t"bananas";\n};/
).with_content(
/Unattended-Upgrade::Package-Blacklist {\n\t"foo";\n\t"bar";\n};/
Expand All @@ -323,11 +332,11 @@
}

it {
should create_file(file_periodic).with({
should create_file(file_periodic).with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
}).with_content(
).with_content(
/APT::Periodic::Enable "1";/
).with_content(
/APT::Periodic::BackupArchiveInterval "0";/
Expand Down Expand Up @@ -356,11 +365,11 @@
)
}

it { should contain_apt__conf('auto-upgrades').with({
'ensure' => 'absent',
})
it {
should contain_apt__conf('auto-upgrades').with(
'ensure' => 'absent',
)
}

end

describe 'validation tests' do
Expand Down