This commit is contained in:
2025-05-26 04:09:29 +00:00
parent 84196f9b13
commit 5a45d6cd45
19 changed files with 2691 additions and 4472 deletions

View File

@ -260,4 +260,66 @@ tap.start();
- 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)
- Always check for complete SMTP responses (ending with space after code)
## SMTP Implementation Findings (2025-05-25)
### Fixed Issues
1. **AUTH Mechanism Implementation**
- The server-side AUTH command handler was incomplete
- Implemented `handleAuthPlain` with proper PLAIN authentication flow
- Implemented `handleAuthLogin` with state-based LOGIN authentication flow
- Added `validateUser` function to test server configuration
- AUTH tests now expect STARTTLS instead of direct TLS (`secure: false` with `requireTLS: true`)
2. **TLS Connection Timeout Handling**
- For secure connections, the client was waiting for 'connect' event instead of 'secureConnect'
- Fixed in `ConnectionManager.establishSocket()` to use the appropriate event based on connection type
- This prevents indefinite hangs during TLS handshake failures
3. **STARTTLS Server Implementation**
- Removed incorrect `(tlsSocket as any)._start()` call which is client-side only
- Server-side TLS sockets handle handshake automatically when data arrives
- The `_start()` method caused Node.js assertion failure: `wrap->is_client()`
4. **Edge Case Test Patterns**
- Tests using non-existent `smtpClient.connect()` method - use `verify()` instead
- SMTP servers must handle DATA mode properly by processing lines individually
- Empty/minimal server responses need to be valid SMTP codes (e.g., "250 OK\r\n")
- Out-of-order pipelined responses break SMTP protocol - responses must be in order
### Common Test Patterns
1. **Connection Testing**
```typescript
const verified = await smtpClient.verify();
expect(verified).toBeTrue();
```
2. **Server Data Handling**
```typescript
socket.on('data', (data) => {
const lines = data.toString().split('\r\n');
lines.forEach(line => {
if (!line && lines[lines.length - 1] === '') return;
// Process each line individually
});
});
```
3. **Authentication Setup**
```typescript
auth: {
required: true,
methods: ['PLAIN', 'LOGIN'],
validateUser: async (username, password) => {
return username === 'testuser' && password === 'testpass';
}
}
```
### Progress Tracking
- Fixed 8 tests total (as of 2025-05-25)
- 30 error logs remaining in `.nogit/testlogs/00err/`
- Edge cases, email composition, error handling, performance, reliability, RFC compliance, and security tests still need fixes