Project

General

Profile

« Previous | Next » 

Revision b446e0ce

Added by Dmitri Dolguikh over 8 years ago

Fixes #10940: puppetrun works properly now on ruby > 1.8.7

View differences:

modules/puppet_proxy/customrun.rb
return false
end
shell_command( [ escape_for_shell(cmd), Proxy::Puppet::Plugin.settings.customrun_args, shell_escaped_nodes ] )
customrun_args = (a = Proxy::Puppet::Plugin.settings.customrun_args).is_a?(Array) ? a : a.split(' ')
shell_command(([escape_for_shell(cmd), customrun_args] + shell_escaped_nodes).flatten)
end
end
test/puppet/customrun_test.rb
require 'test_helper'
require 'puppet_proxy/puppet_plugin'
require 'puppet_proxy/customrun'
class CustomRunTest < Test::Unit::TestCase
def setup
@customrun = Proxy::Puppet::CustomRun.new(:nodes => ["host1", "host2"])
end
def test_customrun
::Proxy::Puppet::Plugin.load_test_settings(:customrun_cmd => "/bin/false", :customrun_args => "-ay -f -s")
@customrun.expects(:shell_command).with(["/bin/false", "-ay", "-f", "-s", "host1", "host2"]).returns(true)
@customrun.run
end
def test_customrun_with_array_command_args
::Proxy::Puppet::Plugin.load_test_settings(:customrun_cmd => "/bin/false", :customrun_args => ["-ay", "-f", "-s"])
@customrun.expects(:shell_command).with(["/bin/false", "-ay", "-f", "-s", "host1", "host2"]).returns(true)
@customrun.run
end
def test_customrun_uses_shell_escaped_command
::Proxy::Puppet::Plugin.load_test_settings(:customrun_cmd => "puppet's_run", :customrun_args => "-ay -f -s")
File.stubs(:exist?).with("puppet's_run").returns(true)
@customrun.expects(:shell_command).with(["puppet\\'s_run", "-ay", "-f", "-s", "host1", "host2"]).returns(true)
@customrun.run
end
end

Also available in: Unified diff