Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
ae5d4eaa
Commit
ae5d4eaa
authored
Jul 26, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asserting print_status() in command_run() tests
parent
a5044a34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
test_interpreter.py
routersploit/test/test_interpreter.py
+6
-2
No files found.
routersploit/test/test_interpreter.py
View file @
ae5d4eaa
...
...
@@ -137,10 +137,12 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
mock_print_error
.
assert_called_once_with
(
"You can't unset global option '{}'.
\n
"
"Available global options: ['foo']"
.
format
(
unknown_option
))
def
test_command_run
(
self
):
@mock.patch
(
'routersploit.utils.print_status'
)
def
test_command_run
(
self
,
mock_print_status
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'run'
)
as
mock_run
:
self
.
interpreter
.
command_run
()
mock_run
.
assert_called_once_with
()
mock_print_status
.
assert_called_once_with
(
'Running module...'
)
@mock.patch
(
'routersploit.utils.print_success'
)
def
test_command_check_target_vulnerable
(
self
,
mock_print_success
):
...
...
@@ -186,7 +188,8 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
@mock.patch
(
'sys.exc_info'
)
@mock.patch
(
'traceback.format_exc'
)
@mock.patch
(
'routersploit.utils.print_error'
)
def
test_command_run_exception_during_exploit_execution
(
self
,
mock_print_error
,
mock_format_exc
,
mock_exc_info
):
@mock.patch
(
'routersploit.utils.print_status'
)
def
test_command_run_exception_during_exploit_execution
(
self
,
mock_print_status
,
mock_print_error
,
mock_format_exc
,
mock_exc_info
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'run'
)
as
mock_run
:
mock_run
.
side_effect
=
RuntimeError
mock_format_exc
.
return_value
=
stacktrace
=
"stacktrace"
...
...
@@ -196,6 +199,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
mock_run
.
assert_called_once_with
()
mock_format_exc
.
assert_called_once_with
(
info
)
mock_print_error
.
assert_called_once_with
(
stacktrace
)
mock_print_status
.
assert_called_once_with
(
'Running module...'
)
def
test_command_back
(
self
):
self
.
assertIsNotNone
(
self
.
interpreter
.
current_module
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment