

def testParseRsyslog(self):
    test_data = '\n    $SomeDirective\n    daemon.* @@tcp.example.com.:514;RSYSLOG_ForwardFormat\n    syslog.debug,info @udp.example.com.:514;RSYSLOG_ForwardFormat\n    kern.* |/var/log/pipe\n    news,uucp.* ~\n    user.* ^/usr/bin/log2cowsay\n    *.* /var/log/messages\n    *.emerg    *\n    mail.*  -/var/log/maillog\n    '
    log_conf = StringIO.StringIO(test_data)
    parser = config_file.RsyslogParser()
    results = list(parser.ParseMultiple([None], [log_conf], None))
    self.assertEqual(1, len(results))
    (tcp, udp, pipe, null, script, fs, wall, async_fs) = [target for target in results[0].targets]
    self.assertEqual('daemon', tcp.facility)
    self.assertEqual('*', tcp.priority)
    self.assertEqual('TCP', tcp.transport)
    self.assertEqual('tcp.example.com.:514', tcp.destination)
    self.assertEqual('syslog', udp.facility)
    self.assertEqual('debug,info', udp.priority)
    self.assertEqual('UDP', udp.transport)
    self.assertEqual('udp.example.com.:514', udp.destination)
    self.assertEqual('kern', pipe.facility)
    self.assertEqual('*', pipe.priority)
    self.assertEqual('PIPE', pipe.transport)
    self.assertEqual('/var/log/pipe', pipe.destination)
    self.assertEqual('news,uucp', null.facility)
    self.assertEqual('*', null.priority)
    self.assertEqual('NONE', null.transport)
    self.assertFalse(null.destination)
    self.assertEqual('user', script.facility)
    self.assertEqual('*', script.priority)
    self.assertEqual('SCRIPT', script.transport)
    self.assertEqual('/usr/bin/log2cowsay', script.destination)
    self.assertEqual('*', fs.facility)
    self.assertEqual('*', fs.priority)
    self.assertEqual('FILE', fs.transport)
    self.assertEqual('/var/log/messages', fs.destination)
    self.assertEqual('*', wall.facility)
    self.assertEqual('emerg', wall.priority)
    self.assertEqual('WALL', wall.transport)
    self.assertEqual('*', wall.destination)
    self.assertEqual('mail', async_fs.facility)
    self.assertEqual('*', async_fs.priority)
    self.assertEqual('FILE', async_fs.transport)
    self.assertEqual('/var/log/maillog', async_fs.destination)

dataset/ETHPy150Open google/grr/grr/parsers/config_file_test.py RsyslogParserTests.testParseRsyslog/original