fix: validate response payload related to reservation OCPP commands
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 5 Jun 2023 16:51:24 +0000 (18:51 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 5 Jun 2023 16:51:24 +0000 (18:51 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/types/ocpp/1.6/Requests.ts

index b82599b768e08ed13cfff1586ef20d1b12190637..7ff1fdb8d43b27da48147a789a1612c87644d8a4 100644 (file)
@@ -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<OCPP16ReserveNowRequest>(
-          'assets/json-schemas/ocpp/1.6/ReserveNow.json',
-          moduleName,
-          'constructor'
-        ),
-      ],
-      [
-        OCPP16RequestCommand.CANCEL_RESERVATION,
-        OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16CancelReservationRequest>(
-          'assets/json-schemas/ocpp/1.6/CancelReservation.json',
-          moduleName,
-          'constructor'
-        ),
-      ],
     ]);
     this.buildRequestPayload = this.buildRequestPayload.bind(this) as <Request extends JsonType>(
       chargingStation: ChargingStation,
index 9e8a2d5f7636a33aba59c198a8a7e337cea8f0bf..fcdcd1a13489da0b1af14355f3735d669f60c78b 100644 (file)
@@ -163,22 +163,6 @@ export class OCPP16ResponseService extends OCPPResponseService {
           'constructor'
         ),
       ],
-      [
-        OCPP16RequestCommand.RESERVE_NOW,
-        OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ReserveNowResponse>(
-          'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json',
-          moduleName,
-          'constructor'
-        ),
-      ],
-      [
-        OCPP16RequestCommand.CANCEL_RESERVATION,
-        OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16CancelReservationResponse>(
-          '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<OCPP16ReserveNowResponse>(
+          'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json',
+          moduleName,
+          'constructor'
+        ),
+      ],
+      [
+        OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
+        OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16CancelReservationResponse>(
+          'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json',
+          moduleName,
+          'constructor'
+        ),
+      ],
     ]);
     this.validatePayload = this.validatePayload.bind(this) as (
       chargingStation: ChargingStation,
index 80128a271c9fd6edd3cb6ec9609ad6b2ed898da7..39e8a9bb3269509639e70b43fb65d4e9f3496e8e 100644 (file)
@@ -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 {