]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test: fix tests
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 12 Nov 2025 13:57:19 +0000 (14:57 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 12 Nov 2025 13:57:19 +0000 (14:57 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/ChargingStationFactory.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts

index 93490b3eea941b097f1b5953ca27d26cbf216331..accdc49fc6b045c19d286cd7af29ade6e08b52bc 100644 (file)
@@ -2,6 +2,7 @@ import { millisecondsToSeconds } from 'date-fns'
 
 import type { ChargingStation } from '../src/charging-station/index.js'
 
+import { getConfigurationKey } from '../src/charging-station/ConfigurationKeyUtils.js'
 import { IdTagsCache } from '../src/charging-station/IdTagsCache.js'
 import {
   AvailabilityType,
@@ -15,8 +16,9 @@ import {
   OCPPVersion,
   RegistrationStatusEnumType,
   type SampledValueTemplate,
+  StandardParametersKey,
 } from '../src/types/index.js'
-import { clone, Constants } from '../src/utils/index.js'
+import { clone, Constants, convertToBoolean } from '../src/utils/index.js'
 
 /**
  * Options to customize the construction of a ChargingStation test instance
@@ -139,6 +141,13 @@ export function createChargingStation (options: ChargingStationOptions = {}): Ch
       return undefined
     },
     getHeartbeatInterval: () => heartbeatInterval,
+    getLocalAuthListEnabled: (): boolean => {
+      const localAuthListEnabled = getConfigurationKey(
+        chargingStation,
+        StandardParametersKey.LocalAuthListEnabled
+      )
+      return localAuthListEnabled != null ? convertToBoolean(localAuthListEnabled.value) : false
+    },
     getWebSocketPingInterval: () => websocketPingInterval,
     hasEvses: useEvses,
     idTagsCache: IdTagsCache.getInstance(),
@@ -169,6 +178,10 @@ export function createChargingStation (options: ChargingStationOptions = {}): Ch
           key: OCPP20OptionalVariableName.HeartbeatInterval,
           value: millisecondsToSeconds(heartbeatInterval).toString(),
         },
+        {
+          key: StandardParametersKey.LocalAuthListEnabled,
+          value: 'true',
+        },
       ],
       ...options.ocppConfiguration,
     },
@@ -227,6 +240,7 @@ export function createChargingStation (options: ChargingStationOptions = {}): Ch
       maximumAmperage: 16,
       maximumPower: 12000,
       ocppVersion: OCPPVersion.VERSION_16,
+      remoteAuthorization: true,
       templateIndex,
       templateName: 'test-template.json',
       ...options.stationInfo,
index 17e34a759344013442622d1d99909edb775aa3f6..27dd75a2dec335ee90fae4ccd40c59d2a27a1e36 100644 (file)
@@ -51,7 +51,7 @@ await describe('E01 - Remote Start Transaction', async () => {
       remoteStartId: 1,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStartTransaction(
+    const response = await (incomingRequestService as any).handleRequestStartTransaction(
       mockChargingStation,
       validRequest
     )
@@ -72,7 +72,7 @@ await describe('E01 - Remote Start Transaction', async () => {
       remoteStartId: 42,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStartTransaction(
+    const response = await (incomingRequestService as any).handleRequestStartTransaction(
       mockChargingStation,
       requestWithRemoteStartId
     )
@@ -96,7 +96,7 @@ await describe('E01 - Remote Start Transaction', async () => {
       remoteStartId: 3,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStartTransaction(
+    const response = await (incomingRequestService as any).handleRequestStartTransaction(
       mockChargingStation,
       requestWithGroupToken
     )
@@ -120,7 +120,7 @@ await describe('E01 - Remote Start Transaction', async () => {
 
     // Should throw OCPPError for invalid evseId
     await expect(
-      (incomingRequestService as any).handleRequestRequestStartTransaction(
+      (incomingRequestService as any).handleRequestStartTransaction(
         mockChargingStation,
         invalidEvseRequest
       )
@@ -138,7 +138,7 @@ await describe('E01 - Remote Start Transaction', async () => {
       remoteStartId: 100,
     }
 
-    await (incomingRequestService as any).handleRequestRequestStartTransaction(
+    await (incomingRequestService as any).handleRequestStartTransaction(
       mockChargingStation,
       firstRequest
     )
@@ -153,7 +153,7 @@ await describe('E01 - Remote Start Transaction', async () => {
       remoteStartId: 101,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStartTransaction(
+    const response = await (incomingRequestService as any).handleRequestStartTransaction(
       mockChargingStation,
       secondRequest
     )
@@ -173,7 +173,7 @@ await describe('E01 - Remote Start Transaction', async () => {
       remoteStartId: 200,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStartTransaction(
+    const response = await (incomingRequestService as any).handleRequestStartTransaction(
       mockChargingStation,
       validRequest
     )
index dcf17b503540c8a74f8aff6cd35f20b035cc44a3..51deb6760e8f56dface21690f0fbb302d2e9874e 100644 (file)
@@ -111,9 +111,10 @@ await describe('E02 - Remote Stop Transaction', async () => {
       remoteStartId,
     }
 
-    const startResponse = await (
-      incomingRequestService as any
-    ).handleRequestRequestStartTransaction(mockChargingStation, startRequest)
+    const startResponse = await (incomingRequestService as any).handleRequestStartTransaction(
+      mockChargingStation,
+      startRequest
+    )
 
     expect(startResponse.status).toBe(RequestStartStopStatusEnumType.Accepted)
     expect(startResponse.transactionId).toBeDefined()
@@ -133,7 +134,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
     }
 
     // Execute stop transaction
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequest
     )
@@ -170,7 +171,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: transactionId2 as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequest
     )
@@ -201,7 +202,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
         nonExistentTransactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequest
     )
@@ -222,7 +223,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: '' as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       invalidRequest
     )
@@ -245,7 +246,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: tooLongTransactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       invalidRequest
     )
@@ -286,7 +287,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: testTransactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequest
     )
@@ -335,9 +336,10 @@ await describe('E02 - Remote Stop Transaction', async () => {
       remoteStartId: 999,
     }
 
-    const startResponse = await (
-      incomingRequestService as any
-    ).handleRequestRequestStartTransaction(failingChargingStation, startRequest)
+    const startResponse = await (incomingRequestService as any).handleRequestStartTransaction(
+      failingChargingStation,
+      startRequest
+    )
 
     const transactionId = startResponse.transactionId as string
 
@@ -346,7 +348,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: transactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       failingChargingStation,
       stopRequest
     )
@@ -367,7 +369,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: transactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequest
     )
@@ -399,7 +401,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: transactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequestWithCustomData
     )
@@ -423,7 +425,7 @@ await describe('E02 - Remote Stop Transaction', async () => {
       transactionId: transactionId as `${string}-${string}-${string}-${string}-${string}`,
     }
 
-    const response = await (incomingRequestService as any).handleRequestRequestStopTransaction(
+    const response = await (incomingRequestService as any).handleRequestStopTransaction(
       mockChargingStation,
       stopRequest
     )