Exemplo n.º 1
0
    def testProcess(self):
        """Tests the Process function."""
        parser_object = bencode_parser.BencodeParser()

        test_file = self._GetTestFilePath([u'bencode_transmission'])
        event_queue_consumer = self._ParseFile(parser_object, test_file)
        event_objects = self._GetEventObjectsFromQueue(event_queue_consumer)

        self.assertEqual(len(event_objects), 3)

        event_object = event_objects[0]

        expected_destination = u'/Users/brian/Downloads'
        self.assertEqual(event_object.destination, expected_destination)

        self.assertEqual(event_object.seedtime, 4)

        expected_description = eventdata.EventTimestamp.ADDED_TIME
        self.assertEqual(event_object.timestamp_desc, expected_description)

        expected_timestamp = timelib.Timestamp.CopyFromString(
            u'2013-11-08 15:31:20')
        self.assertEqual(event_object.timestamp, expected_timestamp)

        # Test on second event of first torrent.
        event_object = event_objects[1]
        self.assertEqual(event_object.destination, expected_destination)
        self.assertEqual(event_object.seedtime, 4)

        expected_description = eventdata.EventTimestamp.FILE_DOWNLOADED
        self.assertEqual(event_object.timestamp_desc, expected_description)

        expected_timestamp = timelib.Timestamp.CopyFromString(
            u'2013-11-08 18:24:24')
        self.assertEqual(event_object.timestamp, expected_timestamp)
Exemplo n.º 2
0
  def testProcess(self):
    """Tests the Process function."""
    parser = bencode_parser.BencodeParser()
    storage_writer = self._ParseFile(['bencode_transmission'], parser)

    self.assertEqual(storage_writer.number_of_events, 3)

    # The order in which BencodeParser generates events is nondeterministic
    # hence we sort the events.
    events = list(storage_writer.GetSortedEvents())

    event = events[0]

    self.CheckTimestamp(event.timestamp, '2013-11-08 15:31:20.000000')
    self.assertEqual(event.timestamp_desc, definitions.TIME_DESCRIPTION_ADDED)
    self.assertEqual(event.destination, '/Users/brian/Downloads')
    self.assertEqual(event.seedtime, 4)

    # Test on second event of first torrent.
    event = events[1]

    self.CheckTimestamp(event.timestamp, '2013-11-08 18:24:24.000000')
    self.assertEqual(
        event.timestamp_desc, definitions.TIME_DESCRIPTION_FILE_DOWNLOADED)
    self.assertEqual(event.destination, '/Users/brian/Downloads')
    self.assertEqual(event.seedtime, 4)

    expected_message = (
        'Saved to /Users/brian/Downloads; '
        'Minutes seeded: 4')

    self._TestGetMessageStrings(event, expected_message, expected_message)
Exemplo n.º 3
0
  def testProcess(self):
    """Tests the Process function."""
    parser = bencode_parser.BencodeParser()
    storage_writer = self._ParseFile(['bencode', 'transmission'], parser)

    self.assertEqual(storage_writer.number_of_events, 3)
    self.assertEqual(storage_writer.number_of_extraction_warnings, 0)
    self.assertEqual(storage_writer.number_of_recovery_warnings, 0)

    # The order in which BencodeParser generates events is nondeterministic
    # hence we sort the events.
    events = list(storage_writer.GetSortedEvents())

    expected_event_values = {
        'data_type': 'p2p:bittorrent:transmission',
        'date_time': '2013-11-08 15:31:20',
        'destination': '/Users/brian/Downloads',
        'seedtime': 4,
        'timestamp_desc': definitions.TIME_DESCRIPTION_ADDED}

    self.CheckEventValues(storage_writer, events[0], expected_event_values)

    # Test on second event of first torrent.
    expected_event_values = {
        'data_type': 'p2p:bittorrent:transmission',
        'date_time': '2013-11-08 18:24:24',
        'destination': '/Users/brian/Downloads',
        'seedtime': 4,
        'timestamp_desc': definitions.TIME_DESCRIPTION_FILE_DOWNLOADED}

    self.CheckEventValues(storage_writer, events[1], expected_event_values)
