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-07: should ensure SMTP interoperability (RFC 5321)', async (tools) => {
const testId = 'CRFC-07-interoperability';
@ -115,13 +115,13 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
}
});
const smtpClient = createSmtpClient({
const smtpClient = 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: `Interoperability test with ${impl.name}`,
@ -185,7 +185,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
@ -233,7 +233,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
for (const test of internationalTests) {
console.log(` Testing: ${test.desc}`);
const email = new plugins.smartmail.Email({
const email = new Email({
from: test.from,
to: [test.to],
subject: test.subject,
@ -320,7 +320,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
@ -330,7 +330,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
const formatTests = [
{
desc: 'Plain text message',
email: new plugins.smartmail.Email({
email: new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Plain text test',
@ -339,7 +339,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
},
{
desc: 'HTML message',
email: new plugins.smartmail.Email({
email: new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'HTML test',
@ -348,7 +348,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
},
{
desc: 'Multipart alternative',
email: new plugins.smartmail.Email({
email: new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Multipart test',
@ -358,7 +358,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
},
{
desc: 'Message with attachment',
email: new plugins.smartmail.Email({
email: new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Attachment test',
@ -371,7 +371,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
},
{
desc: 'Message with custom headers',
email: new plugins.smartmail.Email({
email: new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Custom headers test',
@ -458,7 +458,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false
@ -499,7 +499,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
for (const test of errorTests) {
console.log(` Testing: ${test.desc}`);
const email = new plugins.smartmail.Email({
const email = new Email({
from: test.from,
to: Array.isArray(test.to) ? test.to : [test.to],
subject: `Error test: ${test.desc}`,
@ -610,7 +610,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
}
});
const smtpClient = createSmtpClient({
const smtpClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false,
@ -622,7 +622,7 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
console.log(' Testing connection reuse...');
for (let i = 1; i <= 3; i++) {
const email = new plugins.smartmail.Email({
const email = new Email({
from: 'sender@example.com',
to: [`recipient${i}@example.com`],
subject: `Connection test ${i}`,
@ -700,14 +700,14 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
});
// Test with client that can fall back to basic SMTP
const legacyClient = createSmtpClient({
const legacyClient = createTestSmtpClient({
host: testServer.hostname,
port: testServer.port,
secure: false,
disableESMTP: true // Force HELO mode
});
const email = new plugins.smartmail.Email({
const email = new Email({
from: 'sender@example.com',
to: ['recipient@example.com'],
subject: 'Legacy compatibility test',
@ -723,4 +723,6 @@ tap.test('CRFC-07: should ensure SMTP interoperability (RFC 5321)', async (tools
})();
console.log(`\n${testId}: All ${scenarioCount} interoperability scenarios tested ✓`);
});
});
tap.start();