inspec/test/unit/resources/powershell_test.rb

33 lines
1.8 KiB
Ruby
Raw Normal View History

2015-10-07 11:13:37 +00:00
# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
require 'helper'
2015-10-26 03:04:18 +00:00
require 'inspec/resource'
2015-10-07 11:13:37 +00:00
2016-03-18 22:22:15 +00:00
describe 'Inspec::Resources::Powershell' do
2015-10-07 11:13:37 +00:00
ps1_script = <<-EOH
# call help for get command
Get-Help Get-Command
EOH
2016-03-18 14:47:00 +00:00
it 'check if `powershell` for windows is properly generated ' do
resource = MockLoader.new(:windows).load_resource('powershell', ps1_script)
if Gem.loaded_specs['winrm'].version < Gem::Version.new('1.6.1')
_(resource.command).must_equal 'powershell -encodedCommand IAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
else
_(resource.command).must_equal 'powershell -encodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsAIAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
end
end
it 'check if legacy `script` for windows is properly generated ' do
2015-10-07 11:13:37 +00:00
resource = MockLoader.new(:windows).load_resource('script', ps1_script)
if Gem.loaded_specs['winrm'].version < Gem::Version.new('1.6.1')
_(resource.command).must_equal 'powershell -encodedCommand IAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
else
_(resource.command).must_equal 'powershell -encodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsAIAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
end
2015-10-07 11:13:37 +00:00
end
end