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
This commit is contained in:
parent
739eeb63aa
commit
a2b413a78f
@ -46,6 +46,20 @@ export async function startTestServer(config: ITestServerConfig): Promise<ITestS
|
||||
processEmailByMode: async (emailData: any) => {
|
||||
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<ITestS
|
||||
socketTimeout: serverConfig.timeout,
|
||||
connectionTimeout: serverConfig.timeout * 2,
|
||||
cleanupInterval: 300000,
|
||||
auth: serverConfig.authRequired ? {
|
||||
auth: serverConfig.authRequired ? ({
|
||||
required: true,
|
||||
methods: ['PLAIN', 'LOGIN'] as ('PLAIN' | 'LOGIN' | 'OAUTH2')[],
|
||||
validateUser: async (username: string, password: string) => {
|
||||
// Test server accepts these credentials
|
||||
return username === 'testuser' && password === 'testpass';
|
||||
}
|
||||
} : undefined
|
||||
} as any) : undefined
|
||||
};
|
||||
|
||||
// Create SMTP server
|
||||
|
Loading…
x
Reference in New Issue
Block a user