BREAKING CHANGE(smartproxy): Update documentation and refactor core proxy components; remove legacy performRenewals method from SmartProxy; update router type imports and adjust test suites for improved coverage
This commit is contained in:
		| @@ -1,45 +0,0 @@ | ||||
| import { tap, expect } from '@push.rocks/tapbundle'; | ||||
| import { SmartProxy } from '../ts/smartproxy/classes.smartproxy.js'; | ||||
|  | ||||
| tap.test('performRenewals only renews domains below threshold', async () => { | ||||
|   // Set up SmartProxy instance without real servers | ||||
|   const proxy = new SmartProxy({ | ||||
|     fromPort: 0, | ||||
|     toPort: 0, | ||||
|     domainConfigs: [], | ||||
|     sniEnabled: false, | ||||
|     defaultAllowedIPs: [], | ||||
|     globalPortRanges: [] | ||||
|   }); | ||||
|   // Stub port80Handler status and renewal | ||||
|   const statuses = new Map<string, any>(); | ||||
|   const now = new Date(); | ||||
|   statuses.set('expiring.com', { | ||||
|     certObtained: true, | ||||
|     expiryDate: new Date(now.getTime() + 2 * 24 * 60 * 60 * 1000), | ||||
|     obtainingInProgress: false | ||||
|   }); | ||||
|   statuses.set('ok.com', { | ||||
|     certObtained: true, | ||||
|     expiryDate: new Date(now.getTime() + 100 * 24 * 60 * 60 * 1000), | ||||
|     obtainingInProgress: false | ||||
|   }); | ||||
|   const renewed: string[] = []; | ||||
|   // Inject fake handler | ||||
|   (proxy as any).port80Handler = { | ||||
|     getDomainCertificateStatus: () => statuses, | ||||
|     renewCertificate: async (domain: string) => { renewed.push(domain); } | ||||
|   }; | ||||
|   // Configure threshold | ||||
|   proxy.settings.port80HandlerConfig.enabled = true; | ||||
|   proxy.settings.port80HandlerConfig.autoRenew = true; | ||||
|   proxy.settings.port80HandlerConfig.renewThresholdDays = 10; | ||||
|  | ||||
|   // Execute renewals | ||||
|   await (proxy as any).performRenewals(); | ||||
|  | ||||
|   // Only the expiring.com domain should be renewed | ||||
|   expect(renewed).toEqual(['expiring.com']); | ||||
| }); | ||||
|  | ||||
| export default tap.start(); | ||||
		Reference in New Issue
	
	Block a user