Esempio n. 1
0
  def testParse(self):
    """Tests the Parse function."""
    parser_object = xchatscrollback.XChatScrollbackParser()

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

    self.assertEqual(len(event_objects), 10)

    # TODO: refactor this to use timelib.
    self.assertEqual(event_objects[0].timestamp, 1232074579000000)
    self.assertEqual(event_objects[1].timestamp, 1232074587000000)
    self.assertEqual(event_objects[2].timestamp, 1232315916000000)
    self.assertEqual(event_objects[3].timestamp, 1232315916000000)
    self.assertEqual(event_objects[4].timestamp, 1232959856000000)
    self.assertEqual(event_objects[5].timestamp, 0)
    self.assertEqual(event_objects[7].timestamp, 1232959862000000)
    self.assertEqual(event_objects[8].timestamp, 1232959932000000)
    self.assertEqual(event_objects[9].timestamp, 1232959993000000)

    expected_string = u'[] * Speaking now on ##plaso##'
    self._TestGetMessageStrings(
        event_objects[0], expected_string, expected_string)

    expected_string = u'[] * Joachim \xe8 uscito (Client exited)'
    self._TestGetMessageStrings(
        event_objects[1], expected_string, expected_string)

    expected_string = u'[] Tcl interface unloaded'
    self._TestGetMessageStrings(
        event_objects[2], expected_string, expected_string)

    expected_string = u'[] Python interface unloaded'
    self._TestGetMessageStrings(
        event_objects[3], expected_string, expected_string)

    expected_string = u'[] * Topic of #plasify \xe8: .'
    self._TestGetMessageStrings(
        event_objects[6], expected_string, expected_string)

    expected_string = u'[nickname: fpi] Hi Kristinn!'
    self._TestGetMessageStrings(
        event_objects[8], expected_string, expected_string)

    expected_string = u'[nickname: Kristinn] GO AND WRITE PARSERS!!! O_o'
    self._TestGetMessageStrings(
        event_objects[9], expected_string, expected_string)
Esempio n. 2
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._parser = xchatscrollback.XChatScrollbackParser()
Esempio n. 3
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     pre_obj = event.PreprocessObject()
     pre_obj.zone = pytz.timezone('UTC')
     self._parser = xchatscrollback_parser.XChatScrollbackParser(
         pre_obj, None)
Esempio n. 4
0
    def testParse(self):
        """Tests the Parse function."""
        parser = xchatscrollback.XChatScrollbackParser()
        storage_writer = self._ParseFile(['xchatscrollback.log'], parser)

        self.assertEqual(storage_writer.number_of_events, 10)

        events = list(storage_writer.GetEvents())

        event = events[0]

        self.CheckTimestamp(event.timestamp, '2009-01-16 02:56:19.000000')

        expected_message = '[] * Speaking now on ##plaso##'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[1]

        self.CheckTimestamp(event.timestamp, '2009-01-16 02:56:27.000000')

        expected_message = '[] * Joachim \xe8 uscito (Client exited)'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[2]

        self.CheckTimestamp(event.timestamp, '2009-01-18 21:58:36.000000')

        expected_message = '[] Tcl interface unloaded'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[3]

        self.CheckTimestamp(event.timestamp, '2009-01-18 21:58:36.000000')

        expected_message = '[] Python interface unloaded'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[5]
        self.assertEqual(event.timestamp, 0)

        expected_message = '[nickname: fpi] 0 is a good timestamp'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[6]

        self.CheckTimestamp(event.timestamp, '2009-01-26 08:50:56.000000')

        expected_message = '[] * Topic of #plasify \xe8: .'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[7]

        self.CheckTimestamp(event.timestamp, '2009-01-26 08:51:02.000000')

        event = events[8]

        self.CheckTimestamp(event.timestamp, '2009-01-26 08:52:12.000000')

        expected_message = '[nickname: fpi] Hi Kristinn!'
        self._TestGetMessageStrings(event, expected_message, expected_message)

        event = events[9]

        self.CheckTimestamp(event.timestamp, '2009-01-26 08:53:13.000000')

        expected_message = '[nickname: Kristinn] GO AND WRITE PARSERS!!! O_o'
        self._TestGetMessageStrings(event, expected_message, expected_message)