Exemplo n.º 4
0
    def testProcess(self):
        """Tests the Process function."""
        parser = bencode_parser.BencodeParser()
        storage_writer = self._ParseFile(['bencode', 'utorrent'], parser)

        self.assertEqual(storage_writer.number_of_events, 4)
        self.assertEqual(storage_writer.number_of_extraction_warnings, 0)
        self.assertEqual(storage_writer.number_of_recovery_warnings, 0)

        # The order in which BencodeParser generates events is nondeterministic
        # hence we sort the events.
        events = list(storage_writer.GetSortedEvents())

        # First test on when the torrent was added to the client.
        expected_event_values = {
            'caption': 'plaso test',
            'data_type': 'p2p:bittorrent:utorrent',
            'date_time': '2013-08-03 14:52:12',
            'path': 'e:\\torrent\\files\\plaso test',
            'seedtime': 511,
            'timestamp_desc': definitions.TIME_DESCRIPTION_ADDED
        }

        self.CheckEventValues(storage_writer, events[0], expected_event_values)

        # Second test on when the torrent file was completely downloaded.
        expected_event_values = {
            'caption': 'plaso test',
            'data_type': 'p2p:bittorrent:utorrent',
            'date_time': '2013-08-03 18:11:35',
            'path': 'e:\\torrent\\files\\plaso test',
            'seedtime': 511,
            'timestamp_desc': definitions.TIME_DESCRIPTION_FILE_DOWNLOADED
        }

        self.CheckEventValues(storage_writer, events[3], expected_event_values)

        # Third test on when the torrent was first modified.
        expected_event_values = {
            'caption': 'plaso test',
            'data_type': 'p2p:bittorrent:utorrent',
            'date_time': '2013-08-03 18:11:34',
            'path': 'e:\\torrent\\files\\plaso test',
            'seedtime': 511,
            'timestamp_desc': definitions.TIME_DESCRIPTION_MODIFICATION
        }

        self.CheckEventValues(storage_writer, events[2], expected_event_values)

        # Fourth test on when the torrent was again modified.
        expected_event_values = {
            'caption': 'plaso test',
            'data_type': 'p2p:bittorrent:utorrent',
            'date_time': '2013-08-03 16:27:59',
            'path': 'e:\\torrent\\files\\plaso test',
            'seedtime': 511,
            'timestamp_desc': definitions.TIME_DESCRIPTION_MODIFICATION
        }

        self.CheckEventValues(storage_writer, events[1], expected_event_values)
Exemplo n.º 5
0
  def testProcess(self):
    """Tests the Process function."""
    parser = bencode_parser.BencodeParser()
    storage_writer = self._ParseFile(['bencode', 'utorrent'], parser)

    self.assertEqual(storage_writer.number_of_warnings, 0)
    self.assertEqual(storage_writer.number_of_events, 4)

    # The order in which BencodeParser generates events is nondeterministic
    # hence we sort the events.
    events = list(storage_writer.GetSortedEvents())

    # First test on when the torrent was added to the client.
    expected_event_values = {
        'caption': 'plaso test',
        'path': 'e:\\torrent\\files\\plaso test',
        'seedtime': 511,
        'timestamp': '2013-08-03 14:52:12.000000',
        'timestamp_desc': definitions.TIME_DESCRIPTION_ADDED}

    self.CheckEventValues(storage_writer, events[0], expected_event_values)

    # Second test on when the torrent file was completely downloaded.
    expected_event_values = {
        'caption': 'plaso test',
        'path': 'e:\\torrent\\files\\plaso test',
        'seedtime': 511,
        'timestamp': '2013-08-03 18:11:35.000000',
        'timestamp_desc': definitions.TIME_DESCRIPTION_FILE_DOWNLOADED}

    self.CheckEventValues(storage_writer, events[3], expected_event_values)

    # Third test on when the torrent was first modified.
    expected_event_values = {
        'caption': 'plaso test',
        'path': 'e:\\torrent\\files\\plaso test',
        'seedtime': 511,
        'timestamp': '2013-08-03 18:11:34.000000',
        'timestamp_desc': definitions.TIME_DESCRIPTION_MODIFICATION}

    self.CheckEventValues(storage_writer, events[2], expected_event_values)

    # Fourth test on when the torrent was again modified.
    expected_event_values = {
        'caption': 'plaso test',
        'path': 'e:\\torrent\\files\\plaso test',
        'seedtime': 511,
        'timestamp': '2013-08-03 16:27:59.000000',
        'timestamp_desc': definitions.TIME_DESCRIPTION_MODIFICATION}

    self.CheckEventValues(storage_writer, events[1], expected_event_values)

    expected_message = (
        'Torrent plaso test; Saved to e:\\torrent\\files\\plaso test; '
        'Minutes seeded: 511')

    event_data = self._GetEventDataOfEvent(storage_writer, events[1])
    self._TestGetMessageStrings(event_data, expected_message, expected_message)
