fix(smartproxy): improve certificate manager mocking in tests, enhance IPv6 validation, and record initial bytes for connection metrics
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user