iotagent-node-lib 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +16 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
  4. package/.github/advanced-issue-labeler.yml +30 -0
  5. package/.github/workflows/issue-labeler.yml +43 -0
  6. package/CHANGES_NEXT_RELEASE +0 -2
  7. package/config.js +5 -5
  8. package/doc/api.md +1483 -298
  9. package/doc/deprecated.md +7 -1
  10. package/doc/development.md +120 -0
  11. package/doc/howto.md +58 -62
  12. package/doc/installationguide.md +3 -11
  13. package/doc/requirements.txt +1 -1
  14. package/docker/Mosquitto/Dockerfile +1 -1
  15. package/lib/commonConfig.js +7 -10
  16. package/lib/fiware-iotagent-lib.js +0 -10
  17. package/lib/jexlTranformsMap.js +2 -1
  18. package/lib/model/Device.js +0 -1
  19. package/lib/model/Group.js +0 -1
  20. package/lib/model/dbConn.js +1 -7
  21. package/lib/plugins/bidirectionalData.js +8 -26
  22. package/lib/plugins/expressionPlugin.js +8 -40
  23. package/lib/plugins/jexlParser.js +28 -0
  24. package/lib/services/commands/commandService.js +1 -1
  25. package/lib/services/common/iotManagerService.js +0 -1
  26. package/lib/services/devices/deviceRegistryMongoDB.js +10 -10
  27. package/lib/services/devices/deviceService.js +16 -20
  28. package/lib/services/devices/devices-NGSI-v2.js +2 -5
  29. package/lib/services/ngsi/entities-NGSI-LD.js +16 -60
  30. package/lib/services/ngsi/entities-NGSI-v2.js +179 -119
  31. package/lib/services/northBound/deviceProvisioningServer.js +17 -17
  32. package/lib/templates/createDevice.json +5 -6
  33. package/lib/templates/createDeviceLax.json +6 -8
  34. package/lib/templates/deviceGroup.json +1 -5
  35. package/lib/templates/updateDevice.json +9 -2
  36. package/lib/templates/updateDeviceLax.json +14 -5
  37. package/package.json +1 -1
  38. package/scripts/legacy_expression_tool/README.md +262 -0
  39. package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
  40. package/scripts/legacy_expression_tool/requirements.txt +3 -0
  41. package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
  42. package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
  43. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +3 -13
  44. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
  45. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
  46. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +8 -8
  47. package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
  48. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +1 -1
  49. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
  50. package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
  51. package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
  52. package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
  53. package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
  54. package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
  55. package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
  56. package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +10 -0
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -0
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -0
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -0
  83. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
  84. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -0
  85. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -0
  86. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -0
  87. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
  88. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -8
  89. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
  90. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
  91. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
  92. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +22 -0
  93. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
  94. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
  95. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
  96. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +33 -0
  97. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -0
  98. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -0
  99. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -0
  100. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -0
  101. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -0
  102. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
  103. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
  104. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
  105. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
  106. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
  107. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
  108. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
  109. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
  110. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
  111. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
  112. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
  113. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
  114. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
  115. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
  116. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
  117. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
  118. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
  119. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
  120. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
  121. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
  122. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
  123. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
  124. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  125. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
  126. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
  127. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
  128. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
  129. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
  130. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
  131. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
  132. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
  133. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
  134. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
  135. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +355 -75
  136. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +18 -51
  137. package/test/unit/ngsiv2/general/https-support-test.js +1 -5
  138. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
  139. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +9 -26
  140. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +143 -57
  141. package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
  142. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
  143. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +1 -10
  144. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
  145. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +6 -69
  146. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
  147. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +150 -0
  148. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -16
  149. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
  150. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
  151. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +15 -55
  152. package/test/unit/ngsiv2/provisioning/device-registration_test.js +1 -7
  153. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -9
  154. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
  155. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -7
  156. package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
  157. package/doc/advanced-topics.md +0 -626
  158. package/doc/expressionLanguage.md +0 -762
  159. package/lib/plugins/expressionParser.js +0 -205
  160. package/test/unit/expressions/expression-test.js +0 -197
  161. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -882
  162. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -951
  163. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -296
@@ -129,11 +129,10 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
129
129
  .matchHeader('fiware-service', 'smartgondor')
130
130
  .matchHeader('fiware-servicepath', 'electricity')
131
131
  .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3')
