Beispiel #1
0
  def testGetTags(self):
    """Tests the _GetTags function."""
    fake_cursor = fake_mysqldb.FakeMySQLdbCursor()
    fake_cursor.expected_query = u'SELECT DISTINCT tag FROM log2timeline'
    fake_cursor.query_results = [(u'one',), (u'two,three',), (u'four',)]

    output_mediator = self._CreateOutputMediator()
    output_module = mysql_4n6time.MySQL4n6TimeOutputModule(output_mediator)
    output_module._cursor = fake_cursor

    expected_tags = [u'one', u'two', u'three', u'four']
    tags = output_module._GetTags()
    self.assertEqual(tags, expected_tags)
Beispiel #2
0
  def testGetUniqueValues(self):
    """Tests the _GetUniqueValues function."""
    fake_cursor = fake_mysqldb.FakeMySQLdbCursor()
    fake_cursor.expected_query = (
        u'SELECT source, COUNT(source) FROM log2timeline GROUP BY source')
    fake_cursor.query_results = [(u'one', 1), (u'two', 2), (u'three', 3)]

    output_mediator = self._CreateOutputMediator()
    output_module = mysql_4n6time.MySQL4n6TimeOutputModule(output_mediator)
    output_module._cursor = fake_cursor

    expected_unique_values = {u'one': 1, u'two': 2, u'three': 3}
    unique_values = output_module._GetUniqueValues(u'source')
    self.assertEqual(unique_values, expected_unique_values)
Beispiel #3
0
  def testWriteEventBody(self):
    """Tests the WriteEventBody function."""
    fake_cursor = fake_mysqldb.FakeMySQLdbCursor()
    fake_cursor.expected_query = (
        mysql_4n6time.MySQL4n6TimeOutputModule._INSERT_QUERY)

    fake_cursor.expected_query_args = {
        u'computer_name': u'-',
        u'datetime': u'2012-06-27 18:17:01',
        u'description': u'[',
        u'event_identifier': u'-',
        u'event_type': u'-',
        u'evidence': u'-',
        u'extra': (
            u'my_number: 123  '
            u'some_additional_foo: True  '
            u'text: Reporter <CRON> PID: 8442 (pam_unix(cron:session): '
            u'session closed for user root) '),
        u'filename': u'log/syslog.1',
        u'format': u'-',
        u'host': u'ubuntu',
        u'inode': u'-',
        u'inreport': u'',
        u'MACB': u'M...',
        u'notes': u'-',
        u'offset': 0,
        u'record_number': 0,
        u'reportnotes': u'',
        u'source_name': u'-',
        u'sourcetype': u'Log File',
        u'source': u'LOG',
        u'tag': u'',
        u'timezone': u'UTC',
        u'type': u'Content Modification Time',
        u'URL': u'-',
        u'user_sid': u'-',
        u'user': u'-',
        u'vss_store_number': -1}

    output_mediator = self._CreateOutputMediator()
    output_module = mysql_4n6time.MySQL4n6TimeOutputModule(output_mediator)
    output_module._count = 0
    output_module._cursor = fake_cursor

    timestamp = timelib.Timestamp.CopyFromString(
        u'2012-06-27 18:17:01+00:00')
    event = MySQL4n6TimeTestEvent(timestamp)
    output_module.WriteEventBody(event)