fix(smartproxy): upgrade @push.rocks/smartproxy to ^23.1.0 and adapt code/tests for its async getStatistics() API
This commit is contained in:
@@ -19,23 +19,31 @@ tap.test('setup - start SMTP server for greylisting tests', async () => {
|
||||
tap.test('CERR-04: Basic greylisting response handling', async () => {
|
||||
// Create server that simulates greylisting
|
||||
const greylistServer = net.createServer((socket) => {
|
||||
socket.on('error', () => {});
|
||||
socket.write('220 Greylist Test Server\r\n');
|
||||
|
||||
socket.on('data', (data) => {
|
||||
const command = data.toString().trim();
|
||||
|
||||
if (command.startsWith('EHLO') || command.startsWith('HELO')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('MAIL FROM')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('RCPT TO')) {
|
||||
// Simulate greylisting response
|
||||
socket.write('451 4.7.1 Greylisting in effect, please retry later\r\n');
|
||||
} else if (command === 'QUIT') {
|
||||
socket.write('221 Bye\r\n');
|
||||
socket.end();
|
||||
} else {
|
||||
socket.write('250 OK\r\n');
|
||||
const lines = data.toString().split('\r\n').filter((l: string) => l.trim());
|
||||
for (const line of lines) {
|
||||
const command = line.trim();
|
||||
|
||||
if (command.startsWith('EHLO') || command.startsWith('HELO')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('MAIL FROM')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('RCPT TO')) {
|
||||
// Simulate greylisting response
|
||||
socket.write('451 4.7.1 Greylisting in effect, please retry later\r\n');
|
||||
} else if (command.startsWith('RSET')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('DATA')) {
|
||||
socket.write('503 Bad sequence of commands\r\n');
|
||||
} else if (command === 'QUIT') {
|
||||
socket.write('221 Bye\r\n');
|
||||
socket.end();
|
||||
} else if (command.length > 0) {
|
||||
socket.write('250 OK\r\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -48,7 +56,8 @@ tap.test('CERR-04: Basic greylisting response handling', async () => {
|
||||
host: '127.0.0.1',
|
||||
port: 2560,
|
||||
secure: false,
|
||||
connectionTimeout: 5000
|
||||
connectionTimeout: 5000,
|
||||
socketTimeout: 5000
|
||||
});
|
||||
|
||||
const email = new Email({
|
||||
@@ -59,7 +68,7 @@ tap.test('CERR-04: Basic greylisting response handling', async () => {
|
||||
});
|
||||
|
||||
const result = await smtpClient.sendMail(email);
|
||||
|
||||
|
||||
// Should get a failed result due to greylisting
|
||||
expect(result.success).toBeFalse();
|
||||
console.log('Actual error:', result.error?.message);
|
||||
@@ -107,20 +116,30 @@ tap.test('CERR-04: Different greylisting response codes', async () => {
|
||||
tap.test('CERR-04: Greylisting with temporary failure', async () => {
|
||||
// Create server that sends 450 response (temporary failure)
|
||||
const tempFailServer = net.createServer((socket) => {
|
||||
socket.on('error', () => {});
|
||||
socket.write('220 Temp Fail Server\r\n');
|
||||
|
||||
socket.on('data', (data) => {
|
||||
const command = data.toString().trim();
|
||||
|
||||
if (command.startsWith('EHLO')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('MAIL FROM')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('RCPT TO')) {
|
||||
socket.write('450 4.7.1 Mailbox temporarily unavailable\r\n');
|
||||
} else if (command === 'QUIT') {
|
||||
socket.write('221 Bye\r\n');
|
||||
socket.end();
|
||||
const lines = data.toString().split('\r\n').filter((l: string) => l.trim());
|
||||
for (const line of lines) {
|
||||
const command = line.trim();
|
||||
|
||||
if (command.startsWith('EHLO') || command.startsWith('HELO')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('MAIL FROM')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('RCPT TO')) {
|
||||
socket.write('450 4.7.1 Mailbox temporarily unavailable\r\n');
|
||||
} else if (command.startsWith('RSET')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('DATA')) {
|
||||
socket.write('503 Bad sequence of commands\r\n');
|
||||
} else if (command === 'QUIT') {
|
||||
socket.write('221 Bye\r\n');
|
||||
socket.end();
|
||||
} else if (command.length > 0) {
|
||||
socket.write('250 OK\r\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -133,7 +152,8 @@ tap.test('CERR-04: Greylisting with temporary failure', async () => {
|
||||
host: '127.0.0.1',
|
||||
port: 2561,
|
||||
secure: false,
|
||||
connectionTimeout: 5000
|
||||
connectionTimeout: 5000,
|
||||
socketTimeout: 5000
|
||||
});
|
||||
|
||||
const email = new Email({
|
||||
@@ -144,7 +164,7 @@ tap.test('CERR-04: Greylisting with temporary failure', async () => {
|
||||
});
|
||||
|
||||
const result = await smtpClient.sendMail(email);
|
||||
|
||||
|
||||
expect(result.success).toBeFalse();
|
||||
console.log('Actual error:', result.error?.message);
|
||||
expect(result.error?.message).toMatch(/450|temporary|rejected/i);
|
||||
@@ -199,20 +219,30 @@ tap.test('CERR-04: Basic connection verification', async () => {
|
||||
tap.test('CERR-04: Server with RCPT rejection', async () => {
|
||||
// Test server rejecting at RCPT TO stage
|
||||
const rejectServer = net.createServer((socket) => {
|
||||
socket.on('error', () => {});
|
||||
socket.write('220 Reject Server\r\n');
|
||||
|
||||
socket.on('data', (data) => {
|
||||
const command = data.toString().trim();
|
||||
|
||||
if (command.startsWith('EHLO')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('MAIL FROM')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('RCPT TO')) {
|
||||
socket.write('451 4.2.1 Recipient rejected temporarily\r\n');
|
||||
} else if (command === 'QUIT') {
|
||||
socket.write('221 Bye\r\n');
|
||||
socket.end();
|
||||
const lines = data.toString().split('\r\n').filter((l: string) => l.trim());
|
||||
for (const line of lines) {
|
||||
const command = line.trim();
|
||||
|
||||
if (command.startsWith('EHLO') || command.startsWith('HELO')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('MAIL FROM')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('RCPT TO')) {
|
||||
socket.write('451 4.2.1 Recipient rejected temporarily\r\n');
|
||||
} else if (command.startsWith('RSET')) {
|
||||
socket.write('250 OK\r\n');
|
||||
} else if (command.startsWith('DATA')) {
|
||||
socket.write('503 Bad sequence of commands\r\n');
|
||||
} else if (command === 'QUIT') {
|
||||
socket.write('221 Bye\r\n');
|
||||
socket.end();
|
||||
} else if (command.length > 0) {
|
||||
socket.write('250 OK\r\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -225,7 +255,8 @@ tap.test('CERR-04: Server with RCPT rejection', async () => {
|
||||
host: '127.0.0.1',
|
||||
port: 2562,
|
||||
secure: false,
|
||||
connectionTimeout: 5000
|
||||
connectionTimeout: 5000,
|
||||
socketTimeout: 5000
|
||||
});
|
||||
|
||||
const email = new Email({
|
||||
@@ -236,7 +267,7 @@ tap.test('CERR-04: Server with RCPT rejection', async () => {
|
||||
});
|
||||
|
||||
const result = await smtpClient.sendMail(email);
|
||||
|
||||
|
||||
expect(result.success).toBeFalse();
|
||||
console.log('Actual error:', result.error?.message);
|
||||
expect(result.error?.message).toMatch(/451|reject|recipient/i);
|
||||
|
||||
Reference in New Issue
Block a user