mirror of
https://github.com/inspec/inspec
synced 2024-12-11 22:02:47 +00:00
ba149a9e1a
Unsupported operating systems AND the mockloader when using inspec analysis tools may lead to powershell being called with the command being `nil`, because the resource skips during the initialize phase. Instead, propagate an empty string so that `command` has a valid input and then skip the resource. Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
32 lines
951 B
Ruby
32 lines
951 B
Ruby
# encoding: utf-8
|
|
# author: Christoph Hartmann
|
|
# author: Dominik Richter
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
|
|
describe 'Inspec::Resources::Powershell' do
|
|
|
|
ps1_script = <<-EOH
|
|
# call help for get command
|
|
Get-Help Get-Command
|
|
EOH
|
|
|
|
it 'check if `powershell` for windows is properly generated ' do
|
|
resource = MockLoader.new(:windows).load_resource('powershell', ps1_script)
|
|
# string should be the same
|
|
_(resource.command.to_s).must_equal ps1_script
|
|
end
|
|
|
|
it 'check if legacy `script` for windows is properly generated ' do
|
|
resource = MockLoader.new(:windows).load_resource('script', ps1_script)
|
|
# string should be the same
|
|
_(resource.command.to_s).must_equal ps1_script
|
|
end
|
|
|
|
it 'will return an empty array when called on a non-supported OS with children' do
|
|
resource = MockLoader.new.load_resource('powershell', '...')
|
|
# string should be the same
|
|
_(resource.stdout).must_equal ''
|
|
end
|
|
end
|