2018-03-02 20:33:31 -03:00
|
|
|
|
## Some vars
|
|
|
|
|
common_packages = %w(
|
2018-02-12 08:16:03 -03:00
|
|
|
|
git
|
|
|
|
|
less
|
|
|
|
|
bc
|
|
|
|
|
curl
|
|
|
|
|
fail2ban
|
2018-03-02 20:33:31 -03:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
case os[:name]
|
|
|
|
|
when 'redhat', 'centos'
|
|
|
|
|
os_packages = %w(yum-plugin-versionlock)
|
|
|
|
|
held_packages = {
|
2018-03-06 18:27:16 -03:00
|
|
|
|
# We use this test for held packages in a list,
|
|
|
|
|
# with no version (current version).
|
|
|
|
|
'alien': '',
|
|
|
|
|
'iotop': ''
|
2018-03-02 20:33:31 -03:00
|
|
|
|
}
|
|
|
|
|
lock_file = '/etc/yum/pluginconf.d/versionlock.list'
|
|
|
|
|
when 'fedora'
|
2018-03-02 21:41:12 -03:00
|
|
|
|
os_packages = %w(
|
|
|
|
|
python2-dnf-plugin-versionlock
|
|
|
|
|
python3-dnf-plugin-versionlock
|
|
|
|
|
)
|
2018-03-02 20:33:31 -03:00
|
|
|
|
held_packages = {
|
2019-03-06 09:41:23 -03:00
|
|
|
|
'alien': '8.95-8.fc29',
|
|
|
|
|
'iotop': '0.6-18.fc29'
|
2018-03-02 20:33:31 -03:00
|
|
|
|
}
|
|
|
|
|
lock_file = '/etc/dnf/plugins/versionlock.list'
|
2019-03-06 09:41:23 -03:00
|
|
|
|
# Adding empty Suse entries, to get tests passing
|
|
|
|
|
# Don't know the correct values to add here.
|
|
|
|
|
when 'opensuse'
|
|
|
|
|
os_packages = %w()
|
|
|
|
|
held_packages = {}
|
|
|
|
|
lock_file = ''
|
2018-03-02 20:33:31 -03:00
|
|
|
|
when 'debian', 'ubuntu'
|
|
|
|
|
os_packages = %w()
|
|
|
|
|
held_packages = {
|
|
|
|
|
'alien': '8.95',
|
2019-03-05 23:19:24 -03:00
|
|
|
|
# To match also ubuntu16's
|
|
|
|
|
'iotop': '0.6-'
|
2018-03-02 20:33:31 -03:00
|
|
|
|
}
|
|
|
|
|
lock_file = '/var/lib/dpkg/status'
|
|
|
|
|
end
|
|
|
|
|
|
2019-08-13 19:16:06 +02:00
|
|
|
|
## FIXME - not testing Held packages
|
|
|
|
|
held_packages = {}
|
|
|
|
|
|
2018-03-02 20:33:31 -03:00
|
|
|
|
unheld_packages = (common_packages + os_packages).flatten.uniq
|
|
|
|
|
all_packages = (unheld_packages + held_packages.keys.map { |k| k.to_s }).flatten.uniq
|
|
|
|
|
|
|
|
|
|
### WANTED/REQUIRED/HELD
|
|
|
|
|
control 'Wanted/Required/Held packages' do
|
|
|
|
|
title 'should be installed'
|
|
|
|
|
|
|
|
|
|
all_packages.each do |p|
|
|
|
|
|
describe package(p) do
|
|
|
|
|
it { should be_installed }
|
|
|
|
|
end
|
2018-02-12 08:16:03 -03:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-03-02 20:33:31 -03:00
|
|
|
|
### WANTED UNHELD
|
|
|
|
|
control 'Wanted packages' do
|
|
|
|
|
title 'should NOT be marked as hold'
|
|
|
|
|
|
|
|
|
|
unheld_packages.each do |p,v|
|
|
|
|
|
case os[:name]
|
|
|
|
|
when 'redhat', 'centheld_packagesheld_packagesos', 'fedora'
|
|
|
|
|
match_string = "#{p}-.*#{v}"
|
|
|
|
|
describe file(lock_file) do
|
|
|
|
|
its('content') { should_not match(match_string) }
|
|
|
|
|
end
|
|
|
|
|
when 'debian', 'ubuntu'
|
|
|
|
|
match_string = "^Package: #{p}\nStatus: install ok installed"
|
|
|
|
|
describe file(lock_file) do
|
|
|
|
|
its('content') { should match(match_string) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
### HELD
|
|
|
|
|
control 'Held packages' do
|
|
|
|
|
title 'should be marked as hold'
|
|
|
|
|
|
|
|
|
|
held_packages.each do |p,v|
|
|
|
|
|
case os[:name]
|
|
|
|
|
when 'redhat', 'centos', 'fedora'
|
|
|
|
|
match_string = "#{p}-.*#{v}"
|
|
|
|
|
when 'debian', 'ubuntu'
|
|
|
|
|
match_string = "^Package: #{p}\nStatus: hold ok installed\nP.*\nS.*\nI.*\nM.*\nA.*\nVersion: #{v}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file(lock_file) do
|
|
|
|
|
its('content') { should match(match_string) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
### UNWANTED
|
|
|
|
|
control 'Unwanted packages' do
|
|
|
|
|
title 'should be uninstalled'
|
|
|
|
|
%w{
|
|
|
|
|
avahi-daemon
|
|
|
|
|
}.each do |p|
|
|
|
|
|
describe package(p) do
|
|
|
|
|
it { should_not be_installed }
|
|
|
|
|
end
|
2018-02-12 08:16:03 -03:00
|
|
|
|
end
|
|
|
|
|
end
|