Esempio n. 5
0
    def testParse(self):
        """Tests the Parse function."""
        parser = xchatscrollback.XChatScrollbackParser()
        storage_writer = self._ParseFile(['xchatscrollback.log'], parser)

        number_of_events = storage_writer.GetNumberOfAttributeContainers(
            'event')
        self.assertEqual(number_of_events, 10)

        number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
            'extraction_warning')
        self.assertEqual(number_of_warnings, 1)

        number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
            'recovery_warning')
        self.assertEqual(number_of_warnings, 0)

        events = list(storage_writer.GetEvents())

        expected_event_values = {
            'date_time': '2009-01-16 02:56:19',
            'data_type': 'xchat:scrollback:line',
            'text': '* Speaking now on ##plaso##'
        }

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

        expected_event_values = {
            'date_time': '2009-01-16 02:56:27',
            'data_type': 'xchat:scrollback:line',
            'text': '* Joachim \xe8 uscito (Client exited)'
        }

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

        expected_event_values = {
            'date_time': '2009-01-18 21:58:36',
            'data_type': 'xchat:scrollback:line',
            'text': 'Tcl interface unloaded'
        }

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

        expected_event_values = {
            'date_time': '2009-01-18 21:58:36',
            'data_type': 'xchat:scrollback:line',
            'text': 'Python interface unloaded'
        }

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

        # TODO: change parser to return NotSet semantic time.
        expected_event_values = {
            'date_time': '1970-01-01 00:00:00',
            'data_type': 'xchat:scrollback:line',
            'nickname': 'fpi',
            'text': '0 is a good timestamp',
            'timestamp': 0
        }

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

        expected_event_values = {
            'date_time': '2009-01-26 08:50:56',
            'data_type': 'xchat:scrollback:line',
            'text': '* Topic of #plasify \xe8: .'
        }

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

        expected_event_values = {
            'date_time': '2009-01-26 08:51:02',
            'data_type': 'xchat:scrollback:line'
        }

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

        expected_event_values = {
            'date_time': '2009-01-26 08:52:12',
            'data_type': 'xchat:scrollback:line',
            'nickname': 'fpi',
            'text': 'Hi Kristinn!'
        }

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

        expected_event_values = {
            'date_time': '2009-01-26 08:53:13',
            'data_type': 'xchat:scrollback:line',
            'nickname': 'Kristinn',
            'text': 'GO AND WRITE PARSERS!!! O_o'
        }

        self.CheckEventValues(storage_writer, events[9], expected_event_values)
Esempio n. 6
0
    def testParse(self):
        """Tests the Parse function."""
        parser = xchatscrollback.XChatScrollbackParser()
        storage_writer = self._ParseFile(['xchatscrollback.log'], parser)

        self.assertEqual(storage_writer.number_of_warnings, 1)
        self.assertEqual(storage_writer.number_of_events, 10)

        events = list(storage_writer.GetEvents())

        expected_event_values = {
            'text': '* Speaking now on ##plaso##',
            'timestamp': '2009-01-16 02:56:19.000000'
        }

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

        expected_event_values = {
            'text': '* Joachim \xe8 uscito (Client exited)',
            'timestamp': '2009-01-16 02:56:27.000000'
        }

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

        expected_event_values = {
            'text': 'Tcl interface unloaded',
            'timestamp': '2009-01-18 21:58:36.000000'
        }

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

        expected_event_values = {
            'text': 'Python interface unloaded',
            'timestamp': '2009-01-18 21:58:36.000000'
        }

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

        expected_event_values = {
            'nickname': 'fpi',
            'text': '0 is a good timestamp',
            'timestamp': 0
        }

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

        expected_event_values = {
            'text': '* Topic of #plasify \xe8: .',
            'timestamp': '2009-01-26 08:50:56.000000'
        }

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

        expected_event_values = {'timestamp': '2009-01-26 08:51:02.000000'}

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

        expected_event_values = {
            'nickname': 'fpi',
            'text': 'Hi Kristinn!',
            'timestamp': '2009-01-26 08:52:12.000000'
        }

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

        expected_event_values = {
            'nickname': 'Kristinn',
            'text': 'GO AND WRITE PARSERS!!! O_o',
            'timestamp': '2009-01-26 08:53:13.000000'
        }

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

        expected_message = '[nickname: Kristinn] GO AND WRITE PARSERS!!! O_o'

        event_data = self._GetEventDataOfEvent(storage_writer, events[9])
        self._TestGetMessageStrings(event_data, expected_message,
                                    expected_message)
Esempio n. 7
0
 def setUp(self):
     """Makes preparations before running an individual test."""
     self._parser = xchatscrollback.XChatScrollbackParser()