132
- .patch(
133
- '/v2/entities/light1/attrs',
132
+ .post(
133
+ '/v2/entities?options=upsert',
134
134
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')
135
135
  )
136
- .query({ type: 'Light' })
137
136
  .reply(204, {});
138
137
 
139
138
  iotAgentLib.activate(iotAgentConfig, done);
@@ -169,11 +168,10 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
169
168
  .matchHeader('fiware-service', 'smartgondor')
170
169
  .matchHeader('fiware-servicepath', 'electricity')
171
170
  .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3')
172
- .patch(
173
- '/v2/entities/light1/attrs',
171
+ .post(
172
+ '/v2/entities?options=upsert',
174
173
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')
175
174
  )
176
- .query({ type: 'Light' })
177
175
  .reply(403, {});
178
176
 
179
177
  iotAgentLib.activate(iotAgentConfig, done);
@@ -205,8 +203,8 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
205
203
  .matchHeader('fiware-service', 'smartgondor')
206
204
  .matchHeader('fiware-servicepath', 'electricity')
207
205
  .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3')
208
- .patch(
209
- '/v2/entities/light1/attrs',
206
+ .post(
207
+ '/v2/entities?options=upsert',
210
208
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')
211
209
  )
212
210
  .reply(204, {});
@@ -293,15 +291,6 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
293
291
  )
294
292
  .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
295
293
 
296
- contextBrokerMock
297
- .post(
298
- '/v2/entities?options=upsert',
299
- utils.readExampleFile(
300
- './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json'
301
- )
302
- )
303
- .reply(204, {});
304
-
305
294
  contextBrokerMock
306
295
  .post(
307
296
  '/v2/subscriptions',
@@ -396,11 +385,10 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F
396
385
  .matchHeader('fiware-service', 'smartgondor')
397
386
  .matchHeader('fiware-servicepath', 'electricity')
398
387
  .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605')
399
- .patch(
400
- '/v2/entities/light1/attrs',
388
+ .post(
389
+ '/v2/entities?options=upsert',
401
390
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')
402
391
  )
403
- .query({ type: 'Light' })
404
392
  .reply(204, {});
405
393
 
406
394
  iotAgentConfig.authentication.tokenPath = '/oauth2/token';
@@ -536,11 +524,10 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F
536
524
  .matchHeader('fiware-service', 'smartgondor')
537
525
  .matchHeader('fiware-servicepath', 'electricity')
538
526
  .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605')
539
- .patch(
540
- '/v2/entities/light1/attrs',
527
+ .post(
528
+ '/v2/entities?options=upsert',
541
529
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')
542
530
  )
543
- .query({ type: 'Light' })
544
531
  .reply(401, 'Auth-token not found in request header');
545
532
 
546
533
  iotAgentLib.activate(iotAgentConfig, done);
@@ -624,26 +611,24 @@ describe(
624
611
  .matchHeader('fiware-service', 'testservice')
625
612
  .matchHeader('fiware-servicepath', '/testingPath')
626
613
  .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605')
627
- .patch(
628
- '/v2/entities/machine1/attrs',
614
+ .post(
615
+ '/v2/entities?options=upsert',
629
616
  utils.readExampleFile(
630
617
  './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json'
631
618
  )
632
619
  )
633
- .query({ type: 'SensorMachine' })
634
620
  .reply(204, {});
635
621
 
636
622
  contextBrokerMock2 = nock('http://unexistentHost:1026')
637
623
  .matchHeader('fiware-service', 'testservice')
638
624
  .matchHeader('fiware-servicepath', '/testingPath')
639
625
  .matchHeader('Authorization', 'Bearer bbb752e377680acd1349a3ed59db855a1db076aa')
640
- .patch(
641
- '/v2/entities/machine1/attrs',
626
+ .post(
627
+ '/v2/entities?options=upsert',
642
628
  utils.readExampleFile(
643
629
  './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json'
644
630
  )
645
631
  )
646
- .query({ type: 'SensorMachine' })
647
632
  .reply(204, {});
648
633
 
649
634
  iotAgentConfig.authentication.tokenPath = '/oauth2/token';
@@ -693,7 +678,6 @@ describe(
693
678
  'fiware-servicepath': '/testingPath'
694
679
  }
695
680
  };
696
- let contextBrokerMock2;
697
681
  let contextBrokerMock3;
698
682
  beforeEach(function (done) {
699
683
  const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
@@ -750,27 +734,14 @@ describe(
750
734
  )
751
735
  .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
752
736
 
753
- contextBrokerMock2 = nock('http://unexistenthost:1026')
737
+ contextBrokerMock3 = nock('http://unexistentHost:1026')
754
738
  .matchHeader('fiware-service', 'testservice')
755
739
  .matchHeader('fiware-servicepath', '/testingPath')
756
740
  .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc')
757
741
  .post(
758
742
  '/v2/entities?options=upsert',
759
- utils.readExampleFile(
760
- './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json'
761
- )
762
- )
763
- .reply(204, {});
764
-
765
- contextBrokerMock3 = nock('http://unexistentHost:1026')
766
- .matchHeader('fiware-service', 'testservice')
767
- .matchHeader('fiware-servicepath', '/testingPath')
768
- .matchHeader('authorization', 'Bearer zzz752e377680acd1349a3ed59db855a1db07bbb')
769
- .patch(
770
- '/v2/entities/Light1/attrs',
771
743
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext4.json')
772
744
  )
773
- .query({ type: 'SensorMachine' })
774
745
  .reply(204, {});
775
746
 
776
747
  iotAgentConfig.authentication.tokenPath = '/oauth2/token';
@@ -790,7 +761,6 @@ describe(
790
761
  should.not.exist(error);
791
762
  response.statusCode.should.equal(201);
792
763
  contextBrokerMock.done();
793
- contextBrokerMock2.done();
794
764
  done();
795
765
  });
796
766
  });
@@ -845,14 +815,13 @@ describe(
845
815
  contextBrokerMock = nock('http://unexistentHost:1026')
846
816
  .matchHeader('fiware-service', 'testservice')
847
817
  .matchHeader('fiware-servicepath', '/testingPath')
848
- .matchHeader('Authorization', 'Bearer 999210dacf913772606c95dd0b895d5506cbc988')
849
- .patch(
850
- '/v2/entities/machine1/attrs',
818
+ .matchHeader('Authorization', 'Bearer 000210dacf913772606c95dd0b895d5506cbc700')
819
+ .post(
820
+ '/v2/entities?options=upsert',
851
821
  utils.readExampleFile(
852
822
  './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json'
853
823
  )
854
824
  )
855
- .query({ type: 'SensorMachine' })
856
825
  .reply(204, {});
857
826
 
858
827
  iotAgentConfig.authentication.tokenPath = '/oauth2/token';
@@ -865,7 +834,6 @@ describe(
865
834
  it('should send the permanent token in the auth header', function (done) {
866
835
  iotAgentLib.update('machine1', 'SensorMachine', '', values, function (error) {
867
836
  should.not.exist(error);
868
- contextBrokerMock.done();
869
837
  done();
870
838
  });
871
839
  });
@@ -873,7 +841,6 @@ describe(
873
841
  it('should use the permanent trust token in the following requests', function (done) {
874
842
  iotAgentLib.update('machine1', 'SensorMachine', '', values, function (error) {
875
843
  should.not.exist(error);
876
- contextBrokerMock.done();
877
844
  done();
878
845
  });
879
846
  });
@@ -229,11 +229,7 @@ describe('NGSI-v2 - HTTPS support tests', function () {
229
229
  // This mock does not check the payload since the aim of the test is not to verify
230
230
  // device provisioning functionality. Appropriate verification is done in tests under
231
231
  // provisioning folder
232
- contextBrokerMock = nock('https://192.168.1.1:1026')
233
- .matchHeader('fiware-service', 'smartgondor')
234
- .matchHeader('fiware-servicepath', 'gardens')
235
- .post('/v2/entities?options=upsert')
236
- .reply(204);
232
+ contextBrokerMock = nock('https://192.168.1.1:1026');
237
233
 
238
234
  const nockBody = utils.readExampleFile(
239
235
  './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'
@@ -130,12 +130,6 @@ describe('NGSI-v2 - Command functionalities', function () {
130
130
  )
131
131
  .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
132
132
 
133
- contextBrokerMock
134
- .matchHeader('fiware-service', 'smartgondor')
135
- .matchHeader('fiware-servicepath', 'gardens')
136
- .post('/v2/entities?options=upsert')
137
- .reply(204);
138
-
139
133
  iotAgentLib.activate(iotAgentConfig, done);
140
134
  });
141
135
 
@@ -269,8 +263,8 @@ describe('NGSI-v2 - Command functionalities', function () {
269
263
  statusAttributeMock = nock('http://192.168.1.1:1026')
270
264
  .matchHeader('fiware-service', 'smartgondor')
271
265
  .matchHeader('fiware-servicepath', 'gardens')
272
- .patch(
273
- '/v2/entities/r2d2/attrs?type=Robot',
266
+ .post(
267
+ '/v2/entities?options=upsert',
274
268
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json')
275
269
  )
276
270
  .reply(204);
@@ -293,8 +287,8 @@ describe('NGSI-v2 - Command functionalities', function () {
293
287
  statusAttributeMock = nock('http://192.168.1.1:1026')
294
288
  .matchHeader('fiware-service', 'smartgondor')
295
289
  .matchHeader('fiware-servicepath', 'gardens')
296
- .patch(
297
- '/v2/entities/r2d2/attrs?type=Robot',
290
+ .post(
291
+ '/v2/entities?options=upsert',
298
292
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json')
299
293
  )
300
294
  .reply(204);
@@ -140,8 +140,7 @@ const device4 = {
140
140
  type: 'RobotExp',
141
141
  service: 'smartgondor',
142
142
  subservice: 'gardens',
143
- polling: true,
144
- expressionLanguage: 'jexl'
143
+ polling: true
145
144
  };
146
145
 
147
146
  describe('NGSI-v2 - Polling commands', function () {
@@ -203,14 +202,7 @@ describe('NGSI-v2 - Polling commands', function () {
203
202
  };
204
203
 
205
204
  beforeEach(function (done) {
206
- statusAttributeMock = nock('http://192.168.1.1:1026')
207
- .matchHeader('fiware-service', 'smartgondor')
208
- .matchHeader('fiware-servicepath', 'gardens')
209
- .patch(
210
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
211
- utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')
212
- )
213
- .reply(204);
205
+ statusAttributeMock = nock('http://192.168.1.1:1026');
214
206
 
215
207
  iotAgentLib.register(device3, function (error) {
216
208
  done();
@@ -300,8 +292,8 @@ describe('NGSI-v2 - Polling commands', function () {
300
292
  statusAttributeMock = nock('http://192.168.1.1:1026')
301
293
  .matchHeader('fiware-service', 'smartgondor')
302
294
  .matchHeader('fiware-servicepath', 'gardens')
303
- .patch(
304
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
295
+ .post(
296
+ '/v2/entities?options=upsert',
305
297
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')
306
298
  )
307
299
  .reply(204);
@@ -353,8 +345,8 @@ describe('NGSI-v2 - Polling commands', function () {
353
345
  statusAttributeMock = nock('http://192.168.1.1:1026')
354
346
  .matchHeader('fiware-service', 'smartgondor')
355
347
  .matchHeader('fiware-servicepath', 'gardens')
356
- .patch(
357
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
348
+ .post(
349
+ '/v2/entities?options=upsert',
358
350
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')
359
351
  )
360
352
  .reply(204);
@@ -362,8 +354,8 @@ describe('NGSI-v2 - Polling commands', function () {
362
354
  statusAttributeMock = nock('http://192.168.1.1:1026')
363
355
  .matchHeader('fiware-service', 'smartgondor')
364
356
  .matchHeader('fiware-servicepath', 'gardens')
365
- .patch(
366
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
357
+ .post(
358
+ '/v2/entities?options=upsert',
367
359
  utils.readExampleFile(
368
360
  './test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json'
369
361
  )
@@ -469,16 +461,7 @@ describe('NGSI-v2 - Polling commands expressions', function () {
469
461
  };
470
462
 
471
463
  beforeEach(function (done) {
472
- statusAttributeMock = nock('http://192.168.1.1:1026')
473
- .matchHeader('fiware-service', 'smartgondor')
474
- .matchHeader('fiware-servicepath', 'gardens')
475
- .patch(
476
- '/v2/entities/RobotExp:r2d4/attrs?type=RobotExp',
477
- utils.readExampleFile(
478
- './test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json'
479
- )
480
- )
481
- .reply(204);
464
+ statusAttributeMock = nock('http://192.168.1.1:1026');
482
465
 
483
466
  iotAgentLib.register(device4, function (error) {
484
467
  done();