inspec/test/unit/resources/powershell_test.rb
Miah Johnson 6c19e81a06 Remove authors tags from source files.
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-05-28 12:47:39 -07:00

30 lines
1.1 KiB
Ruby

require 'helper'
require 'inspec/resource'
describe 'Inspec::Resources::PowershellScript' do
let(:base64_command) {
# Encoded version of `$ProgressPreference='SilentlyContinue';Get-Help`
'JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwA' \
'ZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsARwBlAHQALQBIAGUAbABwAA=='
}
it 'properly generates command' do
resource = MockLoader.new(:windows).load_resource('powershell', 'Get-Help')
_(resource.command).must_equal 'Get-Help'
resource = MockLoader.new(:osx104).load_resource('powershell', 'Get-Help')
_(resource.command).must_equal("pwsh -encodedCommand '#{base64_command}'")
end
it 'properly generates command if deprecated `script` is used' do
expect_deprecation(:resource_script) do
resource = MockLoader.new(:windows).load_resource('script', 'Get-Help')
_(resource.command).must_equal 'Get-Help'
end
expect_deprecation(:resource_script) do
resource = MockLoader.new(:osx104).load_resource('script', 'Get-Help')
_(resource.command).must_equal("pwsh -encodedCommand '#{base64_command}'")
end
end
end