]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test(ocpp20): add read-only FileTransferProtocols regression test
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 29 Oct 2025 22:29:12 +0000 (23:29 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 29 Oct 2025 22:29:12 +0000 (23:29 +0100)
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts

index 034878c28c5a6f39ae87d69a91a0ecd609648f53..96afdaf2be916f1ea068c3b75b9fd4cc7706b42c 100644 (file)
@@ -1207,7 +1207,7 @@ await describe('OCPP20VariableManager test suite', async () => {
           variable: { name: OCPP20RequiredVariableName.TxStartPoint },
         },
         {
-          attributeValue: 'EVConnected,PowerPathClosed', // updated default
+          attributeValue: 'EVConnected,PowerPathClosed',
           component: { name: OCPP20ComponentName.TxCtrlr },
           variable: { name: OCPP20RequiredVariableName.TxStopPoint },
         },
@@ -1248,6 +1248,36 @@ await describe('OCPP20VariableManager test suite', async () => {
       expect(getRes.attributeValue).toBe('HTTPS,FTPS,SFTP')
     })
 
+    await it('Should keep FileTransferProtocols value unchanged after rejected update attempt', () => {
+      const beforeCfg = getConfigurationKey(
+        mockChargingStation,
+        OCPP20RequiredVariableName.FileTransferProtocols as unknown as VariableType['name']
+      )
+      expect(beforeCfg?.value).toBe('HTTPS,FTPS,SFTP')
+      const rejected = manager.setVariables(mockChargingStation, [
+        {
+          attributeValue: 'HTTP,HTTPS',
+          component: { name: OCPP20ComponentName.OCPPCommCtrlr },
+          variable: { name: OCPP20RequiredVariableName.FileTransferProtocols },
+        },
+      ])[0]
+      expect(rejected.attributeStatus).toBe(SetVariableStatusEnumType.Rejected)
+      expect(rejected.attributeStatusInfo?.reasonCode).toBe(ReasonCodeEnumType.ReadOnly)
+      const afterGet = manager.getVariables(mockChargingStation, [
+        {
+          component: { name: OCPP20ComponentName.OCPPCommCtrlr },
+          variable: { name: OCPP20RequiredVariableName.FileTransferProtocols },
+        },
+      ])[0]
+      expect(afterGet.attributeStatus).toBe(GetVariableStatusEnumType.Accepted)
+      expect(afterGet.attributeValue).toBe('HTTPS,FTPS,SFTP')
+      const afterCfg = getConfigurationKey(
+        mockChargingStation,
+        OCPP20RequiredVariableName.FileTransferProtocols as unknown as VariableType['name']
+      )
+      expect(afterCfg?.value).toBe(beforeCfg?.value)
+    })
+
     await it('Should reject removed TimeSource members RTC and Manual', () => {
       const res = manager.setVariables(mockChargingStation, [
         {