test: ssh: add windows support for ssh config

This commit is contained in:
khamutov
2019-05-06 21:47:58 +03:00
parent 65fd7f9c8f
commit 02eebd48eb
2 changed files with 13 additions and 9 deletions
+5 -1
View File
@@ -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:
+8 -8
View File
@@ -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