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
090b55e0
Commit
090b55e0
authored
May 13, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tests for 'exploit' and 'widgets' module.
parent
3862604e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
0 deletions
+90
-0
test_exploits.py
routersploit/test/test_exploits.py
+69
-0
test_widgets.py
routersploit/test/test_widgets.py
+21
-0
widgets.py
routersploit/widgets.py
+0
-0
No files found.
routersploit/test/test_exploits.py
0 → 100644
View file @
090b55e0
from
__future__
import
print_function
from
__future__
import
absolute_import
try
:
import
unittest.mock
as
mock
except
ImportError
:
import
mock
from
.
import
RoutersploitTestCase
from
..exploits
import
Exploit
,
Option
def
suffix
(
x
):
return
"{}_suffix"
.
format
(
x
)
def
SUFFIX
(
x
):
return
"{}_SUFFIX"
.
format
(
x
)
class
TestExploitFoo
(
Exploit
):
doo
=
Option
(
default
=
1
,
description
=
"description_one"
)
paa
=
Option
(
default
=
2
,
description
=
"description_two"
)
class
TestExploitBar
(
Exploit
):
doo
=
Option
(
default
=
3
,
description
=
"description_three"
)
paa
=
Option
(
default
=
4
,
description
=
"description_four"
)
class
TestExploitWithWidgets
(
Exploit
):
doo
=
Option
(
default
=
"default_value"
,
description
=
"description_three"
,
widgets
=
suffix
)
paa
=
Option
(
default
=
"default_value"
,
description
=
"description_three"
,
widgets
=
(
suffix
,
SUFFIX
))
class
OptionTest
(
RoutersploitTestCase
):
def
setUp
(
self
):
self
.
exploit_foo
=
TestExploitFoo
()
self
.
exploit_bar
=
TestExploitBar
()
self
.
exploit_with_widgets
=
TestExploitWithWidgets
()
def
test_default_value
(
self
):
""" Test if default value is properly set. """
self
.
assertEqual
(
self
.
exploit_foo
.
doo
,
1
)
self
.
assertEqual
(
self
.
exploit_foo
.
paa
,
2
)
self
.
assertEqual
(
self
.
exploit_bar
.
doo
,
3
)
self
.
assertEqual
(
self
.
exploit_bar
.
paa
,
4
)
def
test_set_value
(
self
):
""" Test if descriptors are properly set. """
self
.
exploit_foo
.
doo
=
"doopaa"
self
.
exploit_foo
.
paa
=
"kajak"
self
.
assertEqual
(
self
.
exploit_foo
.
doo
,
"doopaa"
)
self
.
assertEqual
(
self
.
exploit_foo
.
paa
,
"kajak"
)
self
.
assertEqual
(
self
.
exploit_bar
.
doo
,
3
)
self
.
assertEqual
(
self
.
exploit_bar
.
paa
,
4
)
def
test_if_widget_is_applied_on_default_value
(
self
):
self
.
assertEqual
(
self
.
exploit_with_widgets
.
doo
,
"default_value_suffix"
)
def
test_if_widget_is_applied_after_setting_value
(
self
):
self
.
exploit_with_widgets
.
doo
=
"new_value"
self
.
assertEqual
(
self
.
exploit_with_widgets
.
doo
,
"new_value_suffix"
)
def
test_if_widget_is_applied_in_specific_order
(
self
):
self
.
exploit_with_widgets
.
paa
=
"new_value"
self
.
assertEqual
(
self
.
exploit_with_widgets
.
paa
,
"new_value_suffix_SUFFIX"
)
routersploit/test/test_widgets.py
0 → 100644
View file @
090b55e0
from
__future__
import
print_function
from
__future__
import
absolute_import
try
:
import
unittest.mock
as
mock
except
ImportError
:
import
mock
from
.
import
RoutersploitTestCase
from
..
import
widgets
class
WidgetsTest
(
RoutersploitTestCase
):
def
test_url_adding_http_prefix
(
self
):
self
.
assertEqual
(
widgets
.
url
(
"127.0.0.1"
),
"http://127.0.0.1"
)
def
test_url_already_with_http_prefix
(
self
):
self
.
assertEqual
(
widgets
.
url
(
"http://127.0.0.1"
),
"http://127.0.0.1"
)
def
test_url_already_with_https_prefix
(
self
):
self
.
assertEqual
(
widgets
.
url
(
"https://127.0.0.1"
),
"https://127.0.0.1"
)
routersploit/widgets.py
View file @
090b55e0
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