From: Jérôme Benoit Date: Tue, 24 Feb 2026 14:21:50 +0000 (+0100) Subject: test(ocpp2): add C11.FR.05 test for Authorization Cache not supported scenario X-Git-Tag: ocpp-server@v2.4.0~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9c226835acb33c92b6e58c0408b740eb398d3143;p=e-mobility-charging-stations-simulator.git test(ocpp2): add C11.FR.05 test for Authorization Cache not supported scenario --- diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts index 32c8d705..53953254 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts @@ -221,4 +221,26 @@ await describe('C11 - Clear Authorization Data in Authorization Cache', async () } }) }) + + // C11.FR.05: IF the CS does not support an Authorization Cache → Rejected + await describe('C11.FR.05 - No Authorization Cache Support', async () => { + await it('Should return Rejected when authService factory fails (no cache support)', async () => { + // Mock factory to throw error (simulates no Authorization Cache support) + const originalGetInstance = OCPPAuthServiceFactory.getInstance.bind(OCPPAuthServiceFactory) + ;(OCPPAuthServiceFactory as any).getInstance = (): Promise => + Promise.reject(new Error('Authorization Cache not supported')) + + try { + const response = await (incomingRequestService as any).handleRequestClearCache( + mockChargingStation + ) + + // Per C11.FR.05: SHALL return Rejected if CS does not support Authorization Cache + expect(response.status).toBe(GenericStatus.Rejected) + } finally { + // Restore original factory method + ;(OCPPAuthServiceFactory as any).getInstance = originalGetInstance + } + }) + }) })