fix(smartproxy): Fix route security configuration location and improve ACME timing tests and socket mock implementations

This commit is contained in:
2025-05-29 14:34:00 +00:00
parent e6b3ae395c
commit 32583f784f
8 changed files with 155 additions and 60 deletions

View File

@ -33,6 +33,9 @@ tap.test('should detect and forward non-TLS connections on HttpProxy ports', asy
proxy['httpProxyBridge'].start = async () => {
console.log('Mock: HttpProxyBridge started');
};
proxy['httpProxyBridge'].stop = async () => {
console.log('Mock: HttpProxyBridge stopped');
};
await proxy.start();
@ -60,7 +63,8 @@ tap.test('should detect and forward non-TLS connections on HttpProxy ports', asy
console.log('Client connected to proxy on port 8081');
// Send a non-TLS HTTP request
client.write('GET / HTTP/1.1\r\nHost: test.local\r\n\r\n');
resolve();
// Add a small delay to ensure data is sent
setTimeout(() => resolve(), 50);
});
client.on('error', reject);
@ -128,6 +132,17 @@ tap.test('should properly detect non-TLS connections on HttpProxy ports', async
args[1].end();
};
// Mock HttpProxyBridge methods
proxy['httpProxyBridge'].initialize = async () => {
console.log('Mock: HttpProxyBridge initialized');
};
proxy['httpProxyBridge'].start = async () => {
console.log('Mock: HttpProxyBridge started');
};
proxy['httpProxyBridge'].stop = async () => {
console.log('Mock: HttpProxyBridge stopped');
};
// Mock getHttpProxy to return a truthy value
proxy['httpProxyBridge'].getHttpProxy = () => ({} as any);
@ -140,7 +155,8 @@ tap.test('should properly detect non-TLS connections on HttpProxy ports', async
client.connect(8082, 'localhost', () => {
console.log('Connected to proxy');
client.write('GET / HTTP/1.1\r\nHost: test.local\r\n\r\n');
resolve();
// Add a small delay to ensure data is sent
setTimeout(() => resolve(), 50);
});
client.on('error', () => resolve()); // Ignore errors since we're ending the connection