]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(ocpp): align OCPP 2.x auth adapter version to VERSION_201
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 2 Apr 2026 00:27:55 +0000 (02:27 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 2 Apr 2026 00:27:55 +0000 (02:27 +0200)
OCPP20AuthAdapter was the only 2.x component identifying as
VERSION_20 while all services use VERSION_201. Align adapter
and CertificateAuthStrategy to match the established convention.

src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts
src/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.ts
tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts
tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts
tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts

index 2e4df2d81a77c3877a8a8764c1636320337c003c..f4b46c22adfa2fd3314dfaa7734df671be64736c 100644 (file)
@@ -45,7 +45,7 @@ const moduleName = 'OCPP20AuthAdapter'
  * between auth types and OCPP 2.0 specific types and protocols.
  */
 export class OCPP20AuthAdapter implements OCPPAuthAdapter<OCPP20IdTokenType> {
-  readonly ocppVersion = OCPPVersion.VERSION_20
+  readonly ocppVersion = OCPPVersion.VERSION_201
 
   constructor (private readonly chargingStation: ChargingStation) {}
 
@@ -287,7 +287,7 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter<OCPP20IdTokenType> {
       context: authContext,
       identifier,
       metadata: {
-        ocppVersion: OCPPVersion.VERSION_20,
+        ocppVersion: OCPPVersion.VERSION_201,
         stationId: this.chargingStation.stationInfo?.chargingStationId,
       },
       timestamp: new Date(),
index 7452a93fda5002207e98ae63e39823ffff049ec0..9dad5686049f61195316d89724b78df928d28beb 100644 (file)
@@ -77,7 +77,7 @@ export class CertificateAuthStrategy implements AuthStrategy {
       const adapter = this.adapter
 
       // For OCPP 2.0, we can use certificate-based validation
-      if (this.adapter.ocppVersion === OCPPVersion.VERSION_20) {
+      if (this.adapter.ocppVersion === OCPPVersion.VERSION_201) {
         const result = await this.validateCertificateWithOCPP20(request, adapter, config)
         this.updateStatistics(result, startTime)
         return result
index e42ae6624bd5f6f388974b9800c8c7a10277a802..6d4de7d312d3b20f8aebdafa3f6101946554ff36 100644 (file)
@@ -46,7 +46,7 @@ await describe('OCPP20AuthAdapter', async () => {
 
   await describe('constructor', async () => {
     await it('should initialize with correct OCPP version', () => {
-      assert.strictEqual(adapter.ocppVersion, OCPPVersion.VERSION_20)
+      assert.strictEqual(adapter.ocppVersion, OCPPVersion.VERSION_201)
     })
   })
 
@@ -183,7 +183,7 @@ await describe('OCPP20AuthAdapter', async () => {
       assert.strictEqual(request.connectorId, 1)
       assert.strictEqual(request.transactionId, 'trans_123')
       assert.strictEqual(request.context, AuthContext.TRANSACTION_START)
-      assert.strictEqual(request.metadata?.ocppVersion, OCPPVersion.VERSION_20)
+      assert.strictEqual(request.metadata?.ocppVersion, OCPPVersion.VERSION_201)
     })
 
     await it('should map OCPP 2.0 contexts correctly', () => {
@@ -316,7 +316,7 @@ await describe('OCPP20AuthAdapter', async () => {
     await it('should return adapter status information', () => {
       const status = adapter.getStatus()
 
-      assert.strictEqual(status.ocppVersion, OCPPVersion.VERSION_20)
+      assert.strictEqual(status.ocppVersion, OCPPVersion.VERSION_201)
       assert.strictEqual(status.isOnline, true)
       assert.strictEqual(status.stationId, 'TEST-002')
       assert.notStrictEqual(status.supportsIdTokenTypes, undefined)
@@ -412,7 +412,7 @@ await describe('OCPP20AuthAdapter', async () => {
 
       await it('should have correct OCPP version for offline tests', () => {
         // Verify we're testing the correct OCPP version
-        assert.strictEqual(offlineAdapter.ocppVersion, OCPPVersion.VERSION_20)
+        assert.strictEqual(offlineAdapter.ocppVersion, OCPPVersion.VERSION_201)
       })
     })
 
@@ -446,7 +446,7 @@ await describe('OCPP20AuthAdapter', async () => {
       await it('should initialize with default configuration for offline scenarios', () => {
         // When: Adapter is created
         // Then: Should have OCPP 2.0 version
-        assert.strictEqual(offlineAdapter.ocppVersion, OCPPVersion.VERSION_20)
+        assert.strictEqual(offlineAdapter.ocppVersion, OCPPVersion.VERSION_201)
       })
 
       await it('should validate configuration schema for offline auth', () => {
@@ -467,7 +467,7 @@ await describe('OCPP20AuthAdapter', async () => {
         // Then: Status should be defined and include online state
         assert.notStrictEqual(status, undefined)
         assert.strictEqual(typeof status.isOnline, 'boolean')
-        assert.strictEqual(status.ocppVersion, OCPPVersion.VERSION_20)
+        assert.strictEqual(status.ocppVersion, OCPPVersion.VERSION_201)
       })
     })
   })
index 07b1a7d59e64f07687c53cd81e60823477ec7d1c..9f339effb8d3c6d877418743272276f53ac34cfc 100644 (file)
@@ -37,7 +37,7 @@ await describe('AuthComponentFactory', async () => {
       const adapter = AuthComponentFactory.createAdapter(chargingStation)
 
       assert.notStrictEqual(adapter, undefined)
-      assert.strictEqual(adapter.ocppVersion, OCPPVersion.VERSION_20)
+      assert.strictEqual(adapter.ocppVersion, OCPPVersion.VERSION_201)
     })
 
     await it('should create OCPP 2.0.1 adapter', () => {
@@ -47,7 +47,7 @@ await describe('AuthComponentFactory', async () => {
       const adapter = AuthComponentFactory.createAdapter(chargingStation)
 
       assert.notStrictEqual(adapter, undefined)
-      assert.strictEqual(adapter.ocppVersion, OCPPVersion.VERSION_20)
+      assert.strictEqual(adapter.ocppVersion, OCPPVersion.VERSION_201)
     })
 
     await it('should throw error for unsupported version', () => {
index 19d9a79a72fa561bd4c74957c00c2a5c5667c1b5..31597349eefd8813f54aec4ef4a2d4da989ec392 100644 (file)
@@ -34,11 +34,11 @@ await describe('CertificateAuthStrategy', async () => {
       logPrefix: () => '[TEST-CS-001]',
       stationInfo: {
         chargingStationId: 'TEST-CS-001',
-        ocppVersion: OCPPVersion.VERSION_20,
+        ocppVersion: OCPPVersion.VERSION_201,
       },
     } as unknown as ChargingStation
 
-    mockOCPP20Adapter = createMockOCPPAdapter(OCPPVersion.VERSION_20, {
+    mockOCPP20Adapter = createMockOCPPAdapter(OCPPVersion.VERSION_201, {
       authorizeRemote: () =>
         new Promise<AuthorizationResult>(resolve => {
           resolve(