update
This commit is contained in:
		| @@ -188,6 +188,8 @@ tap.test('should have ACME challenge route ready before certificate provisioning | ||||
|         expect(challengeRouteActive).toEqual(true); | ||||
|       } | ||||
|     }; | ||||
|     // Call initialize like the real createCertificateManager does | ||||
|     await mockCertManager.initialize(); | ||||
|     return mockCertManager; | ||||
|   }; | ||||
|    | ||||
|   | ||||
| @@ -48,7 +48,8 @@ tap.test('should detect and forward non-TLS connections on useHttpProxy ports', | ||||
|   const mockRouteManager = { | ||||
|     findMatchingRoute: (criteria: any) => ({ | ||||
|       route: mockSettings.routes[0] | ||||
|     }) | ||||
|     }), | ||||
|     getAllRoutes: () => mockSettings.routes | ||||
|   }; | ||||
|    | ||||
|   // Mock security manager | ||||
| @@ -141,7 +142,8 @@ tap.test('should handle TLS connections normally', async (tapTest) => { | ||||
|   const mockRouteManager = { | ||||
|     findMatchingRoute: (criteria: any) => ({ | ||||
|       route: mockSettings.routes[0] | ||||
|     }) | ||||
|     }), | ||||
|     getAllRoutes: () => mockSettings.routes | ||||
|   }; | ||||
|    | ||||
|   const mockSecurityManager = { | ||||
|   | ||||
| @@ -22,27 +22,36 @@ tap.test('should detect and forward non-TLS connections on HttpProxy ports', asy | ||||
|     }] | ||||
|   }); | ||||
|    | ||||
|   // Mock the HttpProxy forwarding on the instance | ||||
|   const originalForward = (proxy as any).httpProxyBridge.forwardToHttpProxy; | ||||
|   (proxy as any).httpProxyBridge.forwardToHttpProxy = async function(...args: any[]) { | ||||
|     forwardedToHttpProxy = true; | ||||
|     connectionPath = 'httpproxy'; | ||||
|     console.log('Mock: Connection forwarded to HttpProxy'); | ||||
|     // Just close the connection for the test | ||||
|     args[1].end(); // socket.end() | ||||
|   }; | ||||
|    | ||||
|   // Add detailed logging to the existing proxy instance | ||||
|   proxy.settings.enableDetailedLogging = true; | ||||
|    | ||||
|   // Override the HttpProxy initialization to avoid actual HttpProxy setup | ||||
|   proxy['httpProxyBridge'].getHttpProxy = () => null; | ||||
|   const mockHttpProxy = { available: true }; | ||||
|   proxy['httpProxyBridge'].initialize = async () => { | ||||
|     console.log('Mock: HttpProxyBridge initialized'); | ||||
|   }; | ||||
|   proxy['httpProxyBridge'].start = async () => { | ||||
|     console.log('Mock: HttpProxyBridge started'); | ||||
|   }; | ||||
|    | ||||
|   await proxy.start(); | ||||
|    | ||||
|   // Mock the HttpProxy forwarding AFTER start to ensure it's not overridden | ||||
|   const originalForward = (proxy as any).httpProxyBridge.forwardToHttpProxy; | ||||
|   (proxy as any).httpProxyBridge.forwardToHttpProxy = async function(...args: any[]) { | ||||
|     forwardedToHttpProxy = true; | ||||
|     connectionPath = 'httpproxy'; | ||||
|     console.log('Mock: Connection forwarded to HttpProxy with args:', args[0], 'on port:', args[2]?.localPort); | ||||
|     // Just close the connection for the test | ||||
|     args[1].end(); // socket.end() | ||||
|   }; | ||||
|    | ||||
|   const originalGetHttpProxy = proxy['httpProxyBridge'].getHttpProxy; | ||||
|   proxy['httpProxyBridge'].getHttpProxy = () => { | ||||
|     console.log('Mock: getHttpProxy called, returning:', mockHttpProxy); | ||||
|     return mockHttpProxy; | ||||
|   }; | ||||
|    | ||||
|   // Make a connection to port 8080 | ||||
|   const client = new net.Socket(); | ||||
|    | ||||
|   | ||||
| @@ -708,6 +708,18 @@ export class RouteConnectionHandler { | ||||
|       // No TLS settings - check if this port should use HttpProxy | ||||
|       const isHttpProxyPort = this.settings.useHttpProxy?.includes(record.localPort); | ||||
|        | ||||
|       // Debug logging | ||||
|       if (this.settings.enableDetailedLogging) { | ||||
|         logger.log('debug', `Checking HttpProxy forwarding: port=${record.localPort}, useHttpProxy=${JSON.stringify(this.settings.useHttpProxy)}, isHttpProxyPort=${isHttpProxyPort}, hasHttpProxy=${!!this.httpProxyBridge.getHttpProxy()}`, { | ||||
|           connectionId, | ||||
|           localPort: record.localPort, | ||||
|           useHttpProxy: this.settings.useHttpProxy, | ||||
|           isHttpProxyPort, | ||||
|           hasHttpProxy: !!this.httpProxyBridge.getHttpProxy(), | ||||
|           component: 'route-handler' | ||||
|         }); | ||||
|       } | ||||
|        | ||||
|       if (isHttpProxyPort && this.httpProxyBridge.getHttpProxy()) { | ||||
|         // Forward non-TLS connections to HttpProxy if configured | ||||
|         if (this.settings.enableDetailedLogging) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user