2016-08-03 15:41:27 +00:00
|
|
|
if ENV['DOCKER']
|
2019-05-18 00:43:58 +00:00
|
|
|
$stderr.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
|
2016-08-03 15:41:27 +00:00
|
|
|
return
|
|
|
|
end
|
2016-05-10 17:23:11 +00:00
|
|
|
|
2015-10-22 14:59:56 +00:00
|
|
|
# based on operating system we select the available service
|
2016-09-01 16:27:00 +00:00
|
|
|
if ['centos', 'fedora', 'freebsd', 'opensuse', 'suse'].include?(os[:family])
|
2015-10-22 14:59:56 +00:00
|
|
|
# CentOS, Fedora
|
|
|
|
unavailable_service = 'ssh'
|
|
|
|
available_service = 'sshd'
|
|
|
|
elsif ['debian'].include?(os[:family])
|
|
|
|
# Debian
|
|
|
|
unavailable_service = 'clamav'
|
|
|
|
available_service = 'ssh'
|
2015-11-17 21:14:05 +00:00
|
|
|
elsif ['ubuntu'].include?(os[:family])
|
2015-10-22 17:55:13 +00:00
|
|
|
# Ubuntu
|
2015-10-22 14:59:56 +00:00
|
|
|
unavailable_service = 'sshd'
|
|
|
|
available_service = 'ssh'
|
2016-01-28 13:51:54 +00:00
|
|
|
elsif os.windows?
|
2015-11-17 21:14:05 +00:00
|
|
|
# Ubuntu
|
|
|
|
unavailable_service = 'sshd'
|
|
|
|
available_service = 'dhcp'
|
2015-12-23 19:22:07 +00:00
|
|
|
elsif ['aix'].include?(os[:family])
|
|
|
|
unavailable_service = 'clamav'
|
|
|
|
available_service = 'xntpd'
|
2016-01-28 13:51:54 +00:00
|
|
|
elsif os.solaris?
|
|
|
|
unavailable_service = 'clamav'
|
|
|
|
available_service = 'ssh'
|
2015-10-22 14:59:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe service(unavailable_service) do
|
|
|
|
it { should_not be_enabled }
|
|
|
|
it { should_not be_installed }
|
|
|
|
it { should_not be_running }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe service(available_service) do
|
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_running }
|
|
|
|
end
|
2015-11-09 23:30:23 +00:00
|
|
|
|
|
|
|
# extra test for ubuntu upstart with systemv service
|
2016-05-10 17:23:11 +00:00
|
|
|
if os[:family] == 'ubuntu' && os[:release] == '12.04'
|
|
|
|
describe upstart_service('ssh') do
|
2015-11-09 23:30:23 +00:00
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_running }
|
|
|
|
end
|
|
|
|
end
|
2016-01-20 16:54:04 +00:00
|
|
|
|
|
|
|
# extra tests for alt. runit on centos with runit_service
|
2016-02-17 10:44:15 +00:00
|
|
|
if os[:family] == 'centos' && os[:release].to_i >= 6
|
2016-01-20 16:54:04 +00:00
|
|
|
describe runit_service('running-runit-service') do
|
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_running }
|
|
|
|
end
|
|
|
|
|
2016-01-21 08:53:59 +00:00
|
|
|
describe runit_service('not-running-runit-service') do
|
2016-01-20 16:54:04 +00:00
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should_not be_running }
|
|
|
|
end
|
|
|
|
|
2016-01-21 08:53:59 +00:00
|
|
|
describe runit_service('not-enabled-runit-service') do
|
|
|
|
it { should_not be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should_not be_running }
|
|
|
|
end
|
|
|
|
|
2016-01-20 16:54:04 +00:00
|
|
|
# alt. ctl location
|
|
|
|
describe runit_service('running-runit-service', '/opt/chef/embedded/sbin/sv') do
|
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_running }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe runit_service('unknown') do
|
|
|
|
it { should_not be_enabled }
|
|
|
|
it { should_not be_installed }
|
|
|
|
it { should_not be_running }
|
|
|
|
end
|
2016-02-05 08:05:15 +00:00
|
|
|
|
|
|
|
describe upstart_service('upstart-running') do
|
|
|
|
it { should_not be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_running }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe upstart_service('upstart-enabled-and-running') do
|
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_running }
|
2016-05-06 15:38:56 +00:00
|
|
|
its('type') { should be 'upstart' }
|
|
|
|
its('name') { should be 'upstart-enabled-and-running' }
|
|
|
|
its('description') { should be nil }
|
2016-02-05 08:05:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe upstart_service('upstart-enabled-not-running') do
|
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_installed }
|
|
|
|
it { should_not be_running }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe upstart_service('unknown') do
|
|
|
|
it { should_not be_enabled }
|
|
|
|
it { should_not be_installed }
|
|
|
|
it { should_not be_running }
|
2016-05-06 15:38:56 +00:00
|
|
|
its('type') { should be nil }
|
2016-02-05 08:05:15 +00:00
|
|
|
end
|
2016-01-20 16:54:04 +00:00
|
|
|
end
|
2016-02-17 10:41:34 +00:00
|
|
|
|
|
|
|
# extra tests for sys-v runlevels
|
2016-02-17 10:44:15 +00:00
|
|
|
if os[:family] == 'centos' && os[:release].to_i <= 6
|
2016-02-17 10:41:34 +00:00
|
|
|
describe service('sshd').runlevels do
|
|
|
|
its('keys') { should include(2) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe service('sshd').runlevels(2, 4) do
|
|
|
|
it { should be_enabled }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe service('sshd').runlevels(0, 1) do
|
|
|
|
it { should_not be_enabled }
|
|
|
|
end
|
|
|
|
end
|