75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
|
import * as plugins from '../ts/plugins.js';
|
|
// SzPlatformService doesn't exist in codebase - using DcRouter instead for integration tests
|
|
import DcRouter from '../ts/classes.dcrouter.js';
|
|
import { BounceManager } from '../ts/mail/core/classes.bouncemanager.js';
|
|
import { smtpClientMod } from '../ts/mail/delivery/index.js';
|
|
import { SmtpServer } from '../ts/mail/delivery/smtpserver/smtp-server.js';
|
|
|
|
// Test the new integration architecture
|
|
tap.test('should be able to create an SMTP server', async (tools) => {
|
|
// Create an SMTP server
|
|
const smtpServer = new SmtpServer({
|
|
options: {
|
|
port: 10025,
|
|
hostname: 'test.example.com',
|
|
key: '',
|
|
cert: ''
|
|
}
|
|
});
|
|
|
|
// Verify it was created properly
|
|
expect(smtpServer).toBeTruthy();
|
|
expect(smtpServer.options.port).toEqual(10025);
|
|
expect(smtpServer.options.hostname).toEqual('test.example.com');
|
|
});
|
|
|
|
|
|
tap.test('DcRouter should support email configuration', async (tools) => {
|
|
// Create a DcRouter with email config
|
|
const dcRouter = new DcRouter({
|
|
emailConfig: {
|
|
useEmail: true,
|
|
domainRules: [{
|
|
// name: 'test-rule', // not part of IDomainRule
|
|
match: {
|
|
senderPattern: '.*@test.com',
|
|
},
|
|
actions: []
|
|
}]
|
|
}
|
|
});
|
|
|
|
// Verify it was created properly
|
|
expect(dcRouter).toBeTruthy();
|
|
});
|
|
|
|
tap.test('SMTP client should be able to connect to SMTP server', async (tools) => {
|
|
// Create an SMTP client
|
|
const options = {
|
|
host: 'smtp.test.com',
|
|
port: 587,
|
|
secure: false,
|
|
auth: {
|
|
user: 'test@example.com',
|
|
pass: 'testpass'
|
|
},
|
|
connectionTimeout: 5000,
|
|
socketTimeout: 5000
|
|
};
|
|
|
|
const smtpClient = smtpClientMod.createSmtpClient(options);
|
|
|
|
// Verify it was created properly
|
|
expect(smtpClient).toBeTruthy();
|
|
// Since options are not exposed, just verify the client was created
|
|
expect(typeof smtpClient.sendMail).toEqual('function');
|
|
expect(typeof smtpClient.getPoolStatus).toEqual('function');
|
|
});
|
|
|
|
tap.test('stop', async () => {
|
|
await tap.stopForcefully();
|
|
});
|
|
|
|
// Export for tapbundle execution
|
|
export default tap.start(); |