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.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
- package/.github/ISSUE_TEMPLATE/config.yml +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
- package/.github/advanced-issue-labeler.yml +30 -0
- package/.github/workflows/issue-labeler.yml +43 -0
- package/CHANGES_NEXT_RELEASE +0 -2
- package/config.js +5 -5
- package/doc/api.md +1483 -298
- package/doc/deprecated.md +7 -1
- package/doc/development.md +120 -0
- package/doc/howto.md +58 -62
- package/doc/installationguide.md +3 -11
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/lib/commonConfig.js +7 -10
- package/lib/fiware-iotagent-lib.js +0 -10
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/model/Device.js +0 -1
- package/lib/model/Group.js +0 -1
- package/lib/model/dbConn.js +1 -7
- package/lib/plugins/bidirectionalData.js +8 -26
- package/lib/plugins/expressionPlugin.js +8 -40
- package/lib/plugins/jexlParser.js +28 -0
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/common/iotManagerService.js +0 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +10 -10
- package/lib/services/devices/deviceService.js +16 -20
- package/lib/services/devices/devices-NGSI-v2.js +2 -5
- package/lib/services/ngsi/entities-NGSI-LD.js +16 -60
- package/lib/services/ngsi/entities-NGSI-v2.js +179 -119
- package/lib/services/northBound/deviceProvisioningServer.js +17 -17
- package/lib/templates/createDevice.json +5 -6
- package/lib/templates/createDeviceLax.json +6 -8
- package/lib/templates/deviceGroup.json +1 -5
- package/lib/templates/updateDevice.json +9 -2
- package/lib/templates/updateDeviceLax.json +14 -5
- package/package.json +1 -1
- package/scripts/legacy_expression_tool/README.md +262 -0
- package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
- package/scripts/legacy_expression_tool/requirements.txt +3 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +3 -13
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +8 -8
- package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +1 -1
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
- package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +355 -75
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +18 -51
- package/test/unit/ngsiv2/general/https-support-test.js +1 -5
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +9 -26
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +143 -57
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +1 -10
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +6 -69
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +150 -0
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -16
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +15 -55
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +1 -7
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -9
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -7
- package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
- package/doc/advanced-topics.md +0 -626
- package/doc/expressionLanguage.md +0 -762
- package/lib/plugins/expressionParser.js +0 -205
- package/test/unit/expressions/expression-test.js +0 -197
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -882
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -951
- 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
|
-
.
|
|
133
|
-
'/v2/entities
|
|
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
|
-
.
|
|
173
|
-
'/v2/entities
|
|
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
|
-
.
|
|
209
|
-
'/v2/entities
|
|
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
|
-
.
|
|
400
|
-
'/v2/entities
|
|
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
|
-
.
|
|
540
|
-
'/v2/entities
|
|
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
|
-
.
|
|
628
|
-
'/v2/entities
|
|
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
|
-
.
|
|
641
|
-
'/v2/entities
|
|
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
|
-
|
|
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
|
|
849
|
-
.
|
|
850
|
-
'/v2/entities
|
|
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
|
-
.
|
|
273
|
-
'/v2/entities
|
|
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
|
-
.
|
|
297
|
-
'/v2/entities
|
|
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
|
-
.
|
|
304
|
-
'/v2/entities
|
|
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
|
-
.
|
|
357
|
-
'/v2/entities
|
|
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
|
-
.
|
|
366
|
-
'/v2/entities
|
|
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();
|