From: Jérôme Benoit Date: Wed, 18 Mar 2026 19:04:12 +0000 (+0100) Subject: refactor(test): remove duplicate certificate passthrough tests from broadcast channel X-Git-Tag: ocpp-server@v3.2.0~57 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6d3a9962fa8909d2c4b7b5d1a9da1436e762c4b5;p=e-mobility-charging-stations-simulator.git refactor(test): remove duplicate certificate passthrough tests from broadcast channel These 3 tests duplicated coverage already provided by OCPP20RequestService-ISO15118.test.ts which tests the same code path through the full requestHandler pipeline. Add JSDoc descriptions to buildTransactionEvent implementation to satisfy jsdoc/require-param-description lint rule. --- diff --git a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts index e684ec4a..dd299c2f 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts @@ -489,13 +489,13 @@ export function buildTransactionEvent ( commandParams: JsonObject ): OCPP20TransactionEventRequest /** - * - * @param chargingStation - * @param eventTypeOrParams - * @param triggerReasonArg - * @param connectorIdArg - * @param transactionIdArg - * @param options + * @param chargingStation - Charging station instance + * @param eventTypeOrParams - Event type enum or minimal params object + * @param triggerReasonArg - Trigger reason (explicit overload) + * @param connectorIdArg - Connector identifier (explicit overload) + * @param transactionIdArg - Transaction UUID (explicit overload) + * @param options - Optional transaction event fields + * @returns Built TransactionEventRequest */ export function buildTransactionEvent ( chargingStation: ChargingStation, diff --git a/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts b/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts index 198de2a7..c392a4ea 100644 --- a/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts +++ b/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts @@ -26,10 +26,7 @@ import { import { Constants } from '../../../src/utils/index.js' import { flushMicrotasks, standardCleanup } from '../../helpers/TestLifecycleHelpers.js' import { createMockChargingStation } from '../ChargingStationTestUtils.js' -import { - createMockStationWithRequestTracking, - createOCPP20RequestTestContext, -} from '../ocpp/2.0/OCPP20TestUtils.js' +import { createMockStationWithRequestTracking } from '../ocpp/2.0/OCPP20TestUtils.js' // ============================================================================ // Testable Interfaces @@ -532,67 +529,6 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { }) }) - // ========================================================================== - // Group 3: buildRequestPayload — OCPP 2.0.1 certificate passthrough (3 tests) - // ========================================================================== - - await describe('buildRequestPayload OCPP 2.0.1 certificate passthrough', async () => { - await it('should build GET_15118_EV_CERTIFICATE payload as passthrough', () => { - const { station, testableRequestService } = createOCPP20RequestTestContext() - const commandParams = { - action: 'Install', - exiRequest: 'base64EncodedData', - iso15118SchemaVersion: 'urn:iso:15118:2:2013:MsgDef', - } - - const payload = testableRequestService.buildRequestPayload( - station, - RequestCommand.GET_15118_EV_CERTIFICATE, - commandParams - ) - - assert.deepStrictEqual(payload, commandParams) - }) - - await it('should build GET_CERTIFICATE_STATUS payload as passthrough', () => { - const { station, testableRequestService } = createOCPP20RequestTestContext() - const commandParams = { - ocspRequestData: { - hashAlgorithm: 'SHA256', - issuerKeyHash: 'abc123def456issuerkeyhash', - issuerNameHash: 'abc123def456issuernamehash', - responderURL: 'http://ocsp.example.com', - serialNumber: '1234567890', - }, - } - - const payload = testableRequestService.buildRequestPayload( - station, - RequestCommand.GET_CERTIFICATE_STATUS, - commandParams - ) - - assert.deepStrictEqual(payload, commandParams) - }) - - await it('should build SIGN_CERTIFICATE payload with generated CSR', () => { - const { station, testableRequestService } = createOCPP20RequestTestContext() - const commandParams = { - certificateType: 'ChargingStationCertificate', - } - - const payload = testableRequestService.buildRequestPayload( - station, - RequestCommand.SIGN_CERTIFICATE, - commandParams - ) as { certificateType?: string; csr: string } - - assert.ok(payload.csr.startsWith('-----BEGIN CERTIFICATE REQUEST-----')) - assert.ok(payload.csr.endsWith('-----END CERTIFICATE REQUEST-----')) - assert.strictEqual(payload.certificateType, 'ChargingStationCertificate') - }) - }) - // ========================================================================== // Group 4: commandHandler dispatch pipeline — verify full dispatch (8 tests) // ==========================================================================