feat(tests): Implement ERR-02 Invalid Sequence Handling and update test migration documentation
This commit is contained in:
@@ -99,7 +99,7 @@ Tests for proper error handling and recovery.
|
||||
| ID | Test | Priority | Status |
|
||||
|----|------|----------|--------|
|
||||
| **ERR-01** | **Syntax Error Handling** | **High** | **✅ PORTED** |
|
||||
| ERR-02 | Invalid Sequence Handling | High | Planned |
|
||||
| **ERR-02** | **Invalid Sequence Handling** | **High** | **✅ PORTED** |
|
||||
| ERR-05 | Resource Exhaustion | High | Planned |
|
||||
| ERR-07 | Exception Handling | High | Planned |
|
||||
|
||||
@@ -275,16 +275,36 @@ Tests for proper error handling and recovery.
|
||||
- Server lifecycle management
|
||||
|
||||
**Key validations**:
|
||||
- ✓ Invalid commands rejected with appropriate error codes
|
||||
- ✓ Invalid commands rejected with 500/502 error codes
|
||||
- ✓ MAIL FROM requires angle brackets (501 error if missing)
|
||||
- ✓ RCPT TO requires angle brackets (501 error if missing)
|
||||
- ✓ EHLO requires hostname parameter (501 error if missing)
|
||||
- ✓ Extra parameters on QUIT handled (accepted or rejected with 501)
|
||||
- ✓ Malformed email addresses rejected (501 or 553 error)
|
||||
- ✓ Extra parameters on QUIT handled (501 syntax error)
|
||||
- ✓ Malformed email addresses rejected (501 error)
|
||||
- ✓ Commands in wrong sequence rejected (503 error)
|
||||
- ✓ Excessively long commands handled gracefully
|
||||
|
||||
**Note**: Server currently has a bug where `rateLimiter.recordError` is not implemented, causing invalid commands to return 451 (temporary error) instead of 500/502 (syntax error). Tests accept 451 as valid until this is fixed.
|
||||
### ✅ ERR-02: Invalid Sequence Handling (`test.err-02.invalid-sequence.test.ts`)
|
||||
|
||||
**Tests**: 10 total (10 passing)
|
||||
- Rejects MAIL FROM before EHLO
|
||||
- Rejects RCPT TO before MAIL FROM
|
||||
- Rejects DATA before RCPT TO (RFC 5321 compliance)
|
||||
- Allows multiple EHLO commands
|
||||
- Handles second MAIL FROM without RSET
|
||||
- Rejects DATA without MAIL FROM
|
||||
- Handles commands after QUIT
|
||||
- Recovers from syntax errors in sequence
|
||||
- Server lifecycle management
|
||||
|
||||
**Key validations**:
|
||||
- ✓ MAIL FROM requires EHLO first (503 error if missing)
|
||||
- ✓ RCPT TO requires MAIL FROM first (503 error if missing)
|
||||
- ✓ DATA requires RCPT TO with at least one recipient (503 error if missing)
|
||||
- ✓ Multiple EHLO commands allowed (resets session state)
|
||||
- ✓ Commands after QUIT handled correctly (connection closed)
|
||||
- ✓ Session recovers from syntax errors without terminating
|
||||
- ✓ RFC 5321 compliance: strict command sequence enforcement
|
||||
|
||||
## Running Tests
|
||||
|
||||
@@ -383,7 +403,7 @@ import { connectToSmtp, sendSmtpCommand } from '../../helpers/utils.ts';
|
||||
- 🔄 SEC-08: Rate Limiting
|
||||
- 🔄 SEC-10: Header Injection Prevention
|
||||
- ✅ ERR-01: Syntax Error Handling
|
||||
- 🔄 ERR-02: Invalid Sequence Handling
|
||||
- ✅ ERR-02: Invalid Sequence Handling
|
||||
|
||||
### Phase 3: Advanced Features (Medium Priority)
|
||||
- 🔄 SEC-03: DKIM Processing
|
||||
@@ -408,7 +428,7 @@ import { connectToSmtp, sendSmtpCommand } from '../../helpers/utils.ts';
|
||||
- SMTP protocol utilities with readSmtpResponse helper
|
||||
- Test certificates (self-signed RSA)
|
||||
|
||||
**Tests Ported**: 10/100+ test files (72 total tests passing)
|
||||
**Tests Ported**: 11/100+ test files (82 total tests passing)
|
||||
- ✅ CMD-01: EHLO Command (5 tests passing)
|
||||
- ✅ CMD-02: MAIL FROM Command (6 tests passing)
|
||||
- ✅ CMD-03: RCPT TO Command (7 tests passing)
|
||||
@@ -419,6 +439,7 @@ import { connectToSmtp, sendSmtpCommand } from '../../helpers/utils.ts';
|
||||
- ✅ EP-01: Basic Email Sending (7 tests passing)
|
||||
- ✅ SEC-06: IP Reputation Checking (7 tests passing)
|
||||
- ✅ ERR-01: Syntax Error Handling (10 tests passing)
|
||||
- ✅ ERR-02: Invalid Sequence Handling (10 tests passing)
|
||||
|
||||
**Coverage**: Complete essential SMTP transaction flow
|
||||
- EHLO → MAIL FROM → RCPT TO → DATA → QUIT ✅
|
||||
@@ -427,10 +448,19 @@ import { connectToSmtp, sendSmtpCommand } from '../../helpers/utils.ts';
|
||||
|
||||
**Phase 1 Status**: ✅ **COMPLETE** (7/7 tests, 100%)
|
||||
|
||||
**Phase 2 Status**: 🔄 **IN PROGRESS** (3/6 tests, 50%)
|
||||
- ✅ SEC-06: IP Reputation
|
||||
- ✅ ERR-01: Syntax Errors
|
||||
- ✅ ERR-02: Invalid Sequence
|
||||
- 🔄 SEC-01: Authentication
|
||||
- 🔄 SEC-08: Rate Limiting
|
||||
- 🔄 SEC-10: Header Injection
|
||||
|
||||
**Next Steps**:
|
||||
1. Port remaining security tests (SEC-01 Authentication, SEC-08 Rate Limiting, SEC-10 Header Injection)
|
||||
2. Port ERR-02: Invalid Sequence Handling test
|
||||
3. Continue with remaining high-priority tests
|
||||
1. Port SEC-01: Authentication test
|
||||
2. Port SEC-08: Rate Limiting test
|
||||
3. Port SEC-10: Header Injection Prevention test
|
||||
4. Continue with Phase 3 (Advanced Features)
|
||||
|
||||
## Production Readiness Criteria
|
||||
|
||||
|
||||
Reference in New Issue
Block a user