Skip to content
Snippets Groups Projects
Commit 3ef4d87b authored by Daniel Yang's avatar Daniel Yang
Browse files

Added syn_flooding_detection test, do not know how to send 101 packets in 10 seconds tho

parent 5aa79a10
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ from src.packet_capturing import packet_handler, get_dict, dict_clear, syn_flood
class TestPacketCapturing(unittest.TestCase):
# This method is called before every test
def setUp(self):
dict_clear()
......@@ -66,16 +67,17 @@ class TestPacketCapturing(unittest.TestCase):
mock_print.assert_any_call("Illegal packet with source or destination port 0.")
def test_syn_flood_detection(self):
repetitions = 150
packet = (IP(src="100.84.6.141", dst="192.168.1.1") /
TCP(dport=80, sport=123, flags="S") /
Ether(src="00:11:22:33:44:55", dst="ff:ff:ff:ff:ff:ff"))
with patch('builtins.print') as mock_print:
for i in range(101):
for i in range(repetitions):
syn_flood_detection(packet)
mock_print.assert_called()
self.assertEqual({"100.84.6.141": repetitions}, get_dict(), f"Expected the packet's IP to contain {repetitions} entries.")
if __name__ == '__main__':
unittest.main()
  • Owner

    Either the syn_flood_detection does not work, or my test sucks.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment