fix(smartproxy): Improve port binding intelligence and ACME challenge route management; update route configuration tests and dependency versions.
This commit is contained in:
@ -51,7 +51,7 @@ tap.test('should handle ACME challenges on port 8080 with improved port binding
|
||||
const tempCertDir = './temp-certs';
|
||||
|
||||
try {
|
||||
await plugins.smartfile.SmartFile.createDirectory(tempCertDir);
|
||||
await plugins.smartfile.fs.ensureDir(tempCertDir);
|
||||
} catch (error) {
|
||||
// Directory may already exist, that's ok
|
||||
}
|
||||
@ -156,8 +156,10 @@ tap.test('should handle ACME challenges on port 8080 with improved port binding
|
||||
console.log('Port binding attempts:', portBindAttempts);
|
||||
|
||||
// Check that we tried to bind to port 9009
|
||||
expect(portBindAttempts.includes(9009)).toEqual(true, 'Should attempt to bind to port 9009');
|
||||
expect(portBindAttempts.includes(9003)).toEqual(true, 'Should attempt to bind to port 9003');
|
||||
// Should attempt to bind to port 9009
|
||||
expect(portBindAttempts.includes(9009)).toEqual(true);
|
||||
// Should attempt to bind to port 9003
|
||||
expect(portBindAttempts.includes(9003)).toEqual(true);
|
||||
|
||||
// Get actual bound ports
|
||||
const boundPorts = proxy.getListeningPorts();
|
||||
@ -165,10 +167,12 @@ tap.test('should handle ACME challenges on port 8080 with improved port binding
|
||||
|
||||
// If port 9009 was available, we should be bound to it
|
||||
if (acmePortAvailable) {
|
||||
expect(boundPorts.includes(9009)).toEqual(true, 'Should be bound to port 9009 if available');
|
||||
// Should be bound to port 9009 if available
|
||||
expect(boundPorts.includes(9009)).toEqual(true);
|
||||
}
|
||||
|
||||
expect(boundPorts.includes(9003)).toEqual(true, 'Should be bound to port 9003');
|
||||
// Should be bound to port 9003
|
||||
expect(boundPorts.includes(9003)).toEqual(true);
|
||||
|
||||
// Test adding a new route on port 8080
|
||||
console.log('Testing route update with port reuse...');
|
||||
@ -186,7 +190,7 @@ tap.test('should handle ACME challenges on port 8080 with improved port binding
|
||||
path: '/additional'
|
||||
},
|
||||
action: {
|
||||
type: 'forward',
|
||||
type: 'forward' as const,
|
||||
target: { host: 'localhost', port: targetPort }
|
||||
}
|
||||
}
|
||||
@ -198,16 +202,19 @@ tap.test('should handle ACME challenges on port 8080 with improved port binding
|
||||
console.log('Port binding attempts after update:', portBindAttempts);
|
||||
|
||||
// We should not try to rebind port 9009 since it's already bound
|
||||
expect(portBindAttempts.includes(9009)).toEqual(false, 'Should not attempt to rebind port 9009');
|
||||
// Should not attempt to rebind port 9009
|
||||
expect(portBindAttempts.includes(9009)).toEqual(false);
|
||||
|
||||
// We should still be listening on both ports
|
||||
const portsAfterUpdate = proxy.getListeningPorts();
|
||||
console.log('Bound ports after update:', portsAfterUpdate);
|
||||
|
||||
if (acmePortAvailable) {
|
||||
expect(portsAfterUpdate.includes(9009)).toEqual(true, 'Should still be bound to port 9009');
|
||||
// Should still be bound to port 9009
|
||||
expect(portsAfterUpdate.includes(9009)).toEqual(true);
|
||||
}
|
||||
expect(portsAfterUpdate.includes(9003)).toEqual(true, 'Should still be bound to port 9003');
|
||||
// Should still be bound to port 9003
|
||||
expect(portsAfterUpdate.includes(9003)).toEqual(true);
|
||||
|
||||
// The test is successful at this point - we've verified the port binding intelligence
|
||||
console.log('Port binding intelligence verified successfully!');
|
||||
@ -227,16 +234,8 @@ tap.test('should handle ACME challenges on port 8080 with improved port binding
|
||||
|
||||
// Clean up temp directory
|
||||
try {
|
||||
// Try different removal methods
|
||||
if (typeof plugins.smartfile.fs.removeManySync === 'function') {
|
||||
plugins.smartfile.fs.removeManySync([tempCertDir]);
|
||||
} else if (typeof plugins.smartfile.fs.removeDirectory === 'function') {
|
||||
await plugins.smartfile.fs.removeDirectory(tempCertDir);
|
||||
} else if (typeof plugins.smartfile.removeDirectory === 'function') {
|
||||
await plugins.smartfile.removeDirectory(tempCertDir);
|
||||
} else {
|
||||
console.log('Unable to find appropriate directory removal method');
|
||||
}
|
||||
// Remove temp directory
|
||||
await plugins.smartfile.fs.remove(tempCertDir);
|
||||
} catch (error) {
|
||||
console.error('Failed to remove temp directory:', error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user