def test_incompatible_options(self): args = [ "extract.py", "-c", "capture.pcap", "--raw-times", "times-log.csv" ] with mock.patch("sys.argv", args): with self.assertRaises(ValueError): main()
def test_incomplete_packet_capture_options(self): args = [ "extract.py", "-c", "capture.pcap", "-l", "log.csv", "-o", "/tmp" ] with mock.patch("sys.argv", args): with self.assertRaises(ValueError): main()
def test_raw_times(self): raw_times = "times-log.csv" logfile = "log.csv" output = "/tmp" args = [ "extract.py", "-l", logfile, "-o", output, "--raw-times", raw_times ] mock_init = mock.Mock() mock_init.return_value = None with mock.patch('tlsfuzzer.extract.Extract.parse'): with mock.patch('tlsfuzzer.extract.Extract.__init__', mock_init): with mock.patch('tlsfuzzer.extract.Extract.write_csv'): with mock.patch('tlsfuzzer.extract.Log') as mock_log: with mock.patch("sys.argv", args): main() mock_log.assert_called_once_with(logfile) mock_init.assert_called_once_with( mock.ANY, None, output, None, None, raw_times)
def test_command_line(self): capture = "capture.pcap" logfile = "log.csv" host = "localhost" port = "4433" output = "/tmp" args = [ "extract.py", "-l", logfile, "-c", capture, "-h", host, "-p", port, "-o", output ] mock_init = mock.Mock() mock_init.return_value = None with mock.patch('tlsfuzzer.extract.Extract.parse'): with mock.patch('tlsfuzzer.extract.Extract.__init__', mock_init): with mock.patch('tlsfuzzer.extract.Extract.write_csv'): with mock.patch('tlsfuzzer.extract.Log') as mock_log: with mock.patch("sys.argv", args): main() mock_log.assert_called_once_with(logfile) mock_init.assert_called_once_with( mock.ANY, capture, output, host, int(port))
def test_incomplete_ext_times_options(self): args = ["extract.py", "--raw-times", "times-log.csv", "-o", "/tmp"] with mock.patch("sys.argv", args): with self.assertRaises(ValueError): main()