whisperback (1.8.3)
[whisperback.git] / test.py
blob934b1c790a18b8b1ff22dcff2cace1d66b6b76b5
1 #!/usr/bin/python3
2 # -*- coding: UTF-8 -*-
4 import sys
5 import unittest
7 print(sys.path)
8 import whisperBack.utils
10 class TestIsValidLink(unittest.TestCase):
12 def test_valid_http(self):
13 self.assertTrue(whisperBack.utils.is_valid_link("http://test.example.org/"))
15 def test_valid_ftp(self):
16 self.assertTrue(whisperBack.utils.is_valid_link("ftp://test.example.org/"))
18 def test_valid_https(self):
19 self.assertTrue(whisperBack.utils.is_valid_link("https://test.example.org/"))
21 def test_valid_ftps(self):
22 self.assertTrue(whisperBack.utils.is_valid_link("ftps://test.example.org/"))
24 def test_wrong_scheme(self):
25 self.assertFalse(whisperBack.utils.is_valid_link("error://test.example.org/"))
27 def test_valid_domain2(self):
28 self.assertTrue(whisperBack.utils.is_valid_link("http://example.org/"))
30 def test_wrong_domain(self):
31 self.assertFalse(whisperBack.utils.is_valid_link("ftp://example_org/"))
33 def test_wrong_domain(self):
34 self.assertFalse(whisperBack.utils.is_valid_link("ftp://example_org/"))
36 class TestSanitiseHardwareInfo(unittest.TestCase):
37 def test_iptables_ip(self):
38 sanitized_log = whisperBack.utils.sanitize_hardware_info(
39 "[ 958.314027] Dropped outbound packet: IN= OUT=lo SRC=189.67.1.123 DST=127.0.0.1 LEN=80 TOS=0x00 PREC=0xC0 TTL=64 ID=54418 PROTO=ICMP TYPE=3 CODE=3 [SRC=18.165.88.98 DST=123.138.117.98 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=35937 DF PROTO=TCP SPT=44880 DPT=8118 WINDOW=383 RES=0x00 ACK FIN URGP=0 ]"
41 self.assertTrue(
42 "189.67.1.123" not in sanitized_log and
43 "127.0.0.1" not in sanitized_log and
44 "18.165.88.98" not in sanitized_log and
45 "123.138.117.98" not in sanitized_log
48 def test_iptables_ipv6(self):
49 sanitized_log = whisperBack.utils.sanitize_hardware_info(
50 "[ 12.3456789] Dropped outbound packet: IN= OUT=eth0 SRC=fe80:0000:0000:0000:abcd:efab:cdef:1234 DST=ff02:0000:0000:0000:0000:0000:0000:0002 LEN=56 TC=0 HOPLIMIT=255 FLOWLBL=0 PROTO=ICMPv6 TYPE=133 CODE=0"
52 self.assertTrue(
53 "fe80:0000:0000:0000:abcd:efab:cdef:1234" not in sanitized_log and
54 "ff02:0000:0000:0000:0000:0000:0000:0002" not in sanitized_log
57 def test_usb_serial(self):
58 self.assertTrue(
59 "1234567890AB" not in whisperBack.utils.sanitize_hardware_info(
60 "[ 431.655363] usb 1-1: SerialNumber: 1234567890AB"
63 @unittest.skip("Not implemented yet see: https://labs.riseup.net/code/issues/6799")
64 def test_ata_serial(self):
65 self.assertTrue(
66 "123456789ABYZ" not in whisperBack.utils.sanitize_hardware_info(
67 "ata3.00: ATA-8: Hitachi 123456789ABYZ, JP1234MA, max UDMA/133"
70 def test_tveeprom_serial(self):
71 self.assertTrue(
72 "XXAZ09XX" not in whisperBack.utils.sanitize_hardware_info(
73 "tveeprom 9-0050: Hauppauge model 78631, rev C1E9, serial# XXAZ09XX"
76 def test_intel_serial(self):
77 self.assertTrue(
78 "XXXXAZ09XXXX" not in whisperBack.utils.sanitize_hardware_info(
79 "(II) intel(0): Serial No: XXXXAZ09XXXX"
82 def test_dmi(self):
83 self.assertTrue(
84 "1234ABYZ, BIOS 1234ABYZ.1234ABCDWXYZ.1234.5678.9012" not in whisperBack.utils.sanitize_hardware_info(
85 "DMI: /1234ABYZ, BIOS 1234ABYZ.1234ABCDWXYZ.1234.5678.9012 12/22/2011"
89 if __name__ == '__main__':
90 unittest.main()