This commit is contained in:
2025-05-23 19:49:25 +00:00
parent e0f6e3237b
commit a7438a7cd6
40 changed files with 189 additions and 178 deletions

View File

@ -1,9 +1,9 @@
import { tap, expect } from '@git.zone/tapbundle';
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as net from 'net';
import * as tls from 'tls';
import { startTestServer, stopTestServer, type ITestServer } from '../../helpers/server.loader.js';
import { startTestServer, stopTestServer, type ITestServer } from '../server.loader.js';
const TEST_PORT = 30031;
const TEST_PORT = 2525;
const TEST_PORT_TLS = 30466;
const TEST_TIMEOUT = 30000;
@ -11,9 +11,10 @@ tap.test('TLS Ciphers - should advertise STARTTLS for cipher negotiation', async
const done = tools.defer();
// Start test server
const testServer = await startTestServer({ port: TEST_PORT });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const socket = net.createConnection({
host: 'localhost',
port: TEST_PORT,
@ -63,7 +64,7 @@ tap.test('TLS Ciphers - should advertise STARTTLS for cipher negotiation', async
expect(true).toBeTrue();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -72,9 +73,10 @@ tap.test('TLS Ciphers - should negotiate secure cipher suites', async (tools) =>
const done = tools.defer();
// Start test server on TLS port
const testServer = await startTestServer({ port: TEST_PORT_TLS, tlsEnabled: true });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const tlsOptions = {
host: 'localhost',
port: TEST_PORT_TLS,
@ -118,7 +120,7 @@ tap.test('TLS Ciphers - should negotiate secure cipher suites', async (tools) =>
socket.end();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -127,9 +129,10 @@ tap.test('TLS Ciphers - should reject weak cipher suites', async (tools) => {
const done = tools.defer();
// Start test server on TLS port
const testServer = await startTestServer({ port: TEST_PORT_TLS, tlsEnabled: true });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
// Try to connect with weak ciphers only
const weakCiphers = [
'DES-CBC3-SHA',
@ -187,7 +190,7 @@ tap.test('TLS Ciphers - should reject weak cipher suites', async (tools) => {
expect(true).toBeTrue();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -196,9 +199,10 @@ tap.test('TLS Ciphers - should support forward secrecy', async (tools) => {
const done = tools.defer();
// Start test server on TLS port
const testServer = await startTestServer({ port: TEST_PORT_TLS, tlsEnabled: true });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
// Prefer ciphers with forward secrecy (ECDHE, DHE)
const forwardSecrecyCiphers = [
'ECDHE-RSA-AES128-GCM-SHA256',
@ -248,7 +252,7 @@ tap.test('TLS Ciphers - should support forward secrecy', async (tools) => {
expect(true).toBeTrue();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -257,9 +261,10 @@ tap.test('TLS Ciphers - should list all supported ciphers', async (tools) => {
const done = tools.defer();
// Start test server on TLS port
const testServer = await startTestServer({ port: TEST_PORT_TLS, tlsEnabled: true });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
// Get list of ciphers supported by Node.js
const supportedCiphers = tls.getCiphers();
console.log(`Node.js supports ${supportedCiphers.length} cipher suites`);
@ -303,7 +308,7 @@ tap.test('TLS Ciphers - should list all supported ciphers', async (tools) => {
expect(negotiatedCipher.name).toBeDefined();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});