def test_open_ssh_proxy_session(mocker, instance_id, ssm_mock): m = mocker.patch("aws_gate.session_common.execute_plugin", return_value="output") sess = SshProxySession(instance_id=instance_id, ssm=ssm_mock) sess.open() assert m.called
def test_open_ssh_proxy_session(self): with patch('aws_gate.session_common.execute_plugin', return_value='output') as m: sess = SshProxySession(instance_id=self.instance_id, ssm=self.ssm) sess.open() self.assertTrue(m.called)
def test_create_ssh_proxy_session(self): with patch.object(self.ssm, 'start_session', return_value=self.response): sess = SshProxySession(instance_id=self.instance_id, ssm=self.ssm) sess.create() self.assertTrue(self.ssm.start_session.called)
def test_ssh_proxy_session_context_manager(self): with patch.object(self.ssm, 'start_session', return_value=self.response) as sm, \ patch.object(self.ssm, 'terminate_session', return_value=self.response) as tm: with SshProxySession(instance_id=self.instance_id, ssm=self.ssm): pass self.assertTrue(sm.called) self.assertTrue(tm.called)
def test_terminate_ssh_proxy_session(ssm_mock, instance_id): sess = SshProxySession(instance_id=instance_id, ssm=ssm_mock) sess.create() sess.terminate() assert ssm_mock.terminate_session.called
def test_ssh_proxy_session_context_manager(ssm_mock, instance_id): with SshProxySession(instance_id=instance_id, ssm=ssm_mock): pass assert ssm_mock.start_session.called assert ssm_mock.terminate_session.called