Project

General

Profile

« Previous | Next » 

Revision 442e2bda

Added by Alyssa Hardy about 10 years ago

fixes #5561 pass arguments correctly in run puppet over ssh

View differences:

lib/proxy/puppet/puppet_ssh.rb
cmd = []
cmd.push(which('sudo')) if SETTINGS.puppetssh_sudo
cmd.push(which('ssh'))
cmd.push("-l #{SETTINGS.puppetssh_user}") if SETTINGS.puppetssh_user
cmd.push("-l", "#{SETTINGS.puppetssh_user}") if SETTINGS.puppetssh_user
if (file = SETTINGS.puppetssh_keyfile)
if File.exists?(file)
cmd.push("-i #{file}")
cmd.push("-i", "#{file}")
else
logger.warn("Unable to access SSH private key:#{file}, ignoring...")
end
test/puppetssh_test.rb
@puppetssh.stubs(:which).with("sudo", anything).returns("/usr/bin/sudo")
@puppetssh.stubs(:which).with("ssh", anything).returns("/usr/bin/ssh")
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-i /root/.ssh/id_rsa", "host1", "/bin/true"], false).returns(true)
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-i /root/.ssh/id_rsa", "host2", "/bin/true"], false).returns(true)
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-i", "/root/.ssh/id_rsa", "host1", "/bin/true"], false).returns(true)
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-i", "/root/.ssh/id_rsa", "host2", "/bin/true"], false).returns(true)
assert @puppetssh.run
end
......
@puppetssh.stubs(:which).with("sudo", anything).returns("/usr/bin/sudo")
@puppetssh.stubs(:which).with("ssh", anything).returns("/usr/bin/ssh")
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-l root", "host1", "/bin/true"], false).returns(true)
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-l root", "host2", "/bin/true"], false).returns(true)
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-l", "root", "host1", "/bin/true"], false).returns(true)
@puppetssh.expects(:shell_command).with(["/usr/bin/ssh", "-l", "root", "host2", "/bin/true"], false).returns(true)
assert @puppetssh.run
end

Also available in: Unified diff