test/integration/default/wmi_spec.rb in inspec-0.26.0 vs test/integration/default/wmi_spec.rb in inspec-0.27.0

- old
+ new

@@ -1,28 +1,63 @@ # encoding: utf-8 return unless os.windows? -# Get-WmiObject win32_service -# Get-WmiObject -class win32_service +# Get-WmiObject win32_service or Get-WmiObject -class win32_service # returns an array of service objects -describe wmi('win32_service') do - its(['Path','ClassName']) { should include 'Win32_Service' } +describe wmi({class: 'win32_service'}) do its('DisplayName') { should include 'Windows Remote Management (WS-Management)'} end -# Use win32_service with filter -# this returns a single service object -describe wmi('win32_service', { +# Use win32_service with filter, it returns a single service object +describe wmi({ + class: 'win32_service', filter: "name like '%winrm%'" }) do - its(['Path','ClassName']) { should eq 'Win32_Service' } + its('Status') { should cmp 'ok' } + its('State') { should cmp 'Running' } + its('ExitCode') { should cmp 0 } its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'} end # TODO: this works on domain controllers only +describe wmi({ + class: 'RSOP_SecuritySettingNumeric', + namespace: 'root\\rsop\\computer', + filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1' +}) do + its('Setting') { should eq 1 } +end + +# new syntax +describe wmi({ + namespace: 'root\rsop\computer', + query: "SELECT Setting FROM RSOP_SecuritySettingBoolean WHERE KeyName='LSAAnonymousNameLookup' AND Precedence=1" +}) do + its('Setting') { should eq false } +end + +describe wmi({ + namespace: 'root\cimv2', + query: 'SELECT filesystem FROM win32_logicaldisk WHERE drivetype=3' +}).params.values.join do + it { should eq 'NTFS' } +end + +# deprecated syntax +describe wmi('win32_service') do + its('DisplayName') { should include 'Windows Remote Management (WS-Management)'} +end + describe wmi('RSOP_SecuritySettingNumeric', { namespace: 'root\\rsop\\computer', filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1' }) do its('Setting') { should eq 1 } + its('setting') { should eq 1 } +end + +describe wmi('win32_service', { + filter: "name like '%winrm%'" +}) do + its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'} end