inspec/test/unit/resources/powershell_test.rb

31 lines
1.1 KiB
Ruby
Raw Normal View History

require "helper"
require "inspec/resource"
require "inspec/resources/powershell"
2015-10-07 11:13:37 +00:00
describe "Inspec::Resources::Powershell" do
let(:base64_command) do
# Encoded version of `$ProgressPreference='SilentlyContinue';Get-Help`
"JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwA" \
"ZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsARwBlAHQALQBIAGUAbABwAA=="
end
2015-10-07 11:13:37 +00:00
it "properly generates command" do
resource = MockLoader.new(:windows).load_resource("powershell", "Get-Help")
_(resource.command).must_equal "Get-Help"
2015-10-07 11:13:37 +00:00
resource = MockLoader.new(:osx104).load_resource("powershell", "Get-Help")
_(resource.command).must_equal("pwsh -encodedCommand '#{base64_command}'")
2016-03-18 14:47:00 +00:00
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
2015-10-07 11:13:37 +00:00
end