fix(smartproxy): improve certificate manager mocking in tests, enhance IPv6 validation, and record initial bytes for connection metrics

This commit is contained in:
2026-01-30 19:52:36 +00:00
parent 1d1e5062a6
commit 2068b7a1ad
15 changed files with 230 additions and 119 deletions

View File

@@ -56,6 +56,7 @@ tap.test('should preserve route update callback after updateRoutes', async () =>
setHttpProxy: function() {},
setGlobalAcmeDefaults: function() {},
setAcmeStateManager: function() {},
setRoutes: function(routes: any) {},
initialize: async function() {
// This is where the callback is actually set in the real implementation
return Promise.resolve();
@@ -116,6 +117,7 @@ tap.test('should preserve route update callback after updateRoutes', async () =>
setHttpProxy: function() {},
setGlobalAcmeDefaults: function() {},
setAcmeStateManager: function() {},
setRoutes: function(routes: any) {},
initialize: async function() {},
provisionAllCertificates: async function() {},
stop: async function() {},
@@ -126,12 +128,12 @@ tap.test('should preserve route update callback after updateRoutes', async () =>
return { challengeRouteActive: false };
}
};
// Set the callback as done in createCertificateManager
newMockCertManager.setUpdateRoutesCallback(async (routes: any) => {
await this.updateRoutes(routes);
});
(this as any).certManager = newMockCertManager;
await (this as any).certManager.initialize();
}
@@ -236,6 +238,7 @@ tap.test('should handle route updates when cert manager is not initialized', asy
},
updateRoutesCallback: null,
setHttpProxy: function() {},
setRoutes: function(routes: any) {},
initialize: async function() {},
provisionAllCertificates: async function() {},
stop: async function() {},
@@ -246,9 +249,9 @@ tap.test('should handle route updates when cert manager is not initialized', asy
return { challengeRouteActive: false };
}
};
(this as any).certManager = mockCertManager;
// Set the callback
mockCertManager.setUpdateRoutesCallback(async (routes: any) => {
await this.updateRoutes(routes);
@@ -299,6 +302,7 @@ tap.test('real code integration test - verify fix is applied', async () => {
setHttpProxy: function() {},
setGlobalAcmeDefaults: function() {},
setAcmeStateManager: function() {},
setRoutes: function(routes: any) {},
initialize: async function() {},
provisionAllCertificates: async function() {},
stop: async function() {},
@@ -309,7 +313,7 @@ tap.test('real code integration test - verify fix is applied', async () => {
return initialState || { challengeRouteActive: false };
}
};
// Always set up the route update callback for ACME challenges
mockCertManager.setUpdateRoutesCallback(async (routes) => {
await this.updateRoutes(routes);