From 4d587b336e658c1f6b91843f018b71c7f74c2f18 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 10 Apr 2008 13:38:12 -0400 Subject: [PATCH] pass the entire ssh_options Hash in a ServerDefinition's options to the Net:SSH.start call for that server --- lib/capistrano/ssh.rb | 4 ++-- test/ssh_test.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/capistrano/ssh.rb b/lib/capistrano/ssh.rb index a62fb04f..2e89ab5c 100644 --- a/lib/capistrano/ssh.rb +++ b/lib/capistrano/ssh.rb @@ -91,8 +91,8 @@ module Capistrano def self.connect(server, options={}, &block) methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ] password_value = nil - - ssh_options = (options[:ssh_options] || {}).dup + + ssh_options = (server.options[:ssh_options] || {}).dup.merge(options[:ssh_options] || {}).dup ssh_options[:username] = server.user || options[:user] || ssh_options[:username] ssh_options[:port] = server.port || options[:port] || ssh_options[:port] || DEFAULT_PORT diff --git a/test/ssh_test.rb b/test/ssh_test.rb index 29b26d34..84276f29 100644 --- a/test/ssh_test.rb +++ b/test/ssh_test.rb @@ -63,6 +63,12 @@ class SSHTest < Test::Unit::TestCase assert_equal success, Capistrano::SSH.connect(server) end + def test_connect_with_server_with_other_ssh_options_should_pass_ssh_options_to_net_ssh + server = server("jamis@capistrano:1235", :ssh_options => { :keys => %w(some_valid_key), :auth_methods => %w(a_method), :hmac => 'none' }) + Net::SSH.expects(:start).with(server.host, @options.merge(:username => "jamis", :port => 1235, :keys => %w(some_valid_key), :auth_methods => %w(a_method), :hmac => 'none' )).returns(success = Object.new) + assert_equal success, Capistrano::SSH.connect(server) + end + def test_connect_with_ssh_options_should_use_ssh_options ssh_options = { :username => "JamisMan", :port => 8125 } Net::SSH.expects(:start).with(@server.host, @options.merge(:username => "JamisMan", :port => 8125)).returns(success = Object.new)