Merge pull request #637 from jmccann/fix_systemd_enabled

Add 'static' value as enabled to systemd service enabled check
This commit is contained in:
Christoph Hartmann 2016-04-13 16:10:06 -04:00
commit 1e5209fb0b
4 changed files with 18 additions and 1 deletions

View file

@ -214,7 +214,7 @@ module Inspec::Resources
running = params['SubState'] == 'running'
# test via systemctl --quiet is-enabled
# ActiveState values eg.g inactive, active
enabled = params['UnitFileState'] == 'enabled'
enabled = %w{enabled static}.include? params['UnitFileState']
{
name: params['Id'],

View file

@ -178,6 +178,8 @@ class MockLoader
# show ssh service Centos 7
'systemctl show --all sshd' => cmd.call('systemctl-show-all-sshd'),
'/path/to/systemctl show --all sshd' => cmd.call('systemctl-show-all-sshd'),
'systemctl show --all dbus' => cmd.call('systemctl-show-all-dbus'),
'/path/to/systemctl show --all dbus' => cmd.call('systemctl-show-all-dbus'),
# services on macos
'launchctl list' => cmd.call('launchctl-list'),
# services on freebsd 10

View file

@ -0,0 +1,6 @@
Id=dbus.service
Names=messagebus.service dbus.service
Description=D-Bus System Message Bus
LoadState=loaded
UnitFileState=static
SubState=running

View file

@ -94,6 +94,15 @@ describe 'Inspec::Resources::Service' do
_(resource.running?).must_equal true
end
it 'verify centos 7 package parsing with static loaded service' do
resource = MockLoader.new(:centos7).load_resource('service', 'dbus')
srv = { name: 'dbus.service', description: 'D-Bus System Message Bus', installed: true, running: true, enabled: true, type: 'systemd' }
_(resource.info).must_equal srv
_(resource.installed?).must_equal true
_(resource.enabled?).must_equal true
_(resource.running?).must_equal true
end
# freebsd
it 'verify freebsd10 package parsing' do
resource = MockLoader.new(:freebsd10).load_resource('service', 'sendmail')