iotagent-node-lib 3.2.0 → 3.4.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 (184) 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/README.md +10 -11
  7. package/doc/README.md +16 -0
  8. package/doc/admin.md +565 -0
  9. package/doc/api.md +32 -85
  10. package/doc/deprecated.md +16 -10
  11. package/doc/{architecture.md → devel/architecture.md} +3 -3
  12. package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
  13. package/doc/devel/development.md +1879 -0
  14. package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
  15. package/doc/index.md +3 -5
  16. package/doc/requirements.txt +1 -1
  17. package/docker/Mosquitto/Dockerfile +1 -1
  18. package/docker/Mosquitto/README.md +1 -0
  19. package/lib/commonConfig.js +0 -5
  20. package/lib/fiware-iotagent-lib.js +1 -1
  21. package/lib/jexlTranformsMap.js +2 -1
  22. package/lib/model/Device.js +0 -1
  23. package/lib/model/Group.js +0 -1
  24. package/lib/model/dbConn.js +1 -7
  25. package/lib/plugins/jexlParser.js +1 -1
  26. package/lib/request-shim.js +2 -2
  27. package/lib/services/commands/commandService.js +1 -1
  28. package/lib/services/common/genericMiddleware.js +1 -1
  29. package/lib/services/common/iotManagerService.js +0 -1
  30. package/lib/services/devices/deviceRegistryMemory.js +2 -2
  31. package/lib/services/devices/deviceRegistryMongoDB.js +32 -19
  32. package/lib/services/devices/deviceService.js +44 -43
  33. package/lib/services/devices/devices-NGSI-LD.js +14 -2
  34. package/lib/services/devices/devices-NGSI-mixed.js +0 -2
  35. package/lib/services/devices/devices-NGSI-v2.js +23 -104
  36. package/lib/services/groups/groupService.js +1 -1
  37. package/lib/services/ngsi/entities-NGSI-LD.js +3 -3
  38. package/lib/services/ngsi/entities-NGSI-v2.js +28 -19
  39. package/lib/services/northBound/deviceProvisioningServer.js +14 -8
  40. package/lib/templates/createDevice.json +0 -4
  41. package/lib/templates/createDeviceLax.json +0 -4
  42. package/lib/templates/deviceGroup.json +1 -5
  43. package/lib/templates/updateDevice.json +4 -0
  44. package/lib/templates/updateDeviceLax.json +11 -0
  45. package/mkdocs.yml +6 -11
  46. package/package.json +3 -3
  47. package/scripts/legacy_expression_tool/README.md +280 -0
  48. package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
  49. package/scripts/legacy_expression_tool/requirements.txt +3 -0
  50. package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +0 -1
  51. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -15
  52. package/test/unit/mongodb/mongodb-registry-test.js +1 -1
  53. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
  54. package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
  55. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
  56. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
  57. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
  58. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
  59. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
  60. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
  61. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
  62. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
  63. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
  64. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +12 -0
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
  83. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
  84. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
  85. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
  86. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
  87. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
  88. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
  89. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
  90. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
  91. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
  92. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
  93. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
  94. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -12
  95. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -4
  96. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -4
  97. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
  98. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -12
  99. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -12
  100. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -4
  101. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
  102. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -0
  103. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
  104. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
  105. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
  106. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +2 -0
  107. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
  108. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
  109. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +1 -1
  110. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -10
  111. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -4
  112. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -4
  113. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -4
  114. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -12
  115. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -4
  116. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
  117. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
  118. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
  119. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
  120. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
  121. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
  122. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
  123. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
  124. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
  125. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
  126. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
  127. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
  128. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +2 -6
  129. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
  130. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
  131. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
  132. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
  133. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
  134. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
  135. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
  136. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
  137. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
  138. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  139. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
  140. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
  141. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
  142. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
  143. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
  144. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
  145. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
  146. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
  147. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
  148. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
  149. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +144 -85
  150. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +20 -53
  151. package/test/unit/ngsiv2/general/https-support-test.js +2 -6
  152. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
  153. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +8 -24
  154. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +146 -65
  155. package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
  156. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
  157. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +11 -20
  158. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
  159. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
  160. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +1 -2
  161. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +3 -5
  162. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
  163. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
  164. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +13 -156
  165. package/test/unit/ngsiv2/provisioning/device-registration_test.js +9 -13
  166. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -10
  167. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
  168. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -8
  169. package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
  170. package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
  171. package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
  172. package/.nyc_output/processinfo/index.json +0 -1
  173. package/doc/config-basic-example.js +0 -20
  174. package/doc/development.md +0 -285
  175. package/doc/howto.md +0 -645
  176. package/doc/installationguide.md +0 -370
  177. package/doc/operations.md +0 -127
  178. package/doc/usermanual.md +0 -900
  179. package/lib/plugins/bidirectionalData.js +0 -356
  180. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
  181. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -599
  182. /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
  183. /package/doc/{echo.js → devel/echo.js} +0 -0
  184. /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
