Skip to content

Commit

Permalink
update unit and integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Dec 4, 2023
1 parent 24d2caf commit 07dbd2d
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions tests/integration_tests/test_dataset.py
Original file line number Diff line number Diff line change
@@ -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/',
14 changes: 7 additions & 7 deletions tests/test_database.py
Original file line number Diff line number Diff line change
@@ -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'))

0 comments on commit 07dbd2d

Please sign in to comment.