Beispiel #1
0
    def testParse(self):
        """Tests the Parse function."""
        parser = pls_recall.PlsRecallParser()
        storage_writer = self._ParseFile(['PLSRecall_Test.dat'], parser)

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

        events = list(storage_writer.GetEvents())

        event = events[0]

        self.CheckTimestamp(event.timestamp, '2013-06-18 19:50:00.550000')

        event_data = self._GetEventDataOfEvent(storage_writer, event)
        self.assertEqual(event_data.sequence_number, 206)
        self.assertEqual(event_data.username, 'tsltmp')
        self.assertEqual(event_data.database_name, 'DB11')

        # The test file actually has 'test_databae' in the SQL string.
        expected_query = 'SELECT * from test_databae where date > \'01/01/2012\''
        self.assertEqual(event_data.query, expected_query)

        expected_message = ('Sequence number: 206 '
                            'Username: tsltmp '
                            'Database name: DB11 '
                            'Query: {0:s}').format(expected_query)

        expected_short_message = '206 tsltmp DB11 {0:s}'.format(expected_query)

        self._TestGetMessageStrings(event, expected_message,
                                    expected_short_message)
Beispiel #2
0
    def testParse(self):
        """Tests the Parse function."""
        parser = pls_recall.PlsRecallParser()
        storage_writer = self._ParseFile(['PLSRecall_Test.dat'], parser)

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

        events = list(storage_writer.GetEvents())

        # The test file actually has 'test_databae' in the table name.
        expected_query = 'SELECT * from test_databae where date > \'01/01/2012\''

        expected_event_values = {
            'database_name': 'DB11',
            'query': expected_query,
            'sequence_number': 206,
            'timestamp': '2013-06-18 19:50:00.550000',
            'username': '******'
        }

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

        expected_message = ('Sequence number: 206 '
                            'Username: tsltmp '
                            'Database name: DB11 '
                            'Query: {0:s}').format(expected_query)
        expected_short_message = '206 tsltmp DB11 {0:s}'.format(expected_query)

        event_data = self._GetEventDataOfEvent(storage_writer, events[0])
        self._TestGetMessageStrings(event_data, expected_message,
                                    expected_short_message)
Beispiel #3
0
    def testParse(self):
        """Tests the Parse function."""
        parser = pls_recall.PlsRecallParser()
        storage_writer = self._ParseFile(['PLSRecall_Test.dat'], parser)

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

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

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

        events = list(storage_writer.GetEvents())

        # The test file actually has 'test_databae' in the table name.
        expected_event_values = {
            'data_type': 'PLSRecall:event',
            'database_name': 'DB11',
            'date_time': '2013-06-18 19:50:00.550000',
            'query':
            ('SELECT * from test_databae where date > \'01/01/2012\''),
            'sequence_number': 206,
            'username': '******'
        }

        self.CheckEventValues(storage_writer, events[0], expected_event_values)
Beispiel #4
0
    def testParse(self):
        """Tests the Parse function."""
        parser_object = pls_recall.PlsRecallParser()

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

        # There are two events in test file.
        self.assertEqual(len(event_objects), 2)

        event_object = event_objects[0]

        timestamp_expected = timelib.Timestamp.CopyFromString(
            u'2013-06-18 19:50:00:00:00')
        self.assertEqual(event_object.timestamp, timestamp_expected)

        sequence_expected = 206
        self.assertEqual(event_object.sequence, sequence_expected)

        username_expected = u'tsltmp'
        self.assertEqual(event_object.username, username_expected)

        database_name_expected = u'DB11'
        self.assertEqual(event_object.database_name, database_name_expected)

        # The test file actually has 'test_databae' in the SQL string.
        query_expected = u'SELECT * from test_databae where date > \'01/01/2012\''
        self.assertEqual(event_object.query, query_expected)

        expected_msg = (
            u'Sequence #206 '
            u'User: tsltmp '
            u'Database Name: DB11 '
            u'Query: SELECT * from test_databae where date > \'01/01/2012\'')

        expected_msg_short = (
            u'206 tsltmp DB11 '
            u'SELECT * from test_databae where date > \'01/01/2012\'')

        self._TestGetMessageStrings(event_object, expected_msg,
                                    expected_msg_short)
Beispiel #5
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._parser = pls_recall.PlsRecallParser()
Beispiel #6
0
 def setUp(self):
     """Makes preparations before running an individual test."""
     self._parser = pls_recall.PlsRecallParser()