diff --git a/routersploit/test/test_exploits.py b/routersploit/test/test_exploits.py index bd47a6e..c1de047 100644 --- a/routersploit/test/test_exploits.py +++ b/routersploit/test/test_exploits.py @@ -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()