Commit 17fb3dbb by fwkz

Fixing and adding tests for 'exec' command.

parent a940aadd
...@@ -3,7 +3,6 @@ import os ...@@ -3,7 +3,6 @@ import os
import sys import sys
import traceback import traceback
import atexit import atexit
from subprocess import call
from routersploit.exceptions import RoutersploitException from routersploit.exceptions import RoutersploitException
from routersploit import utils from routersploit import utils
...@@ -384,8 +383,7 @@ class RoutersploitInterpreter(BaseInterpreter): ...@@ -384,8 +383,7 @@ class RoutersploitInterpreter(BaseInterpreter):
print("\n", self.module_help) print("\n", self.module_help)
def command_exec(self, *args, **kwargs): def command_exec(self, *args, **kwargs):
print(' '.join(args)) os.system(args[0])
call(' '.join(args))
def command_exit(self, *args, **kwargs): def command_exit(self, *args, **kwargs):
raise KeyboardInterrupt raise KeyboardInterrupt
...@@ -434,5 +434,10 @@ class RoutersploitInterpreterTest(RoutersploitTestCase): ...@@ -434,5 +434,10 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
with self.assertRaises(KeyboardInterrupt): with self.assertRaises(KeyboardInterrupt):
self.interpreter.command_exit() 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__': if __name__ == '__main__':
unittest.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