This commit is contained in:
2025-05-23 19:03:44 +00:00
parent 7d28d23bbd
commit 1b141ec8f3
101 changed files with 30736 additions and 374 deletions

View File

@ -209,4 +209,55 @@ emailConfig: {
### TLS Handling
- Ports 25 and 587: Use 'passthrough' mode (STARTTLS handled by email server)
- Port 465: Use 'terminate' mode (SmartProxy handles TLS termination)
- Domain-specific TLS can be configured per email rule
- Domain-specific TLS can be configured per email rule
## SMTP Test Migration
### Test Framework
- Tests migrated from custom framework to @push.rocks/tapbundle
- Each test file is self-contained with its own server lifecycle management
- Test files use pattern `test.*.ts` for automatic discovery by tstest
### Server Lifecycle
- SMTP server uses `listen()` method to start (not `start()`)
- SMTP server uses `close()` method to stop (not `stop()` or `destroy()`)
- Server loader module manages server lifecycle for tests
### Test Structure
```typescript
import { expect, tap } from '@push.rocks/tapbundle';
import { startTestServer, stopTestServer } from '../server.loader.js';
const TEST_PORT = 2525;
const TEST_TIMEOUT = 10000;
tap.test('prepare server', async () => {
await startTestServer();
await new Promise(resolve => setTimeout(resolve, 100));
});
tap.test('test name', async (tools) => {
const done = tools.defer();
// test implementation
done.resolve();
});
tap.test('cleanup server', async () => {
await stopTestServer();
});
tap.start();
```
### Common Issues and Solutions
1. **Multi-line SMTP responses**: Handle response buffering carefully, especially for EHLO
2. **Timing issues**: Use proper state management instead of string matching
3. **ES Module imports**: Use `import` statements, not `require()`
4. **Server cleanup**: Always close connections properly to avoid hanging tests
5. **Response buffer management**: Clear the response buffer after processing each state to avoid false matches from previous responses. Use specific response patterns (e.g., '250 OK' instead of just '250') to avoid ambiguity.
### SMTP Protocol Testing
- Server generates self-signed certificates automatically for testing
- Default test port is 2525
- Connection timeout is typically 10 seconds
- Always check for complete SMTP responses (ending with space after code)