From a2b413a78ff8a230d2675f3a36ce8f11d7d9502a Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 30 May 2025 16:17:02 +0000 Subject: [PATCH] fix(test): repair SMTP test suite after rate limiter integration The test helper's mock email server was missing the getRateLimiter() method that was added during the rate limiting feature implementation. This caused all SMTP tests to fail with "getRateLimiter is not a function" error. Changes: - Add getRateLimiter() method to mock email server that returns a mock rate limiter - Update mock rate limiter method signatures to match actual implementation - Fix TypeScript type issue with auth options by adding explicit casting --- test/helpers/server.loader.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/helpers/server.loader.ts b/test/helpers/server.loader.ts index 8b95012..941d489 100644 --- a/test/helpers/server.loader.ts +++ b/test/helpers/server.loader.ts @@ -46,6 +46,20 @@ export async function startTestServer(config: ITestServerConfig): Promise { console.log(`📧 [Test Server] Processing email:`, emailData.subject || 'No subject'); return emailData; + }, + getRateLimiter: () => { + // Return a mock rate limiter for testing + return { + recordConnection: (_ip: string) => ({ allowed: true, remaining: 100 }), + checkConnectionLimit: async (_ip: string) => ({ allowed: true, remaining: 100 }), + checkMessageLimit: (_senderAddress: string, _ip: string, _recipientCount?: number, _pattern?: string, _domain?: string) => ({ allowed: true, remaining: 1000 }), + checkRecipientLimit: async (_session: any) => ({ allowed: true, remaining: 50 }), + recordAuthenticationFailure: async (_ip: string) => {}, + recordSyntaxError: async (_ip: string) => {}, + recordCommandError: async (_ip: string) => {}, + isBlocked: async (_ip: string) => false, + cleanup: async () => {} + }; } } as any; @@ -131,14 +145,14 @@ export async function startTestServer(config: ITestServerConfig): Promise { // Test server accepts these credentials return username === 'testuser' && password === 'testpass'; } - } : undefined + } as any) : undefined }; // Create SMTP server