Exemplo n.º 6
0
    def testEnablePlugins(self):
        """Tests the EnablePlugins function."""
        parser_object = bencode_parser.BencodeParser()
        parser_object.EnablePlugins([u'bencode_transmission'])

        self.assertIsNotNone(parser_object)
        self.assertIsNone(parser_object._default_plugin)
        self.assertNotEqual(parser_object._plugin_objects, [])
        self.assertEqual(len(parser_object._plugin_objects), 1)
Exemplo n.º 7
0
    def testEnablePlugins(self):
        """Tests the EnablePlugins function."""
        parser = bencode_parser.BencodeParser()

        number_of_plugins = len(parser._plugin_classes)

        parser.EnablePlugins([])
        self.assertEqual(len(parser._plugins), 0)

        parser.EnablePlugins(parser.ALL_PLUGINS)
        self.assertEqual(len(parser._plugins), number_of_plugins)

        parser.EnablePlugins(['bencode_transmission'])
        self.assertEqual(len(parser._plugins), 1)
Exemplo n.º 8
0
    def testProcess(self):
        """Tests the Process function."""
        parser = bencode_parser.BencodeParser()
        storage_writer = self._ParseFile(['bencode', 'transmission'], parser)

        self.assertEqual(storage_writer.number_of_warnings, 0)
        self.assertEqual(storage_writer.number_of_events, 3)

        # The order in which BencodeParser generates events is nondeterministic
        # hence we sort the events.
        events = list(storage_writer.GetSortedEvents())

        expected_event_values = {
            'destination': '/Users/brian/Downloads',
            'seedtime': 4,
            'timestamp': '2013-11-08 15:31:20.000000',
            'timestamp_desc': definitions.TIME_DESCRIPTION_ADDED
        }

        self.CheckEventValues(storage_writer, events[0], expected_event_values)

        # Test on second event of first torrent.
        expected_event_values = {
            'destination': '/Users/brian/Downloads',
            'seedtime': 4,
            'timestamp': '2013-11-08 18:24:24.000000',
            'timestamp_desc': definitions.TIME_DESCRIPTION_FILE_DOWNLOADED
        }

        self.CheckEventValues(storage_writer, events[1], expected_event_values)

        expected_message = ('Saved to /Users/brian/Downloads; '
                            'Minutes seeded: 4')

        event_data = self._GetEventDataOfEvent(storage_writer, events[1])
        self._TestGetMessageStrings(event_data, expected_message,
                                    expected_message)
