mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
add centos 7 unit mock for service resource
This commit is contained in:
parent
2a3c3270b3
commit
cb3d170ce6
4 changed files with 18 additions and 1 deletions
|
@ -121,7 +121,7 @@ class Systemd < ServiceManager
|
|||
params['LoadState'] == 'loaded' ? (installed = true) : (installed = false)
|
||||
# test via 'systemctl is-active service'
|
||||
# SubState values running
|
||||
params['LoadState'] == 'running' ? (running = true) : (running = false)
|
||||
params['SubState'] == 'running' ? (running = true) : (running = false)
|
||||
# test via systemctl --quiet is-enabled
|
||||
# ActiveState values eg.g inactive, active
|
||||
params['ActiveState'] == 'active' ? (enabled = true) : (enabled = false)
|
||||
|
|
|
@ -106,6 +106,7 @@ class MockLoader
|
|||
"Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq 'Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161'} | Select-Object -Property Name,Version,Vendor,PackageCode,Caption,Description | ConvertTo-Json" => cmd.call('win32_product'),
|
||||
'initctl status ssh' => cmd.call('initctl-status-ssh'),
|
||||
'initctl show-config ssh' => cmd.call('initctl-show-config-ssh'),
|
||||
'systemctl show --all sshd' => cmd.call('systemctl-show-all-sshd'), # Centos 7
|
||||
}
|
||||
|
||||
# set os emulation
|
||||
|
|
6
test/unit/mock/cmd/systemctl-show-all-sshd
Normal file
6
test/unit/mock/cmd/systemctl-show-all-sshd
Normal file
|
@ -0,0 +1,6 @@
|
|||
Id=sshd.service
|
||||
Names=sshd.service
|
||||
Description=OpenSSH server daemon
|
||||
LoadState=loaded
|
||||
ActiveState=active
|
||||
SubState=running
|
|
@ -24,6 +24,16 @@ describe 'Vulcano::Resources::Service' do
|
|||
_(resource.enabled?).must_equal true
|
||||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# centos 7 with systemd
|
||||
it 'verify centos package parsing' do
|
||||
resource = MockLoader.new(:centos7).load_resource('service', 'sshd')
|
||||
srv = { name: 'sshd.service', description: 'OpenSSH server daemon', 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
|
||||
# unknown OS
|
||||
it 'verify package handling on unsupported os' do
|
||||
resource = MockLoader.new(:undefined).load_resource('service', 'dhcp')
|
||||
|
|
Loading…
Add table
Reference in a new issue