]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test(ocpp2): add C11.FR.05 test for Authorization Cache not supported scenario
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 24 Feb 2026 14:21:50 +0000 (15:21 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 24 Feb 2026 14:29:57 +0000 (15:29 +0100)
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts

index 32c8d70561a600a054720696f10c44340c6ca397..539532544d795da3fbab38adc2c5f9def8a7fd84 100644 (file)
@@ -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<never> =>
+        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
+      }
+    })
+  })
 })