forked from matschaffer/knife-solo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
matschaffer#450 rsync command doesn't work in windows with cygwin due…
… to broken ControlMaster support
- Loading branch information
Showing
3 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
require 'test_helper' | ||
|
||
require 'knife-solo/ssh_command' | ||
require 'knife-solo/tools' | ||
require 'chef/knife' | ||
require 'net/ssh' | ||
|
||
|
@@ -9,6 +10,11 @@ class DummySshCommand < Chef::Knife | |
end | ||
|
||
class SshCommandTest < TestCase | ||
|
||
def setup | ||
KnifeSolo::Tools.stubs(:cygwin_client?).returns(false) | ||
end | ||
|
||
def test_separates_user_and_host | ||
assert_equal "ubuntu", command("[email protected]").user | ||
assert_equal "10.0.0.1", command("[email protected]").host | ||
|
@@ -69,7 +75,7 @@ def test_try_connection_with_gateway_connects_using_ssh_gateway | |
cmd = command("10.0.0.1", "--ssh-gateway=user@gateway") | ||
ssh_mock = mock 'ssh_mock' | ||
Net::SSH::Gateway.expects(:new).with('gateway', 'user').returns(ssh_mock) | ||
ssh_mock.expects(:ssh).with(cmd.host, cmd.user, cmd.connection_options.except(:gateway)) | ||
ssh_mock.expects(:ssh).with(cmd.host, cmd.user, cmd.connection_options.select{|o| o != :gateway}) | ||
|
||
Net::SSH.expects(:start).never | ||
|
||
|
@@ -164,6 +170,26 @@ def test_builds_cli_ssh_args | |
assert_equal "[email protected] -o ControlMaster=auto -o ControlPath=#{cmd.ssh_control_path} -o ControlPersist=3600", cmd.ssh_args | ||
end | ||
|
||
def test_no_control_master_by_default_in_cygwin | ||
DummySshCommand.any_instance.stubs(:try_connection) | ||
DummySshCommand.any_instance.stubs(:ssh_control_path).returns('/path') | ||
KnifeSolo::Tools.stubs(:cygwin_client?).returns(false) | ||
cmd = command_internal('[email protected]') | ||
cmd.validate_ssh_options! | ||
assert_equal '[email protected] -o ControlMaster=auto -o ControlPath=/path -o ControlPersist=3600', cmd.ssh_args | ||
|
||
# if knife-solo runs in cygwin, disable ssh ControlMaster by default | ||
KnifeSolo::Tools.stubs(:cygwin_client?).returns(true) | ||
cmd = command_internal('[email protected]') | ||
cmd.validate_ssh_options! | ||
assert_equal '[email protected]', cmd.ssh_args | ||
|
||
KnifeSolo::Tools.stubs(:cygwin_client?).returns(true) | ||
cmd = command_internal('[email protected]', '--ssh-control-master=auto') | ||
cmd.validate_ssh_options! | ||
assert_equal '[email protected] -o ControlMaster=auto -o ControlPath=/path -o ControlPersist=3600', cmd.ssh_args | ||
end | ||
|
||
def test_barks_without_atleast_a_hostname | ||
cmd = command | ||
cmd.ui.expects(:fatal).with(regexp_matches(/hostname.*argument/)) | ||
|