fix(smartproxy): improve certificate manager mocking in tests, enhance IPv6 validation, and record initial bytes for connection metrics

This commit is contained in:
2026-01-30 19:52:36 +00:00
parent 1d1e5062a6
commit 2068b7a1ad
15 changed files with 230 additions and 119 deletions

View File

@@ -39,9 +39,11 @@ tap.test('should detect and forward non-TLS connections on useHttpProxy ports',
remoteIP: '127.0.0.1',
isTLS: false
}),
generateConnectionId: () => 'test-connection-id',
initiateCleanupOnce: () => {},
cleanupConnection: () => {},
getConnectionCount: () => 1,
trackConnectionByRoute: (routeId: string, connectionId: string) => {},
handleError: (type: string, record: any) => {
return (error: Error) => {
console.log(`Mock: Error handled for ${type}: ${error.message}`);
@@ -70,9 +72,9 @@ tap.test('should detect and forward non-TLS connections on useHttpProxy ports',
// Mock security manager
const mockSecurityManager = {
validateIP: () => ({ allowed: true })
validateAndTrackIP: () => ({ allowed: true })
};
// Create a mock SmartProxy instance with necessary properties
const mockSmartProxy = {
settings: mockSettings,
@@ -163,9 +165,11 @@ tap.test('should handle TLS connections normally', async (tapTest) => {
isTLS: true,
tlsHandshakeComplete: false
}),
generateConnectionId: () => 'test-tls-connection-id',
initiateCleanupOnce: () => {},
cleanupConnection: () => {},
getConnectionCount: () => 1,
trackConnectionByRoute: (routeId: string, connectionId: string) => {},
handleError: (type: string, record: any) => {
return (error: Error) => {
console.log(`Mock: Error handled for ${type}: ${error.message}`);
@@ -198,9 +202,9 @@ tap.test('should handle TLS connections normally', async (tapTest) => {
};
const mockSecurityManager = {
validateIP: () => ({ allowed: true })
validateAndTrackIP: () => ({ allowed: true })
};
// Create a mock SmartProxy instance with necessary properties
const mockSmartProxy = {
settings: mockSettings,