Files
n8n/packages/@n8n/syslog-client/test/client.test.ts
alighasami 3d5eaf9445
Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

85 lines
2.3 KiB
TypeScript

import * as os from 'os';
import { Facility, Severity, SyslogClient, Transport } from '../src';
import { TLS_CERTIFICATE } from './setup';
describe('SyslogClient - Core', () => {
describe('Constructor and defaults', () => {
it('should set default options correctly', () => {
const client = new SyslogClient();
expect(client.target).toBe('127.0.0.1');
expect(client.port).toBe(514);
expect(client.syslogHostname).toBe(os.hostname());
expect(client.tcpTimeout).toBe(10000);
expect(client.transport).toBe(Transport.Udp);
client.close();
});
it('should accept target parameter', () => {
const client = new SyslogClient('127.0.0.2');
expect(client.target).toBe('127.0.0.2');
expect(client.port).toBe(514);
expect(client.syslogHostname).toBe(os.hostname());
client.close();
});
it('should accept custom hostname', () => {
const client = new SyslogClient('127.0.0.2', {
syslogHostname: 'test',
});
expect(client.target).toBe('127.0.0.2');
expect(client.syslogHostname).toBe('test');
client.close();
});
it('should accept custom port and timeout', () => {
const client = new SyslogClient('127.0.0.2', {
syslogHostname: 'test',
port: 5555,
tcpTimeout: 50,
});
expect(client.port).toBe(5555);
expect(client.tcpTimeout).toBe(50);
client.close();
});
it('should accept TCP transport option', () => {
const client = new SyslogClient('127.0.0.2', {
port: 5555,
transport: Transport.Tcp,
});
expect(client.transport).toBe(Transport.Tcp);
client.close();
});
it('should accept TLS transport with certificate', () => {
const client = new SyslogClient('127.0.0.2', {
port: 6514,
transport: Transport.Tls,
tlsCA: TLS_CERTIFICATE,
});
expect(client.transport).toBe(Transport.Tls);
expect(client.tlsCA).toBe(TLS_CERTIFICATE);
client.close();
});
it('should accept facility and severity options', () => {
const client = new SyslogClient('127.0.0.1', {
facility: Facility.Mail,
severity: Severity.Critical,
});
expect(client.facility).toBe(Facility.Mail);
expect(client.severity).toBe(Severity.Critical);
client.close();
});
it('should accept RFC format option', () => {
const client = new SyslogClient('127.0.0.1', {
rfc3164: false,
});
expect(client.rfc3164).toBe(false);
client.close();
});
});
});