Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for default ssh_config path in windows #1043

Merged
merged 3 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/jnpr/junos/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ def _sshconf_lkup(self):
if self._ssh_config:
sshconf_path = os.path.expanduser(self._ssh_config)
else:
home = os.getenv('HOME')
if not home:
return None
sshconf_path = os.path.join(os.getenv('HOME'), '.ssh/config')
sshconf_path = os.path.join(os.path.expanduser('~'), '.ssh', 'config')
if not os.path.exists(sshconf_path):
return None
else:
Expand Down
12 changes: 3 additions & 9 deletions tests/unit/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,11 @@ def test_device__sshconf_lkup_sock_fd(self, mock_paramiko):
self.dev2._sshconf_lkup()
self.assertEqual(self.dev2._sshconf_lkup(), None)

@patch('os.getenv')
def test_device__sshconf_lkup_path_not_exists(self, mock_env):
mock_env.return_value = '/home/test'
@patch('os.path.expanduser')
def test_device__sshconf_lkup_path_not_exists(self, mock_path):
mock_path.return_value = '/home/test'
self.assertEqual(self.dev._sshconf_lkup(), None)

@patch('os.getenv')
def test_device__sshconf_lkup_home_not_defined(self, mock_env):
mock_env.return_value = None
self.assertEqual(self.dev._sshconf_lkup(), None)
mock_env.assert_called_with('HOME')

@patch('ncclient.manager.connect')
@patch('jnpr.junos.Device.execute')
def test_device_open(self, mock_connect, mock_execute):
Expand Down