This commit is contained in:
2025-05-26 14:50:55 +00:00
parent 20583beb35
commit a3721f7a74
22 changed files with 2820 additions and 8112 deletions

View File

@@ -1,7 +1,7 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as plugins from './plugins.js';
import { createTestServer } from '../../helpers/server.loader.js';
import { createSmtpClient } from '../../helpers/smtp.client.js';
import { createTestSmtpClient } from '../../helpers/smtp.client.js';
import { Email } from '../../../ts/index.js';
tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', async (tools) => {
const testId = 'CRFC-06-protocol-negotiation';
@@ -89,13 +89,13 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
});
// Test EHLO negotiation
const esmtpClient = createSmtpClient({
const esmtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
});
const email = new plugins.smartmail.Email({
const email = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Capability negotiation test',
@@ -161,14 +161,14 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
});
// Test with UTF-8 content
const utf8Email = new plugins.smartmail.Email({
const utf8Email = new Email({
from: 'sénder@example.com', // Non-ASCII sender
to: ['recipient@example.com'],
subject: 'UTF-8 test: café, naïve, 你好',
@@ -322,14 +322,14 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
});
// Test with various valid parameters
const email = new plugins.smartmail.Email({
const email = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Parameter validation test',
@@ -429,7 +429,7 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false,
@@ -437,7 +437,7 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
});
// Test service discovery
const email = new plugins.smartmail.Email({
const email = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Service discovery test',
@@ -525,13 +525,13 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
});
// Test ESMTP mode
const esmtpClient = createSmtpClient({
const esmtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
});
const esmtpEmail = new plugins.smartmail.Email({
const esmtpEmail = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'ESMTP compatibility test',
@@ -543,14 +543,14 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
expect(esmtpResult.response).toContain('2.0.0');
// Test basic SMTP mode (fallback)
const basicClient = createSmtpClient({
const basicClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false,
disableESMTP: true // Force HELO instead of EHLO
});
const basicEmail = new plugins.smartmail.Email({
const basicEmail = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Basic SMTP compatibility test',
@@ -648,7 +648,7 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
});
// Test extension dependencies
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false,
@@ -659,7 +659,7 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
}
});
const email = new plugins.smartmail.Email({
const email = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Extension interdependency test',
@@ -683,4 +683,6 @@ tap.test('CRFC-06: should handle protocol negotiation correctly (RFC 5321)', asy
})();
console.log(`\n${testId}: All ${scenarioCount} protocol negotiation scenarios tested ✓`);
});
});
tap.start();