Skip to content

Commit

Permalink
[fix] Close ssh session before opening a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
okraits committed Aug 8, 2022
1 parent 83d56fc commit 0e63597
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions openwisp_controller/connection/connectors/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def _connect(self, address):
params['disabled_algorithms'] = {
'pubkeys': ['rsa-sha2-512', 'rsa-sha2-256']
}
self.shell.close()
continue
raise e
else:
Expand Down
2 changes: 1 addition & 1 deletion openwisp_controller/connection/tests/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_connection_connect_auth_failure(self, mocked_ssh_close):
dc.connect()
self.assertEqual(mocked_connect.call_count, 2)
self.assertFalse(dc.is_working)
mocked_ssh_close.assert_called_once()
self.assertEqual(mocked_ssh_close.call_count, 2)
if sys.version_info[0:2] > (3, 7):
self.assertNotIn('disabled_algorithms', mocked_connect.mock_calls[0].kwargs)
self.assertIn('disabled_algorithms', mocked_connect.mock_calls[1].kwargs)
Expand Down

0 comments on commit 0e63597

Please sign in to comment.