iotagent-node-lib 2.20.0 → 2.23.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 (68) hide show
  1. package/.nyc_output/6e3d7795-bf8c-4a50-bd2f-f8221f27aeae.json +1 -0
  2. package/.nyc_output/processinfo/6e3d7795-bf8c-4a50-bd2f-f8221f27aeae.json +1 -0
  3. package/.nyc_output/processinfo/index.json +1 -1
  4. package/.readthedocs.yml +3 -1
  5. package/CHANGES_NEXT_RELEASE +1 -0
  6. package/README.md +2 -2
  7. package/config +0 -0
  8. package/doc/Contribution.md +3 -3
  9. package/doc/advanced-topics.md +19 -8
  10. package/doc/api.md +14 -3
  11. package/doc/expressionLanguage.md +17 -0
  12. package/doc/northboundinteractions.md +40 -33
  13. package/doc/operations.md +8 -5
  14. package/doc/requirements.txt +4 -0
  15. package/{docs → doc}/roadmap.md +21 -6
  16. package/doc/usermanual.md +4 -4
  17. package/docker/Mosquitto/Dockerfile +28 -12
  18. package/docker/Mosquitto/Dockerfile.debian +38 -0
  19. package/docker/Mosquitto/Dockerfile.debian~ +23 -0
  20. package/docker/Mosquitto/README.md +8 -7
  21. package/docker/Mosquitto/startMosquitto.sh +8 -0
  22. package/lib/fiware-iotagent-lib.js +1 -0
  23. package/lib/jexlTranformsMap.js +3 -1
  24. package/lib/model/Group.js +2 -1
  25. package/lib/model/dbConn.js +4 -0
  26. package/lib/plugins/expressionPlugin.js +56 -21
  27. package/lib/plugins/multiEntity.js +43 -49
  28. package/lib/plugins/multiEntity.js_avg2 +343 -0
  29. package/lib/plugins/pluginUtils.js +16 -0
  30. package/lib/services/commands/commandService.js +29 -2
  31. package/lib/services/common/iotManagerService.js +2 -1
  32. package/lib/services/devices/deviceRegistryMemory.js +13 -2
  33. package/lib/services/devices/deviceRegistryMongoDB.js +15 -7
  34. package/lib/services/devices/deviceService.js +52 -16
  35. package/lib/services/groups/groupRegistryMongoDB.js +13 -12
  36. package/lib/services/ngsi/entities-NGSI-LD.js +13 -4
  37. package/lib/services/ngsi/entities-NGSI-v2.js +64 -13
  38. package/lib/services/ngsi/ngsiService.js +3 -3
  39. package/lib/services/northBound/contextServer-NGSI-LD.js +20 -1
  40. package/lib/services/northBound/contextServer-NGSI-v2.js +39 -30
  41. package/lib/services/northBound/contextServerUtils.js +10 -10
  42. package/lib/services/northBound/deviceProvisioningServer.js +4 -1
  43. package/lib/templates/createDevice.json +13 -2
  44. package/lib/templates/createDeviceLax.json +2 -3
  45. package/lib/templates/updateDevice.json +13 -2
  46. package/package.json +26 -26
  47. package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +14 -0
  48. package/test/unit/mongodb/mongoDBUtils.js +2 -2
  49. package/test/unit/mongodb/mongodb-group-registry-test.js +1 -1
  50. package/test/unit/mongodb/mongodb-registry-test.js +2 -3
  51. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +2 -1
  52. package/test/unit/ngsi-ld/examples/contextRequests/updateContextLanguageProperties1.json +15 -0
  53. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +315 -1
  54. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +112 -0
  55. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +1 -1
  56. package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +8 -0
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +6 -0
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +2 -0
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +12 -0
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +27 -0
  61. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +72 -9
  62. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +151 -0
  63. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +63 -0
  64. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js_avg2 +1224 -0
  65. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +60 -0
  66. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +2 -1
  67. package/.nyc_output/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +0 -1
  68. package/.nyc_output/processinfo/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +0 -1
@@ -705,6 +705,66 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
705
705
  }
706
706
  );
707
707
 
708
+ describe('When a device provisioning request arrives to the IoTA and entityNameExp was configured at group level', function () {
709
+ const options = {
710
+ url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
711
+ method: 'POST',
712
+ json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json'),
713
+ headers: {
714
+ 'fiware-service': 'smartgondor',
715
+ 'fiware-servicepath': '/gardens'
716
+ }
717
+ };
718
+ const groupCreation = {
719
+ url: 'http://localhost:4041/iot/services',
720
+ method: 'POST',
721
+ json: {
722
+ services: [
723
+ {
724
+ resource: '/Thing',
725
+ apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
726
+ /*jshint camelcase: false */
727
+ entity_type: 'MicroLights',
728
+ entityNameExp: 'EntityNameByExp',
729
+ cbroker: 'http://192.168.1.1:1026'
730
+ }
731
+ ]
732
+ },
733
+ headers: {
734
+ 'fiware-service': 'smartgondor',
735
+ 'fiware-servicepath': '/gardens'
736
+ }
737
+ };
738
+
739
+ beforeEach(function (done) {
740
+ nock.cleanAll();
741
+ contextBrokerMock = nock('http://192.168.1.1:1026')
742
+ .matchHeader('fiware-service', 'smartgondor')
743
+ .matchHeader('fiware-servicepath', '/gardens')
744
+ .post(
745
+ '/v2/entities?options=upsert',
746
+ utils.readExampleFile(
747
+ './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json'
748
+ )
749
+ )
750
+ .reply(204);
751
+
752
+ done();
753
+ });
754
+
755
+ it('should store the entity name defined by expression', function (done) {
756
+ request(groupCreation, function (error, response, body) {
757
+ request(options, function (error, response, body) {
758
+ iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
759
+ should.exist(results.devices[0].name);
760
+ results.devices[0].name.should.equal('EntityNameByExp');
761
+ done();
762
+ });
763
+ });
764
+ });
765
+ });
766
+ });
767
+
708
768
  describe(
709
769
  'When a device provisioning request with static attributes arrives to the IoTA' +
710
770
  ' and same static attribute is also configured at group level',
@@ -484,10 +484,11 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
484
484
 
485
485
  it('should provision the explicitAttrs attribute appropriately', function (done) {
486
486
  request(optionsUpdate, function (error, response, body) {
487
+ should.not.exist(error);
488
+ response.statusCode.should.equal(204);
487
489
  request(optionsGetDevice, function (error, response, body) {
488
490
  should.not.exist(error);
489
491
  response.statusCode.should.equal(200);
490
-
491
492
  body.explicitAttrs.should.equal(false);
492
493
  done();
493
494
  });