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
1fd7cb7c
Commit
1fd7cb7c
authored
Jul 02, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding unittest regarding global opts feature to Option()
parent
77851112
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletions
+19
-1
test_exploits.py
routersploit/test/test_exploits.py
+19
-1
No files found.
routersploit/test/test_exploits.py
View file @
1fd7cb7c
...
@@ -6,7 +6,7 @@ except ImportError:
...
@@ -6,7 +6,7 @@ except ImportError:
import
mock
import
mock
from
routersploit.test
import
RoutersploitTestCase
from
routersploit.test
import
RoutersploitTestCase
from
routersploit.exploits
import
Exploit
,
Option
from
routersploit.exploits
import
Exploit
,
Option
,
GLOBAL_OPTS
def
suffix
(
x
):
def
suffix
(
x
):
...
@@ -37,6 +37,7 @@ class OptionTest(RoutersploitTestCase):
...
@@ -37,6 +37,7 @@ class OptionTest(RoutersploitTestCase):
self
.
exploit_foo
=
TestExploitFoo
()
self
.
exploit_foo
=
TestExploitFoo
()
self
.
exploit_bar
=
TestExploitBar
()
self
.
exploit_bar
=
TestExploitBar
()
self
.
exploit_with_validators
=
TestExploitWithValidators
()
self
.
exploit_with_validators
=
TestExploitWithValidators
()
GLOBAL_OPTS
.
clear
()
def
test_default_value
(
self
):
def
test_default_value
(
self
):
""" Test if default value is properly set. """
""" Test if default value is properly set. """
...
@@ -66,6 +67,23 @@ class OptionTest(RoutersploitTestCase):
...
@@ -66,6 +67,23 @@ class OptionTest(RoutersploitTestCase):
self
.
exploit_with_validators
.
paa
=
"new_value"
self
.
exploit_with_validators
.
paa
=
"new_value"
self
.
assertEqual
(
self
.
exploit_with_validators
.
paa
,
"new_value_suffix_SUFFIX"
)
self
.
assertEqual
(
self
.
exploit_with_validators
.
paa
,
"new_value_suffix_SUFFIX"
)
def
test_if_exploit_option_is_picked_up_before_global
(
self
):
GLOBAL_OPTS
[
'doo'
]
=
'global_doo'
self
.
exploit_bar
.
doo
=
'value'
self
.
exploit_foo
.
doo
=
'value'
self
.
assertEqual
(
self
.
exploit_bar
.
doo
,
'value'
)
self
.
assertEqual
(
self
.
exploit_foo
.
doo
,
'value'
)
def
test_if_global_options_is_picked_up_before_default
(
self
):
GLOBAL_OPTS
[
'doo'
]
=
'global_doo'
self
.
assertEqual
(
self
.
exploit_bar
.
doo
,
'global_doo'
)
self
.
assertEqual
(
self
.
exploit_foo
.
doo
,
'global_doo'
)
def
test_if_validators_are_applied_on_global_options
(
self
):
GLOBAL_OPTS
[
'doo'
]
=
'global_doo'
self
.
assertEqual
(
self
.
exploit_with_validators
.
doo
,
'global_doo_suffix'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
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