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
8c6a107b
Commit
8c6a107b
authored
May 13, 2016
by
Max Zinkus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to fit tests where possible, edit tests where not
parent
2fb850b9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
+9
-11
interpreter.py
routersploit/interpreter.py
+3
-3
test_completer.py
routersploit/test/test_completer.py
+2
-2
test_interpreter.py
routersploit/test/test_interpreter.py
+4
-6
No files found.
routersploit/interpreter.py
View file @
8c6a107b
...
...
@@ -367,13 +367,13 @@ class RoutersploitInterpreter(BaseInterpreter):
@utils.module_required
def
command_check
(
self
,
*
args
,
**
kwargs
):
if
self
.
current_module
.
check
()
==
None
:
try
:
result
=
self
.
current_module
.
check
()
if
result
is
None
:
return
if
not
self
.
current_module
.
target
:
utils
.
print_error
(
"No target set"
)
return
try
:
result
=
self
.
current_module
.
check
()
except
:
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
else
:
...
...
routersploit/test/test_completer.py
View file @
8c6a107b
...
...
@@ -32,7 +32,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
def
test_raw_commands_no_module
(
self
):
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
'ex
it
use
\r\n
'
,
self
.
raw_prompt
)
self
.
assertPrompt
(
'ex
ec exit help
use
\r\n
'
,
self
.
raw_prompt
)
def
test_complete_use_raw
(
self
):
self
.
rsf
.
send
(
"u
\t\t
"
)
...
...
@@ -89,7 +89,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
self
.
set_module
()
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
'back check ex
it
run set show
\r\n
'
,
'back check ex
ec exit help
run set show
\r\n
'
,
self
.
module_prompt
(
'FTP Bruteforce'
)
)
...
...
routersploit/test/test_interpreter.py
View file @
8c6a107b
...
...
@@ -95,7 +95,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
print_error
.
assert_called_once_with
(
'Target is not vulnerable'
)
@mock.patch
(
'routersploit.utils.print_status'
)
def
test_command_check_target_could_not_be_verified
_1
(
self
,
print_status
):
def
test_command_check_target_could_not_be_verified
(
self
,
print_status
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
mock_check
.
return_value
=
"something"
self
.
interpreter
.
command_check
()
...
...
@@ -103,12 +103,10 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
print_status
.
assert_called_once_with
(
'Target could not be verified'
)
@mock.patch
(
'routersploit.utils.print_status'
)
def
test_command_check_
target_could_not_be_verified_2
(
self
,
print_status
):
def
test_command_check_
not_supported_by_module
(
self
,
print_status
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
mock_check
.
return_value
=
None
self
.
interpreter
.
command_check
()
mock_check
.
assert_called_once_with
()
print_status
.
assert_called_once_with
(
'Target could not be verified'
)
@mock.patch
(
'sys.exc_info'
)
@mock.patch
(
'traceback.format_exc'
)
...
...
@@ -180,14 +178,14 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
def
test_suggested_commands_with_loaded_module
(
self
):
self
.
assertEqual
(
self
.
interpreter
.
suggested_commands
(),
[
'run'
,
'back'
,
'set '
,
'show '
,
'check'
,
'exit'
]
# Extra space at the end because of following param
[
'run'
,
'back'
,
'set '
,
'show '
,
'check'
,
'exit'
,
'exec'
,
'help'
]
# Extra space at the end because of following param
)
def
test_suggested_commands_without_loaded_module
(
self
):
self
.
interpreter
.
current_module
=
None
self
.
assertEqual
(
self
.
interpreter
.
suggested_commands
(),
# Extra space at the end because of following param
[
'use '
,
'exit'
]
[
'use '
,
'exit'
,
'exec'
,
'help'
]
)
@mock.patch
(
'importlib.import_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