Commit 1fd7cb7c by fwkz

Adding unittest regarding global opts feature to Option()

parent 77851112
......@@ -6,7 +6,7 @@ except ImportError:
import mock
from routersploit.test import RoutersploitTestCase
from routersploit.exploits import Exploit, Option
from routersploit.exploits import Exploit, Option, GLOBAL_OPTS
def suffix(x):
......@@ -37,6 +37,7 @@ class OptionTest(RoutersploitTestCase):
self.exploit_foo = TestExploitFoo()
self.exploit_bar = TestExploitBar()
self.exploit_with_validators = TestExploitWithValidators()
GLOBAL_OPTS.clear()
def test_default_value(self):
""" Test if default value is properly set. """
......@@ -66,6 +67,23 @@ class OptionTest(RoutersploitTestCase):
self.exploit_with_validators.paa = "new_value"
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__':
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