def test_tcps(self): address = ('127.0.0.1', 5515) keyfile = NamedTemporaryFile(delete=False) keyfile.write(key_data) keyfile.close() certfile = NamedTemporaryFile(delete=False) certfile.write(cert_data) certfile.close() serv = SyslogServer(address, Handler, keyfile=keyfile.name, certfile=certfile.name) serv.entry = None thr = threading.Thread( target=syslog_server_thread, args=(serv,)) thr.start() tm = TCPSyslogEmitter(address, octet_based_framing=True, keyfile=None) y = create_test_entry('TCPS') tm.emit(y) tm.close() thr.join() serv.socket.close() os.unlink(keyfile.name) os.unlink(certfile.name) self.assertEqual(serv.entry.msg, "An application event log entry through TCPS...")
def test_tcp(self): address = ('127.0.0.1', 5514) serv = SyslogServer(address, Handler) serv.entry = None thr = threading.Thread( target=syslog_server_thread, args=(serv,)) thr.start() tm = TCPSyslogEmitter(address, octet_based_framing=False) y = create_test_entry('TCP') tm.emit(y) tm.close() thr.join() serv.socket.close() self.assertEqual(serv.entry.msg, "An application event log entry through TCP...")
def test_tcp_msg_handle(self): """A functional test that emits a syslog message to an assumed-running bevis instance at localhost:6514. """ y = SyslogEntry( prival=165, timestamp=datetime.datetime.utcnow(), hostname='myhost', app_name='my_app', procid=os.getpid(), msgid='ID42', structured_data=[SDElement('exampleSDID@32473', [('iut','3'), ('eventSource','Application'), ('eventID','1011'), ('eventID','1012')] )], msg='An application event log entry through TCP' ) client = TCPSyslogEmitter(address=('127.0.0.1', 6514), octet_based_framing=False) client.emit(y)
def test_tcps(self): address = ('127.0.0.1', 5515) keyfile = NamedTemporaryFile(delete=False) keyfile.write(key_data) keyfile.close() certfile = NamedTemporaryFile(delete=False) certfile.write(cert_data) certfile.close() serv = SyslogServer(address, Handler, keyfile=keyfile.name, certfile=certfile.name) serv.entry = None thr = threading.Thread(target=syslog_server_thread, args=(serv, )) thr.start() tm = TCPSyslogEmitter(address, octet_based_framing=True, keyfile=None) y = create_test_entry('TCPS') tm.emit(y) tm.close() thr.join() serv.socket.close() os.unlink(keyfile.name) os.unlink(certfile.name) self.assertEqual(serv.entry.msg, "An application event log entry through TCPS...")
def test_tcp(self): address = ('127.0.0.1', 5514) serv = SyslogServer(address, Handler) serv.entry = None thr = threading.Thread(target=syslog_server_thread, args=(serv, )) thr.start() tm = TCPSyslogEmitter(address, octet_based_framing=False) y = create_test_entry('TCP') tm.emit(y) tm.close() thr.join() serv.socket.close() self.assertEqual(serv.entry.msg, "An application event log entry through TCP...")