Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "cgroups" literal in configuration group operations URL #775

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8f10be2
Update iotManagerService.js
Jagatjot Jan 18, 2019
d765faf
Update commandLine.js
Jagatjot Feb 19, 2019
bcfaeae
Update commandLine.js
Jagatjot Feb 19, 2019
dcc6752
Update deviceGroupAdministrationServer.js
Jagatjot Feb 19, 2019
244e8f4
Update deviceGroupAdministrationServer.js
Jagatjot Apr 16, 2019
18daef2
Update iotManagerService.js
Jagatjot Apr 17, 2019
14bf7ee
Update iotManagerService.js
Jagatjot Apr 17, 2019
fb366b6
Update commandLine.js
Jagatjot Apr 17, 2019
8a3db3c
Update iotManagerService.js
Jagatjot Apr 17, 2019
8bc477d
Update iotManagerService.js
Jagatjot Apr 17, 2019
7b27397
Update iotam-autoregistration-test.js
Jagatjot Apr 17, 2019
7c85105
Update iotam-autoregistration-test.js
Jagatjot Apr 17, 2019
dc3e21f
Update mongodb-group-registry-test.js
Jagatjot Apr 17, 2019
d74de4b
Update device-group-api-test.js
Jagatjot Apr 17, 2019
3ef44e0
Update device-group-utils_test.js
Jagatjot Apr 17, 2019
29ac219
Update capture-configuration-inPlugins_test.js
Jagatjot Apr 17, 2019
3896252
Update singleConfigurationMode-test.js
Jagatjot Apr 17, 2019
9274e02
Update singleConfigurationMode-test.js
Jagatjot Apr 17, 2019
86339ac
Update bidirectional-plugin_test.js
Jagatjot Apr 17, 2019
4b6e21f
Update bidirectional-plugin_test.js
Jagatjot Apr 17, 2019
1f74e30
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
8fe63ec
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
5e0d322
Update README.md
Jagatjot Apr 17, 2019
3075c56
Update iotam-autoregistration-test.js
Jagatjot Apr 17, 2019
900adb5
Update iotam-autoregistration-test.js
Jagatjot Apr 17, 2019
e3616eb
Update mongodb-group-registry-test.js
Jagatjot Apr 17, 2019
f0e5cad
Update device-group-api-test.js
Jagatjot Apr 17, 2019
fcb2b03
Update device-group-utils_test.js
Jagatjot Apr 17, 2019
dbd9046
Update capture-configuration-inPlugins_test.js
Jagatjot Apr 17, 2019
6374302
Update singleConfigurationMode-test.js
Jagatjot Apr 17, 2019
81d869b
Update singleConfigurationMode-test.js
Jagatjot Apr 17, 2019
8362de0
Update bidirectional-plugin_test.js
Jagatjot Apr 17, 2019
2c0a1f3
Update bidirectional-plugin_test.js
Jagatjot Apr 17, 2019
d091b66
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
feb692a
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
e826782
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
60b07ce
Update mongodb-group-registry-test.js
Jagatjot Apr 17, 2019
5a6d0d5
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
de2df5e
Update bidirectional-plugin_test.js
Jagatjot Apr 17, 2019
17f7653
Update singleConfigurationMode-test.js
Jagatjot Apr 17, 2019
5dbddeb
Update bidirectional-plugin_test.js
Jagatjot Apr 17, 2019
0ab3ffa
Update device-group-api-test.js
Jagatjot Apr 17, 2019
afa2b09
Update singleConfigurationMode-test.js
Jagatjot Apr 17, 2019
fd72b22
Update contextBrokerOAuthSecurityAccess-test.js
Jagatjot Apr 17, 2019
d4c83de
Update iotam-autoregistration-test.js
Jagatjot Apr 22, 2019
cbd26c6
Update iotam-autoregistration-test.js
Jagatjot Apr 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ The IoT Agents provide two means to define those device groups:
- Static **Type Configuration**: configuring the `ngsi.types` property in the
`config.js` file.
- Dynamic **Configuration API**: making use of the API URLS in the
configuration URI, `/iot/services`. Please, note that the configuration API
configuration URI, `/iot/services`or `/iot/cgroups` . Please, note that the configuration API
manage servers under an URL that requires the `server.name` parameter to be
set (the name of the IoT Agent we are using). If no name is configured
`default` is taken as the default one.
Expand Down Expand Up @@ -764,7 +764,7 @@ same fields in the database model.
| static_attributes | staticAttributes | this attributes will be added to all the entities of this group 'as is'. |
| internal_attributes | internalAttributes | optional section with free format, to allow specific IoT Agents to store information along with the devices in the Device Registry. |

