mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
can check windows service startup mode now
This commit is contained in:
parent
9e45d71bf3
commit
4041f1898e
2 changed files with 10 additions and 0 deletions
|
@ -77,6 +77,7 @@ module Inspec::Resources
|
||||||
it { should be_enabled }
|
it { should be_enabled }
|
||||||
it { should be_running }
|
it { should be_running }
|
||||||
its('type') { should be 'systemd' }
|
its('type') { should be 'systemd' }
|
||||||
|
its ('startmode') { should be 'Auto'}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe service('service_name').runlevels(3, 5) do
|
describe service('service_name').runlevels(3, 5) do
|
||||||
|
@ -210,6 +211,12 @@ module Inspec::Resources
|
||||||
info[:description]
|
info[:description]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the service start up mode from info
|
||||||
|
def startmode
|
||||||
|
return nil if info.nil?
|
||||||
|
info[:startmode]
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"Service #{@service_name}"
|
"Service #{@service_name}"
|
||||||
end
|
end
|
||||||
|
@ -547,6 +554,7 @@ module Inspec::Resources
|
||||||
#
|
#
|
||||||
# Until StartMode is not added to Get-Service, we need to do a workaround
|
# 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
|
# @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
|
# 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
|
# 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
|
# erty Name, StartMode, State, Status | ConvertTo-Json
|
||||||
|
@ -587,6 +595,7 @@ module Inspec::Resources
|
||||||
installed: true,
|
installed: true,
|
||||||
running: service_running?(service),
|
running: service_running?(service),
|
||||||
enabled: service_enabled?(service),
|
enabled: service_enabled?(service),
|
||||||
|
startmode: service['WMI']['StartMode'],
|
||||||
type: 'windows',
|
type: 'windows',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,7 @@ describe 'Inspec::Resources::Service' do
|
||||||
_(resource.installed?).must_equal true
|
_(resource.installed?).must_equal true
|
||||||
_(resource.enabled?).must_equal true
|
_(resource.enabled?).must_equal true
|
||||||
_(resource.running?).must_equal true
|
_(resource.running?).must_equal true
|
||||||
|
_(resource.startmode). must_equal 'Auto'
|
||||||
_(resource.params).must_equal params
|
_(resource.params).must_equal params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue