This commit is contained in:
2025-05-25 19:02:18 +00:00
parent 5b33623c2d
commit 4c9fd22a86
20 changed files with 1551 additions and 1451 deletions

View File

@ -18,29 +18,22 @@ tap.test('setup - start SMTP server with TLS', async () => {
});
tap.test('CSEC-01: TLS Verification - should reject invalid certificates by default', async () => {
let errorCaught = false;
// Create client with strict certificate checking (default)
const strictClient = createSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: true,
connectionTimeout: 5000,
tls: {
rejectUnauthorized: true // Default should be true
}
});
try {
// Create client with strict certificate checking (default)
const strictClient = createSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: true,
connectionTimeout: 5000,
tls: {
rejectUnauthorized: true // Default should be true
}
});
await strictClient.verify();
} catch (error: any) {
errorCaught = true;
expect(error).toBeInstanceOf(Error);
// Should fail due to self-signed certificate
console.log('✅ Self-signed certificate rejected:', error.message);
}
const result = await strictClient.verify();
expect(errorCaught).toBeTrue();
// Should fail due to self-signed certificate
expect(result).toBeFalse();
console.log('✅ Self-signed certificate rejected as expected');
});
tap.test('CSEC-01: TLS Verification - should accept valid certificates', async () => {

View File

@ -1,12 +1,14 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import { startTestSmtpServer } from '../../helpers/server.loader.js';
import { createSmtpClient } from '../../helpers/smtp.client.js';
import { startTestServer, stopTestServer, type ITestServer } from '../../helpers/server.loader.js';
import { createSmtpClient } from '../../../ts/mail/delivery/smtpclient/index.js';
let testServer: any;
let testServer: ITestServer;
tap.test('setup test SMTP server', async () => {
testServer = await startTestSmtpServer({
features: ['AUTH', 'AUTH=XOAUTH2', 'AUTH=OAUTHBEARER']
testServer = await startTestServer({
port: 2562,
tlsEnabled: false,
authRequired: true
});
expect(testServer).toBeTruthy();
expect(testServer.port).toBeGreaterThan(0);
@ -439,8 +441,8 @@ tap.test('CSEC-02: OAuth2 error handling', async () => {
tap.test('cleanup test SMTP server', async () => {
if (testServer) {
await testServer.stop();
await stopTestServer(testServer);
}
});
export default tap.start();
tap.start();