예제 #1
0
def test_open_ssm_session(mocker, ssm_mock, instance_id):
    m = mocker.patch("aws_gate.session_common.execute_plugin",
                     return_value="output")
    sess = SSMSession(instance_id=instance_id, ssm=ssm_mock)
    sess.open()

    assert m.called
예제 #2
0
    def test_open_ssm_session(self):
        with patch('aws_gate.session_common.execute_plugin',
                   return_value='output') as m:
            sess = SSMSession(instance_id=self.instance_id, ssm=self.ssm)
            sess.open()

            self.assertTrue(m.called)
예제 #3
0
    def test_create_ssm_session(self):
        with patch.object(self.ssm,
                          'start_session',
                          return_value=self.response):
            sess = SSMSession(instance_id=self.instance_id, ssm=self.ssm)
            sess.create()

            self.assertTrue(self.ssm.start_session.called)
예제 #4
0
    def test_ssm_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 SSMSession(instance_id=self.instance_id, ssm=self.ssm):
                pass

            self.assertTrue(sm.called)
            self.assertTrue(tm.called)
예제 #5
0
def test_terminate_ssm_session(ssm_mock, instance_id):
    sess = SSMSession(instance_id=instance_id, ssm=ssm_mock)

    sess.create()
    sess.terminate()

    assert ssm_mock.terminate_session.called
예제 #6
0
def test_ssm_session_context_manager(ssm_mock, instance_id):
    with SSMSession(instance_id=instance_id, ssm=ssm_mock):
        pass

    assert ssm_mock.start_session.called
    assert ssm_mock.terminate_session.called