This commit is contained in:
2025-05-29 11:30:42 +00:00
parent f1c012ec30
commit b0beeae19e
18 changed files with 420 additions and 426 deletions

View File

@ -21,7 +21,7 @@ tap.test('should defer certificate provisioning until after ports are listening'
useHttpProxy: [acmePort],
httpProxyPort: 8844,
acme: {
email: 'test@example.com',
email: 'test@test.local',
useProduction: false,
port: acmePort
},
@ -38,7 +38,7 @@ tap.test('should defer certificate provisioning until after ports are listening'
mode: 'terminate',
certificate: 'auto',
acme: {
email: 'test@example.com',
email: 'test@test.local',
useProduction: false
}
}
@ -72,6 +72,29 @@ tap.test('should defer certificate provisioning until after ports are listening'
};
}
// Mock certificate manager to avoid real ACME initialization
(proxy as any).createCertificateManager = async function() {
operationLog.push('Creating certificate manager');
const mockCertManager = {
setUpdateRoutesCallback: () => {},
setHttpProxy: () => {},
setGlobalAcmeDefaults: () => {},
setAcmeStateManager: () => {},
initialize: async () => {
operationLog.push('Starting certificate provisioning');
if (!port80Listening) {
operationLog.push('ERROR: Certificate provisioning started before ports ready');
}
operationLog.push('Certificate provisioning completed');
},
provisionAllCertificates: async () => {},
stop: async () => {},
getAcmeOptions: () => ({ email: 'test@test.local', useProduction: false }),
getState: () => ({ challengeRouteActive: false })
};
return mockCertManager;
};
// Start the proxy
await proxy.start();
@ -99,7 +122,7 @@ tap.test('should have ACME challenge route ready before certificate provisioning
useHttpProxy: [8080],
httpProxyPort: 8844,
acme: {
email: 'test@example.com',
email: 'test@test.local',
useProduction: false,
port: 8080
},
@ -145,6 +168,34 @@ tap.test('should have ACME challenge route ready before certificate provisioning
};
}
// Mock certificate manager to avoid real ACME initialization
(proxy as any).createCertificateManager = async function() {
const mockCertManager = {
setUpdateRoutesCallback: () => {},
setHttpProxy: () => {},
setGlobalAcmeDefaults: () => {},
setAcmeStateManager: () => {},
initialize: async () => {
challengeRouteActive = true;
},
provisionAllCertificates: async () => {
certificateProvisioningStarted = true;
expect(challengeRouteActive).toEqual(true);
},
stop: async () => {},
getAcmeOptions: () => ({ email: 'test@test.local', useProduction: false }),
getState: () => ({ challengeRouteActive: false }),
addChallengeRoute: async () => {
challengeRouteActive = true;
},
provisionAcmeCertificate: async () => {
certificateProvisioningStarted = true;
expect(challengeRouteActive).toEqual(true);
}
};
return mockCertManager;
};
await proxy.start();
// Give it a moment to complete initialization