Add comprehensive SMTP command tests for RCPT TO, DATA, QUIT, TLS, and basic email sending
- Implement CMD-03 tests for RCPT TO command, validating recipient addresses, handling multiple recipients, and enforcing command sequence. - Implement CMD-04 tests for DATA command, ensuring proper email content transmission, handling of dot-stuffing, large messages, and correct command sequence. - Implement CMD-13 tests for QUIT command, verifying graceful connection termination and idempotency. - Implement CM-01 tests for TLS connections, including STARTTLS capability and direct TLS connections. - Implement EP-01 tests for basic email sending, covering complete SMTP transaction flow, MIME attachments, HTML emails, custom headers, and minimal emails.
This commit is contained in:
@@ -87,19 +87,13 @@ async function readWithTimeout(
|
||||
}
|
||||
|
||||
/**
|
||||
* Send SMTP command and wait for response
|
||||
* Read SMTP response without sending a command
|
||||
*/
|
||||
export async function sendSmtpCommand(
|
||||
export async function readSmtpResponse(
|
||||
conn: Deno.TcpConn,
|
||||
command: string,
|
||||
expectedCode?: string,
|
||||
timeout: number = 5000
|
||||
): Promise<string> {
|
||||
// Send command
|
||||
const encoder = new TextEncoder();
|
||||
await conn.write(encoder.encode(command + '\r\n'));
|
||||
|
||||
// Read response
|
||||
let buffer = '';
|
||||
const startTime = Date.now();
|
||||
|
||||
@@ -116,7 +110,24 @@ export async function sendSmtpCommand(
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Command timeout after ${timeout}ms`);
|
||||
throw new Error(`Response timeout after ${timeout}ms`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send SMTP command and wait for response
|
||||
*/
|
||||
export async function sendSmtpCommand(
|
||||
conn: Deno.TcpConn,
|
||||
command: string,
|
||||
expectedCode?: string,
|
||||
timeout: number = 5000
|
||||
): Promise<string> {
|
||||
// Send command
|
||||
const encoder = new TextEncoder();
|
||||
await conn.write(encoder.encode(command + '\r\n'));
|
||||
|
||||
// Read response using the dedicated function
|
||||
return await readSmtpResponse(conn, expectedCode, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user