Exemplo n.º 9
0
  def testProcess(self):
    """Tests the Process function."""
    parser = bencode_parser.BencodeParser()
    storage_writer = self._ParseFile(['bencode_transmission'], parser)

    self.assertEqual(storage_writer.number_of_events, 3)

    # The order in which BencodeParser generates events is nondeterministic
    # hence we sort the events.
    events = list(storage_writer.GetSortedEvents())

    event = events[0]

    expected_destination = '/Users/brian/Downloads'
    self.assertEqual(event.destination, expected_destination)

    self.assertEqual(event.seedtime, 4)

    expected_description = definitions.TIME_DESCRIPTION_ADDED
    self.assertEqual(event.timestamp_desc, expected_description)

    expected_timestamp = timelib.Timestamp.CopyFromString(
        '2013-11-08 15:31:20')
    self.assertEqual(event.timestamp, expected_timestamp)

    # Test on second event of first torrent.
    event = events[1]
    self.assertEqual(event.destination, expected_destination)
    self.assertEqual(event.seedtime, 4)

    expected_description = definitions.TIME_DESCRIPTION_FILE_DOWNLOADED
    self.assertEqual(event.timestamp_desc, expected_description)

    expected_timestamp = timelib.Timestamp.CopyFromString(
        '2013-11-08 18:24:24')
    self.assertEqual(event.timestamp, expected_timestamp)
Exemplo n.º 10
0
    def testProcess(self):
        """Tests the Process function."""
        parser = bencode_parser.BencodeParser()
        storage_writer = self._ParseFile(['bencode_utorrent'], parser)

        self.assertEqual(storage_writer.number_of_warnings, 0)
        self.assertEqual(storage_writer.number_of_events, 4)

        # The order in which BencodeParser generates events is nondeterministic
        # hence we sort the events.
        events = list(storage_writer.GetSortedEvents())

        expected_caption = 'plaso test'
        expected_path = 'e:\\torrent\\files\\plaso test'

        # First test on when the torrent was added to the client.
        event = events[0]

        self.CheckTimestamp(event.timestamp, '2013-08-03 14:52:12.000000')
        self.assertEqual(event.timestamp_desc,
                         definitions.TIME_DESCRIPTION_ADDED)

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        # Second test on when the torrent file was completely downloaded.
        event = events[3]

        self.CheckTimestamp(event.timestamp, '2013-08-03 18:11:35.000000')
        self.assertEqual(event.timestamp_desc,
                         definitions.TIME_DESCRIPTION_FILE_DOWNLOADED)

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        # Third test on when the torrent was first modified.
        event = events[2]

        self.CheckTimestamp(event.timestamp, '2013-08-03 18:11:34.000000')
        self.assertEqual(event.timestamp_desc,
                         definitions.TIME_DESCRIPTION_MODIFICATION)

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        # Fourth test on when the torrent was again modified.
        event = events[1]

        self.CheckTimestamp(event.timestamp, '2013-08-03 16:27:59.000000')
        self.assertEqual(event.timestamp_desc,
                         definitions.TIME_DESCRIPTION_MODIFICATION)

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        expected_message = (
            'Torrent plaso test; Saved to e:\\torrent\\files\\plaso test; '
            'Minutes seeded: 511')

        self._TestGetMessageStrings(event, expected_message, expected_message)
Exemplo n.º 11
0
    def testProcess(self):
        """Tests the Process function."""
        parser = bencode_parser.BencodeParser()
        storage_writer = self._ParseFile(['bencode_utorrent'], parser)

        self.assertEqual(storage_writer.number_of_events, 4)

        # The order in which BencodeParser generates events is nondeterministic
        # hence we sort the events.
        events = list(storage_writer.GetSortedEvents())

        expected_caption = 'plaso test'
        expected_path = 'e:\\torrent\\files\\plaso test'

        # First test on when the torrent was added to the client.
        event = events[0]

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        expected_description = definitions.TIME_DESCRIPTION_ADDED
        self.assertEqual(event.timestamp_desc, expected_description)

        expected_timestamp = timelib.Timestamp.CopyFromString(
            '2013-08-03 14:52:12')
        self.assertEqual(event.timestamp, expected_timestamp)

        # Second test on when the torrent file was completely downloaded.
        event = events[3]

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        expected_description = definitions.TIME_DESCRIPTION_FILE_DOWNLOADED
        self.assertEqual(event.timestamp_desc, expected_description)

        expected_timestamp = timelib.Timestamp.CopyFromString(
            '2013-08-03 18:11:35')
        self.assertEqual(event.timestamp, expected_timestamp)

        # Third test on when the torrent was first modified.
        event = events[2]

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        expected_description = definitions.TIME_DESCRIPTION_MODIFICATION
        self.assertEqual(event.timestamp_desc, expected_description)

        expected_timestamp = timelib.Timestamp.CopyFromString(
            '2013-08-03 18:11:34')
        self.assertEqual(event.timestamp, expected_timestamp)

        # Fourth test on when the torrent was again modified.
        event = events[1]

        self.assertEqual(event.caption, expected_caption)
        self.assertEqual(event.path, expected_path)
        self.assertEqual(event.seedtime, 511)

        expected_description = definitions.TIME_DESCRIPTION_MODIFICATION
        self.assertEqual(event.timestamp_desc, expected_description)

        expected_timestamp = timelib.Timestamp.CopyFromString(
            '2013-08-03 16:27:59')
        self.assertEqual(event.timestamp, expected_timestamp)