@@ -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',
@@ -321,7 +310,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
321
310
  });
322
311
 
323
312
  it('subscribe requests use auth header', function (done) {
324
- iotAgentLib.getDevice('Light1', 'smartgondor', 'electricity', function (error, device) {
313
+ iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
325
314
  iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
326
315
  should.not.exist(error);
327
316
 
@@ -342,7 +331,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
342
331
 
343
332
  contextBrokerMock.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '').reply(204);
344
333
 
345
- iotAgentLib.getDevice('Light1', 'smartgondor', 'electricity', function (error, device) {
334
+ iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
346
335
  iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
347
336
  iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
348
337
  contextBrokerMock.done();
@@ -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
  });
@@ -210,7 +210,7 @@ describe('NGSI-v2 - HTTPS support tests', function () {
210
210
  });
211
211
 
212
212
  it('should send the appropriate request to the Context Broker', function (done) {
213
- iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
213
+ iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
214
214
  iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
215
215
  should.not.exist(error);
216
216
 
@@ -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);
@@ -202,14 +202,7 @@ describe('NGSI-v2 - Polling commands', function () {
202
202
  };
203
203
 
204
204
  beforeEach(function (done) {
205
- statusAttributeMock = nock('http://192.168.1.1:1026')
206
- .matchHeader('fiware-service', 'smartgondor')
207
- .matchHeader('fiware-servicepath', 'gardens')
208
- .patch(
209
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
210
- utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')
211
- )
212
- .reply(204);
205
+ statusAttributeMock = nock('http://192.168.1.1:1026');
213
206
 
214
207
  iotAgentLib.register(device3, function (error) {
215
208
  done();
@@ -299,8 +292,8 @@ describe('NGSI-v2 - Polling commands', function () {
299
292
  statusAttributeMock = nock('http://192.168.1.1:1026')
300
293
  .matchHeader('fiware-service', 'smartgondor')
301
294
  .matchHeader('fiware-servicepath', 'gardens')
302
- .patch(
303
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
295
+ .post(
296
+ '/v2/entities?options=upsert',
304
297
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')
305
298
  )
306
299
  .reply(204);
@@ -352,8 +345,8 @@ describe('NGSI-v2 - Polling commands', function () {
352
345
  statusAttributeMock = nock('http://192.168.1.1:1026')
353
346
  .matchHeader('fiware-service', 'smartgondor')
354
347
  .matchHeader('fiware-servicepath', 'gardens')
355
- .patch(
356
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
348
+ .post(
349
+ '/v2/entities?options=upsert',
357
350
  utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')
358
351
  )
359
352
  .reply(204);
@@ -361,8 +354,8 @@ describe('NGSI-v2 - Polling commands', function () {
361
354
  statusAttributeMock = nock('http://192.168.1.1:1026')
362
355
  .matchHeader('fiware-service', 'smartgondor')
363
356
  .matchHeader('fiware-servicepath', 'gardens')
364
- .patch(
365
- '/v2/entities/Robot:r2d2/attrs?type=Robot',
357
+ .post(
358
+ '/v2/entities?options=upsert',
366
359
  utils.readExampleFile(
367
360
  './test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json'
368
361
  )
@@ -468,16 +461,7 @@ describe('NGSI-v2 - Polling commands expressions', function () {
468
461
  };
469
462
 
470
463
  beforeEach(function (done) {
471
- statusAttributeMock = nock('http://192.168.1.1:1026')
472
- .matchHeader('fiware-service', 'smartgondor')
473
- .matchHeader('fiware-servicepath', 'gardens')
474
- .patch(
475
- '/v2/entities/RobotExp:r2d4/attrs?type=RobotExp',
476
- utils.readExampleFile(
477
- './test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json'
478
- )
479
- )
480
- .reply(204);
464
+ statusAttributeMock = nock('http://192.168.1.1:1026');
481
465
 
482
466
  iotAgentLib.register(device4, function (error) {
483
467
  done();