Exemple #1
0
    def test_ssh_action_with_stderr(self, mocked_method):
        mocked_method.return_value = (1, 'Error expected')
        cmd = "echo -n ok"
        host = "localhost"
        username = "******"
        action = std.SSHAction(cmd, host, username)

        mock_ctx = None

        self.assertRaisesWithMessageContaining(
            exc.ActionException,
            "Failed to execute ssh cmd 'echo -n ok' on ['localhost']",
            action.run, mock_ctx)
Exemple #2
0
    def test_default_inputs(self):
        cmd = "echo -n ok"
        host = "localhost"
        username = "******"
        action = std.SSHAction(cmd, host, username)
        mock_ctx = None

        stdout = action.test(mock_ctx)
        params = json.loads(stdout)

        self.assertEqual("", params['password'], "Password does not match.")
        self.assertIsNone(params['private_key_filename'],
                          "private_key_filename is not None.")
Exemple #3
0
    def test_ssh_action(self, mocked_method):
        mocked_method.return_value = (0, 'ok')
        cmd = "echo -n ok"
        host = "localhost"
        username = "******"
        action = std.SSHAction(cmd, host, username)

        mock_ctx = None

        stdout = action.run(mock_ctx)

        self.assertEqual('ok', stdout,
                         'stdout from SSH command differs from expected')

        mocked_method.assert_called_with(cmd=cmd,
                                         host=host,
                                         username=username,
                                         password='',
                                         private_key_filename=None)