From 28fe900f67212a25ae58ff48afb46f92bf7a101c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 5 Jun 2023 18:51:24 +0200 Subject: [PATCH] fix: validate response payload related to reservation OCPP commands MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16RequestService.ts | 20 ------------ .../ocpp/1.6/OCPP16ResponseService.ts | 32 +++++++++---------- src/types/ocpp/1.6/Requests.ts | 2 -- 3 files changed, 16 insertions(+), 38 deletions(-) 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 { -- 2.34.1