mirror of
https://github.com/inspec/inspec
synced 2024-11-11 07:34:15 +00:00
*_service: add unit tests
NB I've just added default duplicates to one instance (i.e., there's only one `systemd_service`), since there's no os-specific magic in them. Also these tests only verify that the default choice is equivalent to `service` on the tested distribution.
This commit is contained in:
parent
0e410df69d
commit
5c0cdb31c9
1 changed files with 41 additions and 5 deletions
|
@ -27,6 +27,15 @@ describe 'Inspec::Resources::Service' do
|
|||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
it 'verify ubuntu package parsing with default upstart_service' do
|
||||
resource = MockLoader.new(:ubuntu1404).load_resource('upstart_service', 'ssh')
|
||||
srv = { name: 'ssh', description: nil, installed: true, running: true, enabled: true, type: 'upstart' }
|
||||
_(resource.info).must_equal srv
|
||||
_(resource.installed?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# ubuntu 15.04 with systemd
|
||||
it 'verify ubuntu package parsing' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('service', 'sshd')
|
||||
|
@ -37,8 +46,7 @@ describe 'Inspec::Resources::Service' do
|
|||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# ubuntu 15.04 with systemd_service
|
||||
it 'verify ubuntu package parsing with systemd_service' do
|
||||
it 'verify ubuntu package parsing with default systemd_service' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('systemd_service', 'sshd')
|
||||
srv = { name: 'sshd.service', description: 'OpenSSH server daemon', installed: true, running: true, enabled: true, type: 'systemd' }
|
||||
_(resource.info).must_equal srv
|
||||
|
@ -47,7 +55,7 @@ describe 'Inspec::Resources::Service' do
|
|||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# centos 6 with systemv
|
||||
# centos 6 with sysv
|
||||
it 'verify centos 6 package parsing' do
|
||||
resource = MockLoader.new(:centos6).load_resource('service', 'sshd')
|
||||
srv = { name: 'sshd', description: nil, installed: true, running: true, enabled: true, type: 'sysv' }
|
||||
|
@ -57,6 +65,15 @@ describe 'Inspec::Resources::Service' do
|
|||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
it 'verify centos 6 package parsing with default sysv_service' do
|
||||
resource = MockLoader.new(:centos6).load_resource('sysv_service', 'sshd')
|
||||
srv = { name: 'sshd', description: nil, installed: true, running: true, enabled: true, type: 'sysv' }
|
||||
_(resource.info).must_equal srv
|
||||
_(resource.installed?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# centos 7 with systemd
|
||||
it 'verify centos 7 package parsing' do
|
||||
resource = MockLoader.new(:centos7).load_resource('service', 'sshd')
|
||||
|
@ -77,6 +94,15 @@ describe 'Inspec::Resources::Service' do
|
|||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
it 'verify freebsd10 package parsing with default bsd_service' do
|
||||
resource = MockLoader.new(:freebsd10).load_resource('bsd_service', 'sendmail')
|
||||
srv = { name: 'sendmail', description: nil, installed: true, running: true, enabled: true, type: 'bsd-init' }
|
||||
_(resource.info).must_equal srv
|
||||
_(resource.installed?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# arch linux with systemd
|
||||
it 'verify arch linux package parsing' do
|
||||
resource = MockLoader.new(:arch).load_resource('service', 'sshd')
|
||||
|
@ -98,7 +124,7 @@ describe 'Inspec::Resources::Service' do
|
|||
end
|
||||
|
||||
# debian 8 with systemd
|
||||
it 'verify arch linux package parsing' do
|
||||
it 'verify debian 8 package parsing' do
|
||||
resource = MockLoader.new(:debian8).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
|
||||
|
@ -108,7 +134,7 @@ describe 'Inspec::Resources::Service' do
|
|||
end
|
||||
|
||||
# macos test
|
||||
it 'verify arch linux package parsing' do
|
||||
it 'verify mac osx package parsing' do
|
||||
resource = MockLoader.new(:osx104).load_resource('service', 'ssh')
|
||||
srv = { name: 'org.openbsd.ssh-agent', description: nil, installed: true, running: true, enabled: true, type: 'darwin' }
|
||||
_(resource.info).must_equal srv
|
||||
|
@ -117,6 +143,15 @@ describe 'Inspec::Resources::Service' do
|
|||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
it 'verify mac osx package parsing with default launchd_service' do
|
||||
resource = MockLoader.new(:osx104).load_resource('launchd_service', 'ssh')
|
||||
srv = { name: 'org.openbsd.ssh-agent', description: nil, installed: true, running: true, enabled: true, type: 'darwin' }
|
||||
_(resource.info).must_equal srv
|
||||
_(resource.installed?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
_(resource.running?).must_equal true
|
||||
end
|
||||
|
||||
# wrlinux
|
||||
it 'verify wrlinux package parsing' do
|
||||
resource = MockLoader.new(:wrlinux).load_resource('service', 'sshd')
|
||||
|
@ -127,6 +162,7 @@ describe 'Inspec::Resources::Service' do
|
|||
_(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…
Reference in a new issue