Merge pull request #968 from Anirudh-Gupta/master

can check windows service startup mode now
This commit is contained in:
Kartik Null Cating-Subramanian 2016-08-23 16:41:25 -04:00 committed by GitHub
commit 16a943fae5
2 changed files with 10 additions and 0 deletions

View file

@ -77,6 +77,7 @@ module Inspec::Resources
it { should be_enabled }
it { should be_running }
its('type') { should be 'systemd' }
its ('startmode') { should be 'Auto'}
end
describe service('service_name').runlevels(3, 5) do
@ -210,6 +211,12 @@ module Inspec::Resources
info[:description]
end
# returns the service start up mode from info
def startmode
return nil if info.nil?
info[:startmode]
end
def to_s
"Service #{@service_name}"
end
@ -547,6 +554,7 @@ module Inspec::Resources
#
# Until StartMode is not added to Get-Service, we need to do a workaround
# @see: https://connect.microsoft.com/PowerShell/feedback/details/424948/i-would-like-to-see-the-property-starttype-added-to-get-services
# Also see: https://msdn.microsoft.com/en-us/library/aa384896(v=vs.85).aspx
# Use the following powershell to determine the start mode
# PS: Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq $name -or $_.DisplayName -eq $name} | Select-Object -Prop
# erty Name, StartMode, State, Status | ConvertTo-Json
@ -587,6 +595,7 @@ module Inspec::Resources
installed: true,
running: service_running?(service),
enabled: service_enabled?(service),
startmode: service['WMI']['StartMode'],
type: 'windows',
}
end

View file

@ -19,6 +19,7 @@ describe 'Inspec::Resources::Service' do
_(resource.installed?).must_equal true
_(resource.enabled?).must_equal true
_(resource.running?).must_equal true
_(resource.startmode). must_equal 'Auto'
_(resource.params).must_equal params
end