2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/wmi"
|
2016-03-19 17:50:32 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::WMI" do
|
2016-03-19 17:50:32 +00:00
|
|
|
|
|
|
|
# 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
|
2019-06-11 22:24:35 +00:00
|
|
|
it "verify wmi parsing on windows" do
|
|
|
|
resource = MockLoader.new(:windows).load_resource("wmi", { class: "win32_service", filter: "name like '%winrm%'" })
|
|
|
|
_(resource.send("DisplayName")).must_equal "Windows Remote Management (WS-Management)"
|
2016-03-19 17:50:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# ubuntu 14.04 with upstart
|
2019-06-11 22:24:35 +00:00
|
|
|
it "fail wmi on ubuntu" do
|
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("wmi", { class: "win32_service", filter: "name like '%winrm%'" })
|
2018-07-19 12:16:54 +00:00
|
|
|
_(resource.resource_failed?).must_equal true
|
2018-03-08 21:01:50 +00:00
|
|
|
_(resource.resource_exception_message)
|
2019-06-11 22:24:35 +00:00
|
|
|
.must_equal "Resource `wmi` is not supported on platform ubuntu/14.04."
|
2016-03-19 17:50:32 +00:00
|
|
|
end
|
|
|
|
end
|