|
@@ -1,3 +1,4 @@
|
|
|
|
+import unittest.mock as mock
|
|
import unittest
|
|
import unittest
|
|
|
|
|
|
import Attack.BaseAttack as BAtk
|
|
import Attack.BaseAttack as BAtk
|
|
@@ -153,6 +154,20 @@ class TestBaseAttack(unittest.TestCase):
|
|
def test_is_valid_ipaddress_invalid(self):
|
|
def test_is_valid_ipaddress_invalid(self):
|
|
self.assertFalse(BAtk.BaseAttack.is_valid_ip_address("192.168.1789.42"))
|
|
self.assertFalse(BAtk.BaseAttack.is_valid_ip_address("192.168.1789.42"))
|
|
|
|
|
|
|
|
+ @mock.patch.multiple(BAtk.BaseAttack, __abstractmethods__=set())
|
|
|
|
+ def test_add_param_value_invalid_param_name(self):
|
|
|
|
+ base_attack = BAtk.BaseAttack("testname", "testdescription", "testtype")
|
|
|
|
+ with self.assertRaises(SystemExit):
|
|
|
|
+ base_attack.add_param_value("nonexistent_param", "testvalue")
|
|
|
|
+
|
|
|
|
+ @mock.patch.multiple(BAtk.BaseAttack, __abstractmethods__=set())
|
|
|
|
+ def test_add_param_value_missing_statistics(self):
|
|
|
|
+ base_attack = BAtk.BaseAttack("testname", "testdescription", "testtype")
|
|
|
|
+ with self.assertRaises(RuntimeError) as ex:
|
|
|
|
+ base_attack.add_param_value('inject.after-pkt', 1234)
|
|
|
|
+ self.assertEqual(str(ex.exception),
|
|
|
|
+ 'Error: Statistics-dependent attack parameter added without setting a statistics object first.')
|
|
|
|
+
|
|
def test_ip_src_dst_equal_check_equal(self):
|
|
def test_ip_src_dst_equal_check_equal(self):
|
|
with self.assertRaises(SystemExit):
|
|
with self.assertRaises(SystemExit):
|
|
BAtk.BaseAttack.ip_src_dst_equal_check("192.168.178.42", "192.168.178.42")
|
|
BAtk.BaseAttack.ip_src_dst_equal_check("192.168.178.42", "192.168.178.42")
|