This commit is contained in:
2025-05-23 21:20:39 +00:00
parent 9629329bc2
commit 0907949f8a
86 changed files with 654 additions and 569 deletions

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;
@ -88,7 +88,7 @@ tap.test('RFC 3461 DSN - MAIL FROM with DSN parameters', async (tools) => {
const accepted = dataBuffer.includes('250');
const properlyRejected = dataBuffer.includes('501') || dataBuffer.includes('555');
expect(accepted || properlyRejected).toBeTrue();
expect(accepted || properlyRejected).toEqual(true);
console.log(`DSN parameters in MAIL FROM ${accepted ? 'accepted' : 'rejected'}`);
if (accepted) {
@ -158,7 +158,7 @@ tap.test('RFC 3461 DSN - RCPT TO with DSN parameters', async (tools) => {
const accepted = dataBuffer.includes('250');
const properlyRejected = dataBuffer.includes('501') || dataBuffer.includes('555');
expect(accepted || properlyRejected).toBeTrue();
expect(accepted || properlyRejected).toEqual(true);
console.log(`DSN parameters in RCPT TO ${accepted ? 'accepted' : 'rejected'}`);
if (accepted) {
@ -319,7 +319,7 @@ tap.test('RFC 3461 DSN - Invalid DSN parameter handling', async (tools) => {
if (properlyRejected) {
console.log('Invalid RET parameter properly rejected');
expect(true).toBeTrue();
expect(true).toEqual(true);
} else if (dataBuffer.includes('250')) {
// Server ignores unknown parameters (also acceptable)
console.log('Server ignores invalid DSN parameters');

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;
@ -28,7 +28,7 @@ tap.test('RFC 5321 - Server greeting format', async (tools) => {
const greeting = response.trim();
const validGreeting = greeting.startsWith('220') && greeting.length > 10;
expect(validGreeting).toBeTrue();
expect(validGreeting).toEqual(true);
expect(greeting).toMatch(/^220\s+\S+/); // Should have hostname after 220
socket.write('QUIT\r\n');
@ -170,7 +170,7 @@ tap.test('RFC 5321 - Line length limits', async (tools) => {
const accepted = dataBuffer.includes('250');
const rejected = dataBuffer.includes('501') || dataBuffer.includes('500');
expect(accepted || rejected).toBeTrue();
expect(accepted || rejected).toEqual(true);
console.log(`Long line test ${accepted ? 'accepted' : 'rejected'}`);
socket.write('QUIT\r\n');
@ -244,7 +244,7 @@ tap.test('RFC 5321 - Standard SMTP verb compliance', async (tools) => {
);
console.log('Supported verbs:', supportedVerbs);
expect(hasRequired).toBeTrue();
expect(hasRequired).toEqual(true);
socket.write('QUIT\r\n');
socket.end();

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;
@ -73,7 +73,7 @@ tap.test('RFC 6376 DKIM - Server accepts email with DKIM signature', async (tool
dataBuffer = '';
} else if (dataBuffer.includes('250 ') && dataBuffer.includes('Message accepted')) {
console.log('Email with DKIM signature accepted');
expect(true).toBeTrue(); // Server accepts DKIM headers
expect(true).toEqual(true); // Server accepts DKIM headers
socket.write('QUIT\r\n');
socket.end();

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;
@ -74,7 +74,7 @@ tap.test('RFC 7208 SPF - Server handles SPF checks', async (tools) => {
result.mailFromResponse !== undefined
);
expect(allDomainsHandled).toBeTrue();
expect(allDomainsHandled).toEqual(true);
socket.write('QUIT\r\n');
socket.end();
@ -149,7 +149,7 @@ tap.test('RFC 7208 SPF - SPF record syntax handling', async (tools) => {
dataBuffer.includes('550') ||
dataBuffer.includes('553');
expect(handled).toBeTrue();
expect(handled).toEqual(true);
console.log('SPF handling response:', dataBuffer.trim());
socket.write('QUIT\r\n');
@ -263,7 +263,7 @@ tap.test('RFC 7208 SPF - IPv4 and IPv6 mechanism support', async (tools) => {
dataBuffer.includes('550') ||
dataBuffer.includes('553');
expect(handled).toBeTrue();
expect(handled).toEqual(true);
console.log('IP mechanism SPF response:', dataBuffer.trim());
socket.write('QUIT\r\n');

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;
@ -75,7 +75,7 @@ tap.test('RFC 7489 DMARC - Server handles DMARC policies', async (tools) => {
result.mailFromResponse !== undefined
);
expect(allScenariosHandled).toBeTrue();
expect(allScenariosHandled).toEqual(true);
socket.write('QUIT\r\n');
socket.end();

View File

@ -2,7 +2,7 @@ import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../plugins.js';
import * as net from 'net';
import * as tls from 'tls';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../server.loader.js';
import { startTestServer, stopTestServer, TEST_PORT, sendEmailWithRawSocket } from '../../helpers/server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
let testServer: SmtpServer;
@ -36,7 +36,7 @@ tap.test('RFC 8314 TLS - STARTTLS advertised in EHLO', async (tools) => {
const advertisesStarttls = dataBuffer.toLowerCase().includes('starttls');
console.log('STARTTLS advertised:', advertisesStarttls);
expect(advertisesStarttls).toBeTrue();
expect(advertisesStarttls).toEqual(true);
// Parse other extensions
const lines = dataBuffer.split('\r\n');
@ -98,7 +98,7 @@ tap.test('RFC 8314 TLS - STARTTLS command functionality', async (tools) => {
// In a real test, we would upgrade to TLS here
// For this test, we just verify the command is accepted
expect(true).toBeTrue();
expect(true).toEqual(true);
socket.end();
done.resolve();
@ -144,7 +144,7 @@ tap.test('RFC 8314 TLS - Commands before STARTTLS', async (tools) => {
console.log('Server allows MAIL FROM before STARTTLS');
} else if (dataBuffer.includes('530') || dataBuffer.includes('554')) {
console.log('Server requires STARTTLS before MAIL FROM (RFC 8314 compliant)');
expect(true).toBeTrue(); // This is actually good for security
expect(true).toEqual(true); // This is actually good for security
}
socket.write('QUIT\r\n');