From: Jérôme Benoit Date: Mon, 5 Jun 2023 16:51:24 +0000 (+0200) Subject: fix: validate response payload related to reservation OCPP commands X-Git-Tag: v1.2.16~10 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=28fe900f67212a25ae58ff48afb46f92bf7a101c;p=e-mobility-charging-stations-simulator.git fix: validate response payload related to reservation OCPP commands Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index b82599b7..7ff1fdb8 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -24,10 +24,6 @@ import { OCPPVersion, type RequestParams, } from '../../../types'; -import type { - OCPP16CancelReservationRequest, - OCPP16ReserveNowRequest, -} from '../../../types/ocpp/1.6/Requests'; import { Constants, Utils } from '../../../utils'; import { OCPPRequestService } from '../OCPPRequestService'; import type { OCPPResponseService } from '../OCPPResponseService'; @@ -123,22 +119,6 @@ export class OCPP16RequestService extends OCPPRequestService { 'constructor' ), ], - [ - OCPP16RequestCommand.RESERVE_NOW, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ReserveNow.json', - moduleName, - 'constructor' - ), - ], - [ - OCPP16RequestCommand.CANCEL_RESERVATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/CancelReservation.json', - moduleName, - 'constructor' - ), - ], ]); this.buildRequestPayload = this.buildRequestPayload.bind(this) as ( chargingStation: ChargingStation, diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 9e8a2d5f..fcdcd1a1 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -163,22 +163,6 @@ export class OCPP16ResponseService extends OCPPResponseService { 'constructor' ), ], - [ - OCPP16RequestCommand.RESERVE_NOW, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', - moduleName, - 'constructor' - ), - ], - [ - OCPP16RequestCommand.CANCEL_RESERVATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', - moduleName, - 'constructor' - ), - ], ]); this.jsonIncomingRequestResponseSchemas = new Map([ [ @@ -301,6 +285,22 @@ export class OCPP16ResponseService extends OCPPResponseService { 'constructor' ), ], + [ + OCPP16IncomingRequestCommand.RESERVE_NOW, + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', + moduleName, + 'constructor' + ), + ], + [ + OCPP16IncomingRequestCommand.CANCEL_RESERVATION, + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', + moduleName, + 'constructor' + ), + ], ]); this.validatePayload = this.validatePayload.bind(this) as ( chargingStation: ChargingStation, diff --git a/src/types/ocpp/1.6/Requests.ts b/src/types/ocpp/1.6/Requests.ts index 80128a27..39e8a9bb 100644 --- a/src/types/ocpp/1.6/Requests.ts +++ b/src/types/ocpp/1.6/Requests.ts @@ -21,8 +21,6 @@ export enum OCPP16RequestCommand { DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification', FIRMWARE_STATUS_NOTIFICATION = 'FirmwareStatusNotification', DATA_TRANSFER = 'DataTransfer', - RESERVE_NOW = 'ReserveNow', - CANCEL_RESERVATION = 'CancelReservation', } export enum OCPP16IncomingRequestCommand {