update
This commit is contained in:
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user