From 9c226835acb33c92b6e58c0408b740eb398d3143 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 24 Feb 2026 15:21:50 +0100 Subject: [PATCH] test(ocpp2): add C11.FR.05 test for Authorization Cache not supported scenario --- ...0IncomingRequestService-ClearCache.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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 + } + }) + }) }) -- 2.53.0