Пример #1
0
    def test_extraction_from_external_time_source(self):
        extract = Extract(self.log, None, "/tmp", None, None,
                          join(dirname(abspath(__file__)), "times-log.csv"))
        extract.parse()

        with mock.patch('__main__.__builtins__.open', mock.mock_open()) as mock_file:
            mock_file.return_value.write.side_effect = lambda s: self.assertIn(
                s.strip(), self.expected.splitlines())
            extract.write_csv('timing.csv')
Пример #2
0
    def test_extraction(self):
        extract = Extract(self.log,
                          join(dirname(abspath(__file__)), "capture.pcap"),
                          "/tmp", "localhost", 4433)
        extract.parse()

        with mock.patch('__main__.__builtins__.open', mock.mock_open()) as mock_file:
            mock_file.return_value.write.side_effect = lambda s: self.assertIn(
                s.strip(), self.expected.splitlines())
            extract.write_csv('timing.csv')
Пример #3
0
    def extract(self):
        """Starts the extraction if available."""
        if self.check_extraction_availability():
            from tlsfuzzer.extract import Extract
            self.log.read_log()
            extraction = Extract(self.log,
                                 os.path.join(self.out_dir, "capture.pcap"),
                                 self.out_dir, self.ip_address, self.port)
            extraction.parse()
            extraction.write_csv(os.path.join(self.out_dir, "timing.csv"))
            return True

        print("Extraction is not available. "
              "Install required packages to enable.")
        return False
Пример #4
0
 def test_invalid_hostname(self):
     invalid_hostname = "#invalidhostname*"
     with self.assertRaises(Exception):
         Extract.hostname_to_ip(invalid_hostname)
Пример #5
0
 def test_valid_hostname(self):
     hostname = "localhost"
     self.assertEqual(Extract.hostname_to_ip(hostname),
                      inet_aton("127.0.0.1"))
Пример #6
0
 def test_invalid_ip(self):
     invalid_ip_addr = "256.0.0.1"
     with self.assertRaises(Exception):
         Extract.hostname_to_ip(invalid_ip_addr)
Пример #7
0
 def test_valid_ip(self):
     ip_addr = "127.0.0.1"
     self.assertEqual(Extract.hostname_to_ip(ip_addr), inet_aton(ip_addr))