update
This commit is contained in:
@ -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 () => {
|
||||
|
Reference in New Issue
Block a user