mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Close & remove paramiko connection where appropriate (#37528)
* Close & remove paramiko connection where appropriate * Update unit test
This commit is contained in:
parent
93d2761551
commit
594840c1d6
2 changed files with 6 additions and 1 deletions
|
@ -368,8 +368,11 @@ class Connection(ConnectionBase):
|
|||
self._ssh_shell.close()
|
||||
self._ssh_shell = None
|
||||
display.debug("cli session is now closed")
|
||||
|
||||
self.paramiko_conn.close()
|
||||
self.paramiko_conn = None
|
||||
display.debug("ssh connection has been closed successfully")
|
||||
self._connected = False
|
||||
display.debug("ssh connection has been closed successfully")
|
||||
|
||||
def receive(self, command=None, prompts=None, answer=None, newline=True, prompt_retry_check=False):
|
||||
'''
|
||||
|
|
|
@ -93,11 +93,13 @@ class TestConnectionClass(unittest.TestCase):
|
|||
terminal = MagicMock(supports_multiplexing=False)
|
||||
conn._terminal = terminal
|
||||
conn._ssh_shell = MagicMock()
|
||||
conn.paramiko_conn = MagicMock()
|
||||
conn._connected = True
|
||||
|
||||
conn.close()
|
||||
self.assertTrue(terminal.on_close_shell.called)
|
||||
self.assertIsNone(conn._ssh_shell)
|
||||
self.assertIsNone(conn.paramiko_conn)
|
||||
|
||||
@patch("ansible.plugins.connection.paramiko_ssh.Connection._connect")
|
||||
def test_network_cli_exec_command(self, mocked_super):
|
||||
|
|
Loading…
Reference in a new issue