mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 07:18:27 +01:00
test: ssh: add windows support for ssh config
This commit is contained in:
@@ -72,9 +72,13 @@ class RemoteSSH(RemoteBase):
|
||||
"port": self.port,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def ssh_config_filename():
|
||||
return os.path.expanduser(os.path.join("~", ".ssh", "config"))
|
||||
|
||||
@staticmethod
|
||||
def _load_user_ssh_config(hostname):
|
||||
user_config_file = os.path.expanduser("~/.ssh/config")
|
||||
user_config_file = RemoteSSH.ssh_config_filename()
|
||||
user_ssh_config = dict()
|
||||
if hostname and os.path.exists(user_config_file):
|
||||
with open(user_config_file) as f:
|
||||
|
||||
@@ -96,8 +96,8 @@ def test_ssh_host_override_from_config(
|
||||
):
|
||||
remote = RemoteSSH(None, config)
|
||||
|
||||
mock_exists.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_file.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_exists.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
mock_file.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
assert remote.host == expected_host
|
||||
|
||||
|
||||
@@ -124,8 +124,8 @@ def test_ssh_host_override_from_config(
|
||||
def test_ssh_user(mock_file, mock_exists, config, expected_user):
|
||||
remote = RemoteSSH(None, config)
|
||||
|
||||
mock_exists.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_file.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_exists.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
mock_file.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
assert remote.user == expected_user
|
||||
|
||||
|
||||
@@ -149,8 +149,8 @@ def test_ssh_user(mock_file, mock_exists, config, expected_user):
|
||||
def test_ssh_port(mock_file, mock_exists, config, expected_port):
|
||||
remote = RemoteSSH(None, config)
|
||||
|
||||
mock_exists.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_file.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_exists.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
mock_file.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
assert remote.port == expected_port
|
||||
|
||||
|
||||
@@ -184,6 +184,6 @@ def test_ssh_port(mock_file, mock_exists, config, expected_port):
|
||||
def test_ssh_keyfile(mock_file, mock_exists, config, expected_keyfile):
|
||||
remote = RemoteSSH(None, config)
|
||||
|
||||
mock_exists.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_file.assert_called_with(os.path.expanduser("~/.ssh/config"))
|
||||
mock_exists.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
mock_file.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
assert remote.keyfile == expected_keyfile
|
||||
|
||||
Reference in New Issue
Block a user