##### POST /iot/services
##### POST /iot/services or /iot/cgroups

Creates a set of device groups for the given service and service path. The
service and subservice information will taken from the headers, overwritting any
Expand Down Expand Up @@ -816,7 +816,7 @@ Returns:
- 400 WRONG_SYNTAX if the body doesn't comply with the schema.
- 500 SERVER ERROR if there was any error not contemplated above.

##### GET /iot/services
##### GET /iot/services or /iot/cgroups

Retrieves device groups from the database. If the servicepath header has the
wildcard expression, `/*`, all the subservices for the service are returned. The
Expand All @@ -828,7 +828,7 @@ Returns:
- 400 MISSING_HEADERS if any of the mandatory headers is not present.
- 500 SERVER ERROR if there was any error not contemplated above.

##### PUT /iot/services
##### PUT /iot/services or /iot/cgroups

Modifies the information for a device group configuration, identified by the
`resource` and `apikey` query parameters. Takes a device group body as the
Expand All @@ -850,7 +850,7 @@ Returns:
- 400 MISSING_HEADERS if any of the mandatory headers is not present.
- 500 SERVER ERROR if there was any error not contemplated above.

##### DELETE /iot/services
##### DELETE /iot/services or /iot/cgroups

Removes a device group configuration from the DB, specified by the `resource`
and `apikey` query parameters.
Expand Down
8 changes: 4 additions & 4 deletions lib/services/northBound/deviceGroupAdministrationServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,21 @@ function handleDeleteDeviceGroups(req, res, next) {
* @param {Object} router Express request router object.
*/
function loadContextRoutes(router) {
router.post('/iot/services',
router.post('/iot/:services?/:cgroups?',
restUtils.checkRequestAttributes('headers', mandatoryHeaders),
restUtils.checkBody(templateGroup),
handleCreateDeviceGroup);

router.get('/iot/services',
router.get('/iot/:services?/:cgroups?',
restUtils.checkRequestAttributes('headers', mandatoryHeaders),
handleListDeviceGroups);

router.put('/iot/services',
router.put('/iot/:services?/:cgroups?',
restUtils.checkRequestAttributes('headers', mandatoryHeaders),
restUtils.checkRequestAttributes('query', mandatoryParameters),
handleModifyDeviceGroups);

router.delete('/iot/services',
router.delete('/iot/:services?/:cgroups?',
restUtils.checkRequestAttributes('headers', mandatoryHeaders),
restUtils.checkRequestAttributes('query', mandatoryParameters),
handleDeleteDeviceGroups);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/general/contextBrokerOAuthSecurityAccess-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr
'fiware-servicepath': '/testingPath'
}
};

var values = [
{
name: 'status',
Expand Down
112 changes: 112 additions & 0 deletions test/unit/general/iotam-autoregistration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,43 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
'fiware-servicepath': 'theSubService'
}
},
optionsCreationcgroups = {
url: 'http://localhost:4041/iot/cgroups',
method: 'POST',
json: {
services: [
{
resource: '/deviceTest',
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
entity_type: 'SensorMachine',
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
cbHost: 'http://unexistentHost:1026',
commands: [
{
name: 'wheel1',
type: 'Wheel'
}
],
lazy: [
{
name: 'luminescence',
type: 'Lumens'
}
],
attributes: [
{
name: 'status',
type: 'Boolean'
}
]
}
]
},
headers: {
'fiware-service': 'theService',
'fiware-servicepath': 'theSubService'
}
},
optionsCreationStatic = {
url: 'http://localhost:4041/iot/services',
method: 'POST',
Expand Down Expand Up @@ -172,6 +209,44 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
'fiware-servicepath': 'theSubService'
}
},
optionsCreationStaticcgroups = {
url: 'http://localhost:4041/iot/cgroups',
method: 'POST',
json: {
services: [
{
resource: '/deviceTest',
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
entity_type: 'SensorMachine',
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
cbHost: 'http://unexistentHost:1026',
commands: [
{
name: 'wheel1',
type: 'Wheel'
}
],
static_attributes: [
{
name: 'position',
type: 'location',
values: '123,12'
}
],
attributes: [
{
name: 'status',
type: 'Boolean'
}
]
}
]
},
headers: {
'fiware-service': 'theService',
'fiware-servicepath': 'theSubService'
}
},
optionsDelete = {
url: 'http://localhost:4041/iot/services',
method: 'DELETE',
Expand All @@ -185,6 +260,19 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
}
},
optionsDeletecgroups = {
url: 'http://localhost:4041/iot/cgroups',
method: 'DELETE',
json: {},
headers: {
'fiware-service': 'theService',
'fiware-servicepath': 'theSubService'
},
qs: {
resource: '/deviceTest',
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
}
},
iotamMock;

describe('IoT Manager autoregistration', function() {
Expand Down Expand Up @@ -300,6 +388,14 @@ describe('IoT Manager autoregistration', function() {
done();
});
});

it('should update the registration in the IoT Manager', function(done) {
request(optionsCreationcgroups, function(error, result, body) {
should.not.exist(error);
iotamMock.done();
done();
});
});
});