Exemplo n.º 12
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._parser = bencode_parser.BencodeParser()
Exemplo n.º 13
0
 def setUp(self):
   """Makes preparations before running an individual test."""
   self._parser = bencode_parser.BencodeParser()
Exemplo n.º 14
0
  def testProcess(self):
    """Tests the Process function."""
    parser_object = bencode_parser.BencodeParser()

    test_file = self._GetTestFilePath([u'bencode_utorrent'])
    event_queue_consumer = self._ParseFile(parser_object, test_file)
    event_objects = self._GetEventObjectsFromQueue(event_queue_consumer)

    self.assertEqual(len(event_objects), 4)

    expected_caption = u'plaso test'
    expected_path = u'e:\\torrent\\files\\plaso test'

    # First test on when the torrent was added to the client.
    event_object = event_objects[0]

    self.assertEqual(event_object.caption, expected_caption)

    self.assertEqual(event_object.path, expected_path)

    self.assertEqual(event_object.seedtime, 511)

    expected_description = eventdata.EventTimestamp.ADDED_TIME
    self.assertEqual(event_object.timestamp_desc, expected_description)

    expected_timestamp = timelib.Timestamp.CopyFromString(
        u'2013-08-03 14:52:12')
    self.assertEqual(event_object.timestamp, expected_timestamp)

    # Second test on when the torrent file was completely downloaded.
    event_object = event_objects[3]

    self.assertEqual(event_object.caption, expected_caption)
    self.assertEqual(event_object.path, expected_path)
    self.assertEqual(event_object.seedtime, 511)

    expected_description = eventdata.EventTimestamp.FILE_DOWNLOADED
    self.assertEqual(event_object.timestamp_desc, expected_description)

    expected_timestamp = timelib.Timestamp.CopyFromString(
        u'2013-08-03 18:11:35')
    self.assertEqual(event_object.timestamp, expected_timestamp)

    # Third test on when the torrent was first modified.
    event_object = event_objects[2]

    self.assertEqual(event_object.caption, expected_caption)
    self.assertEqual(event_object.path, expected_path)
    self.assertEqual(event_object.seedtime, 511)

    expected_description = eventdata.EventTimestamp.MODIFICATION_TIME
    self.assertEqual(event_object.timestamp_desc, expected_description)

    expected_timestamp = timelib.Timestamp.CopyFromString(
        u'2013-08-03 18:11:34')
    self.assertEqual(event_object.timestamp, expected_timestamp)

    # Fourth test on when the torrent was again modified.
    event_object = event_objects[1]

    self.assertEqual(event_object.caption, expected_caption)
    self.assertEqual(event_object.path, expected_path)
    self.assertEqual(event_object.seedtime, 511)

    expected_description = eventdata.EventTimestamp.MODIFICATION_TIME
    self.assertEqual(event_object.timestamp_desc, expected_description)

    expected_timestamp = timelib.Timestamp.CopyFromString(
        u'2013-08-03 16:27:59')
    self.assertEqual(event_object.timestamp, expected_timestamp)
Exemplo n.º 15
0
 def setUp(self):
   """Sets up the needed objects used throughout the test."""
   self.pre_obj = event.PreprocessObject()
   self._parser = bencode_parser.BencodeParser(self.pre_obj, None)