2016-03-19 17:50:32 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
# author: Christoph Hartmann
|
|
|
|
# author: Dominik Richter
|
|
|
|
|
|
|
|
require 'helper'
|
|
|
|
require 'inspec/resource'
|
|
|
|
|
|
|
|
describe 'Inspec::Resources::WMI' do
|
|
|
|
|
|
|
|
# Check the following as unit test
|
2016-06-18 15:54:04 +00:00
|
|
|
# describe wmi({
|
|
|
|
# class: 'win32_service',
|
2016-03-19 17:50:32 +00:00
|
|
|
# filter: "name like '%winrm%'"
|
|
|
|
# }) do
|
|
|
|
# its(['Path','ClassName']) { should eq 'Win32_Service' }
|
|
|
|
# its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
|
|
|
# end
|
|
|
|
|
|
|
|
# windows
|
|
|
|
it 'verify wmi parsing on windows' do
|
2016-06-18 15:54:04 +00:00
|
|
|
resource = MockLoader.new(:windows).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
2016-03-19 17:50:32 +00:00
|
|
|
_(resource.send('DisplayName')).must_equal 'Windows Remote Management (WS-Management)'
|
|
|
|
end
|
|
|
|
|
|
|
|
# ubuntu 14.04 with upstart
|
|
|
|
it 'fail wmi on ubuntu' do
|
2016-06-18 15:54:04 +00:00
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.send('DisplayName')).must_be_nil
|
2016-03-19 17:50:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# centos 7 with systemd
|
|
|
|
it 'fail wmi on centos' do
|
2016-06-18 15:54:04 +00:00
|
|
|
resource = MockLoader.new(:centos7).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.send('DisplayName')).must_be_nil
|
2016-03-19 17:50:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# unknown OS
|
|
|
|
it 'fail wmi on unknown os' do
|
2016-06-18 15:54:04 +00:00
|
|
|
resource = MockLoader.new(:undefined).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.send('DisplayName')).must_be_nil
|
2016-03-19 17:50:32 +00:00
|
|
|
end
|
|
|
|
end
|