describe('When a service is removed from the IoT Agent', function() {
Expand Down Expand Up @@ -336,6 +432,14 @@ describe('IoT Manager autoregistration', function() {
done();
});
});

it('should update the registration in the IoT Manager', function(done) {
request(optionsDeletecgroups, function(error, result, body) {
should.not.exist(error);
iotamMock.done();
done();
});
});
});

describe('When a new service with static attributes is created in the IoT Agent', function() {
Expand Down Expand Up @@ -372,5 +476,13 @@ describe('IoT Manager autoregistration', function() {
done();
});
});

it('should update the registration in the IoT Manager', function(done) {
request(optionsCreationStaticcgroups, function(error, result, body) {
should.not.exist(error);
iotamMock.done();
done();
});
});
});
});
117 changes: 116 additions & 1 deletion test/unit/mongodb/mongodb-group-registry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,48 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
'fiware-servicepath': '/testingPath'
}
},
optionsCreation = {
url: 'http://localhost:4041/iot/cgroups',
method: 'POST',
json: {
services: [
{
resource: '/deviceTest',
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
entity_type: 'Light',
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
cbHost: 'http://unexistentHost:1026',
commands: [
{
name: 'wheel1',
type: 'Wheel'
}
],
lazy: [
{
name: 'luminescence',
type: 'Lumens'
}
],
attributes: [
{
name: 'status',
type: 'Boolean'
}
],
internal_attributes: [
{
customField: 'customValue'
}
]
}
]
},
headers: {
'fiware-service': 'TestService',
'fiware-servicepath': '/testingPath'
}
},
optionsDelete = {
url: 'http://localhost:4041/iot/services',
method: 'DELETE',
Expand All @@ -115,6 +157,19 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
}
},
optionsDelete = {
url: 'http://localhost:4041/iot/cgroups',
method: 'DELETE',
json: {},
headers: {
'fiware-service': 'TestService',
'fiware-servicepath': '/testingPath'
},
qs: {
resource: '/deviceTest',
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
}
},
optionsList = {
url: 'http://localhost:4041/iot/services',
method: 'GET',
Expand All @@ -124,6 +179,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
'fiware-servicepath': '/*'
}
},
optionsList = {
url: 'http://localhost:4041/iot/cgroups',
method: 'GET',
json: {},
headers: {
'fiware-service': 'TestService',
'fiware-servicepath': '/*'
}
},
optionsUpdate = {
url: 'http://localhost:4041/iot/services',
method: 'PUT',
Expand Down Expand Up @@ -166,6 +230,48 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
}
},
optionsUpdate = {
url: 'http://localhost:4041/iot/cgroups',
method: 'PUT',
json: {
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
cbHost: 'http://anotherUnexistentHost:1026',
commands: [
{
name: 'wheel1',
type: 'Wheel'
}
],
lazy: [
{
name: 'luminescence',
type: 'Lumens'
}
],
attributes: [
{
name: 'status',
type: 'Boolean'
}
],
static_attributes: [
{
name: 'bootstrapServer',
type: 'Address',
value: '127.0.0.1'
}
]
},
headers: {
'fiware-service': 'TestService',
'fiware-servicepath': '/testingPath'
},
qs: {
resource: '/deviceTest',
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
}
},
optionsGet = {
url: 'http://localhost:4041/iot/services',
method: 'GET',
Expand All @@ -175,6 +281,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
'fiware-servicepath': '/testingPath'
}
},
optionsGet = {
url: 'http://localhost:4041/iot/cgroups',
method: 'GET',
json: {},
headers: {
'fiware-service': 'TestService',
'fiware-servicepath': '/testingPath'
}
},
iotAgentDb;

describe('MongoDB Group Registry test', function() {
Expand Down Expand Up @@ -358,7 +473,7 @@ describe('MongoDB Group Registry test', function() {
'fiware-servicepath': '/*'
}
};

beforeEach(function(done) {
var optionsCreationList = [],
creationFns = [];
Expand Down
Loading