Sha256: dd462122461fc7e78ebf2cc636ca52a6da8dde01464712de0a2bab0eba27bcc4

Contents?: true

Size: 1.65 KB

Versions: 25

Compression:

Stored size: 1.65 KB

Contents

# 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
  # describe wmi('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', 'win32_service', { filter: "name like '%winrm%'" })
    _(resource.send('DisplayName')).must_equal 'Windows Remote Management (WS-Management)'
    _(resource.send('method_missing', 'Path', 'ClassName')).must_equal 'Win32_Service'
  end

  # ubuntu 14.04 with upstart
  it 'fail wmi on ubuntu' do
    resource = MockLoader.new(:ubuntu1404).load_resource('wmi', 'win32_service', { filter: "name like '%winrm%'" })
    _(resource.send('DisplayName')).must_equal nil
    _(resource.send('method_missing', 'Path', 'ClassName')).must_equal nil
  end

  # centos 7 with systemd
  it 'fail wmi on centos' do
    resource = MockLoader.new(:centos7).load_resource('wmi', 'win32_service', { filter: "name like '%winrm%'" })
    _(resource.send('DisplayName')).must_equal nil
    _(resource.send('method_missing', 'Path', 'ClassName')).must_equal nil
  end

  # unknown OS
  it 'fail wmi on unknown os' do
    resource = MockLoader.new(:undefined).load_resource('wmi', 'win32_service', { filter: "name like '%winrm%'" })
    _(resource.send('DisplayName')).must_equal nil
    _(resource.send('method_missing', 'Path', 'ClassName')).must_equal nil
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
inspec-0.26.0 test/unit/resources/wmi_test.rb
inspec-0.25.0 test/unit/resources/wmi_test.rb
inspec-0.24.0 test/unit/resources/wmi_test.rb
inspec-0.23 test/unit/resources/wmi_test.rb
inspec-0.22.1 test/unit/resources/wmi_test.rb
inspec-0.22.0 test/unit/resources/wmi_test.rb
inspec-0.21.6 test/unit/resources/wmi_test.rb
inspec-0.21.5 test/unit/resources/wmi_test.rb
inspec-0.21.4 test/unit/resources/wmi_test.rb
inspec-0.21.3 test/unit/resources/wmi_test.rb
inspec-0.21.2 test/unit/resources/wmi_test.rb
inspec-0.21.1 test/unit/resources/wmi_test.rb
inspec-0.21.0 test/unit/resources/wmi_test.rb
inspec-0.20.1 test/unit/resources/wmi_test.rb
inspec-0.20.0 test/unit/resources/wmi_test.rb
inspec-0.19.2 test/unit/resources/wmi_test.rb
inspec-0.19.1 test/unit/resources/wmi_test.rb
inspec-0.19.0 test/unit/resources/wmi_test.rb
inspec-0.18.0 test/unit/resources/wmi_test.rb
inspec-0.17.1 test/unit/resources/wmi_test.rb