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
|
|
|
|
2016-03-18 23:22:15 +01:00
|
|
|
describe 'Inspec::Resources::Powershell' do
|
2015-10-07 13:13:37 +02:00
|
|
|
|
|
|
|
ps1_script = <<-EOH
|
|
|
|
# call help for get command
|
|
|
|
Get-Help Get-Command
|
|
|
|
EOH
|
|
|
|
|
2016-03-18 15:47:00 +01:00
|
|
|
it 'check if `powershell` for windows is properly generated ' do
|
|
|
|
resource = MockLoader.new(:windows).load_resource('powershell', ps1_script)
|
2016-09-05 12:12:34 +02:00
|
|
|
# string should be the same
|
|
|
|
_(resource.command.to_s).must_equal ps1_script
|
2016-03-18 15:47:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'check if legacy `script` for windows is properly generated ' do
|
2015-10-07 13:13:37 +02:00
|
|
|
resource = MockLoader.new(:windows).load_resource('script', ps1_script)
|
2016-09-05 12:12:34 +02:00
|
|
|
# string should be the same
|
|
|
|
_(resource.command.to_s).must_equal ps1_script
|
2015-10-07 13:13:37 +02:00
|
|
|
end
|
2017-05-30 12:36:15 -04:00
|
|
|
|
|
|
|
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
|
2015-10-07 13:13:37 +02:00
|
|
|
end
|