From 7970349708ab2c7c0fd8bf1f2fe2904e4a443354 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 14 Sep 2023 15:46:08 +0200 Subject: [PATCH 1/4] remove bidirectional plugin --- lib/iotagent-ul.js | 6 +- test/unit/ngsiv2/bidirectionalityHttp-test.js | 231 ------------------ 2 files changed, 3 insertions(+), 234 deletions(-) delete mode 100644 test/unit/ngsiv2/bidirectionalityHttp-test.js diff --git a/lib/iotagent-ul.js b/lib/iotagent-ul.js index 2b6c179b..d6e17316 100644 --- a/lib/iotagent-ul.js +++ b/lib/iotagent-ul.js @@ -188,9 +188,9 @@ function start(newConfig, callback) { iotAgentLib.setUpdatingHandler(deviceUpdatingHandler); iotAgentLib.setDataUpdateHandler(updateHandler); - iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); - iotAgentLib.addConfigurationProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.groupProvision); - iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); + // iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); + // iotAgentLib.addConfigurationProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.groupProvision); + // iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); if (config.getConfig().configRetrieval) { iotAgentLib.setNotificationHandler(configurationNotificationHandler); diff --git a/test/unit/ngsiv2/bidirectionalityHttp-test.js b/test/unit/ngsiv2/bidirectionalityHttp-test.js deleted file mode 100644 index 9d5fd761..00000000 --- a/test/unit/ngsiv2/bidirectionalityHttp-test.js +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright 2016 Telefonica Investigación y Desarrollo, S.A.U - * - * This file is part of iotagent-ul - * - * iotagent-ul is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the License, - * or (at your option) any later version. - * - * iotagent-ul is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with iotagent-ul. - * If not, seehttp://www.gnu.org/licenses/. - * - * For those usages not covered by the GNU Affero General Public License - * please contact with::[iot_support@tid.es] - * - * Modified by: Fernando Méndez, Daniel Calvo - ATOS Research & Innovation - */ - -/* eslint-disable no-unused-vars */ - -const iotagentUl = require('../../../'); -const config = require('./config-test.js'); -const nock = require('nock'); -const iotAgentLib = require('iotagent-node-lib'); -const should = require('should'); - -const utils = require('../../utils'); -const request = utils.request; -let mockedClientServer; -let contextBrokerMock; - -describe('Data Bidirectionality: HTTP', function () { - const notificationOptions = { - url: 'http://localhost:' + config.iota.server.port + '/notify', - method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/subscriptionRequests/bidirectionalNotification.json'), - headers: { - 'fiware-service': 'smartgondor', - 'fiware-servicepath': '/gardens' - } - }; - - afterEach(function (done) { - nock.cleanAll(); - - iotAgentLib.clearAll(function () { - iotagentUl.stop(done); - }); - }); - - describe('When a bidirectional attribute is set and a new value arrives to a device without endpoint', function () { - beforeEach(function (done) { - const provisionOptions = { - url: 'http://localhost:' + config.iota.server.port + '/iot/devices', - method: 'POST', - json: utils.readExampleFile('./test/deviceProvisioning/provisionCommandBidirectional.json'), - headers: { - 'fiware-service': 'smartgondor', - 'fiware-servicepath': '/gardens' - } - }; - - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/subscriptions', - utils.readExampleFile( - './test/unit/ngsiv2/subscriptionRequests/bidirectionalSubscriptionRequest.json' - ) - ) - .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' }); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/createBidirectionalDevice.json') - ) - .reply(204); - - iotagentUl.start(config, function (error) { - request(provisionOptions, function (error, response, body) { - done(); - }); - }); - }); - - it('should return a 200 OK', function (done) { - request(notificationOptions, function (error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(200); - done(); - }); - }); - - it('should leave the data in the polling queue', function (done) { - request(notificationOptions, function (error, response, body) { - iotAgentLib.commandQueue('smartgondor', '/gardens', 'MQTT_2', function (error, list) { - should.not.exist(error); - - list.commands.length.should.equal(3); - done(); - }); - }); - }); - - it('should send all the data from the notification in command syntax', function (done) { - request(notificationOptions, function (error, response, body) { - iotAgentLib.commandQueue('smartgondor', '/gardens', 'MQTT_2', function (error, list) { - let latitudeFound = false; - let longitudeFound = false; - let pointFound = false; - - for (let i = 0; i < list.commands.length; i++) { - if ( - list.commands[i].name === 'location' && - list.commands[i].type === 'geo:point' && - list.commands[i].value === '12.4, -9.6' - ) { - pointFound = true; - } - - if ( - list.commands[i].name === 'latitude' && - list.commands[i].type === 'Number' && - list.commands[i].value === -9.6 - ) { - latitudeFound = true; - } - - if ( - list.commands[i].name === 'longitude' && - list.commands[i].type === 'Number' && - list.commands[i].value === 12.4 - ) { - longitudeFound = true; - } - } - - pointFound.should.equal(true); - latitudeFound.should.equal(true); - longitudeFound.should.equal(true); - - done(); - }); - }); - }); - }); - - describe('When a bidirectional attribute is set and a new value arrives to a device with endpoint', function () { - beforeEach(function (done) { - const provisionOptions = { - url: 'http://localhost:' + config.iota.server.port + '/iot/devices', - method: 'POST', - json: utils.readExampleFile('./test/deviceProvisioning/provisionCommandBidirectionalWithUrl.json'), - headers: { - 'fiware-service': 'smartgondor', - 'fiware-servicepath': '/gardens' - } - }; - - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/subscriptions', - utils.readExampleFile( - './test/unit/ngsiv2/subscriptionRequests/bidirectionalSubscriptionRequest.json' - ) - ) - .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' }); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/createBidirectionalDevice.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8') - .reply(204); - - mockedClientServer = nock('http://localhost:9876') - .post('/command', 'MQTT_2@location|12.4, -9.6') - .reply(200, '') - .post('/command', 'MQTT_2@latitude|-9.6') - .reply(200, '') - .post('/command', 'MQTT_2@longitude|12.4') - .reply(200, ''); - - iotagentUl.start(config, function (error) { - request(provisionOptions, function (error, response, body) { - done(); - }); - }); - }); - - it('should return a 200 OK', function (done) { - request(notificationOptions, function (error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(200); - done(); - }); - }); - - it('should send all the data from the notification in command syntax', function (done) { - request(notificationOptions, function (error, response, body) { - mockedClientServer.done(); - done(); - }); - }); - }); -}); From 25b5c1f0e542c2be70d9fddc04e15aeec2560e48 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Fri, 15 Sep 2023 10:18:13 +0200 Subject: [PATCH 2/4] update CNR --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 9169e9e9..689ef2ff 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,2 +1,3 @@ +- Fix: remove bidirectional plugin (#1413) - Fix: try to use apikey from measure/group to find, update and remove device in first attempt (iota-node-lib#1426) - Fix: ensure device apikey in already provisioned device (iota-node-lib#1430, iota-node-lib#1435) From 0ac74c169df95aae75a42f6ffddd4c416b39c20c Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Fri, 15 Sep 2023 10:37:54 +0200 Subject: [PATCH 3/4] clean code --- lib/iotagent-ul.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/iotagent-ul.js b/lib/iotagent-ul.js index d6e17316..aaced1d0 100644 --- a/lib/iotagent-ul.js +++ b/lib/iotagent-ul.js @@ -188,10 +188,6 @@ function start(newConfig, callback) { iotAgentLib.setUpdatingHandler(deviceUpdatingHandler); iotAgentLib.setDataUpdateHandler(updateHandler); - // iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); - // iotAgentLib.addConfigurationProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.groupProvision); - // iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); - if (config.getConfig().configRetrieval) { iotAgentLib.setNotificationHandler(configurationNotificationHandler); } else { From e271c8a1452bc9f329f9312240405be83589c379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Mon, 18 Sep 2023 12:14:47 +0200 Subject: [PATCH 4/4] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 689ef2ff..855c5c8f 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,3 +1,3 @@ -- Fix: remove bidirectional plugin (#1413) - Fix: try to use apikey from measure/group to find, update and remove device in first attempt (iota-node-lib#1426) - Fix: ensure device apikey in already provisioned device (iota-node-lib#1430, iota-node-lib#1435) +- Remove: bidirectional plugin (iota-node-lib#1413)