inspec/test/unit/resources/wmi_test.rb
Sonu Saha 1fb530e739 CFINSPEC-274: Add resource_id & unit test: wmi
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
2022-06-02 16:44:41 +05:30

31 lines
1.1 KiB
Ruby

require "helper"
require "inspec/resource"
require "inspec/resources/wmi"
describe "Inspec::Resources::WMI" do
# Check the following as unit test
# describe wmi({
# class: 'win32_service',
# 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
resource = MockLoader.new(:windows).load_resource("wmi", { class: "win32_service", filter: "name like '%winrm%'" })
_(resource.send("DisplayName")).must_equal "Windows Remote Management (WS-Management)"
_(resource.resource_id).must_equal "win32_service"
end
# ubuntu
it "fail wmi on ubuntu" do
resource = MockLoader.new(:ubuntu).load_resource("wmi", { class: "win32_service", filter: "name like '%winrm%'" })
_(resource.resource_failed?).must_equal true
_(resource.resource_exception_message)
.must_equal "Resource `wmi` is not supported on platform ubuntu/20.04."
_(resource.resource_id).must_equal "win32_service"
end
end