Skip to content

Commit

Permalink
Merge fd72b22 into c1852d3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagatjot committed Apr 17, 2019
2 parents c1852d3 + fd72b22 commit 6e72bdc
Show file tree
Hide file tree
Showing 11 changed files with 514 additions and 11 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -717,7 +717,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 @@ -766,7 +766,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 @@ -818,7 +818,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 @@ -830,7 +830,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 @@ -852,7 +852,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
Expand Up @@ -264,21 +264,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
Expand Up @@ -754,7 +754,7 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr
'fiware-servicepath': '/testingPath'
}
};

var values = [
{
name: 'status',
Expand Down
88 changes: 88 additions & 0 deletions test/unit/general/iotam-autoregistration-test.js
Expand Up @@ -134,6 +134,43 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'),
'fiware-servicepath': 'theSubService'
}
},
optionsCreation = {
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'
}
},
optionsCreationStatic = {
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'
}
},
optionsDelete = {
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
117 changes: 116 additions & 1 deletion test/unit/mongodb/mongodb-group-registry-test.js
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

0 comments on commit 6e72bdc

Please sign in to comment.