inspec/test/unit/resources/powershell_test.rb

34 lines
1.2 KiB
Ruby
Raw Normal View History

2015-10-07 13:13:37 +02:00
# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
require 'helper'
2015-10-26 04:04:18 +01:00
require 'inspec/resource'
2015-10-07 13:13:37 +02:00
describe 'Inspec::Resources::PowershellScript' do
let(:base64_command) {
# Encoded version of `$ProgressPreference='SilentlyContinue';Get-Help`
'JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwA' \
'ZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsARwBlAHQALQBIAGUAbABwAA=='
}
2015-10-07 13:13:37 +02:00
it 'properly generates command' do
resource = MockLoader.new(:windows).load_resource('powershell', 'Get-Help')
_(resource.command).must_equal 'Get-Help'
2015-10-07 13:13:37 +02:00
resource = MockLoader.new(:osx104).load_resource('powershell', 'Get-Help')
_(resource.command).must_equal("pwsh -encodedCommand '#{base64_command}'")
2016-03-18 15:47:00 +01:00
end
it 'properly generates command if deprecated `script` is used' do
expect_deprecation_warning do
resource = MockLoader.new(:windows).load_resource('script', 'Get-Help')
_(resource.command).must_equal 'Get-Help'
end
expect_deprecation_warning do
resource = MockLoader.new(:osx104).load_resource('script', 'Get-Help')
_(resource.command).must_equal("pwsh -encodedCommand '#{base64_command}'")
end
end
2015-10-07 13:13:37 +02:00
end