Commit 17fb3dbb by fwkz

Fixing and adding tests for 'exec' command.

parent a940aadd
......@@ -3,7 +3,6 @@ import os
import sys
import traceback
import atexit
from subprocess import call
from routersploit.exceptions import RoutersploitException
from routersploit import utils
......@@ -384,8 +383,7 @@ class RoutersploitInterpreter(BaseInterpreter):
print("\n", self.module_help)
def command_exec(self, *args, **kwargs):
print(' '.join(args))
call(' '.join(args))
os.system(args[0])
def command_exit(self, *args, **kwargs):
raise KeyboardInterrupt
......@@ -434,5 +434,10 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
with self.assertRaises(KeyboardInterrupt):
self.interpreter.command_exit()
@mock.patch('os.system')
def test_command_exec(self, mock_system):
self.interpreter.command_exec("foo -bar")
mock_system.assert_called_once_with("foo -bar")
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment