Exemple #1
0
 def test__fun_execute_shell_command_fail_cmd_exception(
         self, mock_log, mock_subprocess):
     cmd = "env"
     mock_subprocess.check_output.side_effect = RuntimeError
     exitcode, _ = attacker_baremetal._execute_shell_command(cmd)
     self.assertEqual(exitcode, -1)
     mock_log.error.assert_called_once()
Exemple #2
0
 def test__fun_execute_shell_command_successful(self, mock_subprocess):
     cmd = "env"
     mock_subprocess.check_output.return_value = (0, 'unittest')
     exitcode, _ = attacker_baremetal._execute_shell_command(cmd)
     self.assertEqual(exitcode, 0)
 def test__fun_execute_shell_command_fail_cmd_exception(self, mock_subprocess):
     cmd = "env"
     mock_subprocess.check_output.side_effect = RuntimeError
     exitcode, output = attacker_baremetal._execute_shell_command(cmd)
     self.assertEqual(exitcode, -1)
 def test__fun_execute_shell_command_successful(self, mock_subprocess):
     cmd = "env"
     mock_subprocess.check_output.return_value = (0, 'unittest')
     exitcode, output = attacker_baremetal._execute_shell_command(cmd)
     self.assertEqual(exitcode, 0)