From 07dbd2d12540620e21cefb561ca71c19368b9a58 Mon Sep 17 00:00:00 2001 From: alya Date: Mon, 4 Dec 2023 16:18:30 +0200 Subject: [PATCH] update unit and integration tests --- tests/integration_tests/test_dataset.py | 18 +++++++++--------- tests/test_database.py | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/integration_tests/test_dataset.py b/tests/integration_tests/test_dataset.py index 1f37bf50c..f71c6b5cd 100644 --- a/tests/integration_tests/test_dataset.py +++ b/tests/integration_tests/test_dataset.py @@ -24,15 +24,15 @@ @pytest.mark.parametrize( 'pcap_path, expected_profiles, output_dir, expected_evidence, redis_port', [ - # ( #TODO fix this test - # 'dataset/test7-malicious.pcap', - # 15, - # 'test7/', - # # Detected A device changing IPs. IP 192.168.2.12 was found with MAC address - # # 68:5b:35:b1:55:93 but the MAC belongs originally to IP: 169.254.242.182 - # 'A device changing IPs', - # 6666, - # ), + ( + 'dataset/test7-malicious.pcap', + 15, + 'test7/', + # Detected A device changing IPs. IP 192.168.2.12 was found with MAC address + # 68:5b:35:b1:55:93 but the MAC belongs originally to IP: 169.254.242.182 + 'A device changing IPs', + 6666, + ), ('dataset/test8-malicious.pcap', 3, 'test8/', diff --git a/tests/test_database.py b/tests/test_database.py index 15aaebc29..908a783c1 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -175,25 +175,25 @@ def test_profile_moddule_labels(): def test_add_mac_addr_to_profile(): ipv4 = '192.168.1.5' profileid_ipv4 = f'profile_{ipv4}' - MAC_info = {'MAC': '00:00:5e:00:53:af'} + mac_addr = '00:00:5e:00:53:af' # first associate this ip with some mac - assert db.add_mac_addr_to_profile(profileid_ipv4, MAC_info) is True - assert ipv4 in str(db.r.hget('MAC', MAC_info['MAC'])) + assert db.add_mac_addr_to_profile(profileid_ipv4, mac_addr) is True + assert ipv4 in str(db.r.hget('MAC', mac_addr)) # now claim that we found another profile # that has the same mac as this one # both ipv4 profileid = 'profile_192.168.1.6' - assert db.add_mac_addr_to_profile(profileid, MAC_info) is False + assert db.add_mac_addr_to_profile(profileid, mac_addr) is False # this ip shouldnt be added to the profile as they're both ipv4 - assert '192.168.1.6' not in db.r.hget('MAC', MAC_info['MAC']) + assert '192.168.1.6' not in db.r.hget('MAC', mac_addr) # now claim that another ipv6 has this mac ipv6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334' profileid_ipv6 = f'profile_{ipv6}' - db.add_mac_addr_to_profile(profileid_ipv6, MAC_info) + db.add_mac_addr_to_profile(profileid_ipv6, mac_addr) # make sure the mac is associated with his ipv6 - assert ipv6 in db.r.hget('MAC', MAC_info['MAC']) + assert ipv6 in db.r.hget('MAC', mac_addr) # make sure the ipv4 is associated with this # ipv6 profile assert ipv4 in str(db.r.hmget(profileid_ipv6, 'IPv4'))