From f369b3ad1613a219f599689d48e3cd43d705f52a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 21 Mar 2026 19:29:50 +0100 Subject: [PATCH] refactor(auth): remove ocppVersion from UnifiedIdentifier Version info is now sourced from adapter.ocppVersion since each station has a single adapter. Eliminates redundant version stamping on every identifier. - Remove ocppVersion field from UnifiedIdentifier interface - CertificateAuthStrategy uses this.adapter.ocppVersion - Adapters no longer stamp version on created identifiers - Fix CertificateAuthStrategy OCPP 1.6 test to use 1.6 adapter instead of relying on missing certificateHashData --- src/charging-station/ocpp/OCPPServiceUtils.ts | 1 - .../ocpp/auth/adapters/OCPP16AuthAdapter.ts | 3 +- .../ocpp/auth/adapters/OCPP20AuthAdapter.ts | 3 +- .../ocpp/auth/services/OCPPAuthServiceImpl.ts | 16 ++-- .../strategies/CertificateAuthStrategy.ts | 6 +- .../ocpp/auth/types/AuthTypes.ts | 3 - .../ocpp/auth/OCPPAuthIntegration.test.ts | 15 ++-- .../auth/adapters/OCPP16AuthAdapter.test.ts | 24 ++---- .../auth/adapters/OCPP20AuthAdapter.test.ts | 39 +++------ .../ocpp/auth/helpers/MockFactories.ts | 6 +- .../auth/services/OCPPAuthServiceImpl.test.ts | 12 --- .../CertificateAuthStrategy.test.ts | 25 +++--- ...lAuthStrategy-DisablePostAuthorize.test.ts | 25 +----- .../auth/strategies/LocalAuthStrategy.test.ts | 31 ++----- .../strategies/RemoteAuthStrategy.test.ts | 83 ++++--------------- .../ocpp/auth/types/AuthTypes.test.ts | 5 -- .../ocpp/auth/utils/AuthHelpers.test.ts | 6 -- .../ocpp/auth/utils/AuthValidators.test.ts | 13 --- tests/helpers/OCPPAuthIntegrationTest.ts | 16 ---- 19 files changed, 74 insertions(+), 258 deletions(-) diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index e96a7166..6c4a881d 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -191,7 +191,6 @@ export const isIdTagAuthorizedUnified = async ( connectorId, context: AuthContext.TRANSACTION_START, identifier: { - ocppVersion: stationOcppVersion, type: IdentifierType.ID_TAG, value: idTag, }, diff --git a/src/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.ts b/src/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.ts index 678640b7..b2983c0a 100644 --- a/src/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.ts +++ b/src/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.ts @@ -144,7 +144,7 @@ export class OCPP16AuthAdapter implements OCPPAuthAdapter { * Convert OCPP 1.6 idTag to unified identifier * @param identifier - OCPP 1.6 idTag string to convert * @param additionalData - Optional metadata to include in unified identifier - * @returns Unified identifier with ID_TAG type and OCPP 1.6 version + * @returns Unified identifier with ID_TAG type */ convertToUnifiedIdentifier ( identifier: string, @@ -154,7 +154,6 @@ export class OCPP16AuthAdapter implements OCPPAuthAdapter { additionalInfo: additionalData ? Object.fromEntries(Object.entries(additionalData).map(([k, v]) => [k, String(v)])) : undefined, - ocppVersion: OCPPVersion.VERSION_16, parentId: additionalData?.parentId as string | undefined, type: IdentifierType.ID_TAG, value: identifier, diff --git a/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts b/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts index fa980921..21ed9af8 100644 --- a/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts +++ b/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts @@ -219,7 +219,7 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter { * Convert OCPP 2.0 IdToken to unified identifier * @param identifier - OCPP 2.0 IdToken or raw string identifier * @param additionalData - Optional metadata to include in the unified identifier - * @returns Unified identifier with normalized type and OCPP version metadata + * @returns Unified identifier with normalized type and metadata */ convertToUnifiedIdentifier ( identifier: OCPP20IdTokenType | string, @@ -256,7 +256,6 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter { ? Object.fromEntries(Object.entries(additionalData).map(([k, v]) => [k, String(v)])) : {}), }, - ocppVersion: OCPPVersion.VERSION_20, parentId: additionalData?.parentId as string | undefined, type: unifiedType, value: idToken.idToken, diff --git a/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts b/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts index f15ed43e..37286c0f 100644 --- a/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts +++ b/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts @@ -308,17 +308,13 @@ export class OCPPAuthServiceImpl implements OCPPAuthService { const supportedTypes = new Set() // Test common identifier types - const ocppVersion = - this.chargingStation.stationInfo?.ocppVersion === OCPPVersion.VERSION_16 - ? OCPPVersion.VERSION_16 - : OCPPVersion.VERSION_20 const testIdentifiers: UnifiedIdentifier[] = [ - { ocppVersion, type: IdentifierType.ISO14443, value: 'test' }, - { ocppVersion, type: IdentifierType.ISO15693, value: 'test' }, - { ocppVersion, type: IdentifierType.KEY_CODE, value: 'test' }, - { ocppVersion, type: IdentifierType.LOCAL, value: 'test' }, - { ocppVersion, type: IdentifierType.MAC_ADDRESS, value: 'test' }, - { ocppVersion, type: IdentifierType.NO_AUTHORIZATION, value: 'test' }, + { type: IdentifierType.ISO14443, value: 'test' }, + { type: IdentifierType.ISO15693, value: 'test' }, + { type: IdentifierType.KEY_CODE, value: 'test' }, + { type: IdentifierType.LOCAL, value: 'test' }, + { type: IdentifierType.MAC_ADDRESS, value: 'test' }, + { type: IdentifierType.NO_AUTHORIZATION, value: 'test' }, ] testIdentifiers.forEach(identifier => { diff --git a/src/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.ts b/src/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.ts index 0059f9f4..6d42dfef 100644 --- a/src/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.ts +++ b/src/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.ts @@ -76,7 +76,7 @@ export class CertificateAuthStrategy implements AuthStrategy { const adapter = this.adapter // For OCPP 2.0, we can use certificate-based validation - if (request.identifier.ocppVersion === OCPPVersion.VERSION_20) { + if (this.adapter.ocppVersion === OCPPVersion.VERSION_20) { const result = await this.validateCertificateWithOCPP20(request, adapter, config) this.updateStatistics(result, startTime) return result @@ -85,7 +85,7 @@ export class CertificateAuthStrategy implements AuthStrategy { // Should not reach here due to canHandle check, but handle gracefully return this.createFailureResult( AuthorizationStatus.INVALID, - `Certificate authentication not supported for OCPP ${request.identifier.ocppVersion}`, + `Certificate authentication not supported for OCPP ${this.adapter.ocppVersion}`, request.identifier, startTime ) @@ -113,7 +113,7 @@ export class CertificateAuthStrategy implements AuthStrategy { } // Only supported in OCPP 2.0+ - if (request.identifier.ocppVersion === OCPPVersion.VERSION_16) { + if (this.adapter.ocppVersion === OCPPVersion.VERSION_16) { return false } diff --git a/src/charging-station/ocpp/auth/types/AuthTypes.ts b/src/charging-station/ocpp/auth/types/AuthTypes.ts index 4d33bb40..414fc093 100644 --- a/src/charging-station/ocpp/auth/types/AuthTypes.ts +++ b/src/charging-station/ocpp/auth/types/AuthTypes.ts @@ -257,9 +257,6 @@ export interface UnifiedIdentifier { /** Group identifier for group-based authorization (OCPP 2.0) */ readonly groupId?: string - /** OCPP version this identifier originated from */ - readonly ocppVersion: OCPPVersion - /** Parent ID for hierarchical authorization (OCPP 1.6) */ readonly parentId?: string diff --git a/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts b/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts index 4c3ed7d6..4816502f 100644 --- a/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts +++ b/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts @@ -74,7 +74,7 @@ await describe('OCPP Authentication', async () => { const request = createMockAuthRequest({ connectorId: 1, context: AuthContext.TRANSACTION_START, - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'VALID_ID_123'), + identifier: createMockIdentifier('VALID_ID_123'), }) const result = await authService16.authenticate(request) @@ -98,7 +98,7 @@ await describe('OCPP Authentication', async () => { const request = createMockAuthRequest({ connectorId: 1, context, - identifier: createMockIdentifier(OCPPVersion.VERSION_16, `CONTEXT_TEST_${context}`), + identifier: createMockIdentifier(`CONTEXT_TEST_${context}`), }) const result = await authService16.authenticate(request) @@ -110,7 +110,7 @@ await describe('OCPP Authentication', async () => { await it('should authorize request directly', async () => { const request = createMockAuthRequest({ connectorId: 1, - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'AUTH_DIRECT_TEST'), + identifier: createMockIdentifier('AUTH_DIRECT_TEST'), }) const result = await authService16.authorize(request) @@ -130,7 +130,7 @@ await describe('OCPP Authentication', async () => { const request = createMockAuthRequest({ connectorId: 2, context: AuthContext.TRANSACTION_START, - identifier: createMockIdentifier(OCPPVersion.VERSION_20, 'VALID_ID_456'), + identifier: createMockIdentifier('VALID_ID_456'), }) const result = await authService20.authenticate(request) @@ -153,7 +153,7 @@ await describe('OCPP Authentication', async () => { const request = createMockAuthRequest({ connectorId: 2, context, - identifier: createMockIdentifier(OCPPVersion.VERSION_20, `V20_CONTEXT_${context}`), + identifier: createMockIdentifier(`V20_CONTEXT_${context}`), }) const result = await authService20.authenticate(request) @@ -175,7 +175,6 @@ await describe('OCPP Authentication', async () => { connectorId: 999, // Invalid connector context: AuthContext.TRANSACTION_START, identifier: { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ISO14443, value: '', // Invalid empty value }, @@ -204,7 +203,7 @@ await describe('OCPP Authentication', async () => { const request = createMockAuthRequest({ connectorId: 1, context: i % 2 === 0 ? AuthContext.TRANSACTION_START : AuthContext.TRANSACTION_STOP, - identifier: createMockIdentifier(OCPPVersion.VERSION_16, `CONCURRENT_${String(i)}`), + identifier: createMockIdentifier(`CONCURRENT_${String(i)}`), }) promises.push(authServiceConcurrent.authenticate(request)) } @@ -356,7 +355,7 @@ await describe('OCPP Authentication', async () => { strategy.initialize(config) const request = createMockAuthRequest({ - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'LIST-ID'), + identifier: createMockIdentifier('LIST-ID'), }) const result = await strategy.authenticate(request, config) diff --git a/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts b/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts index b7f22f2a..52a3fcbb 100644 --- a/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts +++ b/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts @@ -69,10 +69,9 @@ await describe('OCPP16AuthAdapter', async () => { const idTag = 'TEST_ID_TAG' const result = adapter.convertToUnifiedIdentifier(idTag) - const expected = createMockIdentifier(OCPPVersion.VERSION_16, idTag) + const expected = createMockIdentifier(idTag) assert.strictEqual(result.value, expected.value) assert.strictEqual(result.type, expected.type) - assert.strictEqual(result.ocppVersion, expected.ocppVersion) }) await it('should include additional data in unified identifier', () => { @@ -88,7 +87,7 @@ await describe('OCPP16AuthAdapter', async () => { await describe('convertFromUnifiedIdentifier', async () => { await it('should convert unified identifier to OCPP 1.6 idTag', () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_16, 'TEST_ID_TAG') + const identifier = createMockIdentifier('TEST_ID_TAG') const result = adapter.convertFromUnifiedIdentifier(identifier) assert.strictEqual(result, 'TEST_ID_TAG') @@ -97,32 +96,25 @@ await describe('OCPP16AuthAdapter', async () => { await describe('isValidIdentifier', async () => { await it('should validate correct OCPP 1.6 identifier', () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_16, 'VALID_TAG') + const identifier = createMockIdentifier('VALID_TAG') assert.strictEqual(adapter.isValidIdentifier(identifier), true) }) await it('should reject identifier with empty value', () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_16, '') + const identifier = createMockIdentifier('') assert.strictEqual(adapter.isValidIdentifier(identifier), false) }) await it('should reject identifier exceeding max length (20 chars)', () => { - const identifier = createMockIdentifier( - OCPPVersion.VERSION_16, - 'THIS_TAG_IS_TOO_LONG_FOR_OCPP16' - ) + const identifier = createMockIdentifier('THIS_TAG_IS_TOO_LONG_FOR_OCPP16') assert.strictEqual(adapter.isValidIdentifier(identifier), false) }) await it('should reject non-ID_TAG types', () => { - const identifier = createMockIdentifier( - OCPPVersion.VERSION_16, - 'TEST_TAG', - IdentifierType.CENTRAL - ) + const identifier = createMockIdentifier('TEST_TAG', IdentifierType.CENTRAL) assert.strictEqual(adapter.isValidIdentifier(identifier), false) }) @@ -157,7 +149,7 @@ await describe('OCPP16AuthAdapter', async () => { await describe('authorizeRemote', async () => { await it('should perform remote authorization successfully', async () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_16, 'VALID_TAG') + const identifier = createMockIdentifier('VALID_TAG') const result = await adapter.authorizeRemote(identifier, 1, 123) @@ -174,7 +166,7 @@ await describe('OCPP16AuthAdapter', async () => { reject(new Error('Network error')) }) - const identifier = createMockIdentifier(OCPPVersion.VERSION_16, 'TEST_TAG') + const identifier = createMockIdentifier('TEST_TAG') const result = await adapter.authorizeRemote(identifier, 1) diff --git a/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts b/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts index 80d7345e..594711fe 100644 --- a/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts +++ b/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts @@ -58,21 +58,19 @@ await describe('OCPP20AuthAdapter', async () => { } const result = adapter.convertToUnifiedIdentifier(idToken) - const expected = createMockIdentifier(OCPPVersion.VERSION_20, 'TEST_TOKEN') + const expected = createMockIdentifier('TEST_TOKEN') assert.strictEqual(result.value, expected.value) assert.strictEqual(result.type, IdentifierType.ID_TAG) - assert.strictEqual(result.ocppVersion, expected.ocppVersion) assert.strictEqual(result.additionalInfo?.ocpp20Type, OCPP20IdTokenEnumType.Central) }) await it('should convert string to unified identifier', () => { const result = adapter.convertToUnifiedIdentifier('STRING_TOKEN') - const expected = createMockIdentifier(OCPPVersion.VERSION_20, 'STRING_TOKEN') + const expected = createMockIdentifier('STRING_TOKEN') assert.strictEqual(result.value, expected.value) assert.strictEqual(result.type, expected.type) - assert.strictEqual(result.ocppVersion, expected.ocppVersion) }) await it('should handle eMAID type correctly', () => { @@ -107,11 +105,7 @@ await describe('OCPP20AuthAdapter', async () => { await describe('convertFromUnifiedIdentifier', async () => { await it('should convert unified identifier to OCPP 2.0 IdToken', () => { - const identifier = createMockIdentifier( - OCPPVersion.VERSION_20, - 'CENTRAL_TOKEN', - IdentifierType.CENTRAL - ) + const identifier = createMockIdentifier('CENTRAL_TOKEN', IdentifierType.CENTRAL) const result = adapter.convertFromUnifiedIdentifier(identifier) @@ -120,11 +114,7 @@ await describe('OCPP20AuthAdapter', async () => { }) await it('should map E_MAID type correctly', () => { - const identifier = createMockIdentifier( - OCPPVersion.VERSION_20, - 'EMAID_TOKEN', - IdentifierType.E_MAID - ) + const identifier = createMockIdentifier('EMAID_TOKEN', IdentifierType.E_MAID) const result = adapter.convertFromUnifiedIdentifier(identifier) @@ -133,7 +123,7 @@ await describe('OCPP20AuthAdapter', async () => { }) await it('should handle ID_TAG to Local mapping', () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_20, 'LOCAL_TAG') + const identifier = createMockIdentifier('LOCAL_TAG') const result = adapter.convertFromUnifiedIdentifier(identifier) @@ -143,24 +133,19 @@ await describe('OCPP20AuthAdapter', async () => { await describe('isValidIdentifier', async () => { await it('should validate correct OCPP 2.0 identifier', () => { - const identifier = createMockIdentifier( - OCPPVersion.VERSION_20, - 'VALID_TOKEN', - IdentifierType.CENTRAL - ) + const identifier = createMockIdentifier('VALID_TOKEN', IdentifierType.CENTRAL) assert.strictEqual(adapter.isValidIdentifier(identifier), true) }) await it('should reject identifier with empty value', () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_20, '', IdentifierType.CENTRAL) + const identifier = createMockIdentifier('', IdentifierType.CENTRAL) assert.strictEqual(adapter.isValidIdentifier(identifier), false) }) await it('should reject identifier exceeding max length (36 chars)', () => { const identifier = createMockIdentifier( - OCPPVersion.VERSION_20, 'THIS_TOKEN_IS_DEFINITELY_TOO_LONG_FOR_OCPP20_SPECIFICATION', IdentifierType.CENTRAL ) @@ -180,7 +165,7 @@ await describe('OCPP20AuthAdapter', async () => { ] for (const type of validTypes) { - const identifier = createMockIdentifier(OCPPVersion.VERSION_20, 'VALID_TOKEN', type) + const identifier = createMockIdentifier('VALID_TOKEN', type) assert.strictEqual(adapter.isValidIdentifier(identifier), true) } }) @@ -233,11 +218,7 @@ await describe('OCPP20AuthAdapter', async () => { ), } as unknown as ChargingStation['ocppRequestService'] - const identifier = createMockIdentifier( - OCPPVersion.VERSION_20, - 'VALID_TOKEN', - IdentifierType.CENTRAL - ) + const identifier = createMockIdentifier('VALID_TOKEN', IdentifierType.CENTRAL) const result = await adapter.authorizeRemote(identifier, 1, 'tx_123') @@ -248,7 +229,7 @@ await describe('OCPP20AuthAdapter', async () => { }) await it('should handle invalid token gracefully', async () => { - const identifier = createMockIdentifier(OCPPVersion.VERSION_20, '', IdentifierType.CENTRAL) + const identifier = createMockIdentifier('', IdentifierType.CENTRAL) const result = await adapter.authorizeRemote(identifier, 1) diff --git a/tests/charging-station/ocpp/auth/helpers/MockFactories.ts b/tests/charging-station/ocpp/auth/helpers/MockFactories.ts index ebf53db3..09917b9a 100644 --- a/tests/charging-station/ocpp/auth/helpers/MockFactories.ts +++ b/tests/charging-station/ocpp/auth/helpers/MockFactories.ts @@ -32,17 +32,14 @@ import { OCPPVersion } from '../../../../../src/types/index.js' /** * Create a mock UnifiedIdentifier for any OCPP version. - * @param ocppVersion - OCPP version (defaults to VERSION_16) * @param value - Identifier token value (defaults to 'TEST-TAG-001') * @param type - Identifier type enum value (defaults to ID_TAG) - * @returns Mock UnifiedIdentifier configured for specified OCPP version + * @returns Mock UnifiedIdentifier configured for testing */ export const createMockIdentifier = ( - ocppVersion: OCPPVersion = OCPPVersion.VERSION_16, value = 'TEST-TAG-001', type: IdentifierType = IdentifierType.ID_TAG ): UnifiedIdentifier => ({ - ocppVersion, type, value, }) @@ -209,7 +206,6 @@ export const createMockOCPPAdapter = ( ? identifier.value : { idToken: identifier.value, type: identifier.type }, convertToUnifiedIdentifier: (identifier: object | string) => ({ - ocppVersion, type: IdentifierType.ID_TAG, value: typeof identifier === 'string' diff --git a/tests/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.test.ts b/tests/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.test.ts index b3ec2464..eb307b56 100644 --- a/tests/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.test.ts +++ b/tests/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.test.ts @@ -103,7 +103,6 @@ await describe('OCPPAuthServiceImpl', async () => { await authService.initialize() const idTagIdentifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'VALID_ID_TAG', } @@ -116,7 +115,6 @@ await describe('OCPPAuthServiceImpl', async () => { await authService.initialize() const centralIdentifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CENTRAL, value: 'CENTRAL_ID', } @@ -167,7 +165,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'TAG_TO_INVALIDATE', } @@ -208,7 +205,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'VALID_TAG', } @@ -230,7 +226,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'UNKNOWN_TAG', } @@ -259,7 +254,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'LOCAL_TAG', } @@ -284,7 +278,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation16) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'OCPP16_TAG', } @@ -304,7 +297,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation20) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.E_MAID, value: 'EMAID123456', } @@ -332,7 +324,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: '', } @@ -362,7 +353,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation16) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'START_TAG', } @@ -383,7 +373,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation16) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'STOP_TAG', } @@ -404,7 +393,6 @@ await describe('OCPPAuthServiceImpl', async () => { const authService = new OCPPAuthServiceImpl(mockStation20) const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CENTRAL, value: 'REMOTE_ID', } diff --git a/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts b/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts index 3a3f1ffb..321a5320 100644 --- a/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts @@ -48,7 +48,6 @@ await describe('CertificateAuthStrategy', async () => { ) }), convertToUnifiedIdentifier: identifier => ({ - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: typeof identifier === 'string' ? identifier : JSON.stringify(identifier), }), @@ -100,7 +99,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'DEF456', serialNumber: 'TEST_CERT_001', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_IDENTIFIER', }, @@ -113,7 +111,6 @@ await describe('CertificateAuthStrategy', async () => { const config = createTestAuthConfig({ certificateAuthEnabled: true }) const request = createMockAuthRequest({ identifier: { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.ID_TAG, value: 'ID_TAG', }, @@ -123,16 +120,25 @@ await describe('CertificateAuthStrategy', async () => { }) await it('should return false for OCPP 1.6', () => { + const ocpp16Adapter = createMockOCPPAdapter(OCPPVersion.VERSION_16) + const ocpp16Strategy = new CertificateAuthStrategy(mockStation, ocpp16Adapter) + ocpp16Strategy.initialize(createTestAuthConfig({ certificateAuthEnabled: true })) + const config = createTestAuthConfig({ certificateAuthEnabled: true }) const request = createMockAuthRequest({ identifier: { - ocppVersion: OCPPVersion.VERSION_16, + certificateHashData: { + hashAlgorithm: 'SHA256', + issuerKeyHash: 'ABC123', + issuerNameHash: 'DEF456', + serialNumber: 'TEST_CERT_001', + }, type: IdentifierType.CERTIFICATE, value: 'CERT', }, }) - assert.strictEqual(strategy.canHandle(request, config), false) + assert.strictEqual(ocpp16Strategy.canHandle(request, config), false) }) await it('should return false when certificate auth is disabled', () => { @@ -145,7 +151,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'DEF456', serialNumber: 'TEST_CERT_001', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT', }, @@ -158,7 +163,6 @@ await describe('CertificateAuthStrategy', async () => { const config = createTestAuthConfig({ certificateAuthEnabled: true }) const request = createMockAuthRequest({ identifier: { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_NO_DATA', }, @@ -184,7 +188,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: '789012ghi345', serialNumber: 'TEST_CERT_001', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_TEST', }, @@ -207,7 +210,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'def456', serialNumber: 'INVALID_CERT', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_INVALID', }, @@ -229,7 +231,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'def456', serialNumber: 'REVOKED_CERT', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_REVOKED', }, @@ -245,7 +246,6 @@ await describe('CertificateAuthStrategy', async () => { const config = createTestAuthConfig({ certificateAuthEnabled: true }) const request = createMockAuthRequest({ identifier: { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_NO_DATA', }, @@ -267,7 +267,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'def456', serialNumber: 'TEST_CERT', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_BAD_ALGO', }, @@ -289,7 +288,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'also-not-hex!', serialNumber: 'TEST_CERT', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_BAD_HASH', }, @@ -324,7 +322,6 @@ await describe('CertificateAuthStrategy', async () => { issuerNameHash: 'def456', serialNumber: 'TEST_CERT_001', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_TEST', }, diff --git a/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy-DisablePostAuthorize.test.ts b/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy-DisablePostAuthorize.test.ts index 3573265b..ccef7f8c 100644 --- a/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy-DisablePostAuthorize.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy-DisablePostAuthorize.test.ts @@ -11,7 +11,6 @@ import { AuthorizationStatus, IdentifierType, } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' -import { OCPPVersion } from '../../../../../src/types/index.js' import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' import { createMockAuthCache, @@ -46,11 +45,7 @@ await describe('LocalAuthStrategy - DisablePostAuthorize', async () => { }) strategy.initialize(config) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_20, - 'BLOCKED-TAG', - IdentifierType.ISO14443 - ), + identifier: createMockIdentifier('BLOCKED-TAG', IdentifierType.ISO14443), }) // Act @@ -78,11 +73,7 @@ await describe('LocalAuthStrategy - DisablePostAuthorize', async () => { }) strategy.initialize(config) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_20, - 'BLOCKED-TAG', - IdentifierType.ISO14443 - ), + identifier: createMockIdentifier('BLOCKED-TAG', IdentifierType.ISO14443), }) // Act @@ -111,11 +102,7 @@ await describe('LocalAuthStrategy - DisablePostAuthorize', async () => { }) strategy.initialize(config) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_20, - 'BLOCKED-TAG', - IdentifierType.ISO14443 - ), + identifier: createMockIdentifier('BLOCKED-TAG', IdentifierType.ISO14443), }) const result = await strategy.authenticate(request, config) @@ -142,11 +129,7 @@ await describe('LocalAuthStrategy - DisablePostAuthorize', async () => { }) strategy.initialize(config) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_20, - 'BLOCKED-TAG', - IdentifierType.ISO14443 - ), + identifier: createMockIdentifier('BLOCKED-TAG', IdentifierType.ISO14443), }) // Act diff --git a/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts b/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts index b684a91b..c0e64514 100644 --- a/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts @@ -18,7 +18,6 @@ import { AuthorizationStatus, IdentifierType, } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' -import { OCPPVersion } from '../../../../../src/types/index.js' import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' import { createMockAuthCache, @@ -72,7 +71,7 @@ await describe('LocalAuthStrategy', async () => { await it('should return true when local auth list is enabled', () => { const config = createTestAuthConfig({ localAuthListEnabled: true }) const request = createMockAuthRequest({ - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'TEST_TAG', IdentifierType.ID_TAG), + identifier: createMockIdentifier('TEST_TAG', IdentifierType.ID_TAG), }) assert.strictEqual(strategy.canHandle(request, config), true) }) @@ -80,7 +79,7 @@ await describe('LocalAuthStrategy', async () => { await it('should return true when cache is enabled', () => { const config = createTestAuthConfig({ authorizationCacheEnabled: true }) const request = createMockAuthRequest({ - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'TEST_TAG', IdentifierType.ID_TAG), + identifier: createMockIdentifier('TEST_TAG', IdentifierType.ID_TAG), }) assert.strictEqual(strategy.canHandle(request, config), true) }) @@ -88,7 +87,7 @@ await describe('LocalAuthStrategy', async () => { await it('should return false when nothing is enabled', () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'TEST_TAG', IdentifierType.ID_TAG), + identifier: createMockIdentifier('TEST_TAG', IdentifierType.ID_TAG), }) assert.strictEqual(strategy.canHandle(request, config), false) }) @@ -120,11 +119,7 @@ await describe('LocalAuthStrategy', async () => { localAuthListEnabled: true, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'LOCAL_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('LOCAL_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) @@ -144,11 +139,7 @@ await describe('LocalAuthStrategy', async () => { const config = createTestAuthConfig({ authorizationCacheEnabled: true }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'CACHED_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('CACHED_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) @@ -163,11 +154,7 @@ await describe('LocalAuthStrategy', async () => { const request = createMockAuthRequest({ allowOffline: true, context: AuthContext.TRANSACTION_STOP, - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'UNKNOWN_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('UNKNOWN_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) @@ -181,11 +168,7 @@ await describe('LocalAuthStrategy', async () => { await it('should return undefined when no local auth available', async () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'UNKNOWN_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('UNKNOWN_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) diff --git a/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts b/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts index 2faa90ae..6d983106 100644 --- a/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts @@ -83,11 +83,7 @@ await describe('RemoteAuthStrategy', async () => { await it('should return true when remote auth is enabled', () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'REMOTE_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('REMOTE_TAG', IdentifierType.ID_TAG), }) assert.strictEqual(strategy.canHandle(request, config), true) }) @@ -97,11 +93,7 @@ await describe('RemoteAuthStrategy', async () => { remoteAuthorization: false, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'REMOTE_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('REMOTE_TAG', IdentifierType.ID_TAG), }) assert.strictEqual(strategy.canHandle(request, config), false) }) @@ -110,11 +102,7 @@ await describe('RemoteAuthStrategy', async () => { const strategyNoAdapters = new RemoteAuthStrategy() const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'REMOTE_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('REMOTE_TAG', IdentifierType.ID_TAG), }) assert.strictEqual(strategyNoAdapters.canHandle(request, config), false) }) @@ -129,11 +117,7 @@ await describe('RemoteAuthStrategy', async () => { await it('should authenticate using adapter', async () => { const config = createTestAuthConfig({ authorizationCacheEnabled: true }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'REMOTE_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('REMOTE_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) @@ -154,11 +138,7 @@ await describe('RemoteAuthStrategy', async () => { authorizationCacheLifetime: 300, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'CACHE_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('CACHE_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -185,11 +165,7 @@ await describe('RemoteAuthStrategy', async () => { authorizationCacheLifetime: 300, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'BLOCKED_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('BLOCKED_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -216,11 +192,7 @@ await describe('RemoteAuthStrategy', async () => { authorizationCacheLifetime: 300, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'EXPIRED_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('EXPIRED_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -247,11 +219,7 @@ await describe('RemoteAuthStrategy', async () => { authorizationCacheLifetime: 300, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'INVALID_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('INVALID_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -269,11 +237,7 @@ await describe('RemoteAuthStrategy', async () => { authorizationCacheLifetime: 300, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'ACCEPTED_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('ACCEPTED_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -285,11 +249,7 @@ await describe('RemoteAuthStrategy', async () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'UNAVAILABLE_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('UNAVAILABLE_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) @@ -303,7 +263,6 @@ await describe('RemoteAuthStrategy', async () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ identifier: { - ocppVersion: OCPPVersion.VERSION_201, type: IdentifierType.ID_TAG, value: 'UNKNOWN_VERSION_TAG', }, @@ -320,11 +279,7 @@ await describe('RemoteAuthStrategy', async () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'ERROR_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('ERROR_TAG', IdentifierType.ID_TAG), }) const result = await strategy.authenticate(request, config) @@ -355,11 +310,7 @@ await describe('RemoteAuthStrategy', async () => { localAuthListEnabled: true, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'LOCAL_AUTH_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('LOCAL_AUTH_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -383,11 +334,7 @@ await describe('RemoteAuthStrategy', async () => { localAuthListEnabled: true, }) const request = createMockAuthRequest({ - identifier: createMockIdentifier( - OCPPVersion.VERSION_16, - 'REMOTE_AUTH_TAG', - IdentifierType.ID_TAG - ), + identifier: createMockIdentifier('REMOTE_AUTH_TAG', IdentifierType.ID_TAG), }) await strategy.authenticate(request, config) @@ -402,7 +349,7 @@ await describe('RemoteAuthStrategy', async () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'TEST', IdentifierType.ID_TAG), + identifier: createMockIdentifier('TEST', IdentifierType.ID_TAG), }) assert.strictEqual(newStrategy.canHandle(request, config), true) @@ -413,7 +360,7 @@ await describe('RemoteAuthStrategy', async () => { const config = createTestAuthConfig() const request = createMockAuthRequest({ - identifier: createMockIdentifier(OCPPVersion.VERSION_16, 'TEST', IdentifierType.ID_TAG), + identifier: createMockIdentifier('TEST', IdentifierType.ID_TAG), }) assert.strictEqual(strategy.canHandle(request, config), false) diff --git a/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts b/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts index 2d934f6d..361c9384 100644 --- a/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts +++ b/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts @@ -252,14 +252,12 @@ await describe('AuthTypes', async () => { await describe('UnifiedIdentifier', async () => { await it('should create valid OCPP 1.6 identifier', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'VALID_ID_TAG', } assert.strictEqual(identifier.value, 'VALID_ID_TAG') assert.strictEqual(identifier.type, IdentifierType.ID_TAG) - assert.strictEqual(identifier.ocppVersion, OCPPVersion.VERSION_16) }) await it('should create valid OCPP 2.0 identifier with additional info', () => { @@ -268,14 +266,12 @@ await describe('AuthTypes', async () => { contractId: 'CONTRACT123', issuer: 'EMSProvider', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.E_MAID, value: 'EMAID123456', } assert.strictEqual(identifier.value, 'EMAID123456') assert.strictEqual(identifier.type, IdentifierType.E_MAID) - assert.strictEqual(identifier.ocppVersion, OCPPVersion.VERSION_20) assert.notStrictEqual(identifier.additionalInfo, undefined) assert.strictEqual(identifier.additionalInfo?.issuer, 'EMSProvider') }) @@ -288,7 +284,6 @@ await describe('AuthTypes', async () => { issuerNameHash: 'ISSUER_HASH', serialNumber: '123456', }, - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CERTIFICATE, value: 'CERT_IDENTIFIER', } diff --git a/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts b/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts index d59523f5..64a6c556 100644 --- a/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts +++ b/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts @@ -14,7 +14,6 @@ import { type UnifiedIdentifier, } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' import { AuthHelpers } from '../../../../../src/charging-station/ocpp/auth/utils/AuthHelpers.js' -import { OCPPVersion } from '../../../../../src/types/index.js' import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthHelpers', async () => { @@ -53,7 +52,6 @@ await describe('AuthHelpers', async () => { await describe('createAuthRequest', async () => { await it('should create basic auth request with minimal parameters', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'TEST123', } @@ -71,7 +69,6 @@ await describe('AuthHelpers', async () => { await it('should create auth request with connector ID', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.LOCAL, value: 'LOCAL001', } @@ -85,7 +82,6 @@ await describe('AuthHelpers', async () => { await it('should create auth request with metadata', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CENTRAL, value: 'CENTRAL001', } @@ -129,7 +125,6 @@ await describe('AuthHelpers', async () => { await it('should format error message with truncated identifier', () => { const error = new Error('Connection timeout') const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'VERY_LONG_IDENTIFIER_VALUE_12345', } @@ -144,7 +139,6 @@ await describe('AuthHelpers', async () => { await it('should handle short identifiers correctly', () => { const error = new Error('Invalid format') const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.LOCAL, value: 'SHORT', } diff --git a/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts b/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts index 9eceffa4..b41c195e 100644 --- a/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts +++ b/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts @@ -11,7 +11,6 @@ import { type UnifiedIdentifier, } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' import { AuthValidators } from '../../../../../src/charging-station/ocpp/auth/utils/AuthValidators.js' -import { OCPPVersion } from '../../../../../src/types/index.js' import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthValidators', async () => { @@ -257,7 +256,6 @@ await describe('AuthValidators', async () => { await it('should return false for empty value', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: '', } @@ -267,7 +265,6 @@ await describe('AuthValidators', async () => { await it('should return false for ID_TAG exceeding 20 characters', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'VERY_LONG_IDENTIFIER_VALUE_123456789', } @@ -277,7 +274,6 @@ await describe('AuthValidators', async () => { await it('should return true for valid ID_TAG within 20 characters', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ID_TAG, value: 'VALID_ID_TAG', } @@ -287,7 +283,6 @@ await describe('AuthValidators', async () => { await it('should return true for OCPP 2.0 LOCAL type within 36 characters', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.LOCAL, value: 'LOCAL_TOKEN_123', } @@ -297,7 +292,6 @@ await describe('AuthValidators', async () => { await it('should return false for OCPP 2.0 type exceeding 36 characters', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CENTRAL, value: 'VERY_LONG_CENTRAL_IDENTIFIER_VALUE_1234567890123456789', } @@ -307,7 +301,6 @@ await describe('AuthValidators', async () => { await it('should return true for CENTRAL type within 36 characters', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.CENTRAL, value: 'CENTRAL_TOKEN', } @@ -317,7 +310,6 @@ await describe('AuthValidators', async () => { await it('should return true for E_MAID type', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.E_MAID, value: 'DE-ABC-123456', } @@ -327,7 +319,6 @@ await describe('AuthValidators', async () => { await it('should return true for ISO14443 type', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.ISO14443, value: '04A2B3C4D5E6F7', } @@ -337,7 +328,6 @@ await describe('AuthValidators', async () => { await it('should return true for KEY_CODE type', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.KEY_CODE, value: '1234', } @@ -347,7 +337,6 @@ await describe('AuthValidators', async () => { await it('should return true for MAC_ADDRESS type', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.MAC_ADDRESS, value: '00:11:22:33:44:55', } @@ -357,7 +346,6 @@ await describe('AuthValidators', async () => { await it('should return true for NO_AUTHORIZATION type', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.NO_AUTHORIZATION, value: 'NO_AUTH', } @@ -367,7 +355,6 @@ await describe('AuthValidators', async () => { await it('should return false for unsupported type', () => { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, // @ts-expect-error: Testing invalid type type: 'UNSUPPORTED_TYPE', value: 'VALUE', diff --git a/tests/helpers/OCPPAuthIntegrationTest.ts b/tests/helpers/OCPPAuthIntegrationTest.ts index e2afb749..47ad76df 100644 --- a/tests/helpers/OCPPAuthIntegrationTest.ts +++ b/tests/helpers/OCPPAuthIntegrationTest.ts @@ -13,7 +13,6 @@ import { AuthorizationStatus, IdentifierType, } from '../../src/charging-station/ocpp/auth/types/AuthTypes.js' -import { OCPPVersion } from '../../src/types/index.js' import { logger } from '../../src/utils/index.js' export class OCPPAuthIntegrationTest { @@ -115,10 +114,6 @@ export class OCPPAuthIntegrationTest { private async testCacheOperations (): Promise { const testIdentifier: UnifiedIdentifier = { - ocppVersion: - this.chargingStation.stationInfo?.ocppVersion === OCPPVersion.VERSION_16 - ? OCPPVersion.VERSION_16 - : OCPPVersion.VERSION_201, type: IdentifierType.LOCAL, value: 'CACHE_TEST_ID', } @@ -162,7 +157,6 @@ export class OCPPAuthIntegrationTest { private async testErrorHandling (): Promise { const invalidIdentifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ISO14443, value: '', } @@ -195,7 +189,6 @@ export class OCPPAuthIntegrationTest { private async testOCPP16AuthFlow (): Promise { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_16, type: IdentifierType.ISO14443, value: 'VALID_ID_123', } @@ -224,7 +217,6 @@ export class OCPPAuthIntegrationTest { private async testOCPP20AuthFlow (): Promise { const identifier: UnifiedIdentifier = { - ocppVersion: OCPPVersion.VERSION_20, type: IdentifierType.ISO15693, value: 'VALID_ID_456', } @@ -270,10 +262,6 @@ export class OCPPAuthIntegrationTest { } const identifier: UnifiedIdentifier = { - ocppVersion: - this.chargingStation.stationInfo?.ocppVersion === OCPPVersion.VERSION_16 - ? OCPPVersion.VERSION_16 - : OCPPVersion.VERSION_20, type: IdentifierType.ISO14443, value: 'PERF_TEST_ID', } @@ -340,10 +328,6 @@ export class OCPPAuthIntegrationTest { } const testIdentifier: UnifiedIdentifier = { - ocppVersion: - this.chargingStation.stationInfo?.ocppVersion === OCPPVersion.VERSION_16 - ? OCPPVersion.VERSION_16 - : OCPPVersion.VERSION_20, type: IdentifierType.ISO14443, value: 'TEST123', } -- 2.43.0