diff --git a/.jshintrc b/.jshintrc index 517729321..2f835bc6c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -18,6 +18,7 @@ "expr": true, "unused": "vars", "esversion": 6, + "laxbreak": true, "globals": { "describe":true, "it": true, diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..8238852e0 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "arrowParens": "always", + "bracketSpacing": true, + "singleQuote": true, + "parser": "flow", + "printWidth": 120, + "trailingComma": "none", + "tabWidth": 4 +} \ No newline at end of file diff --git a/bin/agentConsole.js b/bin/agentConsole.js index 9ddfa4cab..acd4409b4 100755 --- a/bin/agentConsole.js +++ b/bin/agentConsole.js @@ -32,44 +32,46 @@ var readline = require('readline'), separator = '\n\n\t'; var commands = { - 'start': { + start: { parameters: [], description: '\tStart the IoT Agent', handler: startApp }, - 'stop': { + stop: { parameters: [], description: '\tStop the IoT Agent', handler: stopApp }, - 'register': { + register: { parameters: ['id', 'type'], - description: '\tRegister a new device in the IoT Agent. The attributes to register will be extracted from the\n' + + description: + '\tRegister a new device in the IoT Agent. The attributes to register will be extracted from the\n' + '\ttype configuration', handler: registerDevice }, - 'unregister': { + unregister: { parameters: ['id', 'type'], description: '\tUnregister the selected device', handler: unregisterDevice }, - 'showConfig': { + showConfig: { parameters: [], description: '\tShow the current configuration file', handler: showConfig }, - 'config': { + config: { parameters: ['newConfig'], description: '\tChange the configuration file to a new one', handler: changeConfig }, - 'updatevalue': { + updatevalue: { parameters: ['deviceId', 'deviceType', 'attributes'], - description: '\tUpdate a device value in the Context Broker. The attributes should be triads with the following\n' + + description: + '\tUpdate a device value in the Context Broker. The attributes should be triads with the following\n' + '\tformat: "name/type/value" sepparated by commas.', handler: updateDeviceValue }, - 'listdevices': { + listdevices: { parameters: [], description: '\tList all the devices that have been registered in this IoT Agent session\n', handler: listDevices @@ -77,11 +79,11 @@ var commands = { }; function handleError(message) { - return function (error) { + return function(error) { if (error) { console.log('\n\033[31mERROR:\033[0m %s', error.message); } else { - console.log(message) + console.log(message); } commandUtils.prompt(); @@ -89,7 +91,7 @@ function handleError(message) { } function listDevices() { - iotAgentLib.listDevices(config.service, config.subservice, function (error, devices) { + iotAgentLib.listDevices(config.service, config.subservice, function(error, devices) { if (error) { console.log('\n\033[31mERROR:\033[0m %s', error.message); } else { @@ -115,7 +117,6 @@ function extractAttributes(attributeString, callback) { type: fields[1] }; - if (fields[2]) { attribute.value = fields[2]; } @@ -135,8 +136,12 @@ function changeConfig(command) { } function writeHandler(id, type, attributes, callback) { - console.log('\n\nFake WRITE handler for update in entity [%s] with type [%s]\n%s\n', - id, type, JSON.stringify(attributes, null, 4)); + console.log( + '\n\nFake WRITE handler for update in entity [%s] with type [%s]\n%s\n', + id, + type, + JSON.stringify(attributes, null, 4) + ); callback(null, { id: id, @@ -146,8 +151,12 @@ function writeHandler(id, type, attributes, callback) { } function readHandler(id, type, attributes, callback) { - console.log('\n\nFake READ handler for update in entity [%s] with type [%s]\n%s\n' - , id, type, JSON.stringify(attributes, null, 4)); + console.log( + '\n\nFake READ handler for update in entity [%s] with type [%s]\n%s\n', + id, + type, + JSON.stringify(attributes, null, 4) + ); var sensorData = { id: id, @@ -181,7 +190,7 @@ function exitAgent(command) { } function registerDevice(command) { - var device = { + var device = { id: command[0], type: command[1] }; @@ -199,14 +208,23 @@ function updateDeviceValue(command) { iotAgentLib.getDevice(command[0], function(error, device) { if (device) { extractAttributes(command[2], function(error, attributes) { - iotAgentLib.update(device.name, device.type, '', attributes, device, - handleError('Device value updated')); + iotAgentLib.update( + device.name, + device.type, + '', + attributes, + device, + handleError('Device value updated') + ); }); } else { - async.waterfall([ - async.apply(extractAttributes, command[2]), - async.apply(iotAgentLib.update, command[0], command[1], '') - ], handleError('Device value updated')); + async.waterfall( + [ + async.apply(extractAttributes, command[2]), + async.apply(iotAgentLib.update, command[0], command[1], '') + ], + handleError('Device value updated') + ); } }); } @@ -223,7 +241,7 @@ function queryHandler(id, type, attributes, callback) { } function updateHandler(id, type, attributes, callback) { - console.log("Update message received for device with id [%s] and type [%s]", id, type); + console.log('Update message received for device with id [%s] and type [%s]', id, type); callback(null, { type: type, diff --git a/bin/iotAgentTester.js b/bin/iotAgentTester.js index 73b9a2a2e..8094b7faf 100755 --- a/bin/iotAgentTester.js +++ b/bin/iotAgentTester.js @@ -42,4 +42,4 @@ var commandLine = require('../lib/command/commandLine'), commandLine.init(configCb, configIot); -clUtils.initialize(commandLine.commands, 'IoT Agent tester> '); \ No newline at end of file +clUtils.initialize(commandLine.commands, 'IoT Agent tester> '); diff --git a/config-blank.js b/config-blank.js index f57209bc6..4a76214ee 100644 --- a/config-blank.js +++ b/config-blank.js @@ -33,8 +33,7 @@ var config = { deviceRegistry: { type: 'memory' }, - types: { - }, + types: {}, service: 'tester', subservice: '/test', providerUrl: 'http://192.168.56.1:4041', diff --git a/config.js b/config.js index cb6c8d3b6..7cfde892d 100644 --- a/config.js +++ b/config.js @@ -44,7 +44,7 @@ var config = { type: 'memory' }, types: { - 'Light': { + Light: { url: '/', apikey: '', type: 'Light', diff --git a/ghpages/javascripts/scale.fix.js b/ghpages/javascripts/scale.fix.js index 87a40ca71..39cdc7663 100644 --- a/ghpages/javascripts/scale.fix.js +++ b/ghpages/javascripts/scale.fix.js @@ -1,17 +1,17 @@ var metas = document.getElementsByTagName('meta'); var i; if (navigator.userAgent.match(/iPhone/i)) { - for (i=0; i 0) { - db.db().collection(collection).insertMany(docs, function(error, inserts) { - innerCb(error); - }); + db.db() + .collection(collection) + .insertMany(docs, function(error, inserts) { + innerCb(error); + }); } else { innerCb(); } @@ -130,7 +135,10 @@ function migrate(dbConfig, originDb, targetDb, service, subservice, callback) { query.service_path = subservice; } - db.db().collection(name).find(query).toArray(innerCb); + db.db() + .collection(name) + .find(query) + .toArray(innerCb); } function closeDb(db, innerCb) { @@ -143,29 +151,32 @@ function migrate(dbConfig, originDb, targetDb, service, subservice, callback) { var originDb = dbResults[0], targetDb = dbResults[1]; - async.waterfall([ - apply(getCollection, originDb, 'SERVICE', service, subservice), - generateCollectionTranslator(serviceTranslation), - apply(saveToTargetDb, targetDb, 'groups'), - apply(getCollection, originDb, 'DEVICE', service, subservice), - generateCollectionTranslator(deviceTranslation), - applyDefaultName, - applyProtocolTranslations, - apply(saveToTargetDb, targetDb, 'devices'), - apply(closeDb, originDb), - apply(closeDb, targetDb) - ], function(error) { - innerCb(error); - }); + async.waterfall( + [ + apply(getCollection, originDb, 'SERVICE', service, subservice), + generateCollectionTranslator(serviceTranslation), + apply(saveToTargetDb, targetDb, 'groups'), + apply(getCollection, originDb, 'DEVICE', service, subservice), + generateCollectionTranslator(deviceTranslation), + applyDefaultName, + applyProtocolTranslations, + apply(saveToTargetDb, targetDb, 'devices'), + apply(closeDb, originDb), + apply(closeDb, targetDb) + ], + function(error) { + innerCb(error); + } + ); } - async.waterfall([ - apply(async.series, [ - apply(connectToDb, dbConfig, originDb), - apply(connectToDb, dbConfig, targetDb) - ]), - startMigration - ], callback); + async.waterfall( + [ + apply(async.series, [apply(connectToDb, dbConfig, originDb), apply(connectToDb, dbConfig, targetDb)]), + startMigration + ], + callback + ); } exports.migrate = migrate; diff --git a/lib/commonConfig.js b/lib/commonConfig.js index 30d474242..3ae8db474 100644 --- a/lib/commonConfig.js +++ b/lib/commonConfig.js @@ -52,49 +52,49 @@ function anyIsSet(variableSet) { */ function processEnvironmentVariables() { var environmentVariables = [ - 'IOTA_CB_URL', - 'IOTA_CB_HOST', - 'IOTA_CB_PORT', - 'IOTA_CB_NGSI_VERSION', - 'IOTA_NORTH_HOST', - 'IOTA_NORTH_PORT', - 'IOTA_PROVIDER_URL', - 'IOTA_AUTH_ENABLED', - 'IOTA_AUTH_TYPE', - 'IOTA_AUTH_HEADER', - 'IOTA_AUTH_URL', - 'IOTA_AUTH_HOST', - 'IOTA_AUTH_PORT', - 'IOTA_AUTH_USER', - 'IOTA_AUTH_PASSWORD', - 'IOTA_AUTH_CLIENT_ID', - 'IOTA_AUTH_CLIENT_SECRET', - 'IOTA_AUTH_TOKEN_PATH', - 'IOTA_AUTH_PERMANENT_TOKEN', - 'IOTA_REGISTRY_TYPE', - 'IOTA_LOG_LEVEL', - 'IOTA_TIMESTAMP', - 'IOTA_IOTAM_HOST', - 'IOTA_IOTAM_PORT', - 'IOTA_IOTAM_PATH', - 'IOTA_IOTAM_PROTOCOL', - 'IOTA_IOTAM_DESCRIPTION', - 'IOTA_DEFAULT_RESOURCE', - 'IOTA_MONGO_HOST', - 'IOTA_MONGO_PORT', - 'IOTA_MONGO_DB', - 'IOTA_MONGO_REPLICASET', - 'IOTA_AUTOCAST', - 'IOTA_MONGO_PASSWORD', - 'IOTA_MONGO_AUTH_SOURCE', - 'IOTA_MONGO_RETRIES', - 'IOTA_MONGO_USER', - 'IOTA_MONGO_RETRY_TIME', - 'IOTA_SINGLE_MODE', - 'IOTA_APPEND_MODE', - 'IOTA_POLLING_EXPIRATION', - 'IOTA_POLLING_DAEMON_FREQ', - 'IOTA_MULTI_CORE' + 'IOTA_CB_URL', + 'IOTA_CB_HOST', + 'IOTA_CB_PORT', + 'IOTA_CB_NGSI_VERSION', + 'IOTA_NORTH_HOST', + 'IOTA_NORTH_PORT', + 'IOTA_PROVIDER_URL', + 'IOTA_AUTH_ENABLED', + 'IOTA_AUTH_TYPE', + 'IOTA_AUTH_HEADER', + 'IOTA_AUTH_URL', + 'IOTA_AUTH_HOST', + 'IOTA_AUTH_PORT', + 'IOTA_AUTH_USER', + 'IOTA_AUTH_PASSWORD', + 'IOTA_AUTH_CLIENT_ID', + 'IOTA_AUTH_CLIENT_SECRET', + 'IOTA_AUTH_TOKEN_PATH', + 'IOTA_AUTH_PERMANENT_TOKEN', + 'IOTA_REGISTRY_TYPE', + 'IOTA_LOG_LEVEL', + 'IOTA_TIMESTAMP', + 'IOTA_IOTAM_HOST', + 'IOTA_IOTAM_PORT', + 'IOTA_IOTAM_PATH', + 'IOTA_IOTAM_PROTOCOL', + 'IOTA_IOTAM_DESCRIPTION', + 'IOTA_DEFAULT_RESOURCE', + 'IOTA_MONGO_HOST', + 'IOTA_MONGO_PORT', + 'IOTA_MONGO_DB', + 'IOTA_MONGO_REPLICASET', + 'IOTA_AUTOCAST', + 'IOTA_MONGO_PASSWORD', + 'IOTA_MONGO_AUTH_SOURCE', + 'IOTA_MONGO_RETRIES', + 'IOTA_MONGO_USER', + 'IOTA_MONGO_RETRY_TIME', + 'IOTA_SINGLE_MODE', + 'IOTA_APPEND_MODE', + 'IOTA_POLLING_EXPIRATION', + 'IOTA_POLLING_DAEMON_FREQ', + 'IOTA_MULTI_CORE' ], iotamVariables = [ 'IOTA_IOTAM_URL', @@ -119,8 +119,12 @@ function processEnvironmentVariables() { for (var i = 0; i < environmentVariables.length; i++) { if (process.env[environmentVariables[i]]) { - logger.info(context, 'Setting %s to environment value: %s', - environmentVariables[i], process.env[environmentVariables[i]]); + logger.info( + context, + 'Setting %s to environment value: %s', + environmentVariables[i], + process.env[environmentVariables[i]] + ); } } @@ -128,7 +132,7 @@ function processEnvironmentVariables() { if (config.contextBroker === undefined) { config.contextBroker = {}; } - + if (process.env.IOTA_CB_URL) { config.contextBroker.url = process.env.IOTA_CB_URL; // Not sure if config.contextBroker.host and config.contextBroker.port are used @@ -148,7 +152,7 @@ function processEnvironmentVariables() { config.contextBroker.url += ':' + config.contextBroker.port; } } - + if (process.env.IOTA_CB_NGSI_VERSION) { config.contextBroker.ngsiVersion = process.env.IOTA_CB_NGSI_VERSION; } @@ -157,7 +161,7 @@ function processEnvironmentVariables() { if (config.server === undefined) { config.server = {}; } - + if (process.env.IOTA_NORTH_HOST) { config.server.host = process.env.IOTA_NORTH_HOST; } @@ -386,9 +390,7 @@ function getCommandRegistry() { * @return {boolean} Result of the checking */ function checkNgsi2() { - if (config.contextBroker && - config.contextBroker.ngsiVersion && - config.contextBroker.ngsiVersion === 'v2') { + if (config.contextBroker && config.contextBroker.ngsiVersion && config.contextBroker.ngsiVersion === 'v2') { return true; } diff --git a/lib/errors.js b/lib/errors.js index 9df974f27..aa11e9886 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -77,7 +77,7 @@ module.exports = { this.message = 'No device was found with id:' + id; this.code = 404; }, - AttributeNotFound: function(){ + AttributeNotFound: function() { this.name = 'ATTRIBUTE_NOT_FOUND'; this.message = 'Some of the attributes does not exist'; this.code = 404; @@ -102,8 +102,14 @@ module.exports = { }, AccessForbidden: function(token, service, subservice) { this.name = 'ACCESS_FORBIDDEN'; - this.message = 'The access to the CB was rejected for service [' + - service + '] subservice [ ' + subservice + ' ] and token [' + token + ']'; + this.message = + 'The access to the CB was rejected for service [' + + service + + '] subservice [ ' + + subservice + + ' ] and token [' + + token + + ']'; }, AuthenticationError: function(trust) { this.name = 'AUTHENTICATION_ERROR'; @@ -120,7 +126,8 @@ module.exports = { }, MismatchedService: function(service, subservice) { this.name = 'MISMATCHED_SERVICE'; - this.message = 'The declared service didn\'t match the stored one in the entity'; + /*jshint quotmark: double */ + this.message = "The declared service didn't match the stored one in the entity"; this.code = 403; }, WrongSyntax: function(msg) { @@ -130,7 +137,12 @@ module.exports = { }, CommandNotFound: function(name) { this.name = 'COMMAND_NOT_FOUND'; - this.message = 'Couldn\'t update the command because no command with the name [' + name + '] was found.'; + this.message = + /*jshint quotmark: double */ + "Couldn't update the command because no command with the name [" + + /*jshint quotmark: single */ + name + + '] was found.'; this.code = 400; }, MissingConfigParams: function(missing) { @@ -148,7 +160,9 @@ module.exports = { if (values && fields) { this.message = 'Couldn\t find device group for fields: ' + fields + ' and values: ' + values; } else { - this.message = 'Couldn\t find device group'; + /*jshint quotmark: double */ + this.message = "Couldn't find device group"; + /*jshint quotmark: single */ } this.code = 404; }, diff --git a/lib/fiware-iotagent-lib.js b/lib/fiware-iotagent-lib.js index c315a8a8b..adba86d3f 100644 --- a/lib/fiware-iotagent-lib.js +++ b/lib/fiware-iotagent-lib.js @@ -48,14 +48,17 @@ var async = require('async'), function activateStatLogs(newConfig, callback) { if (newConfig.stats && newConfig.stats.interval) { - async.series([ - apply(statsRegistry.globalLoad, { - deviceCreationRequests: 0, - deviceRemovalRequests: 0, - measureRequests: 0 - }), - apply(statsRegistry.addTimerAction, statsRegistry.logStats) - ], callback); + async.series( + [ + apply(statsRegistry.globalLoad, { + deviceCreationRequests: 0, + deviceRemovalRequests: 0, + measureRequests: 0 + }), + apply(statsRegistry.addTimerAction, statsRegistry.logStats) + ], + callback + ); } else { callback(); } @@ -79,36 +82,33 @@ function globalErrorHandler(err) { * @param {Function} callback The callback function. */ function doActivate(newConfig, callback) { - var registry, - groupRegistry, - commandRegistry, - securityService; + var registry, groupRegistry, commandRegistry, securityService; if (newConfig.contextBroker) { - if (! newConfig.contextBroker.url && newConfig.contextBroker.host && newConfig.contextBroker.port) { + if (!newConfig.contextBroker.url && newConfig.contextBroker.host && newConfig.contextBroker.port) { newConfig.contextBroker.url = 'http://' + newConfig.contextBroker.host + ':' + newConfig.contextBroker.port; - } else if (! newConfig.contextBroker.url && newConfig.contextBroker.host && !newConfig.contextBroker.port) { + } else if (!newConfig.contextBroker.url && newConfig.contextBroker.host && !newConfig.contextBroker.port) { newConfig.contextBroker.url = 'http://' + newConfig.contextBroker.host; } } if (newConfig.iotManager) { - if (! newConfig.iotManager.url && newConfig.iotManager.host && newConfig.iotManager.port) { + if (!newConfig.iotManager.url && newConfig.iotManager.host && newConfig.iotManager.port) { newConfig.iotManager.url = 'http://' + newConfig.iotManager.host + ':' + newConfig.iotManager.port; - } else if (! newConfig.iotManager.url && newConfig.iotManager.host && !newConfig.iotManager.port) { + } else if (!newConfig.iotManager.url && newConfig.iotManager.host && !newConfig.iotManager.port) { newConfig.iotManager.url = 'http://' + newConfig.iotManager.host; } } if (newConfig.authentication && newConfig.authentication.enabled) { - if (! newConfig.authentication.header) { + if (!newConfig.authentication.header) { newConfig.authentication.header = constants.AUTH_HEADER; } - if (! newConfig.authentication.url && newConfig.authentication.host && newConfig.authentication.port) { - newConfig.authentication.url = 'http://' + newConfig.authentication.host + ':' + - newConfig.authentication.port; - } else if (! newConfig.authentication.url && newConfig.authentication.host && !newConfig.authentication.port) { + if (!newConfig.authentication.url && newConfig.authentication.host && newConfig.authentication.port) { + newConfig.authentication.url = + 'http://' + newConfig.authentication.host + ':' + newConfig.authentication.port; + } else if (!newConfig.authentication.url && newConfig.authentication.host && !newConfig.authentication.port) { newConfig.authentication.url = 'http://' + newConfig.authentication.host; } } @@ -118,8 +118,7 @@ function doActivate(newConfig, callback) { logger.info(context, 'Activating IOT Agent NGSI Library.'); if (newConfig.authentication && newConfig.authentication.enabled) { - if (newConfig.authentication.type && - newConfig.authentication.type === 'oauth2') { + if (newConfig.authentication.type && newConfig.authentication.type === 'oauth2') { logger.info(context, 'Using OAuth2 as authentication service'); securityService = require('./services/common/securityServiceOAuth2'); @@ -130,9 +129,7 @@ function doActivate(newConfig, callback) { } } - if (newConfig.deviceRegistry && - newConfig.deviceRegistry.type && - newConfig.deviceRegistry.type === 'mongodb') { + if (newConfig.deviceRegistry && newConfig.deviceRegistry.type && newConfig.deviceRegistry.type === 'mongodb') { logger.info(context, 'MongoDB Device registry selected for NGSI Library'); registry = require('./services/devices/deviceRegistryMongoDB'); @@ -147,13 +144,10 @@ function doActivate(newConfig, callback) { } exports.clearAll = function(callback) { - async.series([ - registry.clear, - groupRegistry.clear, - commandRegistry.clear, - ngsi.resetMiddlewares, - contextServer.clear - ], callback); + async.series( + [registry.clear, groupRegistry.clear, commandRegistry.clear, ngsi.resetMiddlewares, contextServer.clear], + callback + ); }; if (!config.getConfig().dieOnUnexpectedError) { @@ -167,11 +161,7 @@ function doActivate(newConfig, callback) { commands.start(); - async.series([ - db.configureDb, - apply(contextServer.start, newConfig), - apply(activateStatLogs, newConfig) - ], callback); + async.series([db.configureDb, apply(contextServer.start, newConfig), apply(activateStatLogs, newConfig)], callback); } function checkConfig(newConfig, callback) { @@ -210,11 +200,7 @@ function checkConfig(newConfig, callback) { } function activate(newConfig, callback) { - async.series([ - apply(checkConfig, newConfig), - apply(doActivate, newConfig), - iotManager.register - ], callback); + async.series([apply(checkConfig, newConfig), apply(doActivate, newConfig), iotManager.register], callback); } /** @@ -270,18 +256,17 @@ function startServer(newConfig, iotAgent, callback) { } // Log information about the creation of the workers - cluster.on('online', function (worker) { + cluster.on('online', function(worker) { logger.info(context, 'Worker ' + worker.process.pid + ' is online'); }); // If a worker died, automatically we create a new worker to replace it - cluster.on('exit', function (worker, code, signal) { + cluster.on('exit', function(worker, code, signal) { var message = 'Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal; logger.warn(context, message); logger.warn(context, 'Starting a new worker...'); cluster.fork(); }); - } else { // We are in the worker, and they can share any TCP connection logger.info(context, 'Starting a new worker...'); @@ -294,7 +279,6 @@ function startServer(newConfig, iotAgent, callback) { } } - exports.activate = intoTrans(context, activate); exports.deactivate = intoTrans(context, deactivate); exports.register = deviceService.register; diff --git a/lib/model/dbConn.js b/lib/model/dbConn.js index ca7074c0c..106943568 100644 --- a/lib/model/dbConn.js +++ b/lib/model/dbConn.js @@ -58,8 +58,8 @@ function init(host, db, port, username, password, options, callback) { credentials = '', retries = 0, lastError, - maxRetries = (config.getConfig().mongodb && config.getConfig().mongodb.retries || - constants.DEFAULT_MONGODB_RETRIES); + maxRetries = + (config.getConfig().mongodb && config.getConfig().mongodb.retries) || constants.DEFAULT_MONGODB_RETRIES; if (username && password) { credentials = username + ':' + password + '@'; @@ -79,7 +79,8 @@ function init(host, db, port, username, password, options, callback) { return previous; } - hosts = host.split(',') + hosts = host + .split(',') .map(addPort) .reduce(commaConcat, ''); @@ -159,8 +160,9 @@ function init(host, db, port, username, password, options, callback) { function tryCreateConnection(callback) { var attempt = async.apply(connectionAttempt, url, options, callback), - seconds = (config.getConfig().mongodb && config.getConfig().mongodb.retryTime || - constants.DEFAULT_MONGODB_RETRY_TIME); + seconds = + (config.getConfig().mongodb && config.getConfig().mongodb.retryTime) || + constants.DEFAULT_MONGODB_RETRY_TIME; retries++; @@ -181,8 +183,10 @@ function configureDb(callback) { /*jshint camelcase:false, validthis:true */ var currentConfig = config.getConfig(); - if ((currentConfig.deviceRegistry && currentConfig.deviceRegistry.type === 'mongodb') || - (currentConfig.stats && currentConfig.stats.persistence === true)) { + if ( + (currentConfig.deviceRegistry && currentConfig.deviceRegistry.type === 'mongodb') || + (currentConfig.stats && currentConfig.stats.persistence === true) + ) { if (!currentConfig.mongodb || !currentConfig.mongodb.host) { logger.fatal(context, 'MONGODB-003: No host found for MongoDB driver.'); callback(new errors.BadConfiguration('No host found for MongoDB driver')); @@ -205,11 +209,18 @@ function configureDb(callback) { } if (currentConfig.mongodb.authSource) { - options.authSource = {db_name: currentConfig.mongodb.authSource}; + options.authSource = { db_name: currentConfig.mongodb.authSource }; } - init(config.getConfig().mongodb.host, dbName, port, - currentConfig.username, currentConfig.password, options, callback); + init( + config.getConfig().mongodb.host, + dbName, + port, + currentConfig.username, + currentConfig.password, + options, + callback + ); } } else { callback(); diff --git a/lib/plugins/addEvent.js b/lib/plugins/addEvent.js index 9548e8994..e67d3e2f4 100644 --- a/lib/plugins/addEvent.js +++ b/lib/plugins/addEvent.js @@ -1,4 +1,3 @@ - /* * Copyright 2016 Telefonica Investigación y Desarrollo, S.A.U * @@ -28,7 +27,7 @@ var pluginUtils = require('./pluginUtils'), config = require('../commonConfig'); function addEvents() { - return (new Date()).toISOString(); + return new Date().toISOString(); } exports.update = pluginUtils.createUpdateFilter(addEvents, config.getConfig().eventType || 'Event'); diff --git a/lib/plugins/attributeAlias.js b/lib/plugins/attributeAlias.js index 728c29cb4..84a768fcd 100644 --- a/lib/plugins/attributeAlias.js +++ b/lib/plugins/attributeAlias.js @@ -27,9 +27,9 @@ var config = require('../commonConfig'), utils = require('./pluginUtils'), - /*jshint unused:false*/ + /*jshint unused:false*/ logger = require('logops'), - /*jshint unused:false*/ + /*jshint unused:false*/ context = { op: 'IoTAgentNGSI.attributeAlias' }, @@ -51,7 +51,7 @@ function extractSingleMapping(previous, current) { * @return {{direct: {}, inverse: {}}} Object containing the direct and reverse name mappings. */ function extractAllMappings(typeInformation) { - var mappings = { direct: {}, inverse: {}, types: {}, metadata: {}}; + var mappings = { direct: {}, inverse: {}, types: {}, metadata: {} }; if (typeInformation.active) { mappings = typeInformation.active.reduce(extractSingleMapping, mappings); diff --git a/lib/plugins/bidirectionalData.js b/lib/plugins/bidirectionalData.js index 9ff44faad..df5c98d57 100644 --- a/lib/plugins/bidirectionalData.js +++ b/lib/plugins/bidirectionalData.js @@ -101,7 +101,6 @@ function extractVariables(item) { * @param {Array} attributeList List of active attributes for subscription. */ function sendSubscriptions(device, attributeList, callback) { - function sendSingleSubscriptionNgsi1(item, innerCb) { var variables = extractVariables(item); @@ -223,8 +222,10 @@ function processTransformations(values, transformations, callback) { } for (var i = 0; i < resultTransformations.length; i++) { - cleanedExpression = resultTransformations[i].expression - .substr(2, resultTransformations[i].expression.length - 3); + cleanedExpression = resultTransformations[i].expression.substr( + 2, + resultTransformations[i].expression.length - 3 + ); values.push({ name: resultTransformations[i].object_id, @@ -247,17 +248,17 @@ function handleDeviceProvision(device, callback) { if (error) { callback(error); } else { - async.waterfall([ - apply(extractBidirectionalAttributes, device, group), - apply(sendSubscriptions, device) - ], function(error, subscriptionMaps) { - if (error) { - callback(error); - } else { - device = updateDeviceWithSubscriptionIds(subscriptionMaps, device); - callback(null, device); + async.waterfall( + [apply(extractBidirectionalAttributes, device, group), apply(sendSubscriptions, device)], + function(error, subscriptionMaps) { + if (error) { + callback(error); + } else { + device = updateDeviceWithSubscriptionIds(subscriptionMaps, device); + callback(null, device); + } } - }); + ); } }); } @@ -272,20 +273,23 @@ function handleDeviceProvision(device, callback) { function handleNotification(device, values, callback) { deviceService.findConfigurationGroup(device, function(error, group) { var deviceAttributes = device.active || [], - groupAttributes = group && group.attributes || []; + groupAttributes = (group && group.attributes) || []; if (deviceAttributes.length > 0 || groupAttributes.length > 0) { logger.debug(context, 'Processing active attributes notification'); - async.waterfall([ - apply(async.series, [ - apply(getReverseTransformations, deviceAttributes, values), - apply(getReverseTransformations, groupAttributes, values) - ]), - apply(processTransformations, values) - ], function(error, results) { - callback(error, device, results); - }); + async.waterfall( + [ + apply(async.series, [ + apply(getReverseTransformations, deviceAttributes, values), + apply(getReverseTransformations, groupAttributes, values) + ]), + apply(processTransformations, values) + ], + function(error, results) { + callback(error, device, results); + } + ); } else { callback(null, device, values); } @@ -295,4 +299,3 @@ function handleNotification(device, values, callback) { exports.deviceProvision = handleDeviceProvision; exports.groupProvision = handleGroupProvision; exports.notification = handleNotification; - diff --git a/lib/plugins/compressTimestamp.js b/lib/plugins/compressTimestamp.js index 206c022ad..bec08bbf7 100644 --- a/lib/plugins/compressTimestamp.js +++ b/lib/plugins/compressTimestamp.js @@ -1,4 +1,3 @@ - /* * Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U * @@ -40,8 +39,7 @@ function fromBasicToExtended(date) { var split = date.match(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/); if (split) { - return '+00' + split[1] + '-' + split[2] + '-' + split[3] + 'T' + - split[4] + ':' + split[5] + ':' + split[6]; + return '+00' + split[1] + '-' + split[2] + '-' + split[3] + 'T' + split[4] + ':' + split[5] + ':' + split[6]; } else { return null; } diff --git a/lib/plugins/expressionParser.js b/lib/plugins/expressionParser.js index c509f154c..27b972c80 100644 --- a/lib/plugins/expressionParser.js +++ b/lib/plugins/expressionParser.js @@ -49,17 +49,13 @@ var Parser = require('jison').Parser, ['substr', 'return "SUBSTR";'], ['trim', 'return "TRIM";'], ['"[a-zA-Z0-9\\s,]+"', 'return "STRING";'], - ['\'[a-zA-Z0-9\\s,]+\'', 'return "STRING";'], + + [/*jshint quotmark: double */ "'[a-zA-Z0-9\\s,]+'" /*jshint quotmark: single */, 'return "STRING";'], ['$', 'return "EOF";'] ] }, - operators: [ - ['left', '#', '+', '-'], - ['left', '*', '/'], - ['left', '^'], - ['left', 'UMINUS'] - ], + operators: [['left', '#', '+', '-'], ['left', '*', '/'], ['left', '^'], ['left', 'UMINUS']], bnf: { expressions: [['e EOF', 'return $1;']], @@ -71,7 +67,7 @@ var Parser = require('jison').Parser, ['e / e', '$$ = $1 / $3;'], ['e ^ e', '$$ = Math.pow($1, $3);'], ['e # e', '$$ = String($1) + String($3);'], - ['- e', '$$ = -$2;', {'prec': 'UMINUS'}], + ['- e', '$$ = -$2;', { prec: 'UMINUS' }], ['INDEX ( e , e )', '$$ = String($3).indexOf($5)'], ['SUBSTR ( e , e , e )', '$$ = String($3).substr($5, $7)'], ['LENGTH ( e )', '$$ = String($3).length'], @@ -81,14 +77,14 @@ var Parser = require('jison').Parser, ['VARIABLE', '$$ = yy[yytext.substr(1)];'], ['STRING', '$$ = yytext.substr(1, yytext.length -2);'], ['E', '$$ = Math.E;'], - ['PI', '$$ = Math.PI;']] + ['PI', '$$ = Math.PI;'] + ] } }, parser = new Parser(grammar); function parse(expression, context, type, callback) { - var result, - error; + var result, error; if (type !== 'String' && type !== 'Number') { error = new errors.WrongExpressionType(type); @@ -130,7 +126,6 @@ function extractContext(attributeList) { return context; } - function processExpression(context) { return function(expression) { var result, @@ -160,7 +155,6 @@ function applyExpression(expression, context, typeInformation) { function expressionApplier(context, typeInformation) { return function(attribute) { - /** * Determines if a value is of type float * @@ -185,14 +179,11 @@ function expressionApplier(context, typeInformation) { if (attribute.type === 'Number' && isFloat(newAttribute.value)) { newAttribute.value = Number.parseFloat(newAttribute.value); - } - else if (attribute.type === 'Number' && Number.parseInt(newAttribute.value)) { + } else if (attribute.type === 'Number' && Number.parseInt(newAttribute.value)) { newAttribute.value = Number.parseInt(newAttribute.value); - } - else if (attribute.type === 'Boolean') { - newAttribute.value = (newAttribute.value === 'true' || newAttribute.value === '1'); - } - else if (attribute.type === 'None') { + } else if (attribute.type === 'Boolean') { + newAttribute.value = newAttribute.value === 'true' || newAttribute.value === '1'; + } else if (attribute.type === 'None') { newAttribute.value = null; } diff --git a/lib/plugins/expressionPlugin.js b/lib/plugins/expressionPlugin.js index 8ed729556..2460abd32 100644 --- a/lib/plugins/expressionPlugin.js +++ b/lib/plugins/expressionPlugin.js @@ -1,4 +1,3 @@ - /* * Copyright 2016 Telefonica Investigación y Desarrollo, S.A.U * @@ -29,9 +28,9 @@ var _ = require('underscore'), parser = require('./expressionParser'), config = require('../commonConfig'), - /*jshint unused:false*/ + /*jshint unused:false*/ logger = require('logops'), - /*jshint unused:false*/ + /*jshint unused:false*/ context = { op: 'IoTAgentNGSI.expressionPlugin' }, @@ -60,7 +59,6 @@ function mergeAttributes(attrList1, attrList2) { return finalCollection.concat(additionalItems); } - function update(entity, typeInformation, callback) { function processEntityUpdateNgsi1(entity) { var expressionAttributes = [], diff --git a/lib/plugins/multiEntity.js b/lib/plugins/multiEntity.js index 05c9f1791..63f1fd587 100644 --- a/lib/plugins/multiEntity.js +++ b/lib/plugins/multiEntity.js @@ -31,16 +31,15 @@ var _ = require('underscore'), constants = require('../constants'), parser = require('./expressionParser'), config = require('../commonConfig'), - /*jshint unused:false*/ + /*jshint unused:false*/ logger = require('logops'), - /*jshint unused:false*/ + /*jshint unused:false*/ context = { op: 'IoTAgentNGSI.MultiEntityPlugin' }, utils = require('./pluginUtils'), aliasPlugin = require('./attributeAlias'); - function hasEntityName(item) { return item.entity_name; } @@ -127,7 +126,6 @@ function generateNewCEsNgsi1(entity, newEntities, entityTypes, typeInformation, return result; } - /** * Generate new Context Elements for each new Entity, with the attributes of the original entity matching its * entity_name. It considers Ngsiv2. @@ -140,7 +138,6 @@ function generateNewCEsNgsi1(entity, newEntities, entityTypes, typeInformation, * @return {Array} List of the new Context Entities */ function generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, multiEntityAttributes) { - var result = [], newEntityAttributes, newEntityAttributeNames, @@ -163,9 +160,9 @@ function generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, if (entity[att].multi && entity[att].multi.length > 0) { // jshint maxdepth:7 if (mappings.inverse[att] && mappings.inverse[att].length > 0) { - for (var j in (mappings.inverse[att])) { + for (var j in mappings.inverse[att]) { if (_.contains(newEntityAttributeObjectIds, mappings.inverse[att][j])) { - result[att] = _.clone(entity[att]); + result[att] = _.clone(entity[att]); delete entity[att].object_id; delete result[att].multi; } @@ -173,16 +170,17 @@ function generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, } // jshint maxdepth:7 for (var k in entity[att].multi) { - if (entity[att].multi[k].object_id && _.contains(newEntityAttributeObjectIds, - entity[att].multi[k].object_id)) { + if ( + entity[att].multi[k].object_id && + _.contains(newEntityAttributeObjectIds, entity[att].multi[k].object_id) + ) { result[att] = entity[att].multi[k]; delete entity[att].multi[k].object_id; - } + } } } else { result[att] = entity[att]; } - } } } @@ -195,7 +193,7 @@ function generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, for (var att in entity) { if (entity.hasOwnProperty(att)) { if (_.contains(newEntityAttributeNames, att)) { - if (entity[att].object_id && _.contains(newEntityAttributeObjectIds, entity[att].object_id )){ + if (entity[att].object_id && _.contains(newEntityAttributeObjectIds, entity[att].object_id)) { result[att] = entity[att]; delete entity[att].object_id; } else { @@ -203,8 +201,10 @@ function generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, // jshint maxdepth:7 if (entity[att].multi) { for (var j in entity[att].multi) { - if (entity[att].multi[j].object_id && - _.contains(newEntityAttributeObjectIds, entity[att].multi[j].object_id)) { + if ( + entity[att].multi[j].object_id && + _.contains(newEntityAttributeObjectIds, entity[att].multi[j].object_id) + ) { result[att] = entity[att].multi[j]; delete entity[att].multi[j].object_id; } @@ -222,8 +222,10 @@ function generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, for (var i = 0; i < newEntities.length; i++) { newEntityAttributeNames = _.pluck(multiEntityAttributes.filter(filterByEntityName(newEntities[i])), 'name'); - newEntityAttributeObjectIds = _.pluck(multiEntityAttributes.filter( - filterByEntityName(newEntities[i])), 'object_id'); + newEntityAttributeObjectIds = _.pluck( + multiEntityAttributes.filter(filterByEntityName(newEntities[i])), + 'object_id' + ); newEntityAttributes = filterByAttributeObjectIds(); entityName = parser.applyExpression(newEntities[i], ctx, typeInformation); @@ -290,7 +292,8 @@ function updateAttributeNgsi1(entity, typeInformation, callback) { resultAttributes = filterOutMultientitiesNgsi1(entity.contextElements[0].attributes, attributesList); entity.contextElements = entity.contextElements.concat( - generateNewCEsNgsi1(entity, newEntities, entityTypes, typeInformation, multiEntityAttributes)); + generateNewCEsNgsi1(entity, newEntities, entityTypes, typeInformation, multiEntityAttributes) + ); entity.contextElements[0].attributes = resultAttributes; } @@ -302,7 +305,6 @@ function updateAttributeNgsi2(entity, typeInformation, callback) { var entities = []; entities.push(entity); if (typeInformation.active) { - var multiEntityAttributes = typeInformation.active.filter(hasEntityName), newEntities = _.pluck(multiEntityAttributes, 'entity_name'), attributesList = _.pluck(multiEntityAttributes, 'name'), @@ -311,8 +313,7 @@ function updateAttributeNgsi2(entity, typeInformation, callback) { if (multiEntityAttributes.length > 0) { resultAttributes = filterOutMultientitiesNgsi2(entity, attributesList); - var newCes = generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, - multiEntityAttributes); + var newCes = generateNewCEsNgsi2(entity, newEntities, entityTypes, typeInformation, multiEntityAttributes); entities = entities.concat(newCes); entities[0] = resultAttributes; propagateTimestamp(entity, entities); diff --git a/lib/plugins/pluginUtils.js b/lib/plugins/pluginUtils.js index 5af245dcd..70fee8afe 100644 --- a/lib/plugins/pluginUtils.js +++ b/lib/plugins/pluginUtils.js @@ -77,20 +77,20 @@ function createNgsi2Entity(id, type, attsArray, withObjectId) { entity[attsArray[i].name].multi = []; } entity[attsArray[i].name].multi.push({ - 'type' : attsArray[i].type, - 'value' : attsArray[i].value, + type: attsArray[i].type, + value: attsArray[i].value, /*jshint camelcase: false */ - 'object_id' : attsArray[i].object_id, - 'metadata' : attsArray[i].metadata + object_id: attsArray[i].object_id, + metadata: attsArray[i].metadata }); } else { entity[attsArray[i].name] = { - 'type' : attsArray[i].type, - 'value' : attsArray[i].value, - 'metadata' : attsArray[i].metadata + type: attsArray[i].type, + value: attsArray[i].value, + metadata: attsArray[i].metadata }; if (withObjectId && attsArray[i].object_id) { - entity[attsArray[i].name].object_id = attsArray[i].object_id; + entity[attsArray[i].name].object_id = attsArray[i].object_id; } } } @@ -100,16 +100,15 @@ function createNgsi2Entity(id, type, attsArray, withObjectId) { function createProcessAttribute(fn, attributeType) { return function(attribute) { - if (attribute.type && attribute.type === attributeType) { attribute.value = fn(attribute.value); } if (config.checkNgsi2()) { - // This code is backwards compatible to process metadata in the older NGSIv1-style (array) - // as well as supporting the newer NGSIv2-style (object). The redundant Array Check can be + // This code is backwards compatible to process metadata in the older NGSIv1-style (array) + // as well as supporting the newer NGSIv2-style (object). The redundant Array Check can be // therefore be removed if/when NGSIv1 support is removed from the library. - if (Array.isArray (attribute.metadata)){ + if (Array.isArray(attribute.metadata)) { attribute.metadata = attribute.metadata.map(createProcessAttribute(fn, attributeType)); } else if (attribute.metadata) { Object.keys(attribute.metadata).forEach(function(key) { @@ -139,8 +138,7 @@ function createProcessAttribute(fn, attributeType) { function createUpdateFilter(fn, attributeType) { return function update(entity, typeInformation, callback) { function processEntityUpdateNgsi1(entity) { - entity.attributes = entity.attributes.map( - createProcessAttribute(fn, attributeType)); + entity.attributes = entity.attributes.map(createProcessAttribute(fn, attributeType)); return entity; } @@ -174,7 +172,8 @@ function createQueryFilter(fn, attributeType) { return function query(entity, typeInformation, callback) { function processEntityQueryNgsi1(entity) { entity.contextElement.attributes = entity.contextElement.attributes.map( - createProcessAttribute(fn, attributeType)); + createProcessAttribute(fn, attributeType) + ); return entity; } diff --git a/lib/plugins/timestampProcessPlugin.js b/lib/plugins/timestampProcessPlugin.js index 83c21eb13..786944a54 100644 --- a/lib/plugins/timestampProcessPlugin.js +++ b/lib/plugins/timestampProcessPlugin.js @@ -43,7 +43,6 @@ function updatePluginNgsi2(entity, entityType, callback) { var timestamp; function insertMetadata(element) { - if (element.name !== constants.TIMESTAMP_ATTRIBUTE) { var metadata = element.metadata || {}; metadata[constants.TIMESTAMP_ATTRIBUTE] = { @@ -83,8 +82,6 @@ function updatePluginNgsi2(entity, entityType, callback) { var newEntity = updateSingleEntity(entity); callback(null, newEntity, entityType); } - - } /** @@ -97,11 +94,13 @@ function updatePluginNgsi1(entity, entityType, callback) { function insertMetadata(element) { if (element.name !== constants.TIMESTAMP_ATTRIBUTE) { - element.metadatas = [{ - name: constants.TIMESTAMP_ATTRIBUTE, - type: constants.TIMESTAMP_TYPE, - value: timestamp.value - }]; + element.metadatas = [ + { + name: constants.TIMESTAMP_ATTRIBUTE, + type: constants.TIMESTAMP_TYPE, + value: timestamp.value + } + ]; } return element; @@ -123,7 +122,6 @@ function updatePluginNgsi1(entity, entityType, callback) { logger.error(context, 'Bad payload received while processing timestamps'); callback(new errors.WrongSyntax(entity)); } - } /** diff --git a/lib/services/commands/commandRegistryMemory.js b/lib/services/commands/commandRegistryMemory.js index b6d0d0ea6..f8cae6c1a 100644 --- a/lib/services/commands/commandRegistryMemory.js +++ b/lib/services/commands/commandRegistryMemory.js @@ -36,10 +36,12 @@ var registeredCommands = {}, function findCommand(service, subservice, deviceId, name) { var keys = Object.keys(registeredCommands).filter(function filterByCriteria(item) { - return registeredCommands[item].service === service && - registeredCommands[item].subservice === subservice && - registeredCommands[item].deviceId === deviceId, - registeredCommands[item].name === name; + return ( + registeredCommands[item].service === service && + registeredCommands[item].subservice === subservice && + registeredCommands[item].deviceId === deviceId, + registeredCommands[item].name === name + ); }); if (keys.length === 1) { @@ -53,10 +55,12 @@ function exists(service, subservice, deviceId, name) { var keys = _.keys(registeredCommands); for (var i in keys) { - if (registeredCommands[keys[i]].service === service && + if ( + registeredCommands[keys[i]].service === service && registeredCommands[keys[i]].subservice === subservice && registeredCommands[keys[i]].name === name && - registeredCommands[keys[i]].deviceId === deviceId) { + registeredCommands[keys[i]].deviceId === deviceId + ) { return true; } } @@ -91,8 +95,14 @@ function addCommand(service, subservice, deviceId, command, callback) { registeredCommands[storeCommand._id].subservice = subservice; registeredCommands[storeCommand._id].deviceId = deviceId; - logger.debug(context, 'Storing device command [%s] for service [%s], subservice [%s] and deviceId [%s]', - command.name, storeCommand.service, storeCommand.subservice, deviceId); + logger.debug( + context, + 'Storing device command [%s] for service [%s], subservice [%s] and deviceId [%s]', + command.name, + storeCommand.service, + storeCommand.subservice, + deviceId + ); callback(null); } @@ -100,9 +110,11 @@ function addCommand(service, subservice, deviceId, command, callback) { function getFilteredCommands(service, subservice, deviceId) { return Object.keys(registeredCommands).filter(function filterByCriteria(item) { - return registeredCommands[item].service === service && + return ( + registeredCommands[item].service === service && registeredCommands[item].subservice === subservice && - registeredCommands[item].deviceId === deviceId; + registeredCommands[item].deviceId === deviceId + ); }); } @@ -155,12 +167,15 @@ function removeFromDate(creationDate, callback) { removalOrders = []; for (var i in expiredCommands) { - removalOrders.push(apply(remove, - registeredCommands[expiredCommands[i]].service, - registeredCommands[expiredCommands[i]].subservice, - registeredCommands[expiredCommands[i]].deviceId, - registeredCommands[expiredCommands[i]].name - )); + removalOrders.push( + apply( + remove, + registeredCommands[expiredCommands[i]].service, + registeredCommands[expiredCommands[i]].subservice, + registeredCommands[expiredCommands[i]].deviceId, + registeredCommands[expiredCommands[i]].name + ) + ); } async.series(removalOrders, function(error) { diff --git a/lib/services/commands/commandRegistryMongoDB.js b/lib/services/commands/commandRegistryMongoDB.js index 4d7d4b339..947b900bb 100644 --- a/lib/services/commands/commandRegistryMongoDB.js +++ b/lib/services/commands/commandRegistryMongoDB.js @@ -45,7 +45,7 @@ function findCommand(service, subservice, deviceId, name, callback) { query = Command.model.findOne(queryObj); - query.select({__v: 0}); + query.select({ __v: 0 }); query.exec(function handleGet(error, data) { if (error) { @@ -77,11 +77,7 @@ function updateCommand(service, subservice, deviceId, command, callback) { function createCommand(service, subservice, deviceId, command, callback) { var commandObj = new Command.model(), - attributeList = [ - 'name', - 'type', - 'value' - ]; + attributeList = ['name', 'type', 'value']; for (var i = 0; i < attributeList.length; i++) { commandObj[attributeList[i]] = command[attributeList[i]]; @@ -130,10 +126,10 @@ function listCommands(service, subservice, deviceId, callback) { query = Command.model.find(condition).sort(); - async.series([ - query.exec.bind(query), - Command.model.countDocuments.bind(Command.model, condition) - ], function(error, results) { + async.series([query.exec.bind(query), Command.model.countDocuments.bind(Command.model, condition)], function( + error, + results + ) { callback(error, { count: results[1], commands: results[0].map(toObjectFn) @@ -142,8 +138,14 @@ function listCommands(service, subservice, deviceId, callback) { } function remove(service, subservice, deviceId, name, callback) { - logger.debug(context, 'Removing command for service [%s] subservice [%s] and DeviceID [%s] with name [%s]', - service, subservice, deviceId, name); + logger.debug( + context, + 'Removing command for service [%s] subservice [%s] and DeviceID [%s] with name [%s]', + service, + subservice, + deviceId, + name + ); findCommand(service, subservice, deviceId, name, function(error, command) { if (error) { @@ -190,8 +192,11 @@ function removeFromDate(creationDate, callback) { callback(new errors.InternalDbError(error)); } else { - logger.debug(context, 'Expired commands successfully removed from MongoDB for date [%s]', - creationDate); + logger.debug( + context, + 'Expired commands successfully removed from MongoDB for date [%s]', + creationDate + ); callback(null, listToObject(commandList)); } diff --git a/lib/services/commands/commandService.js b/lib/services/commands/commandService.js index 990079791..40c6cfb78 100644 --- a/lib/services/commands/commandService.js +++ b/lib/services/commands/commandService.js @@ -71,19 +71,14 @@ function markAsExpired(command) { function calculateTypeInformation(device, group, callback) { deviceService.mergeDeviceWithConfiguration( - [ - 'lazy', - 'active', - 'staticAttributes', - 'commands', - 'subscriptions' - ], + ['lazy', 'active', 'staticAttributes', 'commands', 'subscriptions'], [null, null, [], [], [], [], []], device, group, function(error, typeInformation) { callback(error, device, group, typeInformation); - }); + } + ); } function updateExpiredCommand(device, group, typeInformation, callback) { @@ -95,28 +90,32 @@ function markAsExpired(command) { constants.COMMAND_EXPIRED_MESSAGE, constants.COMMAND_STATUS_ERROR, typeInformation, - callback); + callback + ); } - async.waterfall([ - apply(deviceService.getDevice, command.deviceId, command.service, command.subservice), - getGroup, - calculateTypeInformation, - updateExpiredCommand - ], function(error) { - if (error) { - logger.error(context, 'Error updating polling command to expire: %j', error); - } else { - logger.debug(context, 'Command successfully expired'); + async.waterfall( + [ + apply(deviceService.getDevice, command.deviceId, command.service, command.subservice), + getGroup, + calculateTypeInformation, + updateExpiredCommand + ], + function(error) { + if (error) { + logger.error(context, 'Error updating polling command to expire: %j', error); + } else { + logger.debug(context, 'Command successfully expired'); + } } - }); + ); } function expirationDaemon() { if (config.getConfig().pollingExpiration) { - config.getCommandRegistry().removeFromDate( - Date.now() - config.getConfig().pollingExpiration, - function(error, results) { + config + .getCommandRegistry() + .removeFromDate(Date.now() - config.getConfig().pollingExpiration, function(error, results) { logger.debug(context, 'Executed expiration daemon'); if (error) { diff --git a/lib/services/common/iotManagerService.js b/lib/services/common/iotManagerService.js index b14ad95a5..e98d84c3a 100644 --- a/lib/services/common/iotManagerService.js +++ b/lib/services/common/iotManagerService.js @@ -72,7 +72,7 @@ function register(callback) { function sendRegistration(services, callback) { var resource = constants.DEFAULT_RESOURCE; // Use an Undefined check since defaultResource override could be blank. - if (config.getConfig().defaultResource !== undefined){ + if (config.getConfig().defaultResource !== undefined) { resource = config.getConfig().defaultResource; } var options = { @@ -96,8 +96,11 @@ function register(callback) { if (result.statusCode !== 200 && result.statusCode !== 201) { alarms.raise(constants.IOTAM_ALARM, 'Wrong status code connecting with the IoTAM'); - logger.error(context, 'IOTAM-001: Error updating information in the IOTAM. Status Code [%d]', - result.statusCode); + logger.error( + context, + 'IOTAM-001: Error updating information in the IOTAM. Status Code [%d]', + result.statusCode + ); } else { alarms.release(constants.IOTAM_ALARM); } @@ -127,22 +130,20 @@ function register(callback) { } if (config.getConfig().iotManager) { - async.waterfall([ - checkConfiguration, - getServices, - sendRegistration, - handleRegistration - ], function registerHandler(error) { - if (error) { - logger.error(context, 'Error connecting to IoT Manager: %j', error); - - alarms.raise(constants.IOTAM_ALARM, 'Unknown error connecting with the IoTAM'); - - callback(error); - } else { - callback(); + async.waterfall( + [checkConfiguration, getServices, sendRegistration, handleRegistration], + function registerHandler(error) { + if (error) { + logger.error(context, 'Error connecting to IoT Manager: %j', error); + + alarms.raise(constants.IOTAM_ALARM, 'Unknown error connecting with the IoTAM'); + + callback(error); + } else { + callback(); + } } - }); + ); } else { callback(); } diff --git a/lib/services/common/securityServiceKeystone.js b/lib/services/common/securityServiceKeystone.js index c48a2e942..cec6c2a07 100644 --- a/lib/services/common/securityServiceKeystone.js +++ b/lib/services/common/securityServiceKeystone.js @@ -1,4 +1,3 @@ - /* * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U * @@ -33,7 +32,6 @@ var request = require('request'), op: 'IoTAgentNGSI.SecurityService' }; - /** * Send a request to the Authorization Server to retrieve a token using the given trust. * @@ -41,15 +39,12 @@ var request = require('request'), */ function auth(trust, callback) { var options = { - url: config.getConfig().authentication.url + - '/v3/auth/tokens', + url: config.getConfig().authentication.url + '/v3/auth/tokens', method: 'POST', json: { auth: { identity: { - methods: [ - 'password' - ], + methods: ['password'], password: { user: { domain: { @@ -83,8 +78,13 @@ function auth(trust, callback) { callback(new errors.AuthenticationError(trust)); } else { logger.error(context, 'KEYSTONE-002: Unexpected status code: %d', response.statusCode); - callback(new errors.TokenRetrievalError( - trust, 'Unexpected status code retrieving token: %d', response.statusCode)); + callback( + new errors.TokenRetrievalError( + trust, + 'Unexpected status code retrieving token: %d', + response.statusCode + ) + ); } }); } @@ -96,7 +96,6 @@ function auth(trust, callback) { */ function getToken(trust, response, callback) { - logger.debug(context, 'Retrieving token from the KEYSTONE response'); if (response.headers['x-subject-token']) { @@ -105,8 +104,7 @@ function getToken(trust, response, callback) { callback(null, response.headers['x-subject-token']); } else { logger.error(context, 'KEYSTONE-003: Token missing in the response headers', response.headers); - callback(new errors.TokenRetrievalError( - trust, 'Unexpected response format', response.headers)); + callback(new errors.TokenRetrievalError(trust, 'Unexpected response format', response.headers)); } } diff --git a/lib/services/common/securityServiceOAuth2.js b/lib/services/common/securityServiceOAuth2.js index 3a3bcafdf..d9b8f7424 100644 --- a/lib/services/common/securityServiceOAuth2.js +++ b/lib/services/common/securityServiceOAuth2.js @@ -1,4 +1,3 @@ - /* * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U * @@ -37,7 +36,6 @@ var request = require('request'), op: 'IoTAgentNGSI.SecurityService' }; - /** * Send a request to the Authorization Server. * @@ -45,16 +43,15 @@ var request = require('request'), */ /* jshint camelcase: false */ function auth(trust, callback) { - if (config.getConfig().authentication.permanentToken) { return callback(null, trust); } var form = { - grant_type: 'refresh_token', - client_id: config.getConfig().authentication.clientId, - client_secret: config.getConfig().authentication.clientSecret, - refresh_token: trust + grant_type: 'refresh_token', + client_id: config.getConfig().authentication.clientId, + client_secret: config.getConfig().authentication.clientSecret, + refresh_token: trust }; var formData = queryString.stringify(form); @@ -64,8 +61,8 @@ function auth(trust, callback) { url: url, method: 'POST', headers: { - 'Content-Length': formData.length, - 'Content-Type': 'application/x-www-form-urlencoded' + 'Content-Length': formData.length, + 'Content-Type': 'application/x-www-form-urlencoded' }, body: formData }; @@ -78,25 +75,35 @@ function auth(trust, callback) { callback(new errors.TokenRetrievalError(trust, error)); } else if (response.statusCode === 201 || response.statusCode === 200 /* Keyrock response */) { logger.debug(context, 'Authentication with trust [%s] was succesful', trust); - logger.debug(context, - 'Received the following response from the OAuth2 provider:\n\n%s\n\n', JSON.stringify(body, null, 4)); + logger.debug( + context, + 'Received the following response from the OAuth2 provider:\n\n%s\n\n', + JSON.stringify(body, null, 4) + ); callback(null, response); - } else if (response.statusCode === 401 || (response.statusCode === 400 && - JSON.parse(response.body).error_description === 'Invalid refresh token')) { + } else if ( + response.statusCode === 401 || + (response.statusCode === 400 && JSON.parse(response.body).error_description === 'Invalid refresh token') + ) { logger.error(context, 'Authentication rejected: %s', trust); callback(new errors.AuthenticationError(trust)); - } else if (response.statusCode === 400 && - JSON.parse(response.body).error === 'invalid_client') { //Keyrock response + } else if (response.statusCode === 400 && JSON.parse(response.body).error === 'invalid_client') { + //Keyrock response logger.error(context, 'Authentication rejected: %s', trust); callback(new errors.AuthenticationError(trust)); - } else if (response.statusCode === 400 && - JSON.parse(response.body).error === 'invalid_grant') { //Keyrock response + } else if (response.statusCode === 400 && JSON.parse(response.body).error === 'invalid_grant') { + //Keyrock response logger.error(context, 'Authentication rejected: %s', trust); callback(new errors.AuthenticationError(trust)); } else { logger.error(context, 'OAUTH2-002: Unexpected status code: %d', response.statusCode); - callback(new errors.TokenRetrievalError( - trust, 'Unexpected status code retrieving token: %d', response.statusCode)); + callback( + new errors.TokenRetrievalError( + trust, + 'Unexpected status code retrieving token: %d', + response.statusCode + ) + ); } }); } @@ -108,7 +115,6 @@ function auth(trust, callback) { */ /* jshint camelcase: false */ function getToken(trust, response, callback) { - logger.debug(context, 'Retrieving token from the OAuth2 response'); if (config.getConfig().authentication.permanentToken) { @@ -123,8 +129,7 @@ function getToken(trust, response, callback) { callback(null, 'Bearer ' + body.access_token); } else { logger.error(context, 'OAUTH2-003: Token missing in the response body', body); - callback(new errors.TokenRetrievalError( - trust, 'Unexpected response format', body)); + callback(new errors.TokenRetrievalError(trust, 'Unexpected response format', body)); } } diff --git a/lib/services/devices/deviceRegistryMemory.js b/lib/services/devices/deviceRegistryMemory.js index 85052eb28..d29fa387f 100644 --- a/lib/services/devices/deviceRegistryMemory.js +++ b/lib/services/devices/deviceRegistryMemory.js @@ -115,13 +115,13 @@ function listDevices(type, service, subservice, limit, offset, callback) { var result = [], skipped = 0, deviceList = getDevicesByService(service, subservice); - + var countNumber = deviceList.length; for (var i in deviceList) { if (registeredDevices[service].hasOwnProperty(deviceList[i])) { if (offset && skipped < parseInt(offset, 10)) { skipped++; - } else if (type && registeredDevices[service][deviceList[i]].type === type){ + } else if (type && registeredDevices[service][deviceList[i]].type === type) { result.push(registeredDevices[service][deviceList[i]]); } else if (type) { countNumber--; diff --git a/lib/services/devices/deviceRegistryMongoDB.js b/lib/services/devices/deviceRegistryMongoDB.js index 4e70b074b..51486fa9a 100644 --- a/lib/services/devices/deviceRegistryMongoDB.js +++ b/lib/services/devices/deviceRegistryMongoDB.js @@ -59,16 +59,35 @@ function saveDeviceHandler(callback) { */ function storeDevice(newDevice, callback) { var deviceObj = new Device.model(), - attributeList = ['id', 'type', 'name', 'service', 'subservice', 'lazy', 'commands', 'staticAttributes', - 'active', 'registrationId', 'internalId', 'internalAttributes', 'resource', 'apikey', 'protocol', - 'endpoint', 'transport', 'polling', 'timestamp', 'autoprovision']; + attributeList = [ + 'id', + 'type', + 'name', + 'service', + 'subservice', + 'lazy', + 'commands', + 'staticAttributes', + 'active', + 'registrationId', + 'internalId', + 'internalAttributes', + 'resource', + 'apikey', + 'protocol', + 'endpoint', + 'transport', + 'polling', + 'timestamp', + 'autoprovision' + ]; for (var i = 0; i < attributeList.length; i++) { deviceObj[attributeList[i]] = newDevice[attributeList[i]]; } // Ensure protocol is in newDevice - if ( !newDevice.protocol && config.getConfig().iotManager && config.getConfig().iotManager.protocol) { + if (!newDevice.protocol && config.getConfig().iotManager && config.getConfig().iotManager.protocol) { deviceObj.protocol = config.getConfig().iotManager.protocol; } @@ -155,10 +174,10 @@ function listDevices(type, service, subservice, limit, offset, callback) { query.skip(parseInt(offset, 10)); } - async.series([ - query.exec.bind(query), - Device.model.countDocuments.bind(Device.model, condition) - ], function(error, results) { + async.series([query.exec.bind(query), Device.model.countDocuments.bind(Device.model, condition)], function( + error, + results + ) { callback(error, { count: results[1], devices: results[0] @@ -184,7 +203,7 @@ function getDeviceById(id, service, subservice, callback) { logger.debug(context, 'Looking for device with id [%s].', id); query = Device.model.findOne(queryParams); - query.select({__v: 0}); + query.select({ __v: 0 }); query.exec(function handleGet(error, data) { if (error) { @@ -209,7 +228,6 @@ function getDeviceById(id, service, subservice, callback) { * @param {String} subservice Division inside the service. */ function getDevice(id, service, subservice, callback) { - getDeviceById(id, service, subservice, function(error, data) { if (error) { callback(error); @@ -230,7 +248,7 @@ function getByName(name, service, servicepath, callback) { subservice: servicepath }); - query.select({__v: 0}); + query.select({ __v: 0 }); query.exec(function handleGet(error, data) { if (error) { @@ -304,7 +322,7 @@ function getDevicesByAttribute(name, value, service, subservice, callback) { logger.debug(context, 'Looking for device with filter [%j].', filter); query = Device.model.find(filter); - query.select({__v: 0}); + query.select({ __v: 0 }); query.exec(function handleGet(error, devices) { if (error) { diff --git a/lib/services/devices/deviceService.js b/lib/services/devices/deviceService.js index 35799a899..234aeca4a 100644 --- a/lib/services/devices/deviceService.js +++ b/lib/services/devices/deviceService.js @@ -78,8 +78,11 @@ function processContextRegistration(deviceData, body, callback) { function createInitialEntityHandlerNgsi1(deviceData, newDevice, callback) { return function handleInitialEntityResponse(error, response, body) { if (error) { - logger.error(context, - 'ORION-001: Connection error creating inital entity in the Context Broker: %s', error); + logger.error( + context, + 'ORION-001: Connection error creating inital entity in the Context Broker: %s', + error + ); alarms.raise(constants.ORION_ALARM, error); @@ -98,8 +101,12 @@ function createInitialEntityHandlerNgsi1(deviceData, newDevice, callback) { } else { var errorObj; - logger.error(context, - 'Protocol error connecting to the Context Broker [%d]: %s', response.statusCode, body); + logger.error( + context, + 'Protocol error connecting to the Context Broker [%d]: %s', + response.statusCode, + body + ); errorObj = new errors.EntityGenericError(deviceData.id, deviceData.type, body); @@ -120,8 +127,11 @@ function createInitialEntityHandlerNgsi1(deviceData, newDevice, callback) { function createInitialEntityHandlerNgsi2(deviceData, newDevice, callback) { return function handleInitialEntityResponse(error, response, body) { if (error) { - logger.error(context, - 'ORION-001: Connection error creating inital entity in the Context Broker: %s', error); + logger.error( + context, + 'ORION-001: Connection error creating inital entity in the Context Broker: %s', + error + ); alarms.raise(constants.ORION_ALARM, error); @@ -133,8 +143,12 @@ function createInitialEntityHandlerNgsi2(deviceData, newDevice, callback) { } else { var errorObj; - logger.error(context, - 'Protocol error connecting to the Context Broker [%d]: %s', response.statusCode, body); + logger.error( + context, + 'Protocol error connecting to the Context Broker [%d]: %s', + response.statusCode, + body + ); errorObj = new errors.EntityGenericError(deviceData.id, deviceData.type, body); @@ -154,8 +168,11 @@ function createInitialEntityHandlerNgsi2(deviceData, newDevice, callback) { function updateEntityHandlerNgsi2(deviceData, updatedDevice, callback) { return function handleEntityResponse(error, response, body) { if (error) { - logger.error(context, - 'ORION-001: Connection error creating inital entity in the Context Broker: %s', error); + logger.error( + context, + 'ORION-001: Connection error creating inital entity in the Context Broker: %s', + error + ); alarms.raise(constants.ORION_ALARM, error); @@ -167,8 +184,12 @@ function updateEntityHandlerNgsi2(deviceData, updatedDevice, callback) { } else { var errorObj; - logger.error(context, - 'Protocol error connecting to the Context Broker [%d]: %s', response.statusCode, body); + logger.error( + context, + 'Protocol error connecting to the Context Broker [%d]: %s', + response.statusCode, + body + ); errorObj = new errors.EntityGenericError(deviceData.id, deviceData.type, body); @@ -214,7 +235,6 @@ function formatAttributesNgsi2(originalVector, staticAtts) { if (originalVector && originalVector.length) { for (var i = 0; i < originalVector.length; i++) { - // (#628) check if attribute has entity_name: // In that case attribute should not be appear in current entity /*jshint camelcase: false */ @@ -229,7 +249,7 @@ function formatAttributesNgsi2(originalVector, staticAtts) { } else { attributeList[originalVector[i].name].value = getInitialValueForType(originalVector[i].type); } - if (originalVector[i].metadata ){ + if (originalVector[i].metadata) { attributeList[originalVector[i].name].metadata = originalVector[i].metadata; } } @@ -271,43 +291,46 @@ function formatCommandsNgsi2(originalVector) { * @param {String} deviceData Device data. */ function executeWithSecurity(requestOptions, deviceData, callback) { - logger.debug(context, 'executeWithSecurity'); - config.getGroupRegistry().getType(deviceData.type, function(error, deviceGroup) { - var typeInformation; - if (error) { - logger.debug(context, 'error %j in get group device', error); - } + logger.debug(context, 'executeWithSecurity'); + config.getGroupRegistry().getType(deviceData.type, function(error, deviceGroup) { + var typeInformation; + if (error) { + logger.debug(context, 'error %j in get group device', error); + } - if (deviceGroup) { - typeInformation = deviceGroup; - } else { - typeInformation = config.getConfig().types[deviceData.type]; - } + if (deviceGroup) { + typeInformation = deviceGroup; + } else { + typeInformation = config.getConfig().types[deviceData.type]; + } - if (config.getConfig().authentication && config.getConfig().authentication.enabled) { - var security = config.getSecurityService(); - if (typeInformation && typeInformation.trust) { - async.waterfall([ + if (config.getConfig().authentication && config.getConfig().authentication.enabled) { + var security = config.getSecurityService(); + if (typeInformation && typeInformation.trust) { + async.waterfall( + [ apply(security.auth, typeInformation.trust), apply(ngsiService.updateTrust, deviceGroup, null, typeInformation.trust), apply(security.getToken, typeInformation.trust) - ], function(error, token) { + ], + function(error, token) { if (error) { callback(new errors.SecurityInformationMissing(typeInformation.type)); - } - else { + } else { requestOptions.headers[config.getConfig().authentication.header] = token; request(requestOptions, callback); } - }); - } else { - callback(new errors.SecurityInformationMissing( - typeInformation ? typeInformation.type : deviceData.type)); - } + } + ); } else { - request(requestOptions, callback); + callback( + new errors.SecurityInformationMissing(typeInformation ? typeInformation.type : deviceData.type) + ); } - }); + } else { + request(requestOptions, callback); + } + }); } /** @@ -343,10 +366,13 @@ function createInitialEntityNgsi2(deviceData, newDevice, callback) { jsonConcat(options.json, formatCommandsNgsi2(deviceData.commands)); logger.debug(context, 'deviceData: %j', deviceData); - if ( (('timestamp' in deviceData && deviceData.timestamp !== undefined) ? - deviceData.timestamp : config.getConfig().timestamp) && - ! utils.isTimestampedNgsi2(options.json)) { - logger.debug(context, 'config.timestamp %s %s', deviceData.timestamp, config.getConfig().timestamp); + if ( + ('timestamp' in deviceData && deviceData.timestamp !== undefined + ? deviceData.timestamp + : config.getConfig().timestamp) && + !utils.isTimestampedNgsi2(options.json) + ) { + logger.debug(context, 'config.timestamp %s %s', deviceData.timestamp, config.getConfig().timestamp); options.json[constants.TIMESTAMP_ATTRIBUTE] = { type: constants.TIMESTAMP_TYPE_NGSI2, value: moment() @@ -373,25 +399,25 @@ function createInitialEntityNgsi1(deviceData, newDevice, callback) { cbHost = 'http://' + deviceData.cbHost; } var options = { - url: cbHost + '/v1/updateContext', - method: 'POST', - json: { - contextElements: [ - { - type: deviceData.type, - isPattern: 'false', - id: String(deviceData.name), - attributes: [] - } - ], - updateAction: 'APPEND' - }, - headers: { - 'fiware-service': deviceData.service, - 'fiware-servicepath': deviceData.subservice, - 'fiware-correlator': (domain.active && domain.active.corr) || uuid.v4() - } - }; + url: cbHost + '/v1/updateContext', + method: 'POST', + json: { + contextElements: [ + { + type: deviceData.type, + isPattern: 'false', + id: String(deviceData.name), + attributes: [] + } + ], + updateAction: 'APPEND' + }, + headers: { + 'fiware-service': deviceData.service, + 'fiware-servicepath': deviceData.subservice, + 'fiware-correlator': (domain.active && domain.active.corr) || uuid.v4() + } + }; function formatAttributes(originalVector) { var attributeList = []; @@ -438,11 +464,15 @@ function createInitialEntityNgsi1(deviceData, newDevice, callback) { options.json.contextElements[0].attributes = [].concat( formatAttributes(deviceData.active), deviceData.staticAttributes, - formatCommands(deviceData.commands)); - - if ( (('timestamp' in deviceData && deviceData.timestamp !== undefined) ? - deviceData.timestamp : config.getConfig().timestamp) && - ! utils.isTimestamped(options.json)) { + formatCommands(deviceData.commands) + ); + + if ( + ('timestamp' in deviceData && deviceData.timestamp !== undefined + ? deviceData.timestamp + : config.getConfig().timestamp) && + !utils.isTimestamped(options.json) + ) { options.json.contextElements[0].attributes.push({ name: constants.TIMESTAMP_ATTRIBUTE, type: constants.TIMESTAMP_TYPE, @@ -479,8 +509,7 @@ function updateEntityNgsi2(deviceData, updatedDevice, callback) { var options = { url: config.getConfig().contextBroker.url + '/v2/entities/' + String(deviceData.name) + '/attrs', method: 'POST', - json: { - }, + json: {}, headers: { 'fiware-service': deviceData.service, 'fiware-servicepath': deviceData.subservice, @@ -495,16 +524,19 @@ function updateEntityNgsi2(deviceData, updatedDevice, callback) { } if (deviceData.type) { - options.url += '?type=' + deviceData.type; + options.url += '?type=' + deviceData.type; } jsonConcat(options.json, formatAttributesNgsi2(deviceData.active, false)); jsonConcat(options.json, formatAttributesNgsi2(deviceData.staticAttributes, true)); jsonConcat(options.json, formatCommandsNgsi2(deviceData.commands)); - if ( (('timestamp' in deviceData && deviceData.timestamp !== undefined) ? - deviceData.timestamp : config.getConfig().timestamp) && - ! utils.isTimestampedNgsi2(options.json)) { + if ( + ('timestamp' in deviceData && deviceData.timestamp !== undefined + ? deviceData.timestamp + : config.getConfig().timestamp) && + !utils.isTimestampedNgsi2(options.json) + ) { options.json[constants.TIMESTAMP_ATTRIBUTE] = { type: constants.TIMESTAMP_TYPE_NGSI2, value: moment() @@ -515,8 +547,7 @@ function updateEntityNgsi2(deviceData, updatedDevice, callback) { if (Object.keys(options.json).length === 0 && options.json.constructor === Object) { logger.debug(context, 'Skip updating entity in the Context Broker (no actual attribute change)'); callback(null, updatedDevice); - } - else{ + } else { logger.debug(context, 'Updating entity in the Context Broker:\n %s', JSON.stringify(options, null, 4)); request(options, updateEntityHandlerNgsi2(deviceData, updatedDevice, callback)); } @@ -581,7 +612,7 @@ function mergeArrays(original, newArray) { function mergeDeviceWithConfiguration(fields, defaults, deviceData, configuration, callback) { logger.debug(context, 'deviceData after merge with conf: %j', deviceData); for (var i = 0; i < fields.length; i++) { - var confField = (fields[i] === 'active') ? 'attributes' : fields[i]; + var confField = fields[i] === 'active' ? 'attributes' : fields[i]; if (deviceData && deviceData[fields[i]] && ['active', 'lazy', 'commands'].indexOf(fields[i]) >= 0) { deviceData[fields[i]] = deviceData[fields[i]].map(setDefaultAttributeIds); @@ -601,8 +632,12 @@ function mergeDeviceWithConfiguration(fields, defaults, deviceData, configuratio if (deviceData[fields[i]] && configuration && configuration[confField]) { deviceData[fields[i]] = mergeArrays(deviceData[fields[i]], configuration[confField]); - } else if (!deviceData[fields[i]] && configuration && - confField in configuration && configuration[confField] !== undefined) { + } else if ( + !deviceData[fields[i]] && + configuration && + confField in configuration && + configuration[confField] !== undefined + ) { deviceData[fields[i]] = configuration[confField]; } else if (!deviceData[fields[i]] && (!configuration || !configuration[confField])) { deviceData[fields[i]] = defaults[i]; @@ -636,17 +671,11 @@ function findConfigurationGroup(deviceObj, callback) { } if (config.getConfig().singleConfigurationMode === true) { - config.getGroupRegistry().find( - deviceObj.service, - deviceObj.subservice, - handlerGroupFind); + config.getGroupRegistry().find(deviceObj.service, deviceObj.subservice, handlerGroupFind); } else { - config.getGroupRegistry().findType( - deviceObj.service, - deviceObj.subservice, - deviceObj.type, - deviceObj.apikey, - handlerGroupFind); + config + .getGroupRegistry() + .findType(deviceObj.service, deviceObj.subservice, deviceObj.type, deviceObj.apikey, handlerGroupFind); } } @@ -706,45 +735,46 @@ function registerDevice(deviceObj, callback) { logger.debug(context, 'Registering device into NGSI Service:\n%s', JSON.stringify(deviceData, null, 4)); - async.waterfall([ - apply(registrationUtils.sendRegistrations, false, deviceData), - apply(processContextRegistration, deviceData), - apply(createInitialEntity, deviceData) - ], function(error, results) { - if (error) { - callback(error); - } else { - deviceObj.registrationId = results.registrationId; - deviceObj.name = deviceData.name; - deviceObj.service = deviceData.service; - deviceObj.subservice = deviceData.subservice; - deviceObj.type = deviceData.type; - if ('timestamp' in deviceData && deviceData.timestamp !== undefined) { - deviceObj.timestamp = deviceData.timestamp; - } - if ('autoprovision' in deviceData && deviceData.autoprovision !== undefined) { - deviceObj.autoprovision = deviceData.autoprovision; + async.waterfall( + [ + apply(registrationUtils.sendRegistrations, false, deviceData), + apply(processContextRegistration, deviceData), + apply(createInitialEntity, deviceData) + ], + function(error, results) { + if (error) { + callback(error); + } else { + deviceObj.registrationId = results.registrationId; + deviceObj.name = deviceData.name; + deviceObj.service = deviceData.service; + deviceObj.subservice = deviceData.subservice; + deviceObj.type = deviceData.type; + if ('timestamp' in deviceData && deviceData.timestamp !== undefined) { + deviceObj.timestamp = deviceData.timestamp; + } + if ('autoprovision' in deviceData && deviceData.autoprovision !== undefined) { + deviceObj.autoprovision = deviceData.autoprovision; + } + config.getRegistry().store(deviceObj, callback); } - config.getRegistry().store(deviceObj, callback); } - }); + ); } - async.waterfall([ - apply(checkDuplicates, deviceObj), - apply(findConfigurationGroup, deviceObj), - apply(prepareDeviceData, deviceObj), - apply(mergeDeviceWithConfiguration, - [ - 'lazy', - 'active', - 'staticAttributes', - 'commands', - 'subscriptions' - ], - [null, null, [], [], [], [], []] - ) - ], completeRegistrations); + async.waterfall( + [ + apply(checkDuplicates, deviceObj), + apply(findConfigurationGroup, deviceObj), + apply(prepareDeviceData, deviceObj), + apply( + mergeDeviceWithConfiguration, + ['lazy', 'active', 'staticAttributes', 'commands', 'subscriptions'], + [null, null, [], [], [], [], []] + ) + ], + completeRegistrations + ); } function removeAllSubscriptions(device, callback) { @@ -779,34 +809,35 @@ function unregisterDevice(id, service, subservice, callback) { config.getRegistry().get(id, service, subservice, function(error, device) { if (error) { - callback(error); + callback(error); } else { - async.waterfall([ - apply(findConfigurationGroup, device), - apply(mergeDeviceWithConfiguration, - [ - 'lazy', - 'active', - 'staticAttributes', - 'commands', - 'subscriptions' - ], - [null, null, [], [], [], [], []], - device - ) - ], function(error, mergedDevice) { - if (error) { - callback(error); - } else { - async.waterfall([ - apply(removeAllSubscriptions, mergedDevice), - processUnsubscribes, - apply(registrationUtils.sendRegistrations, true, mergedDevice), - processContextUnregister, - apply(config.getRegistry().remove, id, service, subservice) - ], callback); + async.waterfall( + [ + apply(findConfigurationGroup, device), + apply( + mergeDeviceWithConfiguration, + ['lazy', 'active', 'staticAttributes', 'commands', 'subscriptions'], + [null, null, [], [], [], [], []], + device + ) + ], + function(error, mergedDevice) { + if (error) { + callback(error); + } else { + async.waterfall( + [ + apply(removeAllSubscriptions, mergedDevice), + processUnsubscribes, + apply(registrationUtils.sendRegistrations, true, mergedDevice), + processContextUnregister, + apply(config.getRegistry().remove, id, service, subservice) + ], + callback + ); + } } - }); + ); } }); } @@ -856,10 +887,7 @@ function updateRegisterDeviceNgsi1(deviceObj, callback) { } function getAttributeDifference(oldArray, newArray) { - var oldActiveKeys, - newActiveKeys, - updateKeys, - result; + var oldActiveKeys, newActiveKeys, updateKeys, result; if (oldArray && newArray) { newActiveKeys = _.pluck(newArray, 'name'); @@ -881,12 +909,12 @@ function updateRegisterDeviceNgsi1(deviceObj, callback) { function extractDeviceDifference(newDevice, oldDevice, callback) { var deviceData = { - id: oldDevice.id, - name: oldDevice.name, - type: oldDevice.type, - service: oldDevice.service, - subservice: oldDevice.subservice - }; + id: oldDevice.id, + name: oldDevice.name, + type: oldDevice.type, + service: oldDevice.service, + subservice: oldDevice.subservice + }; deviceData.active = getAttributeDifference(oldDevice.active, newDevice.active); deviceData.lazy = getAttributeDifference(oldDevice.lazy, newDevice.lazy); @@ -896,15 +924,18 @@ function updateRegisterDeviceNgsi1(deviceObj, callback) { callback(null, deviceData, oldDevice); } - async.waterfall([ - apply(config.getRegistry().get, deviceObj.id, deviceObj.service, deviceObj.subservice), - apply(extractDeviceDifference, deviceObj), - createInitialEntity, - apply(combineWithNewDevice, deviceObj), - apply(registrationUtils.sendRegistrations, false), - apply(processContextRegistration, deviceObj), - config.getRegistry().update - ], callback); + async.waterfall( + [ + apply(config.getRegistry().get, deviceObj.id, deviceObj.service, deviceObj.subservice), + apply(extractDeviceDifference, deviceObj), + createInitialEntity, + apply(combineWithNewDevice, deviceObj), + apply(registrationUtils.sendRegistrations, false), + apply(processContextRegistration, deviceObj), + config.getRegistry().update + ], + callback + ); } /** @@ -952,10 +983,7 @@ function updateRegisterDeviceNgsi2(deviceObj, callback) { } function getAttributeDifference(oldArray, newArray) { - var oldActiveKeys, - newActiveKeys, - updateKeys, - result; + var oldActiveKeys, newActiveKeys, updateKeys, result; if (oldArray && newArray) { newActiveKeys = _.pluck(newArray, 'name'); @@ -977,12 +1005,12 @@ function updateRegisterDeviceNgsi2(deviceObj, callback) { function extractDeviceDifference(newDevice, oldDevice, callback) { var deviceData = { - id: oldDevice.id, - name: oldDevice.name, - type: oldDevice.type, - service: oldDevice.service, - subservice: oldDevice.subservice - }; + id: oldDevice.id, + name: oldDevice.name, + type: oldDevice.type, + service: oldDevice.service, + subservice: oldDevice.subservice + }; deviceData.active = getAttributeDifference(oldDevice.active, newDevice.active); deviceData.lazy = getAttributeDifference(oldDevice.lazy, newDevice.lazy); @@ -992,18 +1020,20 @@ function updateRegisterDeviceNgsi2(deviceObj, callback) { callback(null, deviceData, oldDevice); } - async.waterfall([ - apply(config.getRegistry().get, deviceObj.id, deviceObj.service, deviceObj.subservice), - apply(extractDeviceDifference, deviceObj), - updateEntityNgsi2, - apply(combineWithNewDevice, deviceObj), - apply(registrationUtils.sendRegistrations, false), - apply(processContextRegistration, deviceObj), - config.getRegistry().update - ], callback); + async.waterfall( + [ + apply(config.getRegistry().get, deviceObj.id, deviceObj.service, deviceObj.subservice), + apply(extractDeviceDifference, deviceObj), + updateEntityNgsi2, + apply(combineWithNewDevice, deviceObj), + apply(registrationUtils.sendRegistrations, false), + apply(processContextRegistration, deviceObj), + config.getRegistry().update + ], + callback + ); } - function updateRegisterDevice(deviceObj, callback) { if (config.checkNgsi2()) { updateRegisterDeviceNgsi2(deviceObj, callback); @@ -1032,7 +1062,9 @@ function listDevicesWithType(type, service, subservice, limit, offset, callback) service = null; subservice = null; } else { - logger.fatal(context, 'GENERAL-001: Couldn\'t find callback in listDevices() call.'); + /*jshint quotmark: double */ + logger.fatal(context, "GENERAL-001: Couldn't find callback in listDevices() call."); + /*jshint quotmark: single */ } } @@ -1058,7 +1090,9 @@ function listDevices(service, subservice, limit, offset, callback) { service = null; subservice = null; } else { - logger.fatal(context, 'GENERAL-001: Couldn\'t find callback in listDevices() call.'); + /*jshint quotmark: double */ + logger.fatal(context, "GENERAL-001: Couldn't find callback in listDevices() call."); + /*jshint quotmark: single */ } } @@ -1119,7 +1153,7 @@ function checkRegistry(fn) { if (config.getRegistry()) { fn.apply(null, args); - } else if (callbacks && callbacks.length === 1 && (typeof callbacks[0] === 'function')) { + } else if (callbacks && callbacks.length === 1 && typeof callbacks[0] === 'function') { logger.error(context, 'Tried to access device information before a registry was available'); callbacks[0](new errors.RegistryNotAvailable()); } else { @@ -1128,7 +1162,6 @@ function checkRegistry(fn) { }; } - function findOrCreate(deviceId, group, callback) { getDevice(deviceId, group.service, group.subservice, function(error, device) { if (!error && device) { @@ -1176,27 +1209,25 @@ function retrieveDevice(deviceId, apiKey, callback) { } else if (devices && devices.length === 1) { callback(null, devices[0]); } else { - logger.error(context, 'Couldn\'t find device data for APIKey [%s] and DeviceId[%s]', - deviceId, apiKey); - + /*jshint quotmark: double */ + logger.error(context, "Couldn't find device data for APIKey [%s] and DeviceId[%s]", deviceId, apiKey); + /*jshint quotmark: single */ callback(new errors.DeviceNotFound(deviceId)); } }); } else { - async.waterfall([ - apply(groupService.get, config.getConfig().defaultResource || '', apiKey), - apply(findOrCreate, deviceId), - apply(mergeDeviceWithConfiguration, - [ - 'lazy', - 'active', - 'staticAttributes', - 'commands', - 'subscriptions' - ], - [null, null, [], [], [], [], []] - ) - ], callback); + async.waterfall( + [ + apply(groupService.get, config.getConfig().defaultResource || '', apiKey), + apply(findOrCreate, deviceId), + apply( + mergeDeviceWithConfiguration, + ['lazy', 'active', 'staticAttributes', 'commands', 'subscriptions'], + [null, null, [], [], [], [], []] + ) + ], + callback + ); } } diff --git a/lib/services/devices/registrationUtils.js b/lib/services/devices/registrationUtils.js index 14bfed6d0..045ec8447 100644 --- a/lib/services/devices/registrationUtils.js +++ b/lib/services/devices/registrationUtils.js @@ -92,17 +92,16 @@ function createRegistrationHandlerNgsi2(unregister, deviceData, callback) { callback(error); } else if (response && response.statusCode === 201 && response.headers.location && unregister === false) { logger.debug(context, 'Registration success.'); - callback(null, {registrationId: - response.headers.location.substr(response.headers.location.lastIndexOf('/') + 1)}); + callback(null, { + registrationId: response.headers.location.substr(response.headers.location.lastIndexOf('/') + 1) + }); } else if (response && response.statusCode === 204 && unregister === true) { logger.debug(context, 'Unregistration success.'); callback(null, null); - } - else if (response && response.statusCode && response.statusCode !== 500) { + } else if (response && response.statusCode && response.statusCode !== 500) { logger.error(context, 'Registration error connecting to the Context Broker: %j', response.statusCode); callback(new errors.BadRequest(JSON.stringify(response.statusCode))); - } - else { + } else { var errorObj; logger.error(context, 'ORION-003: Protocol error connecting to the Context Broker: %j', errorObj); @@ -153,7 +152,7 @@ function sendRegistrationsNgsi1(unregister, deviceData, callback) { providingApplication: config.getConfig().providerUrl } ], - duration: (unregister) ? 'PT1S' : config.getConfig().deviceRegistrationDuration + duration: unregister ? 'PT1S' : config.getConfig().deviceRegistrationDuration }, headers: { 'fiware-service': deviceData.service, @@ -190,10 +189,9 @@ function sendRegistrationsNgsi1(unregister, deviceData, callback) { options.json.registrationId = deviceData.registrationId; } - options.json.contextRegistrations[0].attributes = options.json.contextRegistrations[0].attributes.concat( - formatAttributes(deviceData.lazy), - formatAttributes(deviceData.commands) - ).reduce(mergeWithSameName, []); + options.json.contextRegistrations[0].attributes = options.json.contextRegistrations[0].attributes + .concat(formatAttributes(deviceData.lazy), formatAttributes(deviceData.commands)) + .reduce(mergeWithSameName, []); if (options.json.contextRegistrations[0].attributes.length === 0) { logger.debug(context, 'No Context Provider registrations found for unregister'); @@ -205,7 +203,8 @@ function sendRegistrationsNgsi1(unregister, deviceData, callback) { deviceService.executeWithSecurity( options, deviceData, - createRegistrationHandler(unregister, deviceData, callback)); + createRegistrationHandler(unregister, deviceData, callback) + ); } } @@ -242,13 +241,12 @@ function sendUnregistrationsNgsi2(deviceData, callback) { deviceService.executeWithSecurity( options, deviceData, - createRegistrationHandlerNgsi2(true, deviceData, callback)); + createRegistrationHandlerNgsi2(true, deviceData, callback) + ); } else { logger.debug(context, 'No Context Provider registrations found for unregister'); callback(null, deviceData); } - - } /** @@ -269,14 +267,13 @@ function sendRegistrationsNgsi2(unregister, deviceData, callback) { method: 'POST', json: { dataProvided: { - entities: - [ + entities: [ { type: deviceData.type, id: String(deviceData.name) } ], - attrs: [], + attrs: [] }, provider: { http: { @@ -302,7 +299,6 @@ function sendRegistrationsNgsi2(unregister, deviceData, callback) { return attributeList; } - function mergeWithSameName(old, current) { if (old.indexOf(current) < 0) { old.push(current); @@ -331,18 +327,18 @@ function sendRegistrationsNgsi2(unregister, deviceData, callback) { if (unregister) { sendUnregistrationsNgsi2(deviceData, callback); } else { - if (deviceData.registrationId) { updateRegistrationNgsi2(deviceData, callback); } else { - options.json.dataProvided.attrs = options.json.dataProvided.attrs.concat( - formatAttributes(deviceData.lazy), - formatAttributes(deviceData.commands) - ).reduce(mergeWithSameName, []); + options.json.dataProvided.attrs = options.json.dataProvided.attrs + .concat(formatAttributes(deviceData.lazy), formatAttributes(deviceData.commands)) + .reduce(mergeWithSameName, []); if (options.json.dataProvided.attrs.length === 0) { - logger.debug(context, 'Registration with Context Provider is not needed.' + - 'Device without lazy atts or commands'); + logger.debug( + context, + 'Registration with Context Provider is not needed.' + 'Device without lazy atts or commands' + ); callback(null, deviceData); } else { logger.debug(context, 'Sending device registrations to Context Broker at [%s]', options.url); @@ -350,14 +346,13 @@ function sendRegistrationsNgsi2(unregister, deviceData, callback) { deviceService.executeWithSecurity( options, deviceData, - createRegistrationHandlerNgsi2(unregister, deviceData, callback)); + createRegistrationHandlerNgsi2(unregister, deviceData, callback) + ); } } } } - - /** * Sends a Context Provider registration or unregistration request to the Context Broker. As registrations cannot be * removed, an unregistration consists of an update of the existent registration to make reduce its duration to diff --git a/lib/services/groups/groupRegistryMemory.js b/lib/services/groups/groupRegistryMemory.js index b71f7987c..d947780a6 100644 --- a/lib/services/groups/groupRegistryMemory.js +++ b/lib/services/groups/groupRegistryMemory.js @@ -36,8 +36,10 @@ function exists(group) { var keys = _.keys(registeredGroups); for (var i in keys) { - if (registeredGroups[keys[i]].apikey === group.apikey && - registeredGroups[keys[i]].resource === group.resource) { + if ( + registeredGroups[keys[i]].apikey === group.apikey && + registeredGroups[keys[i]].resource === group.resource + ) { return true; } } @@ -56,8 +58,13 @@ function createGroup(group, callback) { registeredGroups[storeGroup._id] = storeGroup; registeredGroups[storeGroup._id].creationDate = Date.now(); - logger.debug(context, 'Storing device group for service [%s] and subservice [%s]', - storeGroup._id, storeGroup.service, storeGroup.subservice); + logger.debug( + context, + 'Storing device group for service [%s] and subservice [%s]', + storeGroup._id, + storeGroup.service, + storeGroup.subservice + ); callback(null); } @@ -127,9 +134,11 @@ function find(service, subservice, callback) { var result; for (var i in registeredGroups) { - if (registeredGroups.hasOwnProperty(i) && + if ( + registeredGroups.hasOwnProperty(i) && registeredGroups[i].service === service && - registeredGroups[i].subservice === subservice) { + registeredGroups[i].subservice === subservice + ) { result = registeredGroups[i]; break; } @@ -163,8 +172,7 @@ function findBy(fields) { var found = 0; for (var j in queryObj) { - if (queryObj.hasOwnProperty(j) && - registeredGroups[p][j] === queryObj[j]) { + if (queryObj.hasOwnProperty(j) && registeredGroups[p][j] === queryObj[j]) { found++; } } @@ -188,9 +196,11 @@ function getSingleGroup(resource, apikey, callback) { var result; for (var i in registeredGroups) { - if (registeredGroups.hasOwnProperty(i) && + if ( + registeredGroups.hasOwnProperty(i) && registeredGroups[i].resource === resource && - registeredGroups[i].apikey === apikey) { + registeredGroups[i].apikey === apikey + ) { result = registeredGroups[i]; break; } @@ -207,8 +217,7 @@ function getSingleGroupType(type, callback) { var result; for (var i in registeredGroups) { - if (registeredGroups.hasOwnProperty(i) && - registeredGroups[i].type === type) { + if (registeredGroups.hasOwnProperty(i) && registeredGroups[i].type === type) { result = registeredGroups[i]; break; } @@ -221,8 +230,6 @@ function getSingleGroupType(type, callback) { } } - - function update(id, body, callback) { var groupToModify = registeredGroups[id]; diff --git a/lib/services/groups/groupRegistryMongoDB.js b/lib/services/groups/groupRegistryMongoDB.js index 56b5be92e..00ffc1541 100644 --- a/lib/services/groups/groupRegistryMongoDB.js +++ b/lib/services/groups/groupRegistryMongoDB.js @@ -73,21 +73,31 @@ function createGroup(group, callback) { 'attributes', 'staticAttributes', 'internalAttributes', - 'autoprovision', + 'autoprovision' ]; for (var i = 0; i < attributeList.length; i++) { groupObj[attributeList[i]] = group[attributeList[i]]; } - logger.debug(context, 'Storing device group with id [%s], type [%s], apikey [%s] and resource [%s]', - groupObj._id, groupObj.type, groupObj.apikey, groupObj.resource); + logger.debug( + context, + 'Storing device group with id [%s], type [%s], apikey [%s] and resource [%s]', + groupObj._id, + groupObj.type, + groupObj.apikey, + groupObj.resource + ); groupObj.save(function saveHandler(error, groupDAO) { if (error) { if (error.code === 11000) { - logger.debug(context, 'Duplicate group entry with resource [%s] and apiKey [%s]', - group.resource, group.apikey); + logger.debug( + context, + 'Duplicate group entry with resource [%s] and apiKey [%s]', + group.resource, + group.apikey + ); callback(new errors.DuplicateGroup(group.resource, group.apikey)); } else { @@ -130,10 +140,10 @@ function listGroups(service, limit, offset, callback) { query.skip(parseInt(offset, 10)); } - async.series([ - query.exec.bind(query), - Group.model.countDocuments.bind(Group.model, condition) - ], function(error, results) { + async.series([query.exec.bind(query), Group.model.countDocuments.bind(Group.model, condition)], function( + error, + results + ) { callback(error, { count: results[1], services: results[0].map(toObjectFn) @@ -146,8 +156,8 @@ function getById(id, callback) { logger.debug(context, 'Looking for device group with id [%s].', id); - query = Group.model.findOne({_id: id}); - query.select({__v: 0}); + query = Group.model.findOne({ _id: id }); + query.select({ __v: 0 }); query.exec(function handleGet(error, data) { if (error) { @@ -185,10 +195,10 @@ function find(service, subservice, callback) { query = Group.model.find(condition).sort(); - async.series([ - query.exec.bind(query), - Group.model.countDocuments.bind(Group.model, condition) - ], function(error, results) { + async.series([query.exec.bind(query), Group.model.countDocuments.bind(Group.model, condition)], function( + error, + results + ) { callback(error, { count: results[1], services: results[0].map(toObjectFn) @@ -196,7 +206,6 @@ function find(service, subservice, callback) { }); } - function findBy(fields) { return function() { var query, @@ -217,7 +226,7 @@ function findBy(fields) { logger.debug(context, 'Looking for group params %j with queryObj %j', fields, queryObj); query = Group.model.findOne(queryObj); - query.select({__v: 0}); + query.select({ __v: 0 }); query.exec(function handleGet(error, data) { if (error) { @@ -226,7 +235,6 @@ function findBy(fields) { } else if (data) { logger.debug(context, 'Device group data found: %j', data.toObject()); callback(null, data.toObject()); - } else { logger.debug(context, 'Device group for fields [%j] not found: [%j]', fields, queryObj); @@ -304,8 +312,10 @@ exports.create = alarmsInt(constants.MONGO_ALARM, intoTrans(context, createGroup exports.list = alarmsInt(constants.MONGO_ALARM, intoTrans(context, listGroups)); exports.init = alarmsInt(constants.MONGO_ALARM, intoTrans(context, init)); exports.find = alarmsInt(constants.MONGO_ALARM, intoTrans(context, find)); -exports.findType = alarmsInt(constants.MONGO_ALARM, - intoTrans(context, findBy(['service', 'subservice', 'type', 'apikey']))); +exports.findType = alarmsInt( + constants.MONGO_ALARM, + intoTrans(context, findBy(['service', 'subservice', 'type', 'apikey'])) +); exports.findBy = alarmsInt(constants.MONGO_ALARM, intoTrans(context, findBy)); exports.get = alarmsInt(constants.MONGO_ALARM, intoTrans(context, findBy(['resource', 'apikey']))); exports.getType = alarmsInt(constants.MONGO_ALARM, intoTrans(context, findBy(['type']))); diff --git a/lib/services/groups/groupService.js b/lib/services/groups/groupService.js index fd1dc56c1..4eee7e09a 100644 --- a/lib/services/groups/groupService.js +++ b/lib/services/groups/groupService.js @@ -181,13 +181,12 @@ function remove(service, subservice, resource, apikey, device, callback) { } function deleteDevices(device, service, subservice, id, callback) { - if(device) { - deviceService.listDevices(service, subservice, function (error, devices) { + if (device) { + deviceService.listDevices(service, subservice, function(error, devices) { if (error) { - callback(error); + callback(error); } else { - if (devices && devices.count > 0){ - + if (devices && devices.count > 0) { async.map(devices.devices, unregisterDevice, function(error) { if (error) { callback(error); @@ -201,13 +200,16 @@ function remove(service, subservice, resource, apikey, device, callback) { callback(null, id); } - async.waterfall([ - apply(config.getGroupRegistry().get, resource, apikey), - apply(checkServiceIdentity, service, subservice), - extractId, - apply(deleteDevices, device, service, subservice), - config.getGroupRegistry().remove - ], handleWithIotaRegistration(callback)); + async.waterfall( + [ + apply(config.getGroupRegistry().get, resource, apikey), + apply(checkServiceIdentity, service, subservice), + extractId, + apply(deleteDevices, device, service, subservice), + config.getGroupRegistry().remove + ], + handleWithIotaRegistration(callback) + ); } /** @@ -225,12 +227,15 @@ function update(service, subservice, resource, apikey, body, callback) { callback(null, deviceGroup._id, body); } - async.waterfall([ - apply(config.getGroupRegistry().get, resource, apikey), - apply(checkServiceIdentity, service, subservice), - extractId, - config.getGroupRegistry().update - ], handleWithIotaRegistration(callback)); + async.waterfall( + [ + apply(config.getGroupRegistry().get, resource, apikey), + apply(checkServiceIdentity, service, subservice), + extractId, + config.getGroupRegistry().update + ], + handleWithIotaRegistration(callback) + ); } /** @@ -266,16 +271,23 @@ function getGroup(resource, apikey, callback) { * @param {String} type Type of the device. */ function getEffectiveApiKey(service, subservice, type, callback) { - logger.debug(context, 'Getting effective API Key for service [%s], subservice [%s] and type [%s]', - service, subservice, type); + logger.debug( + context, + 'Getting effective API Key for service [%s], subservice [%s] and type [%s]', + service, + subservice, + type + ); function handleFindGroup(error, group) { if (group) { logger.debug(context, 'Using found group: %j', group); callback(null, group.apikey); - } else if (config.getConfig().types && + } else if ( + config.getConfig().types && config.getConfig().types[type] && - config.getConfig().types[type].apikey) { + config.getConfig().types[type].apikey + ) { logger.debug(context, 'Using API Key for type [%s]: %s', type, config.getConfig().types[type].apikey); callback(null, config.getConfig().types[type].apikey); } else if (config.getConfig().defaultKey) { diff --git a/lib/services/ngsi/ngsiParser.js b/lib/services/ngsi/ngsiParser.js index b1b76bc97..35000b720 100644 --- a/lib/services/ngsi/ngsiParser.js +++ b/lib/services/ngsi/ngsiParser.js @@ -38,8 +38,7 @@ var async = require('async'), * @return {Number|*} */ function getErrorField(body) { - var errorField = body.errorCode || - body.orionError; + var errorField = body.errorCode || body.orionError; if (body && body.contextResponses) { for (var i in body.contextResponses) { diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index a9b7a5ba9..0b7200dd2 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -68,25 +68,32 @@ function generateNGSIOperationHandler(operationName, entityName, typeInformation alarms.raise(constants.ORION_ALARM, error); callback(error); } else if (body && body.orionError) { - logger.debug(context, 'Orion error found executing ' + operationName + ' action in Context Broker: %j', - body.orionError); + logger.debug( + context, + 'Orion error found executing ' + operationName + ' action in Context Broker: %j', + body.orionError + ); callback(new errors.BadRequest(body.orionError.details)); } else if (response && body && response.statusCode === 200) { var errorField = ngsiParser.getErrorField(body); - logger.debug(context, - 'Received the following request from the CB:\n\n%s\n\n', JSON.stringify(body, null, 4)); + logger.debug( + context, + 'Received the following request from the CB:\n\n%s\n\n', + JSON.stringify(body, null, 4) + ); if (errorField) { - logger.error(context, - 'Operation ' + operationName + ' error connecting to the Context Broker: %j', errorField); + logger.error( + context, + 'Operation ' + operationName + ' error connecting to the Context Broker: %j', + errorField + ); - if (errorField.code && errorField.code === '404' && - errorField.details.includes(typeInformation.type) ){ + if (errorField.code && errorField.code === '404' && errorField.details.includes(typeInformation.type)) { callback(new errors.DeviceNotFound(entityName)); - } - else if (errorField.code && errorField.code === '404') { + } else if (errorField.code && errorField.code === '404') { callback(new errors.AttributeNotFound()); } else { callback(new errors.EntityGenericError(entityName, typeInformation.type, errorField)); @@ -98,16 +105,26 @@ function generateNGSIOperationHandler(operationName, entityName, typeInformation } } else if (response && (response.statusCode === 403 || response.statusCode === 401)) { logger.debug(context, 'Access forbidden executing ' + operationName + ' operation'); - callback(new errors.AccessForbidden( - token, - options.headers['fiware-service'], - options.headers['fiware-servicepath'])); + callback( + new errors.AccessForbidden( + token, + options.headers['fiware-service'], + options.headers['fiware-servicepath'] + ) + ); } else { logger.debug(context, 'Unknown error executing ' + operationName + ' operation'); - callback(new errors.EntityGenericError(entityName, typeInformation.type, { - details: body - }, response.statusCode)); + callback( + new errors.EntityGenericError( + entityName, + typeInformation.type, + { + details: body + }, + response.statusCode + ) + ); } }; } @@ -134,61 +151,78 @@ function generateNGSI2OperationHandler(operationName, entityName, typeInformatio alarms.raise(constants.ORION_ALARM, error); callback(error); } else if (body && body.orionError) { - logger.debug(context, 'Orion error found executing ' + operationName + ' action in Context Broker: %j', - body.orionError); + logger.debug( + context, + 'Orion error found executing ' + operationName + ' action in Context Broker: %j', + body.orionError + ); callback(new errors.BadRequest(body.orionError.details)); - } else if (response && operationName === 'update' && (response.statusCode === 204)) { - logger.debug(context, 'Received the following response from the CB: Value updated successfully\n'); - alarms.release(constants.ORION_ALARM); - callback(null, body); + } else if (response && operationName === 'update' && response.statusCode === 204) { + logger.debug(context, 'Received the following response from the CB: Value updated successfully\n'); + alarms.release(constants.ORION_ALARM); + callback(null, body); } else if (response && operationName === 'query' && body !== undefined && response.statusCode === 200) { - logger.debug(context, - 'Received the following response from the CB:\n\n%s\n\n', JSON.stringify(body, null, 4)); - logger.debug(context, 'Value queried successfully'); - alarms.release(constants.ORION_ALARM); - callback(null, body); + logger.debug( + context, + 'Received the following response from the CB:\n\n%s\n\n', + JSON.stringify(body, null, 4) + ); + logger.debug(context, 'Value queried successfully'); + alarms.release(constants.ORION_ALARM); + callback(null, body); } else if (response && operationName === 'query' && response.statusCode === 204) { - logger.debug(context, - 'Received the following response from the CB:\n\n%s\n\n', JSON.stringify(body, null, 4)); + logger.debug( + context, + 'Received the following response from the CB:\n\n%s\n\n', + JSON.stringify(body, null, 4) + ); - logger.error(context, - 'Operation ' + operationName + ' bad status code from the CB: 204.' + - 'A query operation must always return a body'); + logger.error( + context, + 'Operation ' + + operationName + + ' bad status code from the CB: 204.' + + 'A query operation must always return a body' + ); callback(new errors.BadAnswer(response.statusCode, operationName)); } else if (response && (response.statusCode === 403 || response.statusCode === 401)) { logger.debug(context, 'Access forbidden executing ' + operationName + ' operation'); - callback(new errors.AccessForbidden( - token, - options.headers['fiware-service'], - options.headers['fiware-servicepath'])); + callback( + new errors.AccessForbidden( + token, + options.headers['fiware-service'], + options.headers['fiware-servicepath'] + ) + ); } else if (response && body && response.statusCode === 404) { - logger.debug(context, - 'Received the following response from the CB:\n\n%s\n\n', JSON.stringify(body, null, 4)); + logger.debug( + context, + 'Received the following response from the CB:\n\n%s\n\n', + JSON.stringify(body, null, 4) + ); - logger.error(context, - 'Operation ' + operationName + ' error connecting to the Context Broker: %j', body); + logger.error(context, 'Operation ' + operationName + ' error connecting to the Context Broker: %j', body); var errorField = ngsiParser.getErrorField(body); - if (response.statusCode && response.statusCode === 404 && - errorField.details.includes(typeInformation.type) ) { + if ( + response.statusCode && + response.statusCode === 404 && + errorField.details.includes(typeInformation.type) + ) { callback(new errors.DeviceNotFound(entityName)); - } - else if (errorField.code && errorField.code === '404') { + } else if (errorField.code && errorField.code === '404') { callback(new errors.AttributeNotFound()); - } - else { + } else { callback(new errors.EntityGenericError(entityName, typeInformation.type, body)); } } else { logger.debug(context, 'Unknown error executing ' + operationName + ' operation'); - if (! (body instanceof Array || body instanceof Object)) - { + if (!(body instanceof Array || body instanceof Object)) { body = JSON.parse(body); } - callback(new errors.EntityGenericError(entityName, typeInformation.type, - body, response.statusCode)); + callback(new errors.EntityGenericError(entityName, typeInformation.type, body, response.statusCode)); } }; } @@ -238,7 +272,6 @@ function createRequestObject(url, typeInformation, token) { headers: headers }; - return intoTrans(serviceContext, function() { return options; })(); @@ -266,16 +299,17 @@ function applyMiddlewares(middlewareCollection, entity, typeInformation, callbac } function addTimestamp(payload, timezone) { - var timestamp = { - name: constants.TIMESTAMP_ATTRIBUTE, - type: constants.TIMESTAMP_TYPE - }; + name: constants.TIMESTAMP_ATTRIBUTE, + type: constants.TIMESTAMP_TYPE + }; if (!timezone) { - timestamp.value = (new Date()).toISOString(); + timestamp.value = new Date().toISOString(); } else { - timestamp.value = moment().tz(timezone).format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + timestamp.value = moment() + .tz(timezone) + .format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); } function addMetadata(attribute) { @@ -286,8 +320,10 @@ function addTimestamp(payload, timezone) { } for (var i = 0; i < attribute.metadatas.length; i++) { - if (attribute.metadatas[i].type === constants.TIMESTAMP_TYPE && - attribute.metadatas[i].name === constants.TIMESTAMP_ATTRIBUTE) { + if ( + attribute.metadatas[i].type === constants.TIMESTAMP_TYPE && + attribute.metadatas[i].name === constants.TIMESTAMP_ATTRIBUTE + ) { attribute.metadatas[i].value = timestamp.value; timestampFound = true; break; @@ -307,17 +343,17 @@ function addTimestamp(payload, timezone) { } function addTimestampNgsi2(payload, timezone) { - function addTimestampEntity(entity, timezone) { - var timestamp = { - type: constants.TIMESTAMP_TYPE_NGSI2 - }; + type: constants.TIMESTAMP_TYPE_NGSI2 + }; if (!timezone) { - timestamp.value = (new Date()).toISOString(); + timestamp.value = new Date().toISOString(); } else { - timestamp.value = moment().tz(timezone).format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + timestamp.value = moment() + .tz(timezone) + .format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); } function addMetadata(attribute) { @@ -329,11 +365,13 @@ function addTimestampNgsi2(payload, timezone) { for (var i = 0; i < attribute.metadata.length; i++) { if (attribute.metadata[i] === constants.TIMESTAMP_ATTRIBUTE) { - if (attribute.metadata[constants.TIMESTAMP_ATTRIBUTE].type === constants.TIMESTAMP_TYPE_NGSI2 && - attribute.metadata[constants.TIMESTAMP_ATTRIBUTE].value === timestamp.value) { - timestampFound = true; - break; - } + if ( + attribute.metadata[constants.TIMESTAMP_ATTRIBUTE].type === constants.TIMESTAMP_TYPE_NGSI2 && + attribute.metadata[constants.TIMESTAMP_ATTRIBUTE].value === timestamp.value + ) { + timestampFound = true; + break; + } } } @@ -370,34 +408,32 @@ function addTimestampNgsi2(payload, timezone) { } else { return addTimestampEntity(payload, timezone); } - } -function getMetaData(typeInformation, name, metadata){ - if(metadata){ +function getMetaData(typeInformation, name, metadata) { + if (metadata) { return metadata; } var i; - if(typeInformation.active){ + if (typeInformation.active) { for (i = 0; i < typeInformation.active.length; i++) { /* jshint camelcase: false */ - if (name === typeInformation.active[i].object_id){ - return typeInformation.active[i].metadata; + if (name === typeInformation.active[i].object_id) { + return typeInformation.active[i].metadata; } } } - if(typeInformation.staticAttributes){ + if (typeInformation.staticAttributes) { for (i = 0; i < typeInformation.staticAttributes.length; i++) { - if (name === typeInformation.staticAttributes[i].name){ - return typeInformation.staticAttributes[i].metadata; + if (name === typeInformation.staticAttributes[i].name) { + return typeInformation.staticAttributes[i].metadata; } } } return undefined; } - /** * It casts attribute values which are reported using JSON native types * @@ -405,7 +441,6 @@ function getMetaData(typeInformation, name, metadata){ * @return {String} New payload where attributes's values are casted to the corresponding JSON types */ function castJsonNativeAttributes(payload) { - /** * Determines if a value is of type float * @@ -421,26 +456,30 @@ function castJsonNativeAttributes(payload) { } for (var key in payload) { - if (payload.hasOwnProperty(key) && payload[key].value && - payload[key].type && typeof(payload[key].value) === 'string') { + if ( + payload.hasOwnProperty(key) && + payload[key].value && + payload[key].type && + typeof payload[key].value === 'string' + ) { if (payload[key].type === 'Number' && isFloat(payload[key].value)) { payload[key].value = Number.parseFloat(payload[key].value); } else if (payload[key].type === 'Number' && Number.parseInt(payload[key].value)) { payload[key].value = Number.parseInt(payload[key].value); - } - else if (payload[key].type === 'Boolean') { - payload[key].value = (payload[key].value === 'true' || payload[key].value === '1'); - } - else if (payload[key].type === 'None') { + } else if (payload[key].type === 'Boolean') { + payload[key].value = payload[key].value === 'true' || payload[key].value === '1'; + } else if (payload[key].type === 'None') { payload[key].value = null; - } - else if (payload[key].type === 'Array' || payload[key].type === 'Object') { + } else if (payload[key].type === 'Array' || payload[key].type === 'Object') { try { var parsedValue = JSON.parse(payload[key].value); payload[key].value = parsedValue; } catch (e) { - logger.error(context, 'Bad attribute value type.' + - 'Expecting JSON Array or JSON Object. Received:%s', payload[key].value); + logger.error( + context, + 'Bad attribute value type.' + 'Expecting JSON Array or JSON Object. Received:%s', + payload[key].value + ); } } } @@ -459,18 +498,16 @@ function castJsonNativeAttributes(payload) { * @param {String} token User token to identify against the PEP Proxies (optional). */ function sendUpdateValueNgsi2(entityName, attributes, typeInformation, token, callback) { - var payload = {}; var url = '/v2/entities/' + entityName + '/attrs'; if (typeInformation.type) { - url += '?type=' + typeInformation.type; + url += '?type=' + typeInformation.type; } var options = createRequestObject(url, typeInformation, token); - if (typeInformation && typeInformation.staticAttributes) { attributes = attributes.concat(typeInformation.staticAttributes); } @@ -486,11 +523,11 @@ function sendUpdateValueNgsi2(entityName, attributes, typeInformation, token, ca for (var i = 0; i < attributes.length; i++) { if (attributes[i].name && attributes[i].type) { payload[attributes[i].name] = { - 'value' : attributes[i].value, - 'type' : attributes[i].type + value: attributes[i].value, + type: attributes[i].type }; var metadata = getMetaData(typeInformation, attributes[i].name, attributes[i].metadata); - if (metadata){ + if (metadata) { payload[attributes[i].name].metadata = metadata; } } else { @@ -500,96 +537,104 @@ function sendUpdateValueNgsi2(entityName, attributes, typeInformation, token, ca } payload = castJsonNativeAttributes(payload); - async.waterfall([ - apply(statsService.add, 'measureRequests', 1), - apply(applyMiddlewares, updateMiddleware, payload, typeInformation)], + async.waterfall( + [ + apply(statsService.add, 'measureRequests', 1), + apply(applyMiddlewares, updateMiddleware, payload, typeInformation) + ], function(error, result) { - if (error) { - callback(error); - } else { - if (result) { - // The payload has been transformed by multientity plugin. It is not a JSON object but an Array. - if (result instanceof Array) { - options = createRequestObject( - '/v2/op/update', - typeInformation, - token); - - if ( ('timestamp' in typeInformation && typeInformation.timestamp !== - undefined) ? typeInformation.timestamp : config.getConfig().timestamp) { - // jshint maxdepth:5 - if (!utils.isTimestampedNgsi2(result)) { - options.json = addTimestampNgsi2(result, typeInformation.timezone); - // jshint maxdepth:5 - } else if (!utils.IsValidTimestampedNgsi2(result)) { - logger.error(context, 'Invalid timestamp:%s', JSON.stringify(result)); - callback(new errors.BadTimestamp(result)); - return; + if (error) { + callback(error); + } else { + if (result) { + // The payload has been transformed by multientity plugin. It is not a JSON object but an Array. + if (result instanceof Array) { + options = createRequestObject('/v2/op/update', typeInformation, token); + + if ( + 'timestamp' in typeInformation && typeInformation.timestamp !== undefined + ? typeInformation.timestamp + : config.getConfig().timestamp + ) { + // jshint maxdepth:5 + if (!utils.isTimestampedNgsi2(result)) { + options.json = addTimestampNgsi2(result, typeInformation.timezone); + // jshint maxdepth:5 + } else if (!utils.IsValidTimestampedNgsi2(result)) { + logger.error(context, 'Invalid timestamp:%s', JSON.stringify(result)); + callback(new errors.BadTimestamp(result)); + return; + } } - } - options.json = { - actionType: 'append', - entities: result - }; - } else { - delete result.id; - delete result.type; - options.json = result; - logger.debug(context, 'typeInformation: %j', typeInformation); - if ( ('timestamp' in typeInformation && typeInformation.timestamp !== - undefined) ? typeInformation.timestamp : config.getConfig().timestamp) { - if (!utils.isTimestampedNgsi2(options.json)) { - options.json = addTimestampNgsi2(options.json, typeInformation.timezone); - } else if (!utils.IsValidTimestampedNgsi2(options.json)) { - logger.error(context, 'Invalid timestamp:%s', JSON.stringify(options.json)); - callback(new errors.BadTimestamp(options.json)); - return; + options.json = { + actionType: 'append', + entities: result + }; + } else { + delete result.id; + delete result.type; + options.json = result; + logger.debug(context, 'typeInformation: %j', typeInformation); + if ( + 'timestamp' in typeInformation && typeInformation.timestamp !== undefined + ? typeInformation.timestamp + : config.getConfig().timestamp + ) { + if (!utils.isTimestampedNgsi2(options.json)) { + options.json = addTimestampNgsi2(options.json, typeInformation.timezone); + } else if (!utils.IsValidTimestampedNgsi2(options.json)) { + logger.error(context, 'Invalid timestamp:%s', JSON.stringify(options.json)); + callback(new errors.BadTimestamp(options.json)); + return; + } } } + } else { + delete payload.id; + delete payload.type; + options.json = payload; } - } else { - delete payload.id; - delete payload.type; - options.json = payload; - } - // Purge object_id from entities before sent to CB - // object_id was added by createNgsi2Entity to allow multientity - // with duplicate attribute names. - var att; - if (options.json.entities) { - for (var entity = 0; entity < options.json.entities.length; entity++) { - for (att in options.json.entities[entity]) { - /*jshint camelcase: false */ - if (options.json.entities[entity][att].object_id) { + // Purge object_id from entities before sent to CB + // object_id was added by createNgsi2Entity to allow multientity + // with duplicate attribute names. + var att; + if (options.json.entities) { + for (var entity = 0; entity < options.json.entities.length; entity++) { + for (att in options.json.entities[entity]) { /*jshint camelcase: false */ - delete options.json.entities[entity][att].object_id; - } - if (options.json.entities[entity][att].multi) { - delete options.json.entities[entity][att].multi; + if (options.json.entities[entity][att].object_id) { + /*jshint camelcase: false */ + delete options.json.entities[entity][att].object_id; + } + if (options.json.entities[entity][att].multi) { + delete options.json.entities[entity][att].multi; + } } } - } - } else { - for (att in options.json) { - /*jshint camelcase: false */ - if (options.json[att].object_id) { + } else { + for (att in options.json) { /*jshint camelcase: false */ - delete options.json[att].object_id; - } - if (options.json[att].multi) { - delete options.json[att].multi; + if (options.json[att].object_id) { + /*jshint camelcase: false */ + delete options.json[att].object_id; + } + if (options.json[att].multi) { + delete options.json[att].multi; + } } } - } - logger.debug(context, 'Updating device value in the Context Broker at [%s]', options.url); - logger.debug(context, 'Using the following request:\n\n%s\n\n', JSON.stringify(options, null, 4)); + logger.debug(context, 'Updating device value in the Context Broker at [%s]', options.url); + logger.debug(context, 'Using the following request:\n\n%s\n\n', JSON.stringify(options, null, 4)); - request(options, - generateNGSI2OperationHandler('update', entityName, typeInformation, token, options, callback)); + request( + options, + generateNGSI2OperationHandler('update', entityName, typeInformation, token, options, callback) + ); + } } - }); + ); } /** @@ -615,54 +660,65 @@ function sendUpdateValueNgsi1(entityName, attributes, typeInformation, token, ca } payload = { - contextElements: [ - { - type: typeInformation.type, - isPattern: 'false', - id: entityName, - attributes: attributes - } - ] + contextElements: [ + { + type: typeInformation.type, + isPattern: 'false', + id: entityName, + attributes: attributes + } + ] }; - if ('autoprovision' in typeInformation && + if ( + 'autoprovision' in typeInformation && /* jshint -W101 */ - typeInformation.autoprovision === undefined ? typeInformation.autoprovision === true : config.getConfig().appendMode === true) { + typeInformation.autoprovision === undefined + ? typeInformation.autoprovision === true + : config.getConfig().appendMode === true + ) { payload.updateAction = 'APPEND'; } else { payload.updateAction = 'UPDATE'; } - async.waterfall([ - apply(statsService.add, 'measureRequests', 1), - apply(applyMiddlewares, updateMiddleware, payload, typeInformation) - ], function(error, result) { - if (error) { - callback(error); - } else { - if (result) { - options.json = result; + async.waterfall( + [ + apply(statsService.add, 'measureRequests', 1), + apply(applyMiddlewares, updateMiddleware, payload, typeInformation) + ], + function(error, result) { + if (error) { + callback(error); } else { - options.json = payload; - } - - if ( ('timestamp' in typeInformation && typeInformation.timestamp !== undefined) ? - typeInformation.timestamp : config.getConfig().timestamp) { - if (!utils.isTimestamped(options.json)) { - options.json = addTimestamp(options.json, typeInformation.timezone); - } else if (!utils.IsValidTimestamped(options.json)) { - logger.error(context, 'Invalid timestamp:%s', JSON.stringify(options.json)); - callback(new errors.BadTimestamp(options.json)); - return; + if (result) { + options.json = result; + } else { + options.json = payload; } - } + if ( + 'timestamp' in typeInformation && typeInformation.timestamp !== undefined + ? typeInformation.timestamp + : config.getConfig().timestamp + ) { + if (!utils.isTimestamped(options.json)) { + options.json = addTimestamp(options.json, typeInformation.timezone); + } else if (!utils.IsValidTimestamped(options.json)) { + logger.error(context, 'Invalid timestamp:%s', JSON.stringify(options.json)); + callback(new errors.BadTimestamp(options.json)); + return; + } + } - logger.debug(context, 'Updating device value in the Context Broker at [%s]', options.url); - logger.debug(context, 'Using the following request:\n\n%s\n\n', JSON.stringify(options, null, 4)); + logger.debug(context, 'Updating device value in the Context Broker at [%s]', options.url); + logger.debug(context, 'Using the following request:\n\n%s\n\n', JSON.stringify(options, null, 4)); - request(options, - generateNGSIOperationHandler('update', entityName, typeInformation, token, options, callback)); + request( + options, + generateNGSIOperationHandler('update', entityName, typeInformation, token, options, callback) + ); + } } - }); + ); } /** @@ -727,16 +783,16 @@ function sendQueryValueNgsi2(entityName, attributes, typeInformation, token, cal logger.debug(context, 'Querying values of the device in the Context Broker at [%s]', options.url); logger.debug(context, 'Using the following request:\n\n%s\n\n', JSON.stringify(options, null, 4)); - - request(options, - generateNGSI2OperationHandler('query', entityName, typeInformation, token, options, - function(error, result) { - if (error) { - callback(error); - } else { - applyMiddlewares(queryMiddleware, result, typeInformation, callback); - } - })); + request( + options, + generateNGSI2OperationHandler('query', entityName, typeInformation, token, options, function(error, result) { + if (error) { + callback(error); + } else { + applyMiddlewares(queryMiddleware, result, typeInformation, callback); + } + }) + ); } /** @@ -757,29 +813,29 @@ function sendQueryValueNgsi1(entityName, attributes, typeInformation, token, cal } options.json = { - entities: [ - { - type: typeInformation.type, - isPattern: 'false', - id: entityName - } - ], - attributes: attributes - }; + entities: [ + { + type: typeInformation.type, + isPattern: 'false', + id: entityName + } + ], + attributes: attributes + }; logger.debug(context, 'Querying values of the device in the Context Broker at [%s]', options.url); logger.debug(context, 'Using the following request:\n\n%s\n\n', JSON.stringify(options, null, 4)); - - request(options, - generateNGSIOperationHandler('query', entityName, typeInformation, token, options, - function(error, result) { - if (error) { - callback(error); - } else { - applyMiddlewares(queryMiddleware, result, typeInformation, callback); - } - })); + request( + options, + generateNGSIOperationHandler('query', entityName, typeInformation, token, options, function(error, result) { + if (error) { + callback(error); + } else { + applyMiddlewares(queryMiddleware, result, typeInformation, callback); + } + }) + ); } /** @@ -837,11 +893,16 @@ function updateTrust(deviceGroup, deviceInformation, trust, response, callback) * @return {Function} The function that gets all the information wrapping the given operation. */ function executeWithDeviceInformation(operationFunction) { - return function(entityName, type, apikey, attributes, deviceInformation, callback) { - logger.debug(context, + logger.debug( + context, 'executeWithDeviceInfo entityName %s type %s apikey %s attributes %j deviceInformation %j', - entityName, type, apikey, attributes, deviceInformation); + entityName, + type, + apikey, + attributes, + deviceInformation + ); config.getGroupRegistry().getType(type, function(error, deviceGroup) { var typeInformation; if (error) { @@ -864,7 +925,7 @@ function executeWithDeviceInformation(operationFunction) { typeInformation.trust = config.getConfig().types[type].trust; } - if(deviceGroup && deviceGroup.cbHost) { + if (deviceGroup && deviceGroup.cbHost) { typeInformation.cbHost = deviceGroup.cbHost; } } @@ -873,12 +934,15 @@ function executeWithDeviceInformation(operationFunction) { if (config.getConfig().authentication && config.getConfig().authentication.enabled) { var security = config.getSecurityService(); if (typeInformation && typeInformation.trust) { - async.waterfall([ - apply(security.auth, typeInformation.trust), - apply(updateTrust, deviceGroup, deviceInformation, typeInformation.trust), - apply(security.getToken, typeInformation.trust), - apply(operationFunction, entityName, attributes, typeInformation) - ], callback); + async.waterfall( + [ + apply(security.auth, typeInformation.trust), + apply(updateTrust, deviceGroup, deviceInformation, typeInformation.trust), + apply(security.getToken, typeInformation.trust), + apply(operationFunction, entityName, attributes, typeInformation) + ], + callback + ); } else { callback(new errors.SecurityInformationMissing(typeInformation.type)); } @@ -901,9 +965,16 @@ function executeWithDeviceInformation(operationFunction) { * @param {String} commandResult Result of the command in string format. * @param {Object} deviceInformation Device information, including security and service information. (optional). */ -function setCommandResult(entityName, resource, apikey, commandName, - commandResult, status, deviceInformation, callback) { - +function setCommandResult( + entityName, + resource, + apikey, + commandName, + commandResult, + status, + deviceInformation, + callback +) { config.getGroupRegistry().get(resource, apikey, function(error, deviceGroup) { var typeInformation, commandInfo, @@ -920,7 +991,6 @@ function setCommandResult(entityName, resource, apikey, commandName, } ]; - if (!callback) { callback = deviceInformation; @@ -949,21 +1019,14 @@ function setCommandResult(entityName, resource, apikey, commandName, typeInformation.subservice = config.getConfig().subservice; } - commandInfo = _.where(typeInformation.commands, {name: commandName}); + commandInfo = _.where(typeInformation.commands, { name: commandName }); - if(deviceGroup && commandInfo.length !== 1){ - commandInfo = _.where(deviceGroup.commands, {name: commandName}); + if (deviceGroup && commandInfo.length !== 1) { + commandInfo = _.where(deviceGroup.commands, { name: commandName }); } if (commandInfo.length === 1) { - exports.update( - entityName, - resource, - apikey, - attributes, - typeInformation, - callback - ); + exports.update(entityName, resource, apikey, attributes, typeInformation, callback); } else { callback(new errors.CommandNotFound(commandName)); } diff --git a/lib/services/ngsi/subscriptionService.js b/lib/services/ngsi/subscriptionService.js index e1e5a3799..d506ef69b 100644 --- a/lib/services/ngsi/subscriptionService.js +++ b/lib/services/ngsi/subscriptionService.js @@ -35,7 +35,6 @@ var errors = require('../../errors'), op: 'IoTAgentNGSI.NGSIService' }; - /** * Generate a new subscription request handler using NGSIv1, based on the device and triggers given to the function. * @@ -50,23 +49,37 @@ function createSubscriptionHandlerNgsi1(device, triggers, store, callback) { if (error || !body) { logger.debug( context, - 'Transport error found subscribing device with id [%s] to entity [%s]', device.id, device.name); + 'Transport error found subscribing device with id [%s] to entity [%s]', + device.id, + device.name + ); callback(error); - } else if (response.statusCode !== 200 && response.statusCode !== 201) { - logger.debug(context, 'Unknown error subscribing device with id [%s] to entity [%s]: $s', - response.statusCode); - - callback(new errors.EntityGenericError(device.name, device.type, { - details: body - }, response.statusCode)); + logger.debug( + context, + 'Unknown error subscribing device with id [%s] to entity [%s]: $s', + response.statusCode + ); + callback( + new errors.EntityGenericError( + device.name, + device.type, + { + details: body + }, + response.statusCode + ) + ); } else if (body && body.orionError) { logger.debug( context, 'Orion found subscribing device with id [%s] to entity [%s]: %s', - device.id, device.name, body.orionError); + device.id, + device.name, + body.orionError + ); callback(new errors.BadRequest(body.orionError.details)); } else if (store) { @@ -100,23 +113,37 @@ function createSubscriptionHandlerNgsi2(device, triggers, store, callback) { if (error) { logger.debug( context, - 'Transport error found subscribing device with id [%s] to entity [%s]', device.id, device.name); + 'Transport error found subscribing device with id [%s] to entity [%s]', + device.id, + device.name + ); callback(error); - } else if (response.statusCode !== 200 && response.statusCode !== 201) { - logger.debug(context, 'Unknown error subscribing device with id [%s] to entity [%s]: $s', - response.statusCode); - - callback(new errors.EntityGenericError(device.name, device.type, { - details: body - }, response.statusCode)); + logger.debug( + context, + 'Unknown error subscribing device with id [%s] to entity [%s]: $s', + response.statusCode + ); + callback( + new errors.EntityGenericError( + device.name, + device.type, + { + details: body + }, + response.statusCode + ) + ); } else if (body && body.orionError) { logger.debug( context, 'Orion found subscribing device with id [%s] to entity [%s]: %s', - device.id, device.name, body.orionError); + device.id, + device.name, + body.orionError + ); callback(new errors.BadRequest(body.orionError.details)); } else if (store) { @@ -147,12 +174,12 @@ function createSubscriptionHandlerNgsi2(device, triggers, store, callback) { */ function subscribeNgsi1(device, triggers, content, callback) { var options = { - method: 'POST', - headers: { - 'fiware-service': device.service, - 'fiware-servicepath': device.subservice - }, - json: { + method: 'POST', + headers: { + 'fiware-service': device.service, + 'fiware-servicepath': device.subservice + }, + json: { entities: [ { type: device.type, @@ -184,8 +211,11 @@ function subscribeNgsi1(device, triggers, content, callback) { } else { options.uri = config.getConfig().contextBroker.url + '/v1/subscribeContext'; } - deviceService.executeWithSecurity(options, - device, createSubscriptionHandlerNgsi1(device, triggers, store, callback)); + deviceService.executeWithSecurity( + options, + device, + createSubscriptionHandlerNgsi1(device, triggers, store, callback) + ); } /** @@ -198,33 +228,32 @@ function subscribeNgsi1(device, triggers, content, callback) { * @param {Object} content Array with the names of the attributes to retrieve in the notification. */ function subscribeNgsi2(device, triggers, content, callback) { - var options = { + var options = { method: 'POST', headers: { 'fiware-service': device.service, 'fiware-servicepath': device.subservice }, json: { - subject: - { - entities: [ - { - id: device.name, - type: device.type - } - ], - - condition: { - attrs: triggers - }, - }, - notification: { - http: { - url: config.getConfig().providerUrl + '/notify' - }, - attrs: content || [], - attrsFormat: 'normalized' + subject: { + entities: [ + { + id: device.name, + type: device.type + } + ], + + condition: { + attrs: triggers } + }, + notification: { + http: { + url: config.getConfig().providerUrl + '/notify' + }, + attrs: content || [], + attrsFormat: 'normalized' + } } }; @@ -241,8 +270,11 @@ function subscribeNgsi2(device, triggers, content, callback) { } else { options.uri = config.getConfig().contextBroker.url + '/v2/subscriptions'; } - deviceService.executeWithSecurity(options, - device, createSubscriptionHandlerNgsi2(device, triggers, store, callback)); + deviceService.executeWithSecurity( + options, + device, + createSubscriptionHandlerNgsi2(device, triggers, store, callback) + ); } /** @@ -276,25 +308,37 @@ function createUnsubscribeHandlerNgsi1(device, id, callback) { if (error || !body) { logger.debug( context, - 'Transport error found subscribing device with id [%s] to entity [%s]', device.id, device.name); + 'Transport error found subscribing device with id [%s] to entity [%s]', + device.id, + device.name + ); callback(error); - } else if (response.statusCode !== 200 && response.statusCode !== 201) { logger.debug( context, 'Unknown error subscribing device with id [%s] to entity [%s]: $s', - response.statusCode); - - callback(new errors.EntityGenericError(device.name, device.type, { - details: body - }, response.statusCode)); + response.statusCode + ); + callback( + new errors.EntityGenericError( + device.name, + device.type, + { + details: body + }, + response.statusCode + ) + ); } else if (body && body.orionError) { logger.debug( context, 'Orion found subscribing device with id [%s] to entity [%s]: %s', - device.id, device.name, body.orionError); + device.id, + device.name, + body.orionError + ); callback(new errors.BadRequest(body.orionError.details)); } else { @@ -318,25 +362,37 @@ function createUnsubscribeHandlerNgsi2(device, id, callback) { if (error) { logger.debug( context, - 'Transport error found subscribing device with id [%s] to entity [%s]', device.id, device.name); + 'Transport error found subscribing device with id [%s] to entity [%s]', + device.id, + device.name + ); callback(error); - } else if (response.statusCode !== 204) { logger.debug( context, 'Unknown error subscribing device with id [%s] to entity [%s]: $s', - response.statusCode); - - callback(new errors.EntityGenericError(device.name, device.type, { - details: body - }, response.statusCode)); + response.statusCode + ); + callback( + new errors.EntityGenericError( + device.name, + device.type, + { + details: body + }, + response.statusCode + ) + ); } else if (body && body.orionError) { logger.debug( context, 'Orion found subscribing device with id [%s] to entity [%s]: %s', - device.id, device.name, body.orionError); + device.id, + device.name, + body.orionError + ); callback(new errors.BadRequest(body.orionError.details)); } else { @@ -362,7 +418,6 @@ function unsubscribeNgsi1(device, id, callback) { json: { subscriptionId: id } - }; if (device.cbHost && device.cbHost.indexOf('://') !== -1) { diff --git a/lib/services/northBound/contextServer.js b/lib/services/northBound/contextServer.js index d757bc89b..a9d60b36c 100644 --- a/lib/services/northBound/contextServer.js +++ b/lib/services/northBound/contextServer.js @@ -150,13 +150,7 @@ function executeUpdateSideEffects(device, id, type, service, subservice, attribu ]; sideEffects.push( - apply(ngsi.update, - device.name, - device.resource, - device.apikey, - newAttributes, - device - ) + apply(ngsi.update, device.name, device.resource, device.apikey, newAttributes, device) ); } } @@ -206,7 +200,6 @@ function generateUpdateActionsNgsi1(req, contextElement, callback) { attributes.push(contextElement.attributes[i]); } - } else { attributes = contextElement.attributes; } @@ -225,7 +218,8 @@ function generateUpdateActionsNgsi1(req, contextElement, callback) { contextElement.type, req.headers['fiware-service'], req.headers['fiware-servicepath'], - attributes) + attributes + ) ); } @@ -239,7 +233,8 @@ function generateUpdateActionsNgsi1(req, contextElement, callback) { contextElement.type, req.headers['fiware-service'], req.headers['fiware-servicepath'], - contextElement.attributes) + contextElement.attributes + ) ); } else { updateActions.push( @@ -249,7 +244,8 @@ function generateUpdateActionsNgsi1(req, contextElement, callback) { contextElement.type, req.headers['fiware-service'], req.headers['fiware-servicepath'], - commands) + commands + ) ); } } @@ -262,36 +258,38 @@ function generateUpdateActionsNgsi1(req, contextElement, callback) { contextElement.type, req.headers['fiware-service'], req.headers['fiware-servicepath'], - contextElement.attributes) + contextElement.attributes + ) ); callback(null, updateActions); } - deviceService.getDeviceByName(contextElement.id, req.headers['fiware-service'], req.headers['fiware-servicepath'], + deviceService.getDeviceByName( + contextElement.id, + req.headers['fiware-service'], + req.headers['fiware-servicepath'], function(error, deviceObj) { if (error) { callback(error); } else { - async.waterfall([ - apply(deviceService.findConfigurationGroup, deviceObj), - apply(deviceService.mergeDeviceWithConfiguration, - [ - 'lazy', - 'internalAttributes', - 'active', - 'staticAttributes', - 'commands', - 'subscriptions' - ], - [null, null, [], [], [], [], []], - deviceObj - ), - splitUpdates, - createActionsArray - ], callback); + async.waterfall( + [ + apply(deviceService.findConfigurationGroup, deviceObj), + apply( + deviceService.mergeDeviceWithConfiguration, + ['lazy', 'internalAttributes', 'active', 'staticAttributes', 'commands', 'subscriptions'], + [null, null, [], [], [], [], []], + deviceObj + ), + splitUpdates, + createActionsArray + ], + callback + ); } - }); + } + ); } /** @@ -308,7 +306,7 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { if (contextElement.id && contextElement.type) { entityId = contextElement.id; entityType = contextElement.type; - }else if (req.params.entity) { + } else if (req.params.entity) { entityId = req.params.entity; } @@ -322,7 +320,6 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { if (device.commands) { attributeLoop: for (i in contextElement) { for (var j in device.commands) { - if (i === device.commands[j].name) { newAtt = {}; newAtt[i] = contextElement[i]; @@ -333,7 +330,6 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { } } } - } for (i in contextElement) { @@ -351,7 +347,7 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { function createActionsArray(attributes, commands, device, callback) { var updateActions = []; - if(!entityType) { + if (!entityType) { entityType = device.type; } @@ -363,7 +359,8 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { entityType, req.headers['fiware-service'], req.headers['fiware-servicepath'], - attributes) + attributes + ) ); } @@ -377,7 +374,8 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { entityType, req.headers['fiware-service'], req.headers['fiware-servicepath'], - attributes) + attributes + ) ); } else { updateActions.push( @@ -387,7 +385,8 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { entityType, req.headers['fiware-service'], req.headers['fiware-servicepath'], - commands) + commands + ) ); } } @@ -400,36 +399,36 @@ function generateUpdateActionsNgsi2(req, contextElement, callback) { entityType, req.headers['fiware-service'], req.headers['fiware-servicepath'], - attributes) + attributes + ) ); callback(null, updateActions); } - deviceService.getDeviceByName(entityId, req.headers['fiware-service'], req.headers['fiware-servicepath'], - function(error, deviceObj) { - if (error) { - callback(error); - } else { - async.waterfall([ + deviceService.getDeviceByName(entityId, req.headers['fiware-service'], req.headers['fiware-servicepath'], function( + error, + deviceObj + ) { + if (error) { + callback(error); + } else { + async.waterfall( + [ apply(deviceService.findConfigurationGroup, deviceObj), - apply(deviceService.mergeDeviceWithConfiguration, - [ - 'lazy', - 'internalAttributes', - 'active', - 'staticAttributes', - 'commands', - 'subscriptions' - ], + apply( + deviceService.mergeDeviceWithConfiguration, + ['lazy', 'internalAttributes', 'active', 'staticAttributes', 'commands', 'subscriptions'], [null, null, [], [], [], [], []], deviceObj ), splitUpdates, createActionsArray - ], callback); - } - }); + ], + callback + ); + } + }); } /** @@ -444,20 +443,19 @@ function handleUpdateNgsi2(req, res, next) { logger.debug(context, 'Handling update from [%s]', req.get('host')); logger.debug(context, req.body); - async.waterfall([ - apply(async.map, req.body.entities, apply(generateUpdateActionsNgsi2, req)), - reduceActions, - async.series - ], function(error, result) { - if (error) { - logger.debug(context, 'There was an error handling the update action: %s.', error); + async.waterfall( + [apply(async.map, req.body.entities, apply(generateUpdateActionsNgsi2, req)), reduceActions, async.series], + function(error, result) { + if (error) { + logger.debug(context, 'There was an error handling the update action: %s.', error); - next(error); - } else { - logger.debug(context, 'Update action from [%s] handled successfully.', req.get('host')); - res.status(204).json(); + next(error); + } else { + logger.debug(context, 'Update action from [%s] handled successfully.', req.get('host')); + res.status(204).json(); + } } - }); + ); } else { logger.error(context, 'Tried to handle an update request before the update handler was stablished.'); @@ -474,7 +472,6 @@ function handleUpdateNgsi2(req, res, next) { * to the user update handler function is made. */ function handleUpdateNgsi1(req, res, next) { - function reduceActions(actions, callback) { callback(null, _.flatten(actions)); } @@ -483,20 +480,23 @@ function handleUpdateNgsi1(req, res, next) { logger.debug(context, 'Handling update from [%s]', req.get('host')); logger.debug(context, req.body); - async.waterfall([ - apply(async.map, req.body.contextElements, apply(generateUpdateActionsNgsi1, req)), - reduceActions, - async.series - ], function(error, result) { - if (error) { - logger.debug(context, 'There was an error handling the update action: %s.', error); + async.waterfall( + [ + apply(async.map, req.body.contextElements, apply(generateUpdateActionsNgsi1, req)), + reduceActions, + async.series + ], + function(error, result) { + if (error) { + logger.debug(context, 'There was an error handling the update action: %s.', error); - next(error); - } else { - logger.debug(context, 'Update action from [%s] handled successfully.', req.get('host')); - res.status(200).json(createUpdateResponse(req, res, result)); + next(error); + } else { + logger.debug(context, 'Update action from [%s] handled successfully.', req.get('host')); + res.status(200).json(createUpdateResponse(req, res, result)); + } } - }); + ); } else { logger.error(context, 'Tried to handle an update request before the update handler was stablished.'); @@ -609,7 +609,6 @@ function handleQueryNgsi1(req, res, next) { } function addStaticAttributes(attributes, device, contextElement, callback) { - function inAttributes(item) { return item.name && attributes.indexOf(item.name) >= 0; } @@ -637,7 +636,9 @@ function handleQueryNgsi1(req, res, next) { logger.debug(context, 'Handling stored set of attributes: %j', attributes); callback(null, device.lazy.map(getName)); } else { - logger.debug(context, 'Couldn\'t find any attributes. Handling with null reference'); + /*jshint quotmark: double */ + logger.debug(context, "Couldn't find any attributes. Handling with null reference"); + /*jshint quotmark: single */ callback(null, null); } } @@ -651,39 +652,33 @@ function handleQueryNgsi1(req, res, next) { actualHandler = defaultQueryHandlerNgsi1; } - async.waterfall([ - apply( - deviceService.getDeviceByName, - contextEntity.id, - req.headers['fiware-service'], - req.headers['fiware-servicepath']), - deviceService.findConfigurationGroup - ], function handleFindDevice(error, device) { - var executeCompleteAttributes = apply( - completeAttributes, - attributes, - device - ), - executeQueryHandler = apply( - actualHandler, + async.waterfall( + [ + apply( + deviceService.getDeviceByName, contextEntity.id, - contextEntity.type, req.headers['fiware-service'], req.headers['fiware-servicepath'] ), - executeAddStaticAttributes = apply( - addStaticAttributes, - attributes, - device - ); - - callback(error, apply(async.waterfall, [ - executeCompleteAttributes, - executeQueryHandler, - executeAddStaticAttributes - ])); - }); + deviceService.findConfigurationGroup + ], + function handleFindDevice(error, device) { + var executeCompleteAttributes = apply(completeAttributes, attributes, device), + executeQueryHandler = apply( + actualHandler, + contextEntity.id, + contextEntity.type, + req.headers['fiware-service'], + req.headers['fiware-servicepath'] + ), + executeAddStaticAttributes = apply(addStaticAttributes, attributes, device); + callback( + error, + apply(async.waterfall, [executeCompleteAttributes, executeQueryHandler, executeAddStaticAttributes]) + ); + } + ); } function handleQueryContextRequests(error, result) { @@ -698,10 +693,10 @@ function handleQueryNgsi1(req, res, next) { logger.debug(context, 'Handling query from [%s]', req.get('host')); - async.waterfall([ - apply(async.map, req.body.entities, apply(createQueryRequests, req.body.attributes)), - async.series - ], handleQueryContextRequests); + async.waterfall( + [apply(async.map, req.body.entities, apply(createQueryRequests, req.body.attributes)), async.series], + handleQueryContextRequests + ); } /** @@ -713,25 +708,22 @@ function handleQueryNgsi2(req, res, next) { } function addStaticAttributes(attributes, device, contextElement, callback) { - function inAttributes(item) { return item.name && attributes.indexOf(item.name) >= 0; } if (device.staticAttributes) { - var selectedAttributes = []; if (attributes === undefined || attributes.length === 0) { selectedAttributes = device.staticAttributes; - } - else { + } else { selectedAttributes = device.staticAttributes.filter(inAttributes); } for (var att in selectedAttributes) { contextElement[selectedAttributes[att].name] = { - 'type' : selectedAttributes[att].type, - 'value' : selectedAttributes[att].value + type: selectedAttributes[att].type, + value: selectedAttributes[att].value }; } } @@ -748,7 +740,9 @@ function handleQueryNgsi2(req, res, next) { var results = device.lazy.map(getName); callback(null, results); } else { - logger.debug(context, 'Couldn\'t find any attributes. Handling with null reference'); + /*jshint quotmark: double */ + logger.debug(context, "Couldn't find any attributes. Handling with null reference"); + /*jshint quotmark: single */ callback(null, null); } } @@ -756,20 +750,16 @@ function handleQueryNgsi2(req, res, next) { function finishQueryForDevice(attributes, contextEntity, actualHandler, device, callback) { var contextId = contextEntity.id; var contextType = contextEntity.type; - if(!contextId) { + if (!contextId) { contextId = device.id; } - if(!contextType) { + if (!contextType) { contextType = device.type; } deviceService.findConfigurationGroup(device, function(error, group) { - var executeCompleteAttributes = apply( - completeAttributes, - attributes, - group - ), + var executeCompleteAttributes = apply(completeAttributes, attributes, group), executeQueryHandler = apply( actualHandler, contextId, @@ -777,18 +767,10 @@ function handleQueryNgsi2(req, res, next) { req.headers['fiware-service'], req.headers['fiware-servicepath'] ), - executeAddStaticAttributes = apply( - addStaticAttributes, - attributes, - group - ); + executeAddStaticAttributes = apply(addStaticAttributes, attributes, group); - async.waterfall([ - executeCompleteAttributes, - executeQueryHandler, - executeAddStaticAttributes - ], callback); - }); + async.waterfall([executeCompleteAttributes, executeQueryHandler, executeAddStaticAttributes], callback); + }); } function createQueryRequest(attributes, contextEntity, callback) { @@ -806,7 +788,8 @@ function handleQueryNgsi2(req, res, next) { deviceService.getDeviceByName, contextEntity.id, req.headers['fiware-service'], - req.headers['fiware-servicepath']); + req.headers['fiware-servicepath'] + ); } else { getFunction = apply( deviceService.listDevicesWithType, @@ -814,7 +797,8 @@ function handleQueryNgsi2(req, res, next) { req.headers['fiware-service'], req.headers['fiware-servicepath'], null, - null); + null + ); } getFunction(function handleFindDevice(error, innerDevice) { @@ -823,7 +807,7 @@ function handleQueryNgsi2(req, res, next) { return callback(new errors.DeviceNotFound(contextEntity.id)); } - if(innerDevice.count) { + if (innerDevice.count) { if (innerDevice.count === 0) { return callback(null, []); } else { @@ -833,21 +817,21 @@ function handleQueryNgsi2(req, res, next) { deviceList = [innerDevice]; } - async.map(deviceList, async.apply( - finishQueryForDevice, attributes, contextEntity, actualHandler), function (error, results) { + async.map(deviceList, async.apply(finishQueryForDevice, attributes, contextEntity, actualHandler), function( + error, + results + ) { if (error) { callback(error); - } - else if(innerDevice.count) { - callback(null,results); - } else if(Array.isArray(results) && results.length > 0){ + } else if (innerDevice.count) { + callback(null, results); + } else if (Array.isArray(results) && results.length > 0) { callback(null, results); } else { callback(null, results); } }); }); - } function handleQueryContextRequests(error, result) { @@ -865,17 +849,17 @@ function handleQueryNgsi2(req, res, next) { // At the present moment, IOTA supports query request with one entity and without patterns. This is aligned // with the utilization cases in combination with ContextBroker. Other cases are returned as error - if (req.body.entities.length !== 1) - { - logger.warn('queries with entities number different to 1 are not supported (%d found)', - req.body.entities.length); - handleQueryContextRequests({code: 400, name: 'BadRequest', message: 'more than one entity in query'}); + if (req.body.entities.length !== 1) { + logger.warn( + 'queries with entities number different to 1 are not supported (%d found)', + req.body.entities.length + ); + handleQueryContextRequests({ code: 400, name: 'BadRequest', message: 'more than one entity in query' }); return; } - if (req.body.entities[0].idPattern) - { + if (req.body.entities[0].idPattern) { logger.warn('queries with idPattern are not supported'); - handleQueryContextRequests({code: 400, name: 'BadRequest', message: 'idPattern usage in query'}); + handleQueryContextRequests({ code: 400, name: 'BadRequest', message: 'idPattern usage in query' }); return; } @@ -883,11 +867,9 @@ function handleQueryNgsi2(req, res, next) { contextEntity.type = req.body.entities[0].type; var queryAtts = req.body.attrs; createQueryRequest(queryAtts, contextEntity, handleQueryContextRequests); - } function handleNotificationNgsi1(req, res, next) { - function checkStatus(statusCode, callback) { if (statusCode.code && statusCode.code === '200') { callback(); @@ -907,7 +889,8 @@ function handleNotificationNgsi1(req, res, next) { } else { callback(null, device, contextResponse.contextElement.attributes); } - }); + } + ); } function applyNotificationMiddlewares(device, values, callback) { @@ -924,12 +907,15 @@ function handleNotificationNgsi1(req, res, next) { } function createNotificationHandler(contextResponse, callback) { - async.waterfall([ - apply(checkStatus, contextResponse.statusCode), - apply(extractInformation, contextResponse), - applyNotificationMiddlewares, - notificationHandler - ], callback); + async.waterfall( + [ + apply(checkStatus, contextResponse.statusCode), + apply(extractInformation, contextResponse), + applyNotificationMiddlewares, + notificationHandler + ], + callback + ); } function handleNotificationRequests(error) { @@ -945,7 +931,6 @@ function handleNotificationNgsi1(req, res, next) { logger.debug(context, 'Handling notification from [%s]', req.get('host')); async.map(req.body.contextResponses, createNotificationHandler, handleNotificationRequests); - } else { var errorNotFound = new Error({ message: 'Notification handler not found' @@ -981,7 +966,8 @@ function handleNotificationNgsi2(req, res, next) { } else { callback(null, device, atts); } - }); + } + ); } function applyNotificationMiddlewares(device, values, callback) { @@ -998,11 +984,10 @@ function handleNotificationNgsi2(req, res, next) { } function createNotificationHandler(contextResponse, callback) { - async.waterfall([ - apply(extractInformation, contextResponse), - applyNotificationMiddlewares, - notificationHandler - ], callback); + async.waterfall( + [apply(extractInformation, contextResponse), applyNotificationMiddlewares, notificationHandler], + callback + ); } function handleNotificationRequests(error) { @@ -1017,7 +1002,6 @@ function handleNotificationNgsi2(req, res, next) { if (notificationHandler) { logger.debug(context, 'Handling notification from [%s]', req.get('host')); async.map(req.body.data, createNotificationHandler, handleNotificationRequests); - } else { var errorNotFound = new Error({ message: 'Notification handler not found' @@ -1027,7 +1011,6 @@ function handleNotificationNgsi2(req, res, next) { next(errorNotFound); } - } /** @@ -1128,20 +1111,18 @@ function updateErrorHandlingNgsi1(error, req, res, next) { code = error.code; } - res.status(code).json( - { - contextResponses: [ - { - contextElement: req.body, - statusCode: { - code: code, - reasonPhrase: error.name, - details: error.message.replace(/[<>\"\'=;\(\)]/g, '') - } + res.status(code).json({ + contextResponses: [ + { + contextElement: req.body, + statusCode: { + code: code, + reasonPhrase: error.name, + details: error.message.replace(/[<>\"\'=;\(\)]/g, '') } - ] - } - ); + } + ] + }); } function updateErrorHandlingNgsi2(error, req, res, next) { @@ -1184,30 +1165,13 @@ function loadContextRoutes(router) { handleQueryNgsi1, queryErrorHandlingNgsi1 ], - queryMiddlewaresNgsi2 = [ - handleQueryNgsi2, - queryErrorHandlingNgsi2 - ], - updatePathsNgsi1 = [ - '/v1/updateContext', - '/NGSI10/updateContext', - '//updateContext' - ], - updatePathsNgsi2 = [ - '/v2/op/update', - '//op/update' - ], - queryPathsNgsi1 = [ - '/v1/queryContext', - '/NGSI10/queryContext', - '//queryContext' - ], - queryPathsNgsi2 = [ - '/v2/op/query', - '//op/query' - ]; - // In a more evolved implementation, more endpoints could be added to queryPathsNgsi2 - // according to http://fiware.github.io/specifications/ngsiv2/stable. + queryMiddlewaresNgsi2 = [handleQueryNgsi2, queryErrorHandlingNgsi2], + updatePathsNgsi1 = ['/v1/updateContext', '/NGSI10/updateContext', '//updateContext'], + updatePathsNgsi2 = ['/v2/op/update', '//op/update'], + queryPathsNgsi1 = ['/v1/queryContext', '/NGSI10/queryContext', '//queryContext'], + queryPathsNgsi2 = ['/v2/op/query', '//op/query']; + // In a more evolved implementation, more endpoints could be added to queryPathsNgsi2 + // according to http://fiware.github.io/specifications/ngsiv2/stable. logger.info(context, 'Loading NGSI Contect server routes'); var i; diff --git a/lib/services/northBound/deviceGroupAdministrationServer.js b/lib/services/northBound/deviceGroupAdministrationServer.js index 85801399e..28a51b42f 100644 --- a/lib/services/northBound/deviceGroupAdministrationServer.js +++ b/lib/services/northBound/deviceGroupAdministrationServer.js @@ -33,23 +33,18 @@ var restUtils = require('./restUtils'), removeConfigurationHandler, configurationMiddleware = [], _ = require('underscore'), - mandatoryHeaders = [ - 'fiware-service', - 'fiware-servicepath' - ], - mandatoryParameters = [ - 'resource', - 'apikey' - ], + mandatoryHeaders = ['fiware-service', 'fiware-servicepath'], + mandatoryParameters = ['resource', 'apikey'], + /*jshint camelcase: false */ apiToInternal = { - 'entity_type': 'type', - 'internal_attributes': 'internalAttributes', - 'static_attributes': 'staticAttributes' + entity_type: 'type', + internal_attributes: 'internalAttributes', + static_attributes: 'staticAttributes' }, internalToApi = { - 'type': 'entity_type', - 'internalAttributes': 'internal_attributes', - 'staticAttributes': 'static_attributes' + type: 'entity_type', + internalAttributes: 'internal_attributes', + staticAttributes: 'static_attributes' }; function applyMap(translation, body) { @@ -82,7 +77,6 @@ function applyConfigurationHandler(newConfiguration, callback) { } } - /** * Apply the handler for configuration removal. * @@ -93,7 +87,7 @@ function applyRemoveConfigurationHandler(groupToDelete, callback) { removeConfigurationHandler(groupToDelete, callback); } else { callback(); - } + } } /** @@ -115,7 +109,6 @@ function applyConfigurationMiddlewares(newConfiguration, callback) { } } - /** * Handle the device group creation requests, adding the header information to the device group body. * @@ -132,17 +125,20 @@ function handleCreateDeviceGroup(req, res, next) { req.body.services[i].subservice = req.headers['fiware-servicepath']; } - async.series([ - apply(groupService.create, req.body), - apply(applyConfigurationMiddlewares, req.body), - apply(applyConfigurationHandler, req.body) - ], function(error) { - if (error) { - next(error); - } else { - res.status(201).send({}); + async.series( + [ + apply(groupService.create, req.body), + apply(applyConfigurationMiddlewares, req.body), + apply(applyConfigurationHandler, req.body) + ], + function(error) { + if (error) { + next(error); + } else { + res.status(201).send({}); + } } - }); + ); } /** @@ -172,11 +168,7 @@ function handleListDeviceGroups(req, res, next) { }; if (req.headers['fiware-servicepath'] === '/*') { - groupService.list( - req.headers['fiware-service'], - req.query.limit, - req.query.offset, - listHandler); + groupService.list(req.headers['fiware-service'], req.query.limit, req.query.offset, listHandler); } else { groupService.find(req.headers['fiware-service'], req.headers['fiware-servicepath'], null, listHandler); } @@ -201,18 +193,27 @@ function handleModifyDeviceGroups(req, res, next) { callback(null, group); } - async.series([ - apply(groupService.update, req.headers['fiware-service'], req.headers['fiware-servicepath'], - req.query.resource, req.query.apikey, req.body), - apply(addInformation, req.body), - apply(applyConfigurationHandler, req.body) - ], function(error) { - if (error) { - next(error); - } else { - res.status(204).send({}); + async.series( + [ + apply( + groupService.update, + req.headers['fiware-service'], + req.headers['fiware-servicepath'], + req.query.resource, + req.query.apikey, + req.body + ), + apply(addInformation, req.body), + apply(applyConfigurationHandler, req.body) + ], + function(error) { + if (error) { + next(error); + } else { + res.status(204).send({}); + } } - }); + ); } /** @@ -224,38 +225,39 @@ function handleModifyDeviceGroups(req, res, next) { */ function handleDeleteDeviceGroups(req, res, next) { - - function getGroup (req, callback) { - groupService.get(req.query.resource, req.query.apikey, function (error, group){ + function getGroup(req, callback) { + groupService.get(req.query.resource, req.query.apikey, function(error, group) { if (error) { callback(error); - } else{ + } else { callback(null, group); - } + } }); } - function deleteGroup (req, groupToDelete, callback) { - groupService.remove(req.headers['fiware-service'], req.headers['fiware-servicepath'], - req.query.resource, req.query.apikey, req.query.device, function (error){ - if (error) { - callback(error); - } else{ - callback(null, groupToDelete); + function deleteGroup(req, groupToDelete, callback) { + groupService.remove( + req.headers['fiware-service'], + req.headers['fiware-servicepath'], + req.query.resource, + req.query.apikey, + req.query.device, + function(error) { + if (error) { + callback(error); + } else { + callback(null, groupToDelete); + } } - }); + ); } - async.waterfall([ - apply(getGroup, req), - apply(deleteGroup, req), - applyRemoveConfigurationHandler], - function(error) { - if (error) { - next(error); - } else { - res.status(204).send({}); - } - }); + async.waterfall([apply(getGroup, req), apply(deleteGroup, req), applyRemoveConfigurationHandler], function(error) { + if (error) { + next(error); + } else { + res.status(204).send({}); + } + }); } /** @@ -264,24 +266,28 @@ function handleDeleteDeviceGroups(req, res, next) { * @param {Object} router Express request router object. */ function loadContextRoutes(router) { - router.post('/iot/services', + router.post( + '/iot/services', restUtils.checkRequestAttributes('headers', mandatoryHeaders), restUtils.checkBody(templateGroup), - handleCreateDeviceGroup); + handleCreateDeviceGroup + ); - router.get('/iot/services', - restUtils.checkRequestAttributes('headers', mandatoryHeaders), - handleListDeviceGroups); + router.get('/iot/services', restUtils.checkRequestAttributes('headers', mandatoryHeaders), handleListDeviceGroups); - router.put('/iot/services', + router.put( + '/iot/services', restUtils.checkRequestAttributes('headers', mandatoryHeaders), restUtils.checkRequestAttributes('query', mandatoryParameters), - handleModifyDeviceGroups); + handleModifyDeviceGroups + ); - router.delete('/iot/services', + router.delete( + '/iot/services', restUtils.checkRequestAttributes('headers', mandatoryHeaders), restUtils.checkRequestAttributes('query', mandatoryParameters), - handleDeleteDeviceGroups); + handleDeleteDeviceGroups + ); } function setConfigurationHandler(newHandler) { diff --git a/lib/services/northBound/deviceProvisioningServer.js b/lib/services/northBound/deviceProvisioningServer.js index 751fc7557..4423903b9 100644 --- a/lib/services/northBound/deviceProvisioningServer.js +++ b/lib/services/northBound/deviceProvisioningServer.js @@ -38,10 +38,7 @@ var async = require('async'), removeDeviceHandler, updateDeviceTemplate = require('../../templates/updateDevice.json'), createDeviceTemplate = require('../../templates/createDevice.json'), - mandatoryHeaders = [ - 'fiware-service', - 'fiware-servicepath' - ], + mandatoryHeaders = ['fiware-service', 'fiware-servicepath'], provisioningMiddlewares = [], provisioningAPITranslation = { /* jshint camelcase:false */ @@ -69,7 +66,6 @@ var async = require('async'), * NGSI Service for the registration. */ function handleProvision(req, res, next) { - function handleProvisioningFinish(error, results) { if (error) { logger.debug(context, 'Device provisioning failed due to the following error: ', error.message); @@ -128,15 +124,17 @@ function handleProvision(req, res, next) { } function provisionSingleDevice(device, callback) { - async.waterfall([ - apply(statsRegistry.add, 'deviceCreationRequests', 1), - apply(restUtils.checkMandatoryQueryParams, - ['device_id'], device), - apply(fillDeviceData, req.headers['fiware-service'], req.headers['fiware-servicepath']), - applyProvisioningMiddlewares, - applyProvisioningHandler, - deviceService.register - ], callback); + async.waterfall( + [ + apply(statsRegistry.add, 'deviceCreationRequests', 1), + apply(restUtils.checkMandatoryQueryParams, ['device_id'], device), + apply(fillDeviceData, req.headers['fiware-service'], req.headers['fiware-servicepath']), + applyProvisioningMiddlewares, + applyProvisioningHandler, + deviceService.register + ], + callback + ); } function extractDevices() { @@ -183,9 +181,9 @@ function toProvisioningAPIFormat(device) { timestamp: device.timestamp, endpoint: device.endpoint, transport: device.transport, - attributes: (device.active) ? device.active.map(attributeToProvisioningAPIFormat) : undefined, - lazy: (device.lazy) ? device.lazy.map(attributeToProvisioningAPIFormat) : undefined, - commands: (device.commands) ? device.commands.map(attributeToProvisioningAPIFormat) : undefined, + attributes: device.active ? device.active.map(attributeToProvisioningAPIFormat) : undefined, + lazy: device.lazy ? device.lazy.map(attributeToProvisioningAPIFormat) : undefined, + commands: device.commands ? device.commands.map(attributeToProvisioningAPIFormat) : undefined, static_attributes: device.staticAttributes, internal_attributes: device.internalAttributes, protocol: device.protocol, @@ -211,7 +209,8 @@ function handleListDevices(req, res, next) { res.status(200).json(response); } - }); + } + ); } /** @@ -219,7 +218,10 @@ function handleListDevices(req, res, next) { * JSON format. */ function handleGetDevice(req, res, next) { - deviceService.getDevice(req.params.deviceId, req.headers['fiware-service'], req.headers['fiware-servicepath'], + deviceService.getDevice( + req.params.deviceId, + req.headers['fiware-service'], + req.headers['fiware-servicepath'], function(error, device) { if (error) { next(error); @@ -228,25 +230,24 @@ function handleGetDevice(req, res, next) { } else { next(new errors.DeviceNotFound(req.params.deviceId)); } - }); + } + ); } /** * This middleware handles the removal of a particular device specified with the deviceId. */ function handleRemoveDevice(req, res, next) { - - function getDevice(deviceId, service, subservice, callback){ - deviceService.getDevice(deviceId, service, subservice, - function(error, device) { - if (error) { - callback(error); - } else if (device) { - callback(null, device); - } else { - callback(new errors.DeviceNotFound(deviceId)); - } - }); + function getDevice(deviceId, service, subservice, callback) { + deviceService.getDevice(deviceId, service, subservice, function(error, device) { + if (error) { + callback(error); + } else if (device) { + callback(null, device); + } else { + callback(new errors.DeviceNotFound(deviceId)); + } + }); } function applyRemoveDeviceHandler(device, callback) { @@ -261,20 +262,28 @@ function handleRemoveDevice(req, res, next) { return deviceService.unregister(deviceId, service, subservice, callback); } - async.waterfall([ - apply(statsRegistry.add, 'deviceRemovalRequests', 1), - apply(getDevice, req.params.deviceId, req.headers['fiware-service'], req.headers['fiware-servicepath']), - applyRemoveDeviceHandler, - apply(unregisterDevice, req.params.deviceId, - req.headers['fiware-service'], req.headers['fiware-servicepath'])], function (error) { - if (error && error.code !== 404) { - next(error); - } else if (error && error.code === 404) { - next(new errors.DeviceNotFound(req.params.deviceId)); - } else { - res.status(204).send(); + async.waterfall( + [ + apply(statsRegistry.add, 'deviceRemovalRequests', 1), + apply(getDevice, req.params.deviceId, req.headers['fiware-service'], req.headers['fiware-servicepath']), + applyRemoveDeviceHandler, + apply( + unregisterDevice, + req.params.deviceId, + req.headers['fiware-service'], + req.headers['fiware-servicepath'] + ) + ], + function(error) { + if (error && error.code !== 404) { + next(error); + } else if (error && error.code === 404) { + next(new errors.DeviceNotFound(req.params.deviceId)); + } else { + res.status(204).send(); + } } - }); + ); } /** @@ -282,9 +291,14 @@ function handleRemoveDevice(req, res, next) { */ function handleUpdateDevice(req, res, next) { if (req.body.deviceId) { - next(new errors.BadRequest('Can\'t change the ID of a preprovisioned device')); + /*jshint quotmark: double */ + next(new errors.BadRequest("Can't change the ID of a preprovisioned device")); + /*jshint quotmark: single */ } else { - deviceService.getDevice(req.params.deviceId, req.headers['fiware-service'], req.headers['fiware-servicepath'], + deviceService.getDevice( + req.params.deviceId, + req.headers['fiware-service'], + req.headers['fiware-servicepath'], function(error, device) { if (error) { next(error); @@ -306,7 +320,8 @@ function handleUpdateDevice(req, res, next) { } else { next(new errors.DeviceNotFound(req.params.deviceId)); } - }); + } + ); } } @@ -316,29 +331,30 @@ function handleUpdateDevice(req, res, next) { * @param {Object} router Express request router object. */ function loadContextRoutes(router) { - router.post('/iot/devices', + router.post( + '/iot/devices', restUtils.checkRequestAttributes('headers', mandatoryHeaders), restUtils.checkBody(createDeviceTemplate), handleProvision ); - router.get('/iot/devices', - restUtils.checkRequestAttributes('headers', mandatoryHeaders), - handleListDevices - ); + router.get('/iot/devices', restUtils.checkRequestAttributes('headers', mandatoryHeaders), handleListDevices); - router.get('/iot/devices/:deviceId', + router.get( + '/iot/devices/:deviceId', restUtils.checkRequestAttributes('headers', mandatoryHeaders), handleGetDevice ); - router.put('/iot/devices/:deviceId', + router.put( + '/iot/devices/:deviceId', restUtils.checkRequestAttributes('headers', mandatoryHeaders), restUtils.checkBody(updateDeviceTemplate), handleUpdateDevice ); - router.delete('/iot/devices/:deviceId', + router.delete( + '/iot/devices/:deviceId', restUtils.checkRequestAttributes('headers', mandatoryHeaders), handleRemoveDevice ); diff --git a/lib/services/northBound/northboundServer.js b/lib/services/northBound/northboundServer.js index f40bab39d..298749b96 100644 --- a/lib/services/northBound/northboundServer.js +++ b/lib/services/northBound/northboundServer.js @@ -105,11 +105,7 @@ function stop(callback) { } function clear(callback) { - async.series([ - deviceProvisioning.clear, - groupProvisioning.clear, - contextServer.clear - ], callback); + async.series([deviceProvisioning.clear, groupProvisioning.clear, contextServer.clear], callback); } exports.setUpdateHandler = intoTrans(context, contextServer.setUpdateHandler); @@ -117,7 +113,7 @@ exports.setQueryHandler = intoTrans(context, contextServer.setQueryHandler); exports.setCommandHandler = intoTrans(context, contextServer.setCommandHandler); exports.setNotificationHandler = intoTrans(context, contextServer.setNotificationHandler); exports.setConfigurationHandler = intoTrans(context, groupProvisioning.setConfigurationHandler); -exports.setRemoveConfigurationHandler = intoTrans (context, groupProvisioning.setRemoveConfigurationHandler); +exports.setRemoveConfigurationHandler = intoTrans(context, groupProvisioning.setRemoveConfigurationHandler); exports.setProvisioningHandler = intoTrans(context, deviceProvisioning.setProvisioningHandler); exports.setRemoveDeviceHandler = intoTrans(context, deviceProvisioning.setRemoveDeviceHandler); exports.addDeviceProvisionMiddleware = deviceProvisioning.addDeviceProvisionMiddleware; diff --git a/lib/services/northBound/restUtils.js b/lib/services/northBound/restUtils.js index 7bcbfd35a..aed5698e5 100644 --- a/lib/services/northBound/restUtils.js +++ b/lib/services/northBound/restUtils.js @@ -125,8 +125,10 @@ function checkBody(template) { */ function IsValidTimestamped(payload) { for (var i in payload.contextElements[0].attributes) { - if (payload.contextElements[0].attributes[i].name === constants.TIMESTAMP_ATTRIBUTE && - ! moment(payload.contextElements[0].attributes[i].value, moment.ISO_8601).isValid()) { + if ( + payload.contextElements[0].attributes[i].name === constants.TIMESTAMP_ATTRIBUTE && + !moment(payload.contextElements[0].attributes[i].value, moment.ISO_8601).isValid() + ) { return false; } } @@ -144,8 +146,7 @@ function IsValidTimestampedNgsi2(payload) { function isValidTimestampedNgsi2Entity(entity) { for (var i in entity) { if (entity.hasOwnProperty(i)) { - if (i === constants.TIMESTAMP_ATTRIBUTE && - ! moment(entity[i].value, moment.ISO_8601).isValid()) { + if (i === constants.TIMESTAMP_ATTRIBUTE && !moment(entity[i].value, moment.ISO_8601).isValid()) { return false; } } @@ -190,7 +191,6 @@ function isTimestamped(payload) { * @return {Boolean} true if timestamp attributes are included. false if not. */ function isTimestampedNgsi2(payload) { - function isTimestampedNgsi2Entity(entity) { for (var i in entity) { if (entity.hasOwnProperty(i)) { diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..b99ad5a7e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,8004 @@ +{ + "name": "iotagent-node-lib", + "version": "2.11.0-next", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@azu/format-text": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@azu/format-text/-/format-text-1.0.1.tgz", + "integrity": "sha1-aWc1CpRkD2sChVFpvYl85U1s6+I=", + "dev": true + }, + "@azu/style-format": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@azu/style-format/-/style-format-1.0.0.tgz", + "integrity": "sha1-5wGH+Khi4ZGxvObAJo8TrNOlayA=", + "dev": true, + "requires": { + "@azu/format-text": "^1.0.1" + } + }, + "@samverschueren/stream-to-observable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz", + "integrity": "sha512-MI4Xx6LHs4Webyvi6EbspgyAb4D2Q2VtnCQ1blOJcoLS6mVa8lNN2rkIy1CVxfTUpoyIbCTkXES1rLXztFD1lg==", + "dev": true, + "requires": { + "any-observable": "^0.3.0" + } + }, + "@textlint/ast-node-types": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-4.2.5.tgz", + "integrity": "sha512-+rEx4jLOeZpUcdvll7jEg/7hNbwYvHWFy4IGW/tk2JdbyB3SJVyIP6arAwzTH/sp/pO9jftfyZnRj4//sLbLvQ==", + "dev": true + }, + "@textlint/ast-tester": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@textlint/ast-tester/-/ast-tester-2.1.6.tgz", + "integrity": "sha512-i+UrSKZXs561g8LXsCBkgpNYkgBS3T3Pif2/+DraZmSKpQ2r2D1yCOdH82IGPWWpQ/GMSg6Z0qpLJpjnYz+bpg==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.5" + } + }, + "@textlint/ast-traverse": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@textlint/ast-traverse/-/ast-traverse-2.1.7.tgz", + "integrity": "sha512-73Nw0R4TaskPmF36Hop1DZ8AbH339WrGiLQjzbOLaXHaBHQ4hdNw28UMlw4glfPZb7/zvxPcJRtg9AB8F3ZW0g==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.5" + } + }, + "@textlint/feature-flag": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/@textlint/feature-flag/-/feature-flag-3.1.6.tgz", + "integrity": "sha512-R2s027/WG3zhCMHZG79OhRFmkSL2ghwvFYg/W+2VUva5aYC8i9yeuwRyWt7m83tP1qlI+bq7j3S04fyn6yNheg==", + "dev": true, + "requires": { + "map-like": "^2.0.0" + } + }, + "@textlint/fixer-formatter": { + "version": "3.1.13", + "resolved": "https://registry.npmjs.org/@textlint/fixer-formatter/-/fixer-formatter-3.1.13.tgz", + "integrity": "sha512-FXqAJZ+5fLsOZjvFmn1JhCer8gQI4ZQk3R45bXizRJm6DASByPAGGh/MAQxxHSGeR5wR8miO/koxA2BrS8OhAw==", + "dev": true, + "requires": { + "@textlint/module-interop": "^1.0.2", + "@textlint/types": "^1.3.1", + "chalk": "^1.1.3", + "debug": "^4.1.1", + "diff": "^4.0.1", + "is-file": "^1.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^6.0.0", + "text-table": "^0.2.0", + "try-resolve": "^1.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + } + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "@textlint/kernel": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@textlint/kernel/-/kernel-3.2.1.tgz", + "integrity": "sha512-gMCgP/tAjCX8dGqgu7nhUwaDC/TzDKeRZb9qa50nqbnILRasKplj3lOWn2osZdkScVZPLQp+al1pDh9pU4D+Dw==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.5", + "@textlint/ast-tester": "^2.1.6", + "@textlint/ast-traverse": "^2.1.7", + "@textlint/feature-flag": "^3.1.6", + "@textlint/types": "^1.3.1", + "@textlint/utils": "^1.0.3", + "debug": "^4.1.1", + "deep-equal": "^1.1.0", + "map-like": "^2.0.0", + "structured-source": "^3.0.2" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-equal": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", + "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", + "dev": true, + "requires": { + "is-arguments": "^1.0.4", + "is-date-object": "^1.0.1", + "is-regex": "^1.0.4", + "object-is": "^1.0.1", + "object-keys": "^1.1.1", + "regexp.prototype.flags": "^1.2.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@textlint/linter-formatter": { + "version": "3.1.12", + "resolved": "https://registry.npmjs.org/@textlint/linter-formatter/-/linter-formatter-3.1.12.tgz", + "integrity": "sha512-OEP4pklu01MEgBJrftD9vwe3HFx+jhiEe1JFIgf7GZ4a0fSer5vQWXBo5wHW6WtZtSa+iLBsLC3mI5VMeshzdA==", + "dev": true, + "requires": { + "@azu/format-text": "^1.0.1", + "@azu/style-format": "^1.0.0", + "@textlint/module-interop": "^1.0.2", + "@textlint/types": "^1.3.1", + "chalk": "^1.0.0", + "concat-stream": "^1.5.1", + "debug": "^4.1.1", + "is-file": "^1.0.0", + "js-yaml": "^3.2.4", + "optionator": "^0.8.1", + "pluralize": "^2.0.0", + "string-width": "^1.0.1", + "string.prototype.padstart": "^3.0.0", + "strip-ansi": "^6.0.0", + "table": "^3.7.8", + "text-table": "^0.2.0", + "try-resolve": "^1.0.1", + "xml-escape": "^1.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + } + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "@textlint/markdown-to-ast": { + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/@textlint/markdown-to-ast/-/markdown-to-ast-6.1.7.tgz", + "integrity": "sha512-B0QtokeQR4a9+4q0NQr8T9l7A1fFihTN5Ze57tVgqW+3ymzXEouh8DvPHeNQ4T6jEkAThvdjk95mxAMpGRJ79w==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.5", + "debug": "^4.1.1", + "remark-frontmatter": "^1.2.0", + "remark-parse": "^5.0.0", + "structured-source": "^3.0.2", + "traverse": "^0.6.6", + "unified": "^6.1.6" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "remark-parse": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-5.0.0.tgz", + "integrity": "sha512-b3iXszZLH1TLoyUzrATcTQUZrwNl1rE70rVdSruJFlDaJ9z5aMkhrG43Pp68OgfHndL/ADz6V69Zow8cTQu+JA==", + "dev": true, + "requires": { + "collapse-white-space": "^1.0.2", + "is-alphabetical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-whitespace-character": "^1.0.0", + "is-word-character": "^1.0.0", + "markdown-escapes": "^1.0.0", + "parse-entities": "^1.1.0", + "repeat-string": "^1.5.4", + "state-toggle": "^1.0.0", + "trim": "0.0.1", + "trim-trailing-lines": "^1.0.0", + "unherit": "^1.0.4", + "unist-util-remove-position": "^1.0.0", + "vfile-location": "^2.0.0", + "xtend": "^4.0.1" + } + }, + "unified": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/unified/-/unified-6.2.0.tgz", + "integrity": "sha512-1k+KPhlVtqmG99RaTbAv/usu85fcSRu3wY8X+vnsEhIxNP5VbVIDiXnLqyKIG+UMdyTg0ZX9EI6k2AfjJkHPtA==", + "dev": true, + "requires": { + "bail": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^1.1.0", + "trough": "^1.0.0", + "vfile": "^2.0.0", + "x-is-string": "^0.1.0" + } + }, + "unist-util-stringify-position": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz", + "integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ==", + "dev": true + }, + "vfile": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-2.3.0.tgz", + "integrity": "sha512-ASt4mBUHcTpMKD/l5Q+WJXNtshlWxOogYyGYYrg4lt/vuRjC1EFQtlAofL5VmtVNIZJzWYFJjzGWZ0Gw8pzW1w==", + "dev": true, + "requires": { + "is-buffer": "^1.1.4", + "replace-ext": "1.0.0", + "unist-util-stringify-position": "^1.0.0", + "vfile-message": "^1.0.0" + } + }, + "vfile-message": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.1.1.tgz", + "integrity": "sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==", + "dev": true, + "requires": { + "unist-util-stringify-position": "^1.1.1" + } + } + } + }, + "@textlint/module-interop": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@textlint/module-interop/-/module-interop-1.0.2.tgz", + "integrity": "sha512-qQ6dqlg4SYywCywimIbkveQZu1MG6ugf6fcJuWDi3D51FbdkSRsMrPusJ1YoW6Y3XBp0ww9fJjXWtlUStGeQsw==", + "dev": true + }, + "@textlint/text-to-ast": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@textlint/text-to-ast/-/text-to-ast-3.1.7.tgz", + "integrity": "sha512-CBAEQmiEa2G/wonlLr1HgUtXfTSas6OGGvYGRIRMJweNh5Ilhbz2nM2/9XQMfLQbdn5pGYrAAAQRB2+/9fZ31A==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.5" + } + }, + "@textlint/textlint-plugin-markdown": { + "version": "5.1.12", + "resolved": "https://registry.npmjs.org/@textlint/textlint-plugin-markdown/-/textlint-plugin-markdown-5.1.12.tgz", + "integrity": "sha512-CJWWTaomR22hQD3ogrZujMH1pNN7DqZadmx9CJXxgKwpI/cuD5d2kClwXO3MeLFckJr5HRso7SFN5ebqKu1ycw==", + "dev": true, + "requires": { + "@textlint/markdown-to-ast": "^6.1.7" + } + }, + "@textlint/textlint-plugin-text": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@textlint/textlint-plugin-text/-/textlint-plugin-text-4.1.13.tgz", + "integrity": "sha512-KQfSYNDt8HSX8ZL/r86N8OrAuQ9LEuevAtGomtfkw0h7Ed/pUfmuYXjht8wYRdysYBa4JyjrXcmqzRAUdkWrag==", + "dev": true, + "requires": { + "@textlint/text-to-ast": "^3.1.7" + } + }, + "@textlint/types": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@textlint/types/-/types-1.3.1.tgz", + "integrity": "sha512-9MJ6PRPYWiFs2lfvp/Qhq72WrkZLL5ncBUXAVoj1Ug17ug8d7psmr/KJstMMocW3EWHSOuIDj7unh413c3jPqQ==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.5" + } + }, + "@textlint/utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@textlint/utils/-/utils-1.0.3.tgz", + "integrity": "sha512-6oGaBKXYpg5Ooph5p32OFdp1dXDUC1z5mpHg2gmQbx6QZjmP4QX+ygBQdNoCq15d1w88+We6koJl0n0WXjItYw==", + "dev": true + }, + "@types/bluebird": { + "version": "3.5.29", + "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.29.tgz", + "integrity": "sha512-kmVtnxTuUuhCET669irqQmPAez4KFnFVKvpleVRyfC3g+SHD1hIkFZcWLim9BVcwUBLO59o8VZE4yGCmTif8Yw==", + "dev": true + }, + "@types/node": { + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.0.tgz", + "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==", + "dev": true + }, + "@types/unist": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz", + "integrity": "sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==", + "dev": true + }, + "@types/vfile": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/vfile/-/vfile-3.0.2.tgz", + "integrity": "sha512-b3nLFGaGkJ9rzOcuXRfHkZMdjsawuDD0ENL9fzTophtBg8FJHSGbH7daXkEpcwy3v7Xol3pAvsmlYyFhR4pqJw==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/unist": "*", + "@types/vfile-message": "*" + } + }, + "@types/vfile-message": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/vfile-message/-/vfile-message-2.0.0.tgz", + "integrity": "sha512-GpTIuDpb9u4zIO165fUy9+fXcULdD8HFRNli04GehoMVbeNq7D6OBnqSmg3lxZnC+UvgUhEWKxdKiwYUkGltIw==", + "dev": true, + "requires": { + "vfile-message": "*" + } + }, + "JSONSelect": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz", + "integrity": "sha1-oI7cxn6z/L6Z7WMIVTRKDPKCu40=" + }, + "JSV": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", + "integrity": "sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=" + }, + "abbrev": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "dev": true + }, + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "~2.1.18", + "negotiator": "0.6.1" + } + }, + "adverb-where": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/adverb-where/-/adverb-where-0.0.9.tgz", + "integrity": "sha1-CcXN3Y1QO5/l924LjcXHCo8ZPjQ=", + "dev": true + }, + "ajv": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.7.0.tgz", + "integrity": "sha512-RZXPviBTtfmtka9n9sy1N5M5b82CbxWIR6HIis4s3WQTXDJamc/0gpCWNGz6EWdWp4DOfjzJfhz/AS9zVPjjWg==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "optional": true + }, + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true + }, + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "any-observable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz", + "integrity": "sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog==", + "dev": true + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "requires": { + "lodash": "^4.17.11" + } + }, + "async-each": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "bail": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.5.tgz", + "integrity": "sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "dev": true + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "dependencies": { + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + } + } + }, + "boundary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/boundary/-/boundary-1.0.1.tgz", + "integrity": "sha1-TWfcJgLAzBbdm85+v4fpSCkPWBI=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "bson": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", + "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "caller-callsite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", + "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", + "dev": true, + "requires": { + "callsites": "^2.0.0" + } + }, + "caller-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", + "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", + "dev": true, + "requires": { + "caller-callsite": "^2.0.0" + } + }, + "callsites": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "ccount": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.5.tgz", + "integrity": "sha512-MOli1W+nfbPLlKEhInaxhRdp7KVLFxLN5ykwzHgLsLI3H3gs5jjFAK4Eoj3OzzcxCtumDaI8onoVDeQyWaNTkw==", + "dev": true + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "character-entities": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz", + "integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==", + "dev": true + }, + "character-entities-html4": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.4.tgz", + "integrity": "sha512-HRcDxZuZqMx3/a+qrzxdBKBPUpxWEq9xw2OPZ3a/174ihfrQKVsFhqtthBInFy1zZ9GgZyFXOatNujm8M+El3g==", + "dev": true + }, + "character-entities-legacy": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz", + "integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==", + "dev": true + }, + "character-reference-invalid": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz", + "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==", + "dev": true + }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", + "dev": true + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "chokidar": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "dev": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + } + }, + "ci-info": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz", + "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==", + "dev": true + }, + "cjson": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/cjson/-/cjson-0.3.0.tgz", + "integrity": "sha1-5kObkHA9MS/24iJAl76pLOPQKhQ=", + "requires": { + "jsonlint": "1.6.0" + } + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "^7.1.1" + }, + "dependencies": { + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-truncate": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-0.2.1.tgz", + "integrity": "sha1-nxXPuwcFAFNpIWxiasfQWrkN1XQ=", + "dev": true, + "requires": { + "slice-ansi": "0.0.4", + "string-width": "^1.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "co": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/co/-/co-3.1.0.tgz", + "integrity": "sha1-TqVOpaCJOBUxheFSEMaNkJK8G3g=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "collapse-white-space": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.6.tgz", + "integrity": "sha512-jEovNnrhMuqyCcjfEJA56v0Xq8SkIoPKDyaHahwo3POf4qcSXqMYuwNcOTzp74vTsR9Tn08z4MxWqAhcekogkQ==", + "dev": true + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "colors": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz", + "integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q=" + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "command-shell-lib": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/command-shell-lib/-/command-shell-lib-1.0.0.tgz", + "integrity": "sha1-KWC3MJvpBwojAYYjcvvjjtL3+RA=", + "requires": { + "async": "*" + } + }, + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cosmiconfig": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", + "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==", + "dev": true, + "requires": { + "import-fresh": "^2.0.0", + "is-directory": "^0.3.1", + "js-yaml": "^3.13.1", + "parse-json": "^4.0.0" + } + }, + "coveralls": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.3.tgz", + "integrity": "sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg==", + "dev": true, + "requires": { + "growl": "~> 1.10.0", + "js-yaml": "^3.11.0", + "lcov-parse": "^0.0.10", + "log-driver": "^1.2.7", + "minimist": "^1.2.0", + "request": "^2.86.0" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", + "dev": true + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "date-fns": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz", + "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==", + "dev": true + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" + }, + "dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=", + "dev": true + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "dev": true + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "dom-serializer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", + "dev": true, + "requires": { + "domelementtype": "^1.3.0", + "entities": "^1.1.1" + }, + "dependencies": { + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "e-prime": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/e-prime/-/e-prime-0.10.3.tgz", + "integrity": "sha512-QGKWEWRVUfjUXSoio9AW43RzzMQzI23No8uyKQD9yZJm4Hbc+8ZRZhyEtWdnpAkY7dXFmTxtcFR4cM0T0U1jGw==", + "dev": true + }, + "ebnf-parser": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/ebnf-parser/-/ebnf-parser-0.1.10.tgz", + "integrity": "sha1-zR9rpHfFY4xAyX7ZtXLbW6tdgzE=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "elegant-spinner": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.3.3.tgz", + "integrity": "sha1-8CQBb1qI4Eb9EgBQVek5gC5sXyM=", + "requires": { + "esprima": "~1.1.1", + "estraverse": "~1.5.0", + "esutils": "~1.0.0", + "source-map": "~0.1.33" + } + }, + "esprima": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.1.1.tgz", + "integrity": "sha1-W28VR/TRAuZw4UDFCb5ncdautUk=" + }, + "estraverse": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.5.1.tgz", + "integrity": "sha1-hno+jlip+EYYr7bC3bzZFrfLr3E=" + }, + "esutils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.0.0.tgz", + "integrity": "sha1-gVHTWOIMisx/t0XnRywAJf5JZXA=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "eventemitter3": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", + "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==", + "dev": true + }, + "exec-sh": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.2.2.tgz", + "integrity": "sha512-FIUCJz1RbuS0FKTdaAafAByGS0CPvU3R0MeHxgtl+djzCc//F8HakL8GzmVNZanasTbTAY/3DRFA0KpVqj/eAw==", + "dev": true, + "requires": { + "merge": "^1.2.0" + } + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "express": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.3", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.2", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "fault": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz", + "integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==", + "dev": true, + "requires": { + "format": "^0.2.0" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "find-parent-dir": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/find-parent-dir/-/find-parent-dir-0.3.0.tgz", + "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, + "fn-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fn-name/-/fn-name-2.0.1.tgz", + "integrity": "sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=", + "dev": true + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "format": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", + "integrity": "sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs=", + "dev": true + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.11.tgz", + "integrity": "sha512-+ux3lx6peh0BpvY0JebGyZoiR4D+oYzdPZMKJwkZ+sFkNJzpL7tXc/wehS49gUAxg3tmMHPHZkA8JU2rhhgDHw==", + "dev": true, + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1", + "node-pre-gyp": "*" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.3", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "3.2.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.6.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "bundled": true, + "dev": true, + "optional": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true, + "optional": true + }, + "minipass": { + "version": "2.9.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.9.0" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^3.2.6", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.14.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4.4.2" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "npm-normalize-package-bin": "^1.0.1" + } + }, + "npm-normalize-package-bin": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.4.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.7.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.7.1", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.13", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "yallist": { + "version": "3.1.1", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "get-own-enumerable-property-symbols": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", + "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", + "dev": true + }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "get-url-origin": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-url-origin/-/get-url-origin-1.0.1.tgz", + "integrity": "sha512-MMSKo16gB2+6CjWy55jNdIAqUEaKgw3LzZCb8wVVtFrhoQ78EXyuYXxDdn3COI3A4Xr4ZfM3fZa9RTjO6DOTxw==", + "dev": true + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "handlebars": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", + "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "dev": true, + "requires": { + "neo-async": "^2.6.0", + "optimist": "^0.6.1", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + } + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "hosted-git-info": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.4.tgz", + "integrity": "sha512-pzXIvANXEFrc5oFFXRMkbLPQ2rXRoDERwDLyrcUxGhaZhgP54BBSl9Oheh7Vv0T090cszWBxPjkQQ5Sq1PbBRQ==", + "dev": true + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + } + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "husky": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-1.1.4.tgz", + "integrity": "sha512-cZjGpS7qsaBSo3fOMUuR7erQloX3l5XzL1v/RkIqU6zrQImDdU70z5Re9fGDp7+kbYlM2EtS4aYMlahBeiCUGw==", + "dev": true, + "requires": { + "cosmiconfig": "^5.0.6", + "execa": "^1.0.0", + "find-up": "^3.0.0", + "get-stdin": "^6.0.0", + "is-ci": "^1.2.1", + "pkg-dir": "^3.0.0", + "please-upgrade-node": "^3.1.1", + "read-pkg": "^4.0.1", + "run-node": "^1.0.0", + "slash": "^2.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "dev": true + }, + "import-fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz", + "integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=", + "dev": true, + "requires": { + "caller-path": "^2.0.0", + "resolve-from": "^3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, + "ipaddr.js": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", + "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" + }, + "irregular-plurals": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-2.0.0.tgz", + "integrity": "sha512-Y75zBYLkh0lJ9qxeHlMjQ7bSbyiSqNW/UOPWDmzC7cXskL1hekSITh1Oc6JV0XCWWZ9DE8VYSB71xocLk3gmGw==", + "dev": true + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-alphabetical": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz", + "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", + "dev": true + }, + "is-alphanumeric": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-alphanumeric/-/is-alphanumeric-1.0.0.tgz", + "integrity": "sha1-Spzvcdr0wAHB2B1j0UDPU/1oifQ=", + "dev": true + }, + "is-alphanumerical": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", + "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", + "dev": true, + "requires": { + "is-alphabetical": "^1.0.0", + "is-decimal": "^1.0.0" + } + }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-ci": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", + "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "dev": true, + "requires": { + "ci-info": "^1.5.0" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-decimal": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz", + "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", + "dev": true + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-directory": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", + "dev": true + }, + "is-empty": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-empty/-/is-empty-1.2.0.tgz", + "integrity": "sha1-3pu1snhzigWgsJpX4ftNSjQan2s=", + "dev": true + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-file/-/is-file-1.0.0.tgz", + "integrity": "sha1-KKRM+9nT2xkwRfIrZfzo7fliBZY=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-hexadecimal": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz", + "integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==", + "dev": true + }, + "is-hidden": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-hidden/-/is-hidden-1.1.3.tgz", + "integrity": "sha512-FFzhGKA9h59OFxeaJl0W5ILTYetI8WsdqdofKr69uLKZdV6hbDKxj8vkpG3L9uS/6Q/XYh1tkXm6xwRGFweETA==", + "dev": true + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", + "dev": true + }, + "is-observable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-1.1.0.tgz", + "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==", + "dev": true, + "requires": { + "symbol-observable": "^1.1.0" + } + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "is-whitespace-character": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.4.tgz", + "integrity": "sha512-SDweEzfIZM0SJV0EUga669UTKlmL0Pq8Lno0QDQsPnvECB3IM2aP0gdx5TrU0A01MAPfViaZiI2V1QMZLaKK5w==", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "is-word-character": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.4.tgz", + "integrity": "sha512-5SMO8RVennx3nZrqtKwCGyyetPE9VDba5ugvKLaD4KopPG5kR4mQ7tNt/r7feL5yt5h3lpuBbIUmCOG2eSzXHA==", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "istanbul": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", + "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "dev": true, + "requires": { + "abbrev": "1.0.x", + "async": "1.x", + "escodegen": "1.8.x", + "esprima": "2.7.x", + "glob": "^5.0.15", + "handlebars": "^4.0.1", + "js-yaml": "3.x", + "mkdirp": "0.5.x", + "nopt": "3.x", + "once": "1.x", + "resolve": "1.1.x", + "supports-color": "^3.1.0", + "which": "^1.1.1", + "wordwrap": "^1.0.0" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "escodegen": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "dev": true, + "requires": { + "esprima": "^2.7.1", + "estraverse": "^1.9.1", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.2.0" + } + }, + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "estraverse": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + } + } + }, + "jest-get-type": { + "version": "22.4.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz", + "integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==", + "dev": true + }, + "jest-validate": { + "version": "23.6.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.6.0.tgz", + "integrity": "sha512-OFKapYxe72yz7agrDAWi8v2WL8GIfVqcbKRCLbRG9PAxtzF9b1SEDdTpytNDN12z2fJynoBwpMpvj2R39plI2A==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "jest-get-type": "^22.1.0", + "leven": "^2.1.0", + "pretty-format": "^23.6.0" + } + }, + "jison": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/jison/-/jison-0.4.18.tgz", + "integrity": "sha512-FKkCiJvozgC7VTHhMJ00a0/IApSxhlGsFIshLW6trWJ8ONX2TQJBBz6DlcO1Gffy4w9LT+uL+PA+CVnUSJMF7w==", + "requires": { + "JSONSelect": "0.4.0", + "cjson": "0.3.0", + "ebnf-parser": "0.1.10", + "escodegen": "1.3.x", + "esprima": "1.1.x", + "jison-lex": "0.3.x", + "lex-parser": "~0.1.3", + "nomnom": "1.5.2" + } + }, + "jison-lex": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/jison-lex/-/jison-lex-0.3.4.tgz", + "integrity": "sha1-gcoo2E+ESZ36jFlNzePYo/Jux6U=", + "requires": { + "lex-parser": "0.1.x", + "nomnom": "1.5.2" + } + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + } + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "jshint": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", + "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", + "dev": true, + "requires": { + "cli": "~1.0.0", + "console-browserify": "1.1.x", + "exit": "0.1.x", + "htmlparser2": "3.8.x", + "lodash": "~4.17.11", + "minimatch": "~3.0.2", + "shelljs": "0.3.x", + "strip-json-comments": "1.0.x" + } + }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsonlint": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/jsonlint/-/jsonlint-1.6.0.tgz", + "integrity": "sha1-iKpGvCiaesk7tGyuLVihh6m7SUo=", + "requires": { + "JSV": ">= 4.0.x", + "nomnom": ">= 1.5.x" + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "kareem": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", + "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==" + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "lcov-parse": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", + "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", + "dev": true + }, + "leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lex-parser": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz", + "integrity": "sha1-ZMTwJfF/1Tv7RXY/rrFvAVp0dVA=" + }, + "lint-staged": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-7.3.0.tgz", + "integrity": "sha512-AXk40M9DAiPi7f4tdJggwuKIViUplYtVj1os1MVEteW7qOkU50EOehayCfO9TsoGK24o/EsWb41yrEgfJDDjCw==", + "dev": true, + "requires": { + "chalk": "^2.3.1", + "commander": "^2.14.1", + "cosmiconfig": "^5.0.2", + "debug": "^3.1.0", + "dedent": "^0.7.0", + "execa": "^0.9.0", + "find-parent-dir": "^0.3.0", + "is-glob": "^4.0.0", + "is-windows": "^1.0.2", + "jest-validate": "^23.5.0", + "listr": "^0.14.1", + "lodash": "^4.17.5", + "log-symbols": "^2.2.0", + "micromatch": "^3.1.8", + "npm-which": "^3.0.1", + "p-map": "^1.1.1", + "path-is-inside": "^1.0.2", + "pify": "^3.0.0", + "please-upgrade-node": "^3.0.2", + "staged-git-files": "1.1.1", + "string-argv": "^0.0.2", + "stringify-object": "^3.2.2" + }, + "dependencies": { + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "execa": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.9.0.tgz", + "integrity": "sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA==", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "dev": true + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "listr": { + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/listr/-/listr-0.14.3.tgz", + "integrity": "sha512-RmAl7su35BFd/xoMamRjpIE4j3v+L28o8CT5YhAXQJm1fD+1l9ngXY8JAQRJ+tFK2i5njvi0iRUKV09vPwA0iA==", + "dev": true, + "requires": { + "@samverschueren/stream-to-observable": "^0.3.0", + "is-observable": "^1.1.0", + "is-promise": "^2.1.0", + "is-stream": "^1.1.0", + "listr-silent-renderer": "^1.1.1", + "listr-update-renderer": "^0.5.0", + "listr-verbose-renderer": "^0.5.0", + "p-map": "^2.0.0", + "rxjs": "^6.3.3" + }, + "dependencies": { + "p-map": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", + "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==", + "dev": true + } + } + }, + "listr-silent-renderer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz", + "integrity": "sha1-kktaN1cVN3C/Go4/v3S4u/P5JC4=", + "dev": true + }, + "listr-update-renderer": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.5.0.tgz", + "integrity": "sha512-tKRsZpKz8GSGqoI/+caPmfrypiaq+OQCbd+CovEC24uk1h952lVj5sC7SqyFUm+OaJ5HN/a1YLt5cit2FMNsFA==", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "elegant-spinner": "^1.0.1", + "figures": "^1.7.0", + "indent-string": "^3.0.0", + "log-symbols": "^1.0.2", + "log-update": "^2.3.0", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "^1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "listr-verbose-renderer": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.5.0.tgz", + "integrity": "sha512-04PDPqSlsqIOaaaGZ+41vq5FejI9auqTInicFRndCBgE3bXG8D6W1I+mWhk+1nqbHmyhla/6BUrd5OSiHwKRXw==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "cli-cursor": "^2.1.0", + "date-fns": "^1.27.2", + "figures": "^2.0.0" + }, + "dependencies": { + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + } + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + }, + "dependencies": { + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, + "load-plugin": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/load-plugin/-/load-plugin-2.3.1.tgz", + "integrity": "sha512-dYB1lbwqHgPTrruy9glukCu8Ya9vzj6TMfouCtj2H/GuJ+8syioisgKTBPxnCi6m8K8jINKfTOxOHngFkUYqHw==", + "dev": true, + "requires": { + "npm-prefix": "^1.2.0", + "resolve-from": "^5.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + } + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "log-driver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", + "dev": true + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } + }, + "log-update": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-2.3.0.tgz", + "integrity": "sha1-iDKP19HOeTiykoN0bwsbwSayRwg=", + "dev": true, + "requires": { + "ansi-escapes": "^3.0.0", + "cli-cursor": "^2.0.0", + "wrap-ansi": "^3.0.1" + }, + "dependencies": { + "wrap-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-3.0.1.tgz", + "integrity": "sha1-KIoE2H7aXChuBg3+jxNc6NAH+Lo=", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0" + } + } + } + }, + "logops": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/logops/-/logops-2.1.0.tgz", + "integrity": "sha1-mHIkVNeHG9KqR2j7QWZvFCuVNc8=", + "requires": { + "colors": "^1.1.2", + "lodash": "^4.1.0", + "safe-json-stringify": "^1.0.4", + "serr": "^1.0.0" + }, + "dependencies": { + "colors": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==" + } + } + }, + "longest-streak": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz", + "integrity": "sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==", + "dev": true + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-like": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/map-like/-/map-like-2.0.0.tgz", + "integrity": "sha1-lEltSa0zPA3DI0snrbvR6FNZU7Q=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "markdown-escapes": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.4.tgz", + "integrity": "sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==", + "dev": true + }, + "markdown-extensions": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz", + "integrity": "sha512-WWC0ZuMzCyDHYCasEGs4IPvLyTGftYwh6wIEOULOF0HXcqZlhwRzrK0w2VUlxWA98xnvb/jszw4ZSkJ6ADpM6Q==", + "dev": true + }, + "markdown-table": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.3.tgz", + "integrity": "sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==", + "dev": true + }, + "md5": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz", + "integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=", + "dev": true, + "requires": { + "charenc": "~0.0.1", + "crypt": "~0.0.1", + "is-buffer": "~1.1.1" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + } + } + }, + "mdast-comment-marker": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/mdast-comment-marker/-/mdast-comment-marker-1.1.1.tgz", + "integrity": "sha512-TWZDaUtPLwKX1pzDIY48MkSUQRDwX/HqbTB4m3iYdL/zosi/Z6Xqfdv0C0hNVKvzrPjZENrpWDt4p4odeVO0Iw==", + "dev": true + }, + "mdast-util-compact": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.4.tgz", + "integrity": "sha512-3YDMQHI5vRiS2uygEFYaqckibpJtKq5Sj2c8JioeOQBU6INpKbdWzfyLqFFnDwEcEnRFIdMsguzs5pC1Jp4Isg==", + "dev": true, + "requires": { + "unist-util-visit": "^1.1.0" + } + }, + "mdast-util-heading-style": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/mdast-util-heading-style/-/mdast-util-heading-style-1.0.5.tgz", + "integrity": "sha512-8zQkb3IUwiwOdUw6jIhnwM6DPyib+mgzQuHAe7j2Hy1rIarU4VUxe472bp9oktqULW3xqZE+Kz6OD4Gi7IA3vw==", + "dev": true + }, + "mdast-util-to-string": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-1.0.7.tgz", + "integrity": "sha512-P+gdtssCoHOX+eJUrrC30Sixqao86ZPlVjR5NEAoy0U79Pfxb1Y0Gntei0+GrnQD4T04X9xA8tcugp90cSmNow==", + "dev": true + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + } + }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, + "merge": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", + "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==", + "dev": true + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "~1.37.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "misspellings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/misspellings/-/misspellings-1.1.0.tgz", + "integrity": "sha1-U9UAJmy9Cc2p2UxM85LmBYm1syQ=", + "dev": true + }, + "mixin-deep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "mocha": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.1.4.tgz", + "integrity": "sha512-PN8CIy4RXsIoxoFJzS4QNnCH4psUCPWc4/rPrst/ecSJJbLBkubMiyGCP2Kj/9YnWbotFqAoeXyXMucj7gwCFg==", + "dev": true, + "requires": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "find-up": "3.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "ms": "2.1.1", + "node-environment-flags": "1.0.5", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.2.2", + "yargs-parser": "13.0.0", + "yargs-unparser": "1.5.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "moment": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + }, + "moment-timezone": { + "version": "0.5.25", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.25.tgz", + "integrity": "sha512-DgEaTyN/z0HFaVcVbSyVCUU6HeFdnNC3vE4c9cgu2dgMTvjBUBdBzWfasTBmAW45u5OIMeCJtU8yNjM22DHucw==", + "requires": { + "moment": ">= 2.9.0" + } + }, + "mongodb": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.3.tgz", + "integrity": "sha512-jw8UyPsq4QleZ9z+t/pIVy3L++51vKdaJ2Q/XXeYxk/3cnKioAH8H6f5tkkDivrQL4PUgUOHe9uZzkpRFH1XtQ==", + "requires": { + "mongodb-core": "^3.2.3", + "safe-buffer": "^5.1.2" + } + }, + "mongodb-core": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.3.tgz", + "integrity": "sha512-UyI0rmvPPkjOJV8XGWa9VCTq7R4hBVipimhnAXeSXnuAPjuTqbyfA5Ec9RcYJ1Hhu+ISnc8bJ1KfGZd4ZkYARQ==", + "requires": { + "bson": "^1.1.1", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + } + }, + "mongoose": { + "version": "5.7.5", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.7.5.tgz", + "integrity": "sha512-BZ4FxtnbTurc/wcm/hLltLdI4IDxo4nsE0D9q58YymTdZwreNzwO62CcjVtaHhmr8HmJtOInp2W/T12FZaMf8g==", + "requires": { + "bson": "~1.1.1", + "kareem": "2.3.1", + "mongodb": "3.3.2", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.6.0", + "mquery": "3.2.2", + "ms": "2.1.2", + "regexp-clone": "1.0.0", + "safe-buffer": "5.1.2", + "sift": "7.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "mongodb": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.3.2.tgz", + "integrity": "sha512-fqJt3iywelk4yKu/lfwQg163Bjpo5zDKhXiohycvon4iQHbrfflSAz9AIlRE6496Pm/dQKQK5bMigdVo2s6gBg==", + "requires": { + "bson": "^1.1.1", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "mongoose-legacy-pluralize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", + "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" + }, + "mpath": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", + "integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==" + }, + "mquery": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz", + "integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "^1.0.0", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mu2": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/mu2/-/mu2-0.5.21.tgz", + "integrity": "sha1-iIqPD9kOsc/anbgUdvbhmcyeWNM=" + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "neo-async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", + "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "no-cliches": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/no-cliches/-/no-cliches-0.1.1.tgz", + "integrity": "sha512-mYihjs47X5+N71CN3P+QBrEIBuclIfMMpgWEpkmLqFPvrOXdzokvDlhbLfjdBNZOqYgniaeZC6J1ZCgxFdyvXw==", + "dev": true + }, + "nock": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/nock/-/nock-10.0.6.tgz", + "integrity": "sha512-b47OWj1qf/LqSQYnmokNWM8D88KvUl2y7jT0567NB3ZBAZFz2bWp2PC81Xn7u8F2/vJxzkzNZybnemeFa7AZ2w==", + "dev": true, + "requires": { + "chai": "^4.1.2", + "debug": "^4.1.0", + "deep-equal": "^1.0.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.5", + "mkdirp": "^0.5.0", + "propagate": "^1.0.0", + "qs": "^6.5.1", + "semver": "^5.5.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==", + "dev": true + }, + "nomnom": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.5.2.tgz", + "integrity": "sha1-9DRUSKhTz71cDSYyDyR3qwUm/i8=", + "requires": { + "colors": "0.5.x", + "underscore": "1.1.x" + }, + "dependencies": { + "underscore": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.1.7.tgz", + "integrity": "sha1-QLq4S60Z0jAJbo1u9ii/8FXYPbA=" + } + } + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + }, + "dependencies": { + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "npm-path": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/npm-path/-/npm-path-2.0.4.tgz", + "integrity": "sha512-IFsj0R9C7ZdR5cP+ET342q77uSRdtWOlWpih5eC+lu29tIDbNEgDbzgVJ5UFvYHWhxDZ5TFkJafFioO0pPQjCw==", + "dev": true, + "requires": { + "which": "^1.2.10" + } + }, + "npm-prefix": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/npm-prefix/-/npm-prefix-1.2.0.tgz", + "integrity": "sha1-5hlFX3B0ulTMZtbQ033Z8b5ry8A=", + "dev": true, + "requires": { + "rc": "^1.1.0", + "shellsubstitute": "^1.1.0", + "untildify": "^2.1.0" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "npm-which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-which/-/npm-which-3.0.1.tgz", + "integrity": "sha1-kiXybsOihcIJyuZ8OxGmtKtxQKo=", + "dev": true, + "requires": { + "commander": "^2.9.0", + "npm-path": "^2.0.2", + "which": "^1.2.10" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "object-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.2.tgz", + "integrity": "sha512-Epah+btZd5wrrfjkJZq1AOB9O6OxUQto45hzFd7lXGrpHPGE0W1k+426yrZV+k6NJOzLNNW/nVsmZdIWsAqoOQ==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + } + } + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "dev": true, + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true + }, + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-map": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", + "integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==", + "dev": true + }, + "p-memoize": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-memoize/-/p-memoize-3.1.0.tgz", + "integrity": "sha512-e5tIvrsr7ydUUnxb534iQWtXxWgk/86IsH+H+nV4FHouIggBt4coXboKBt26o4lTu7JbEnGSeXdEsYR8BhAHFA==", + "dev": true, + "requires": { + "mem": "^4.3.0", + "mimic-fn": "^2.1.0" + } + }, + "p-queue": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.2.1.tgz", + "integrity": "sha512-wV8yC/rkuWpgu9LGKJIb48OynYSrE6lVl2Bx6r8WjbyVKrFAzzQ/QevAvwnDjlD+mLt8xy0LTDOU1freOvMTCg==", + "dev": true, + "requires": { + "eventemitter3": "^4.0.0", + "p-timeout": "^3.1.0" + } + }, + "p-timeout": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", + "integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==", + "dev": true, + "requires": { + "p-finally": "^1.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-entities": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.2.tgz", + "integrity": "sha512-NzfpbxW/NPrzZ/yYSoQxyqUZMZXIdCfE0OIN4ESsnptHJECoUk3FZktxNuzQf4tjt5UEopnxpYJbvYuxIFDdsg==", + "dev": true, + "requires": { + "character-entities": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "character-reference-invalid": "^1.0.0", + "is-alphanumerical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-hexadecimal": "^1.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "passive-voice": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/passive-voice/-/passive-voice-0.1.0.tgz", + "integrity": "sha1-Fv+RrkC6DpLEPmcXY/3IQqcCcLE=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-to-glob-pattern": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-to-glob-pattern/-/path-to-glob-pattern-1.0.2.tgz", + "integrity": "sha1-Rz5qOikqnRP7rj7czuctO6uoxhk=", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + }, + "please-upgrade-node": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", + "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "dev": true, + "requires": { + "semver-compare": "^1.0.0" + } + }, + "plur": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/plur/-/plur-3.1.1.tgz", + "integrity": "sha512-t1Ax8KUvV3FFII8ltczPn2tJdjqbd1sIzu6t4JL7nQ3EyeL/lTrj5PWKb06ic5/6XYDr65rQ4uzQEGN70/6X5w==", + "dev": true, + "requires": { + "irregular-plurals": "^2.0.0" + } + }, + "pluralize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-2.0.0.tgz", + "integrity": "sha1-crcmqm+sHt7uQiVsfY3CVrM1Z38=", + "dev": true + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prettier": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.3.tgz", + "integrity": "sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==", + "dev": true + }, + "pretty-format": { + "version": "23.6.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.6.0.tgz", + "integrity": "sha512-zf9NV1NSlDLDjycnwm6hpFATCGl/K1lt0R/GdkAK2O5LN/rwJoB+Mh93gGJjut4YbmecbfgLWVGSTCr0Ewvvbw==", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0", + "ansi-styles": "^3.2.0" + } + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "propagate": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-1.0.0.tgz", + "integrity": "sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk=", + "dev": true + }, + "proxy-addr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", + "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.8.0" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "query-string": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.5.0.tgz", + "integrity": "sha512-TYC4hDjZSvVxLMEucDMySkuAS9UIzSbAiYGyA9GWCjLKB8fQpviFbjd20fD7uejCDxZS+ftSdBKE6DS+xucJFg==", + "requires": { + "decode-uri-component": "^0.2.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + } + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "dependencies": { + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + } + } + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dev": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + } + } + }, + "rc-config-loader": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/rc-config-loader/-/rc-config-loader-2.0.5.tgz", + "integrity": "sha512-T464K2MQlnNWOblUDIglpFhyN+zYJq7jSlL++/N0hUkcmIXeNFumwXFVdtf8qhUGohn4RYQ0wdi74R575I44PQ==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "js-yaml": "^3.12.0", + "json5": "^2.1.0", + "object-assign": "^4.1.0", + "object-keys": "^1.0.12", + "path-exists": "^3.0.0", + "require-from-string": "^2.0.2" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "json5": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz", + "integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "read-pkg": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz", + "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=", + "dev": true, + "requires": { + "normalize-package-data": "^2.3.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0" + } + }, + "read-pkg-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "regexp-clone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", + "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==" + }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + } + } + }, + "remark": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/remark/-/remark-10.0.1.tgz", + "integrity": "sha512-E6lMuoLIy2TyiokHprMjcWNJ5UxfGQjaMSMhV+f4idM625UjjK4j798+gPs5mfjzDE6vL0oFKVeZM6gZVSVrzQ==", + "dev": true, + "requires": { + "remark-parse": "^6.0.0", + "remark-stringify": "^6.0.0", + "unified": "^7.0.0" + } + }, + "remark-cli": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/remark-cli/-/remark-cli-6.0.1.tgz", + "integrity": "sha512-h7Hwnfdcm5J03t2mxhl9BAav+Goqauqfz3LhpE7TP+RIiPnK6njU7qRDD7qlUd/hLyMSB+WBjYc7gVDQT3pv0A==", + "dev": true, + "requires": { + "markdown-extensions": "^1.1.0", + "remark": "^10.0.0", + "unified-args": "^6.0.0" + } + }, + "remark-frontmatter": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/remark-frontmatter/-/remark-frontmatter-1.3.2.tgz", + "integrity": "sha512-2eayxITZ8rezsXdgcXnYB3iLivohm2V/ZT4Ne8uhua6A4pk6GdLE2ZzJnbnINtD1HRLaTdB7RwF9sgUbMptJZA==", + "dev": true, + "requires": { + "fault": "^1.0.1", + "xtend": "^4.0.1" + } + }, + "remark-lint": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/remark-lint/-/remark-lint-6.0.5.tgz", + "integrity": "sha512-o1I3ddm+KNsTxk60wWGI+p2yU1jB1gcm8jo2Sy6VhJ4ab2TrQIp1oQbp5xeLoFXYSh/NAqCpKjHkCM/BYpkFdQ==", + "dev": true, + "requires": { + "remark-message-control": "^4.0.0" + } + }, + "remark-lint-final-newline": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-final-newline/-/remark-lint-final-newline-1.0.3.tgz", + "integrity": "sha512-ETAadktv75EwUS3XDhyZUVstXKxfPAEn7SmfN9kZ4+Jb4qo4hHE9gtTOzhE6HxLUxxl9BBhpC5mMO3JcL8UZ5A==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0" + } + }, + "remark-lint-hard-break-spaces": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/remark-lint-hard-break-spaces/-/remark-lint-hard-break-spaces-1.0.4.tgz", + "integrity": "sha512-YM82UpgliZCZhGNmFxEe7ArfhqR5CplFf2bc0k0+8w3rKWKx7EJcGMar2NK410tIi40gGeWtH/pIEypPJFCCiA==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-list-item-bullet-indent": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-list-item-bullet-indent/-/remark-lint-list-item-bullet-indent-1.0.3.tgz", + "integrity": "sha512-iVxQbrgzLpMHG3C6o6wRta/+Bc96etOiBYJnh2zm/aWz6DJ7cGLDykngblP/C4he7LYSeWOD/8Y57HbXZwM2Og==", + "dev": true, + "requires": { + "plur": "^3.0.0", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-list-item-indent": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/remark-lint-list-item-indent/-/remark-lint-list-item-indent-1.0.4.tgz", + "integrity": "sha512-Sv0gVH6qP1/nFpbJuyyguB9sAD2o42StD2WbEZeUcEexXwRO4u/YaX0Pm5pMtCiEHyN+qyL6ShKBQMtgol9BeA==", + "dev": true, + "requires": { + "plur": "^3.0.0", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-no-auto-link-without-protocol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-no-auto-link-without-protocol/-/remark-lint-no-auto-link-without-protocol-1.0.3.tgz", + "integrity": "sha512-k+hg2mXnO4Q9WV+UShPLen5oThvFxcRVWkx2hviVd/nu3eiszBKH3o38csBwjeJoMG3l2ZhdUW8dlOBhq8670Q==", + "dev": true, + "requires": { + "mdast-util-to-string": "^1.0.2", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-no-blockquote-without-marker": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-no-blockquote-without-marker/-/remark-lint-no-blockquote-without-marker-2.0.3.tgz", + "integrity": "sha512-faDzKrA6aKidsRXG6gcIlCO8TexLxIxe+n9B3mdnl8mhZGgE0FfWTkIWVMj0IYps/xVsVMf45KxhXgc1wU9kwg==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1", + "vfile-location": "^2.0.1" + } + }, + "remark-lint-no-duplicate-definitions": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/remark-lint-no-duplicate-definitions/-/remark-lint-no-duplicate-definitions-1.0.5.tgz", + "integrity": "sha512-zKXmfNUODXhJsGQdqfguMG9Nl9v1sLaDsQgMjUtmOSoQRnNud9ThQAZl62eX5jBn5HKcpOifG80tgkyBvU5eEw==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-stringify-position": "^2.0.0", + "unist-util-visit": "^1.4.0" + } + }, + "remark-lint-no-heading-content-indent": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-no-heading-content-indent/-/remark-lint-no-heading-content-indent-1.0.3.tgz", + "integrity": "sha512-7xM6X5E/dt8OXOHdejH+sfYb139a3kMr8ZSSkcp90Ab1y+ZQBNaWsR3mYh8FRKkYPTN5eyd+KjhNpLWyqqCbgg==", + "dev": true, + "requires": { + "mdast-util-heading-style": "^1.0.2", + "plur": "^3.0.0", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-no-inline-padding": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/remark-lint-no-inline-padding/-/remark-lint-no-inline-padding-1.0.4.tgz", + "integrity": "sha512-u5rgbDkcfVv645YxxOwoGBBJbsHEwWm/XqnO8EhfKTxkfKOF4ZItG7Ajhj89EDaeXMkvCcB/avBl4bj50eJH3g==", + "dev": true, + "requires": { + "mdast-util-to-string": "^1.0.2", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-visit": "^1.4.0" + } + }, + "remark-lint-no-literal-urls": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-no-literal-urls/-/remark-lint-no-literal-urls-1.0.3.tgz", + "integrity": "sha512-H5quyMzl2kaewK+jYD1FI0G1SIinIsIp4DEyOUwIR+vYUoKwo0B4vvW0cmPpD1dgqqxHYx0B2B0JQQKFVWzGiw==", + "dev": true, + "requires": { + "mdast-util-to-string": "^1.0.2", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-no-shortcut-reference-image": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-image/-/remark-lint-no-shortcut-reference-image-1.0.3.tgz", + "integrity": "sha512-CGm27X54kXp/5ehXejDTsZjqzK4uIhLGcrFzN3k/KjdwunQouEY92AARGrLSEuJ1hQx0bJsmnvr/hvQyWAfNJg==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-no-shortcut-reference-link": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-link/-/remark-lint-no-shortcut-reference-link-1.0.4.tgz", + "integrity": "sha512-FXdMJYqspZBhPlxYqfVgVluVXjxStg0RHJzqrk8G9wS8fCS62AE3reoaoiCahwoH1tfKcA+poktbKqDAmZo7Jg==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-lint-no-undefined-references": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-undefined-references/-/remark-lint-no-undefined-references-1.1.1.tgz", + "integrity": "sha512-b1eIjWFaCu6m16Ax2uG33o1v+eRYqDTQRUqU6UeQ76JXmDmVtVO75ZuyRpqqE7VTZRW8YLVurXfJPDXfIa5Wng==", + "dev": true, + "requires": { + "collapse-white-space": "^1.0.4", + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-visit": "^1.4.0" + } + }, + "remark-lint-no-unused-definitions": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/remark-lint-no-unused-definitions/-/remark-lint-no-unused-definitions-1.0.5.tgz", + "integrity": "sha512-Bo22e0RNzc1QMW317KTuStGFDG7uTDUQhm/TrW6Qzud0WXnNnqUyvts+e7wTYoj8VnwhhjyjyoA9lKA3uXMdAQ==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-visit": "^1.4.0" + } + }, + "remark-lint-ordered-list-marker-style": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/remark-lint-ordered-list-marker-style/-/remark-lint-ordered-list-marker-style-1.0.3.tgz", + "integrity": "sha512-24TmW1eUa/2JlwprZg9jJ8LKLxNGKnlKiI5YOhN4taUp2yv8daqlV9vR54yfn/ZZQh6EQvbIX0jeVY9NYgQUtw==", + "dev": true, + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^1.1.1" + } + }, + "remark-message-control": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/remark-message-control/-/remark-message-control-4.2.0.tgz", + "integrity": "sha512-WXH2t5ljTyhsXlK1zPBLF3iPHbXl58R94phPMreS1xcHWBZJt6Oiu8RtNjy1poZFb3PqKnbYLJeR/CWcZ1bTFw==", + "dev": true, + "requires": { + "mdast-comment-marker": "^1.0.0", + "unified-message-control": "^1.0.0", + "xtend": "^4.0.1" + } + }, + "remark-parse": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-6.0.3.tgz", + "integrity": "sha512-QbDXWN4HfKTUC0hHa4teU463KclLAnwpn/FBn87j9cKYJWWawbiLgMfP2Q4XwhxxuuuOxHlw+pSN0OKuJwyVvg==", + "dev": true, + "requires": { + "collapse-white-space": "^1.0.2", + "is-alphabetical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-whitespace-character": "^1.0.0", + "is-word-character": "^1.0.0", + "markdown-escapes": "^1.0.0", + "parse-entities": "^1.1.0", + "repeat-string": "^1.5.4", + "state-toggle": "^1.0.0", + "trim": "0.0.1", + "trim-trailing-lines": "^1.0.0", + "unherit": "^1.0.4", + "unist-util-remove-position": "^1.0.0", + "vfile-location": "^2.0.0", + "xtend": "^4.0.1" + } + }, + "remark-preset-lint-recommended": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/remark-preset-lint-recommended/-/remark-preset-lint-recommended-3.0.3.tgz", + "integrity": "sha512-5sQ34j1Irlsj6Tt4WWRylZ7UU+1jD5es/LfDZBZp/LXDwC4ldGqKpMmCCR6Z00x1jYM1phmS4M+eGqTdah0qkQ==", + "dev": true, + "requires": { + "remark-lint": "^6.0.0", + "remark-lint-final-newline": "^1.0.0", + "remark-lint-hard-break-spaces": "^1.0.0", + "remark-lint-list-item-bullet-indent": "^1.0.0", + "remark-lint-list-item-indent": "^1.0.0", + "remark-lint-no-auto-link-without-protocol": "^1.0.0", + "remark-lint-no-blockquote-without-marker": "^2.0.0", + "remark-lint-no-duplicate-definitions": "^1.0.0", + "remark-lint-no-heading-content-indent": "^1.0.0", + "remark-lint-no-inline-padding": "^1.0.0", + "remark-lint-no-literal-urls": "^1.0.0", + "remark-lint-no-shortcut-reference-image": "^1.0.0", + "remark-lint-no-shortcut-reference-link": "^1.0.0", + "remark-lint-no-undefined-references": "^1.0.0", + "remark-lint-no-unused-definitions": "^1.0.0", + "remark-lint-ordered-list-marker-style": "^1.0.0" + } + }, + "remark-stringify": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-6.0.4.tgz", + "integrity": "sha512-eRWGdEPMVudijE/psbIDNcnJLRVx3xhfuEsTDGgH4GsFF91dVhw5nhmnBppafJ7+NWINW6C7ZwWbi30ImJzqWg==", + "dev": true, + "requires": { + "ccount": "^1.0.0", + "is-alphanumeric": "^1.0.0", + "is-decimal": "^1.0.0", + "is-whitespace-character": "^1.0.0", + "longest-streak": "^2.0.1", + "markdown-escapes": "^1.0.0", + "markdown-table": "^1.1.0", + "mdast-util-compact": "^1.0.0", + "parse-entities": "^1.0.2", + "repeat-string": "^1.5.4", + "state-toggle": "^1.0.0", + "stringify-entities": "^1.0.1", + "unherit": "^1.0.4", + "xtend": "^4.0.1" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + } + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "^2.0.0", + "semver": "^5.1.0" + } + }, + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "revalidator": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.3.1.tgz", + "integrity": "sha1-/yzEz3zHxjhaxxAXgnbm280Ddi8=" + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "run-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", + "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", + "dev": true + }, + "rxjs": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.4.tgz", + "integrity": "sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safe-json-stringify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/safe-json-stringify/-/safe-json-stringify-1.2.0.tgz", + "integrity": "sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==" + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "saslprep": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.2.tgz", + "integrity": "sha512-4cDsYuAjXssUSjxHKRe4DTZC0agDwsCqcMqtJAQPzC74nJ7LfAJflAtC1Zed5hMzEQKj82d3tuzqdGNRsLJ4Gw==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "dependencies": { + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "serr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/serr/-/serr-1.0.1.tgz", + "integrity": "sha1-dKW55/rdW1X4qF5+crwApBm25II=", + "requires": { + "lodash": "^4.0.0" + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "set-value": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "shellsubstitute": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shellsubstitute/-/shellsubstitute-1.2.0.tgz", + "integrity": "sha1-5PcCpQxRiw9v6YRRiQ1wWvKba3A=", + "dev": true + }, + "should": { + "version": "13.2.3", + "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", + "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", + "dev": true, + "requires": { + "should-equal": "^2.0.0", + "should-format": "^3.0.3", + "should-type": "^1.4.0", + "should-type-adaptors": "^1.0.1", + "should-util": "^1.0.0" + } + }, + "should-equal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", + "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", + "dev": true, + "requires": { + "should-type": "^1.4.0" + } + }, + "should-format": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", + "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-type-adaptors": "^1.0.1" + } + }, + "should-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", + "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", + "dev": true + }, + "should-type-adaptors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", + "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-util": "^1.0.0" + } + }, + "should-util": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", + "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", + "dev": true + }, + "sift": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", + "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "source-map": { + "version": "0.1.43", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", + "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, + "split-on-first": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==" + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "staged-git-files": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/staged-git-files/-/staged-git-files-1.1.1.tgz", + "integrity": "sha512-H89UNKr1rQJvI1c/PIR3kiAMBV23yvR7LItZiV74HWZwzt7f3YHuujJ9nJZlt58WlFox7XQsOahexwk7nTe69A==", + "dev": true + }, + "state-toggle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.3.tgz", + "integrity": "sha512-d/5Z4/2iiCnHw6Xzghyhb+GcmF89bxwgXG60wjIiZaxnymbyOmI8Hk4VqHXiVVp6u2ysaskFfXg3ekCj4WNftQ==", + "dev": true + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=" + }, + "string-argv": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.0.2.tgz", + "integrity": "sha1-2sMECGkMIfPDYwo/86BYd73L1zY=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string.prototype.padstart": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.padstart/-/string.prototype.padstart-3.1.0.tgz", + "integrity": "sha512-envqZvUp2JItI+OeQ5UAh1ihbAV5G/2bixTojvlIa090GGqF+NQRxbWb2nv9fTGrZABv6+pE6jXoAZhhS2k4Hw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + } + } + }, + "string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "stringify-entities": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.2.tgz", + "integrity": "sha512-nrBAQClJAPN2p+uGCVJRPIPakKeKWZ9GtBCmormE7pWOSlHat7+x5A8gx85M7HM5Dt0BP3pP5RhVW77WdbJJ3A==", + "dev": true, + "requires": { + "character-entities-html4": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "is-alphanumerical": "^1.0.0", + "is-hexadecimal": "^1.0.0" + } + }, + "stringify-object": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", + "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", + "dev": true, + "requires": { + "get-own-enumerable-property-symbols": "^3.0.0", + "is-obj": "^1.0.1", + "is-regexp": "^1.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "^0.2.0" + } + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "structured-source": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/structured-source/-/structured-source-3.0.2.tgz", + "integrity": "sha1-3YAkJeD1PcSm56yjdSkBoczaevU=", + "dev": true, + "requires": { + "boundary": "^1.0.1" + } + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true + }, + "table": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", + "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "dev": true, + "requires": { + "ajv": "^4.7.0", + "ajv-keywords": "^1.0.0", + "chalk": "^1.1.1", + "lodash": "^4.0.0", + "slice-ansi": "0.0.4", + "string-width": "^2.0.0" + }, + "dependencies": { + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true, + "requires": { + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "textlint": { + "version": "11.3.1", + "resolved": "https://registry.npmjs.org/textlint/-/textlint-11.3.1.tgz", + "integrity": "sha512-svbO/fhj7dLTJcdKgrW5fJtNRHoFFVL+sutsKBmNUcSJgvgWteLOUZAKT/dp/4S0QfkwkpNOts7Bzn9T+0h0Cw==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.4", + "@textlint/ast-traverse": "^2.1.5", + "@textlint/feature-flag": "^3.1.3", + "@textlint/fixer-formatter": "^3.1.8", + "@textlint/kernel": "^3.1.8", + "@textlint/linter-formatter": "^3.1.7", + "@textlint/module-interop": "^1.0.1", + "@textlint/textlint-plugin-markdown": "^5.1.8", + "@textlint/textlint-plugin-text": "^4.1.8", + "@textlint/types": "^1.2.1", + "@textlint/utils": "^1.0.2", + "@types/bluebird": "^3.5.18", + "bluebird": "^3.0.5", + "debug": "^4.1.1", + "deep-equal": "^1.0.1", + "file-entry-cache": "^5.0.1", + "get-stdin": "^5.0.1", + "glob": "^7.1.3", + "is-file": "^1.0.0", + "log-symbols": "^1.0.2", + "map-like": "^2.0.0", + "md5": "^2.2.1", + "mkdirp": "^0.5.0", + "optionator": "^0.8.0", + "path-to-glob-pattern": "^1.0.2", + "rc-config-loader": "^2.0.4", + "read-pkg": "^1.1.0", + "read-pkg-up": "^3.0.0", + "structured-source": "^3.0.2", + "try-resolve": "^1.0.1", + "unique-concat": "^0.2.2" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "get-stdin": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", + "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "textlint-filter-rule-comments": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/textlint-filter-rule-comments/-/textlint-filter-rule-comments-1.2.2.tgz", + "integrity": "sha1-OnLElJlOBo4OSqrQ8k6nz+M4UDo=", + "dev": true + }, + "textlint-rule-common-misspellings": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/textlint-rule-common-misspellings/-/textlint-rule-common-misspellings-1.0.1.tgz", + "integrity": "sha1-jEEzzzu1mqFZGZ0sm87RJBM2V3Q=", + "dev": true, + "requires": { + "misspellings": "^1.0.1", + "textlint-rule-helper": "^1.1.5" + } + }, + "textlint-rule-helper": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/textlint-rule-helper/-/textlint-rule-helper-1.2.0.tgz", + "integrity": "sha1-vmjUelFGsW3RFieMmut701YxzNo=", + "dev": true, + "requires": { + "unist-util-visit": "^1.1.0" + } + }, + "textlint-rule-no-dead-link": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/textlint-rule-no-dead-link/-/textlint-rule-no-dead-link-4.6.2.tgz", + "integrity": "sha512-f11iwmihzQhWwO8KCa4sYMhiZhnfRYwXQbuFILZVoNhBRfcxYF3A19N/poYgAcCJRre9GkCv7/B2RiraxKUUjA==", + "dev": true, + "requires": { + "fs-extra": "^8.1.0", + "get-url-origin": "^1.0.1", + "minimatch": "^3.0.4", + "node-fetch": "^2.6.0", + "p-memoize": "^3.1.0", + "p-queue": "^6.2.0", + "textlint-rule-helper": "^2.1.1" + }, + "dependencies": { + "textlint-rule-helper": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/textlint-rule-helper/-/textlint-rule-helper-2.1.1.tgz", + "integrity": "sha512-6fxgHzoJVkjl3LaC1b2Egi+5wbhG4i0pU0knJmQujVhxIJ3D3AcQQZPs457xKAi5xKz1WayYeTeJ5jrD/hnO7g==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.1", + "@textlint/types": "^1.1.2", + "structured-source": "^3.0.2", + "unist-util-visit": "^1.1.0" + } + } + } + }, + "textlint-rule-terminology": { + "version": "1.1.30", + "resolved": "https://registry.npmjs.org/textlint-rule-terminology/-/textlint-rule-terminology-1.1.30.tgz", + "integrity": "sha512-PsLiridAdaLyho236adWnTEAbAcxxUsxVqaXWaJce+aRsjCOeyYPBLNRisFGz90KZ0S1NDYT/v5CvzBrgsiuzQ==", + "dev": true, + "requires": { + "lodash": "^4.17.4", + "strip-json-comments": "^2.0.1", + "textlint-rule-helper": "^2.0.0" + }, + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "textlint-rule-helper": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/textlint-rule-helper/-/textlint-rule-helper-2.1.1.tgz", + "integrity": "sha512-6fxgHzoJVkjl3LaC1b2Egi+5wbhG4i0pU0knJmQujVhxIJ3D3AcQQZPs457xKAi5xKz1WayYeTeJ5jrD/hnO7g==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.1", + "@textlint/types": "^1.1.2", + "structured-source": "^3.0.2", + "unist-util-visit": "^1.1.0" + } + } + } + }, + "textlint-rule-write-good": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/textlint-rule-write-good/-/textlint-rule-write-good-1.6.2.tgz", + "integrity": "sha1-PHmwQJExnU6L5ftELFlr9QDoST4=", + "dev": true, + "requires": { + "textlint-rule-helper": "^2.0.0", + "write-good": "^0.11.0" + }, + "dependencies": { + "textlint-rule-helper": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/textlint-rule-helper/-/textlint-rule-helper-2.1.1.tgz", + "integrity": "sha512-6fxgHzoJVkjl3LaC1b2Egi+5wbhG4i0pU0knJmQujVhxIJ3D3AcQQZPs457xKAi5xKz1WayYeTeJ5jrD/hnO7g==", + "dev": true, + "requires": { + "@textlint/ast-node-types": "^4.2.1", + "@textlint/types": "^1.1.2", + "structured-source": "^3.0.2", + "unist-util-visit": "^1.1.0" + } + } + } + }, + "timekeeper": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/timekeeper/-/timekeeper-2.2.0.tgz", + "integrity": "sha512-W3AmPTJWZkRwu+iSNxPIsLZ2ByADsOLbbLxe46UJyWj3mlYLlwucKiq+/dPm0l9wTzqoF3/2PH0AGFCebjq23A==", + "dev": true + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "to-vfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-4.0.0.tgz", + "integrity": "sha512-Y7EDM+uoU8TZxF5ej2mUR0dLO4qbuuNRnJKxEht2QJWEq2421pyG1D1x8YxPKmyTc6nHh7Td/jLGFxYo+9vkLA==", + "dev": true, + "requires": { + "is-buffer": "^2.0.0", + "vfile": "^3.0.0" + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "too-wordy": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/too-wordy/-/too-wordy-0.1.6.tgz", + "integrity": "sha512-MV5F74YF9+UYsvwXGXTh+5YP3EqH/ivwWfyFE2/YHWQQxm9jDPmkIC23nkN133Ye4nO3HTXmiMcfGqJ5xRPfOA==", + "dev": true + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } + } + }, + "traverse": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz", + "integrity": "sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=", + "dev": true + }, + "trim": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", + "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=", + "dev": true + }, + "trim-trailing-lines": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.3.tgz", + "integrity": "sha512-4ku0mmjXifQcTVfYDfR5lpgV7zVqPg6zV9rdZmwOPqq0+Zq19xDqEgagqVbc4pOOShbncuAOIs59R3+3gcF3ZA==", + "dev": true + }, + "trough": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz", + "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==", + "dev": true + }, + "try-resolve": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/try-resolve/-/try-resolve-1.0.1.tgz", + "integrity": "sha1-z95vq9ctY+V5fPqrhzq76OcA6RI=", + "dev": true + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "3.5.9", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.9.tgz", + "integrity": "sha512-WpT0RqsDtAWPNJK955DEnb6xjymR8Fn0OlK4TT4pS0ASYsVPqr5ELhgwOwLCP5J5vHeJ4xmMmz3DEgdqC10JeQ==", + "dev": true, + "optional": true, + "requires": { + "commander": "~2.20.0", + "source-map": "~0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "optional": true + } + } + }, + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "unherit": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.3.tgz", + "integrity": "sha512-Ft16BJcnapDKp0+J/rqFC3Rrk6Y/Ng4nzsC028k2jdDII/rdZ7Wd3pPT/6+vIIxRagwRc9K0IUX0Ra4fKvw+WQ==", + "dev": true, + "requires": { + "inherits": "^2.0.0", + "xtend": "^4.0.0" + } + }, + "unified": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/unified/-/unified-7.1.0.tgz", + "integrity": "sha512-lbk82UOIGuCEsZhPj8rNAkXSDXd6p0QLzIuSsCdxrqnqU56St4eyOB+AlXsVgVeRmetPTYydIuvFfpDIed8mqw==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "@types/vfile": "^3.0.0", + "bail": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^1.1.0", + "trough": "^1.0.0", + "vfile": "^3.0.0", + "x-is-string": "^0.1.0" + } + }, + "unified-args": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unified-args/-/unified-args-6.0.0.tgz", + "integrity": "sha512-1m2pGiTClgcCtCvgtABkJLze8JJiZpzsqujRhzBjZsRwaIIU1Yj36YHY6t2RvidO8d6fucZdk3KX+8eS4+uv9g==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "chalk": "^2.0.0", + "chokidar": "^2.0.0", + "fault": "^1.0.2", + "json5": "^1.0.0", + "minimist": "^1.2.0", + "text-table": "^0.2.0", + "unified-engine": "^6.0.0" + } + }, + "unified-engine": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unified-engine/-/unified-engine-6.0.1.tgz", + "integrity": "sha512-iDJYH82TgcezQA4IZzhCNJQx7vBsGk4h9s4Q7Fscrb3qcPsxBqVrVNYez2W3sBVTxuU1bFAhyRpA6ba/R4j93A==", + "dev": true, + "requires": { + "concat-stream": "^1.5.1", + "debug": "^3.1.0", + "fault": "^1.0.0", + "fn-name": "^2.0.1", + "glob": "^7.0.3", + "ignore": "^3.2.0", + "is-empty": "^1.0.0", + "is-hidden": "^1.0.1", + "is-object": "^1.0.1", + "js-yaml": "^3.6.1", + "load-plugin": "^2.0.0", + "parse-json": "^4.0.0", + "to-vfile": "^4.0.0", + "trough": "^1.0.0", + "unist-util-inspect": "^4.1.2", + "vfile-reporter": "^5.0.0", + "vfile-statistics": "^1.1.0", + "x-is-string": "^0.1.0", + "xtend": "^4.0.1" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "unified-lint-rule": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-1.0.4.tgz", + "integrity": "sha512-q9wY6S+d38xRAuWQVOMjBQYi7zGyKkY23ciNafB8JFVmDroyKjtytXHCg94JnhBCXrNqpfojo3+8D+gmF4zxJQ==", + "dev": true, + "requires": { + "wrapped": "^1.0.1" + } + }, + "unified-message-control": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unified-message-control/-/unified-message-control-1.0.4.tgz", + "integrity": "sha512-e1dEtN4Z/TvLn/qHm+xeZpzqhJTtfZusFErk336kkZVpqrJYiV9ptxq+SbRPFMlN0OkjDYHmVJ929KYjsMTo3g==", + "dev": true, + "requires": { + "trim": "0.0.1", + "unist-util-visit": "^1.0.0", + "vfile-location": "^2.0.0" + } + }, + "union-value": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^2.0.1" + } + }, + "unique-concat": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/unique-concat/-/unique-concat-0.2.2.tgz", + "integrity": "sha1-khD5vcqsxeHjkpSQ18AZ35bxhxI=", + "dev": true + }, + "unist-util-generated": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.5.tgz", + "integrity": "sha512-1TC+NxQa4N9pNdayCYA1EGUOCAO0Le3fVp7Jzns6lnua/mYgwHo0tz5WUAfrdpNch1RZLHc61VZ1SDgrtNXLSw==", + "dev": true + }, + "unist-util-inspect": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/unist-util-inspect/-/unist-util-inspect-4.1.4.tgz", + "integrity": "sha512-7xxyvKiZ1SC9vL5qrMqKub1T31gRHfau4242F69CcaOrXt//5PmRVOmDZ36UAEgiT+tZWzmQmbNZn+mVtnR9HQ==", + "dev": true, + "requires": { + "is-empty": "^1.0.0" + } + }, + "unist-util-is": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", + "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==", + "dev": true + }, + "unist-util-position": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.0.4.tgz", + "integrity": "sha512-tWvIbV8goayTjobxDIr4zVTyG+Q7ragMSMeKC3xnPl9xzIc0+she8mxXLM3JVNDDsfARPbCd3XdzkyLdo7fF3g==", + "dev": true + }, + "unist-util-remove-position": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.4.tgz", + "integrity": "sha512-tLqd653ArxJIPnKII6LMZwH+mb5q+n/GtXQZo6S6csPRs5zB0u79Yw8ouR3wTw8wxvdJFhpP6Y7jorWdCgLO0A==", + "dev": true, + "requires": { + "unist-util-visit": "^1.1.0" + } + }, + "unist-util-stringify-position": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.2.tgz", + "integrity": "sha512-nK5n8OGhZ7ZgUwoUbL8uiVRwAbZyzBsB/Ddrlbu6jwwubFza4oe15KlyEaLNMXQW1svOQq4xesUeqA85YrIUQA==", + "dev": true, + "requires": { + "@types/unist": "^2.0.2" + } + }, + "unist-util-visit": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", + "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "dev": true, + "requires": { + "unist-util-visit-parents": "^2.0.0" + } + }, + "unist-util-visit-parents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", + "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "dev": true, + "requires": { + "unist-util-is": "^3.0.0" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "untildify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-2.1.0.tgz", + "integrity": "sha1-F+soB5h/dpUunASF/DEdBqgmouA=", + "dev": true, + "requires": { + "os-homedir": "^1.0.0" + } + }, + "upath": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", + "dev": true + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "vfile": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-3.0.1.tgz", + "integrity": "sha512-y7Y3gH9BsUSdD4KzHsuMaCzRjglXN0W2EcMf0gpvu6+SbsGhMje7xDc8AEoeXy6mIwCKMI6BkjMsRjzQbhMEjQ==", + "dev": true, + "requires": { + "is-buffer": "^2.0.0", + "replace-ext": "1.0.0", + "unist-util-stringify-position": "^1.0.0", + "vfile-message": "^1.0.0" + }, + "dependencies": { + "unist-util-stringify-position": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz", + "integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ==", + "dev": true + }, + "vfile-message": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.1.1.tgz", + "integrity": "sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==", + "dev": true, + "requires": { + "unist-util-stringify-position": "^1.1.1" + } + } + } + }, + "vfile-location": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.6.tgz", + "integrity": "sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA==", + "dev": true + }, + "vfile-message": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.2.tgz", + "integrity": "sha512-gNV2Y2fDvDOOqq8bEe7cF3DXU6QgV4uA9zMR2P8tix11l1r7zju3zry3wZ8sx+BEfuO6WQ7z2QzfWTvqHQiwsA==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^2.0.0" + } + }, + "vfile-reporter": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-5.1.2.tgz", + "integrity": "sha512-b15sTuss1wOPWVlyWOvu+n6wGJ/eTYngz3uqMLimQvxZ+Q5oFQGYZZP1o3dR9sk58G5+wej0UPCZSwQBX/mzrQ==", + "dev": true, + "requires": { + "repeat-string": "^1.5.0", + "string-width": "^2.0.0", + "supports-color": "^5.0.0", + "unist-util-stringify-position": "^2.0.0", + "vfile-sort": "^2.1.2", + "vfile-statistics": "^1.1.0" + }, + "dependencies": { + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "vfile-sort": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-2.2.1.tgz", + "integrity": "sha512-5dt7xEhC44h0uRQKhbM2JAe0z/naHphIZlMOygtMBM9Nn0pZdaX5fshhwWit9wvsuP8t/wp43nTDRRErO1WK8g==", + "dev": true + }, + "vfile-statistics": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-1.1.3.tgz", + "integrity": "sha512-CstaK/ebTz1W3Qp41Bt9Lj/2DmumFsCwC2sKahDNSPh0mPh7/UyMLCoU8ZBX34CRU0d61B4W41yIFsV0NKMZeA==", + "dev": true + }, + "watch": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/watch/-/watch-1.0.2.tgz", + "integrity": "sha1-NApxe952Vyb6CqB9ch4BR6VR3ww=", + "dev": true, + "requires": { + "exec-sh": "^0.2.0", + "minimist": "^1.2.0" + } + }, + "weasel-words": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/weasel-words/-/weasel-words-0.1.1.tgz", + "integrity": "sha1-cTeUZYXHP+RIggE4U70ADF1oek4=", + "dev": true + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "wrapped": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wrapped/-/wrapped-1.0.1.tgz", + "integrity": "sha1-x4PZ2Aeyc+mwHoUWgKk4yHyQckI=", + "dev": true, + "requires": { + "co": "3.1.0", + "sliced": "^1.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "write-good": { + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/write-good/-/write-good-0.11.3.tgz", + "integrity": "sha512-fDKIHO5wCzTLCOGNJl1rzzJrZlTIzfZl8msOoJQZzRhYo0X/tFTm4+2B1zTibFYK01Nnd1kLZBjj4xjcFLePNQ==", + "dev": true, + "requires": { + "adverb-where": "0.0.9", + "e-prime": "^0.10.2", + "no-cliches": "^0.1.0", + "object.assign": "^4.0.4", + "passive-voice": "^0.1.0", + "too-wordy": "^0.1.4", + "weasel-words": "^0.1.1" + } + }, + "x-is-string": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz", + "integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI=", + "dev": true + }, + "xml-escape": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xml-escape/-/xml-escape-1.1.0.tgz", + "integrity": "sha1-OQTBQ/qOs6ADDsZG0pAqLxtwbEQ=", + "dev": true + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, + "yargs": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.2.tgz", + "integrity": "sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", + "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" + }, + "dependencies": { + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + } + } +} diff --git a/package.json b/package.json index 61dd653fd..4cd939506 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "iotagent-node-lib", + "license": "AGPL-3.0-only", "description": "IoT Agent library to interface with NGSI Context Broker", "version": "2.11.0-next", "homepage": "https://github.com/telefonicaid/iotagent-node-lib", @@ -35,6 +36,7 @@ "lint": "jshint lib/ --config .jshintrc && jshint test/ --config test/.jshintrc", "lint:md": "remark -f '*.md' 'doc/*.md'", "lint:text": "textlint '*.md' 'doc/*.md'", + "prettier": "prettier --config .prettierrc.json --write '**/**/**/**/*.js' '**/**/**/*.js' '**/**/*.js' '**/*.js' '*.js'", "test:coverage": "istanbul cover _mocha -- --recursive 'test/**/*.js' --reporter spec --exit", "test:coveralls": "npm run test:coverage && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage", "watch": "watch 'npm test && npm run lint' ./lib ./test" @@ -59,13 +61,15 @@ }, "devDependencies": { "coveralls": "~3.0.3", + "husky": "~1.1.0", "istanbul": "~0.4.5", "jshint": "~2.10.2", + "lint-staged": "~7.3.0", "mocha": "6.1.4", "nock": "10.0.6", + "prettier": "~1.14.2", "should": "13.2.3", "timekeeper": "2.2.0", - "watch": "~1.0.2", "remark-cli": "~6.0.1", "remark-preset-lint-recommended": "~3.0.3", "textlint": "~11.3.1", @@ -73,6 +77,18 @@ "textlint-rule-common-misspellings": "~1.0.1", "textlint-rule-no-dead-link": "~4.6.1", "textlint-rule-terminology": "~1.1.29", - "textlint-rule-write-good": "~1.6.2" + "textlint-rule-write-good": "~1.6.2", + "watch": "~1.0.2" + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "*.js": [ + "prettier --config .prettierrc.json --write", + "git add" + ] } } diff --git a/test/.jshintrc b/test/.jshintrc index 2cbeefda0..2b9a71fe7 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -13,7 +13,7 @@ "maxparams": 6, "maxdepth": 4, "camelcase": true, - "maxlen": 120, + "maxlen": 180, "node": true, "expr": true, "unused": "vars", diff --git a/test/unit/expressions/expression-test.js b/test/unit/expressions/expression-test.js index 2bd6ddcb4..e700d93c4 100644 --- a/test/unit/expressions/expression-test.js +++ b/test/unit/expressions/expression-test.js @@ -87,21 +87,21 @@ describe('Expression interpreter', function() { describe('When string transformation functions are executed', function() { it('should return the appropriate piece of the string', function(done) { expressionParser.parse( - 'trim(substr(@theString, indexOf(@theString, \",\") + 1, length(@theString)))', + 'trim(substr(@theString, indexOf(@theString, ",") + 1, length(@theString)))', scope, 'String', function(error, result) { should.not.exist(error); result.should.equal('-19.4'); done(); - }); + } + ); }); }); describe('When an expression contains variables with numbers', function() { it('should return the appropriate result', function(done) { - expressionParser.parse('@number + @number2 + @number3inside', - scope, 'String', function(error, result) { + expressionParser.parse('@number + @number2 + @number3inside', scope, 'String', function(error, result) { should.not.exist(error); result.should.equal(500); done(); @@ -111,26 +111,21 @@ describe('Expression interpreter', function() { describe('When an expression contains multiple parenthesis', function() { it('should return the appropriate result', function(done) { - expressionParser.parse('((@number) * (@number2))', - scope, 'String', function(error, result) { - should.not.exist(error); - result.should.equal(22475); - done(); - }); + expressionParser.parse('((@number) * (@number2))', scope, 'String', function(error, result) { + should.not.exist(error); + result.should.equal(22475); + done(); + }); }); }); describe('When trim() function is executed', function() { it('should return the appropriate piece of the string', function(done) { - expressionParser.parse( - 'trim(@spaces)', - scope, - 'String', - function(error, result) { - should.not.exist(error); - result.should.equal('5 a b c d 5'); - done(); - }); + expressionParser.parse('trim(@spaces)', scope, 'String', function(error, result) { + should.not.exist(error); + result.should.equal('5 a b c d 5'); + done(); + }); }); }); @@ -146,11 +141,18 @@ describe('Expression interpreter', function() { describe('When an expression with strings with single quotation marks is parsed', function() { it('should accept the strings', function(done) { - expressionParser.parse('\'Pruebas \' # \'De Strings\'', scope, 'String', function(error, result) { - should.not.exist(error); - result.should.equal('Pruebas De Strings'); - done(); - }); + expressionParser.parse( + /*jshint quotmark: double */ + "'Pruebas ' # 'De Strings'", + /*jshint quotmark: single */ + scope, + 'String', + function(error, result) { + should.not.exist(error); + result.should.equal('Pruebas De Strings'); + done(); + } + ); }); }); @@ -193,5 +195,4 @@ describe('Expression interpreter', function() { }); }); }); - }); diff --git a/test/unit/expressions/expressionBasedTransformations-test.js b/test/unit/expressions/expressionBasedTransformations-test.js index c59cafb9c..b6a51322a 100644 --- a/test/unit/expressions/expressionBasedTransformations-test.js +++ b/test/unit/expressions/expressionBasedTransformations-test.js @@ -39,7 +39,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [], @@ -52,7 +52,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'LightError': { + LightError: { commands: [], type: 'Light', lazy: [], @@ -65,7 +65,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStation': { + WeatherStation: { commands: [], type: 'WeatherStation', lazy: [], @@ -88,7 +88,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStationMultiple': { + WeatherStationMultiple: { commands: [], type: 'WeatherStation', lazy: [], @@ -153,10 +153,16 @@ describe('NGSI-v1 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextExpressionPlugin1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json' + ) + ); }); it('should apply the expression before sending the values', function(done) { @@ -183,10 +189,16 @@ describe('NGSI-v1 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextExpressionPlugin4.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin4.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json' + ) + ); }); it('should apply the expression before sending the values', function(done) { @@ -219,10 +231,16 @@ describe('NGSI-v1 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextExpressionPlugin2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextExpressionPlugin2Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin2.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextExpressionPlugin2Success.json' + ) + ); }); it('should calculate them and add them to the payload', function(done) { @@ -254,10 +272,16 @@ describe('NGSI-v1 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextExpressionPlugin5.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextExpressionPlugin5Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin5.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextExpressionPlugin5Success.json' + ) + ); }); it('should calculate it and add it to the payload', function(done) { @@ -284,10 +308,16 @@ describe('NGSI-v1 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextExpressionPlugin3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextExpressionPlugin3Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextExpressionPlugin3Success.json' + ) + ); }); it('should not calculate the expression', function(done) { diff --git a/test/unit/general/config-multi-core-test.js b/test/unit/general/config-multi-core-test.js index 251fc3d30..56b04c398 100644 --- a/test/unit/general/config-multi-core-test.js +++ b/test/unit/general/config-multi-core-test.js @@ -30,13 +30,13 @@ let config = require('../../../lib/commonConfig'), logLevel: 'FATAL', contextBroker: { host: '192.168.1.1', - port: '1026', + port: '1026' }, server: { port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -55,13 +55,11 @@ let config = require('../../../lib/commonConfig'), }, providerUrl: 'http://smartGondor.com', deviceRegistrationDuration: 'P1M', - throttling: 'PT5S', + throttling: 'PT5S' }; - describe('Startup Multi-Core tests', function() { - - describe('When the IoT Agent is started with Multi-Core environment variable with value \'true\'', function() { + describe('When the IoT Agent is started with Multi-Core environment variable with value=true', function() { beforeEach(function() { process.env.IOTA_MULTI_CORE = 'true'; iotAgentConfig.multiCore = false; @@ -71,15 +69,14 @@ describe('Startup Multi-Core tests', function() { delete process.env.IOTA_MULTI_CORE; }); - it('should load the correct configuration parameter with value \'true\'', function(done) { + it('should load the correct configuration parameter with value=true', function(done) { config.setConfig(iotAgentConfig); config.getConfig().multiCore.should.equal(true); done(); }); - }); - describe('When the IoT Agent is started with Multi-Core environment variable with value \'false\'', function() { + describe('When the IoT Agent is started with Multi-Core environment variable with value=false', function() { beforeEach(function() { process.env.IOTA_MULTI_CORE = 'false'; iotAgentConfig.multiCore = true; @@ -89,31 +86,33 @@ describe('Startup Multi-Core tests', function() { delete process.env.IOTA_MULTI_CORE; }); - it('should load the correct configuration parameter with value \'false\'', function(done) { + it('should load the correct configuration parameter with value=false', function(done) { config.setConfig(iotAgentConfig); config.getConfig().multiCore.should.equal(false); done(); }); }); - - describe('When the IoT Agent is started with Multi-Core environment variable with any other value except ' + - '\'true\' or \'false\'', function() { - beforeEach(function() { - process.env.IOTA_MULTI_CORE = 'foo'; - iotAgentConfig.multiCore = true; - }); - - afterEach(function() { - delete process.env.IOTA_MULTI_CORE; - }); - - it('should load the correct configuration parameter with value \'false\'', function(done) { - config.setConfig(iotAgentConfig); - config.getConfig().multiCore.should.equal(false); - done(); - }); - }); + describe( + 'When the IoT Agent is started with Multi-Core environment variable with any other value except ' + + 'true or false', + function() { + beforeEach(function() { + process.env.IOTA_MULTI_CORE = 'foo'; + iotAgentConfig.multiCore = true; + }); + + afterEach(function() { + delete process.env.IOTA_MULTI_CORE; + }); + + it('should load the correct configuration parameter with value=false', function(done) { + config.setConfig(iotAgentConfig); + config.getConfig().multiCore.should.equal(false); + done(); + }); + } + ); describe('When the IoT Agent is started with Multi-Core environment variable with a numeric value', function() { beforeEach(function() { @@ -125,93 +124,106 @@ describe('Startup Multi-Core tests', function() { delete process.env.IOTA_MULTI_CORE; }); - it('should load the correct configuration parameter with value \'false\'', function(done) { - config.setConfig(iotAgentConfig); - config.getConfig().multiCore.should.equal(false); - done(); - }); - }); - - describe('When the IoT Agent is either started with Multi-Core environment variable nor it is ' + - 'configured', function() { - beforeEach(function() { - }); - - afterEach(function() { - delete process.env.IOTA_MULTI_CORE; - }); - - it('should load the correct configuration parameter with value \'false\'', function(done) { - config.setConfig(iotAgentConfig); - config.getConfig().multiCore.should.equal(false); - done(); - }); - }); - - describe('When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + - 'value \'true\'', function() { - beforeEach(function() { - iotAgentConfig.multiCore = true; - }); - - afterEach(function() { - delete process.env.IOTA_MULTI_CORE; - }); - - it('should load the correct configuration parameter with value \'true\'', function(done) { - config.setConfig(iotAgentConfig); - config.getConfig().multiCore.should.equal(true); - done(); - }); - }); - - describe('When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + - 'value \'false\'', function() { - beforeEach(function() { - iotAgentConfig.multiCore = false; - }); - - afterEach(function() { - delete process.env.IOTA_MULTI_CORE; - }); - - it('should load the correct configuration parameter with value \'false\'', function(done) { + it('should load the correct configuration parameter with value=false', function(done) { config.setConfig(iotAgentConfig); config.getConfig().multiCore.should.equal(false); done(); }); }); - describe('When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + - 'any other value except \'true\' or \'false\'', function() { - beforeEach(function() { - iotAgentConfig.multiCore = 'foo'; - }); - - afterEach(function() { - delete process.env.IOTA_MULTI_CORE; - }); - - it('should load the correct configuration parameter with value \'false\'', function(done) { - config.setConfig(iotAgentConfig); - config.getConfig().multiCore.should.equal(false); - done(); - }); - }); - - describe('When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + - 'a numeric value', function() { - beforeEach(function() { - iotAgentConfig.multiCore = 123; - }); - - afterEach(function() { - delete process.env.IOTA_MULTI_CORE; - }); - it('should load the correct configuration parameter with value \'false\'', function(done) { - config.setConfig(iotAgentConfig); - config.getConfig().multiCore.should.equal(false); - done(); - }); - }); + describe( + 'When the IoT Agent is either started with Multi-Core environment variable nor it is ' + 'configured', + function() { + beforeEach(function() {}); + + afterEach(function() { + delete process.env.IOTA_MULTI_CORE; + }); + + it('should load the correct configuration parameter with value=false', function(done) { + config.setConfig(iotAgentConfig); + config.getConfig().multiCore.should.equal(false); + done(); + }); + } + ); + + describe( + 'When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + + 'value=true', + function() { + beforeEach(function() { + iotAgentConfig.multiCore = true; + }); + + afterEach(function() { + delete process.env.IOTA_MULTI_CORE; + }); + + it('should load the correct configuration parameter with value=true', function(done) { + config.setConfig(iotAgentConfig); + config.getConfig().multiCore.should.equal(true); + done(); + }); + } + ); + + describe( + 'When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + + 'value=false', + function() { + beforeEach(function() { + iotAgentConfig.multiCore = false; + }); + + afterEach(function() { + delete process.env.IOTA_MULTI_CORE; + }); + + it('should load the correct configuration parameter with value=false', function(done) { + config.setConfig(iotAgentConfig); + config.getConfig().multiCore.should.equal(false); + done(); + }); + } + ); + + describe( + 'When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + + 'any other value except true or false', + function() { + beforeEach(function() { + iotAgentConfig.multiCore = 'foo'; + }); + + afterEach(function() { + delete process.env.IOTA_MULTI_CORE; + }); + + it('should load the correct configuration parameter with value=false', function(done) { + config.setConfig(iotAgentConfig); + config.getConfig().multiCore.should.equal(false); + done(); + }); + } + ); + + describe( + 'When the IoT Agent is not started with Multi-Core environment variable and it is configured with ' + + 'a numeric value', + function() { + beforeEach(function() { + iotAgentConfig.multiCore = 123; + }); + + afterEach(function() { + delete process.env.IOTA_MULTI_CORE; + }); + it('should load the correct configuration parameter with value=false', function(done) { + config.setConfig(iotAgentConfig); + config.getConfig().multiCore.should.equal(false); + done(); + }); + } + ); }); diff --git a/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js index ddfca1bf3..e502bd83f 100644 --- a/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +++ b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js @@ -49,7 +49,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), enabled: true }, types: { - 'Light': { + Light: { service: 'smartGondor', subservice: 'electricity', trust: 'BBBB987654321', @@ -68,7 +68,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], type: 'Termometer', lazy: [ @@ -77,8 +77,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] } }, service: 'smartGondor', @@ -115,24 +114,23 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio nock.cleanAll(); keystoneMock = nock('http://128.16.109.11:5000') - .post('/v3/auth/tokens', - utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json')) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), - { - 'X-Subject-Token': '12345679ABCDEF' - }); + .post( + '/v3/auth/tokens', + utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json') + ) + .reply(201, utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), { + 'X-Subject-Token': '12345679ABCDEF' + }); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -157,12 +155,11 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio nock.cleanAll(); keystoneMock = nock('http://128.16.109.11:5000') - .post('/v3/auth/tokens', - utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json')) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), - { + .post( + '/v3/auth/tokens', + utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json') + ) + .reply(201, utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), { 'X-Subject-Token': '12345679ABCDEF' }); @@ -170,11 +167,11 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 403, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(403, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -192,21 +189,24 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio nock.cleanAll(); keystoneMock = nock('http://128.16.109.11:5000') - .post('/v3/auth/tokens', - utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json')) + .post( + '/v3/auth/tokens', + utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json') + ) .reply( - 401, - utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrustUnauthorized.json')); + 401, + utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrustUnauthorized.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -221,21 +221,17 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio }); describe('When the user requests information about a device in a protected CB', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function(done) { nock.cleanAll(); keystoneMock = nock('http://128.16.109.11:5000') - .post('/v3/auth/tokens', - utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json')) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), - { + .post( + '/v3/auth/tokens', + utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json') + ) + .reply(201, utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), { 'X-Subject-Token': '12345679ABCDEF' }); @@ -243,10 +239,11 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -261,64 +258,76 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio }); describe('When subscriptions are used on a protected Context Broker', function() { - beforeEach(function(done) { - + beforeEach(function(done) { var optionsProvision = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice3.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice3.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': 'electricity' } }; - + nock.cleanAll(); - + iotAgentLib.activate(iotAgentConfig, function() { keystoneMock = nock('http://128.16.109.11:5000') - .post('/v3/auth/tokens', - utils.readExampleFile( - './test/unit/examples/keystoneRequests/getTokenFromTrust.json')) + .post( + '/v3/auth/tokens', + utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json') + ) .times(3) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), - { + .reply(201, utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), { 'X-Subject-Token': '12345679ABCDEF' }); - contextBrokerMock = nock('http://192.168.1.1:1026'); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext5.json')) + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext5.json') + ) .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); contextBrokerMock - .post('/NGSI9/registerContext', - utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json')) + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json' + ) + ) .reply( - 200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json')); + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json' + ) + ); contextBrokerMock - .post('/v1/subscribeContext', + .post( + '/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json')) + './test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json' + ) + ) .matchHeader('X-Auth-Token', '12345679ABCDEF') - .reply(200, + .reply( + 200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); - + './test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json' + ) + ); + iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { done(); @@ -340,23 +349,25 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio }); it('unsubscribe requests use auth header', function(done) { + keystoneMock + .post( + '/v3/auth/tokens', + utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json') + ) + .reply(201, utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), { + 'X-Subject-Token': '12345679ABCDEF' + }); - keystoneMock - .post('/v3/auth/tokens', - utils.readExampleFile('./test/unit/examples/keystoneRequests/getTokenFromTrust.json')) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/keystoneResponses/tokenFromTrust.json'), - { - 'X-Subject-Token': '12345679ABCDEF' - }); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v1/unsubscribeContext', - utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json')) - .matchHeader('X-Auth-Token', '12345679ABCDEF') - .reply(200, - utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); + contextBrokerMock = nock('http://192.168.1.1:1026') + .post( + '/v1/unsubscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json') + ) + .matchHeader('X-Auth-Token', '12345679ABCDEF') + .reply( + 200, + utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json') + ); iotAgentLib.getDevice('Light1', 'smartGondor', 'electricity', function(error, device) { iotAgentLib.subscribe(device, ['dimming'], null, function(error) { @@ -367,6 +378,5 @@ describe('NGSI-v1 - Secured access to the Context Broker with Keystone', functio }); }); }); - }); }); diff --git a/test/unit/general/contextBrokerOAuthSecurityAccess-test.js b/test/unit/general/contextBrokerOAuthSecurityAccess-test.js index 59d2bf191..04e0a29a6 100644 --- a/test/unit/general/contextBrokerOAuthSecurityAccess-test.js +++ b/test/unit/general/contextBrokerOAuthSecurityAccess-test.js @@ -50,7 +50,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), enabled: true }, types: { - 'Light': { + Light: { service: 'smartGondor', subservice: 'electricity', trust: 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3', @@ -69,7 +69,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], type: 'Termometer', lazy: [ @@ -78,8 +78,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] } }, service: 'smartGondor', @@ -116,22 +115,21 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -156,22 +154,21 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 403, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(403, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -188,22 +185,25 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', beforeEach(function(done) { nock.cleanAll(); - oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + oauth2Mock = nock('http://192.168.1.1:3000') + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( - 400, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorized.json')); + 400, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorized.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -218,30 +218,27 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', }); describe('When the user requests information about a device in a protected CB', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function(done) { nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -256,31 +253,29 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', }); describe('When subscriptions are used on a protected Context Broker', function() { - beforeEach(function(done) { - + beforeEach(function(done) { var optionsProvision = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice3.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice3.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': 'electricity' } }; - + nock.cleanAll(); - + iotAgentLib.activate(iotAgentConfig, function() { oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .times(3) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); - + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026'); @@ -288,30 +283,44 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext5.json')) + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext5.json') + ) .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); contextBrokerMock - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json')) + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json' + ) + ) .reply( - 200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json')); + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json' + ) + ); contextBrokerMock - .post('/v1/subscribeContext', + .post( + '/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json')) + './test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json' + ) + ) .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .reply(200, + .reply( + 200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); - + './test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json' + ) + ); + iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { done(); @@ -333,21 +342,23 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', }); it('unsubscribe requests use auth header', function(done) { + oauth2Mock + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); - oauth2Mock - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v1/unsubscribeContext', - utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json')) - .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .reply(200, - utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); + contextBrokerMock = nock('http://192.168.1.1:1026') + .post( + '/v1/unsubscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json') + ) + .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') + .reply( + 200, + utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json') + ); iotAgentLib.getDevice('Light1', 'smartGondor', 'electricity', function(error, device) { iotAgentLib.subscribe(device, ['dimming'], null, function(error) { @@ -358,12 +369,10 @@ describe('NGSI-v1 - Secured access to the Context Broker with OAuth2 provider', }); }); }); - }); }); describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)', function() { - var values = [ { name: 'state', @@ -391,22 +400,25 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( 200, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + {} + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentConfig.authentication.tokenPath = '/oauth2/token'; iotAgentLib.activate(iotAgentConfig, done); @@ -429,30 +441,31 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr }); describe('When the user requests information about a device in a protected CB', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function(done) { nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( 200, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + {} + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -471,11 +484,14 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( - 400, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorizedKeyrock.json')); + 400, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorizedKeyrock.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -494,12 +510,17 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( - 400, - utils.readExampleFile('./test/unit/examples/oauthResponses/' + - 'tokenFromTrustInvalidCredentialsKeyrock.json'), {}); + 400, + utils.readExampleFile( + './test/unit/examples/oauthResponses/' + 'tokenFromTrustInvalidCredentialsKeyrock.json' + ), + {} + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -518,22 +539,25 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( 200, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + {} + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply( - 401, - 'Auth-token not found in request header'); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(401, 'Auth-token not found in request header'); iotAgentLib.activate(iotAgentConfig, done); }); @@ -548,102 +572,273 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr }); }); -describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + - 'configured through group provisioning', function() { - var groupCreation = { - url: 'http://localhost:4041/iot/services', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - } - }; - - var values = [ - { - name: 'status', - type: 'String', - value: 'STARTING' - } - ]; +describe( + 'Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + + 'configured through group provisioning', + function() { + var groupCreation = { + url: 'http://localhost:4041/iot/services', + method: 'POST', + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + } + }; - beforeEach(function() { - logger.setLevel('FATAL'); - }); + var values = [ + { + name: 'status', + type: 'String', + value: 'STARTING' + } + ]; - afterEach(function(done) { - iotAgentLib.deactivate(done); - nock.cleanAll(); - }); + beforeEach(function() { + logger.setLevel('FATAL'); + }); - describe('When a measure is sent to the Context Broker via an Update Context operation', function() { - var oauth2Mock2; - var contextBrokerMock2; - beforeEach(function(done) { + afterEach(function(done) { + iotAgentLib.deactivate(done); nock.cleanAll(); - oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + }); - oauth2Mock2 = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup2.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock2.json'), - {}); + describe('When a measure is sent to the Context Broker via an Update Context operation', function() { + var oauth2Mock2; + var contextBrokerMock2; + beforeEach(function(done) { + nock.cleanAll(); + oauth2Mock = nock('http://192.168.1.1:3000') + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), + {} + ); + + oauth2Mock2 = nock('http://192.168.1.1:3000') + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup2.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock2.json'), + {} + ); + + contextBrokerMock = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + + contextBrokerMock2 = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer bbb752e377680acd1349a3ed59db855a1db076aa') + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + iotAgentConfig.authentication.tokenPath = '/oauth2/token'; + iotAgentLib.activate(iotAgentConfig, function() { + request(groupCreation, function(error, response, body) { + done(); + }); + }); + }); + it( + 'should ask OAuth2 provider for a token based on the' + + 'trust token and send the generated token in the auth header', + function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + oauth2Mock.done(); + contextBrokerMock.done(); + done(); + }); + } + ); - contextBrokerMock = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - - contextBrokerMock2 = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer bbb752e377680acd1349a3ed59db855a1db076aa') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - iotAgentConfig.authentication.tokenPath = '/oauth2/token'; - iotAgentLib.activate(iotAgentConfig, function() { - request(groupCreation, function(error, response, body) { + it('should use the updated trust token in the following requests', function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + oauth2Mock2.done(); + contextBrokerMock2.done(); done(); }); }); }); - it('should ask OAuth2 provider for a token based on the' + - 'trust token and send the generated token in the auth header', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - oauth2Mock.done(); - contextBrokerMock.done(); - done(); + + describe('When a device is provisioned for a configuration contains an OAuth2 trust token', function() { + var values = [ + { + name: 'status', + type: 'String', + value: 'STARTING' + } + ]; + var deviceCreation = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', + method: 'POST', + json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionNewDevice2.json'), + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + } + }; + var contextBrokerMock2; + var contextBrokerMock3; + beforeEach(function(done) { + nock.cleanAll(); + + oauth2Mock = nock('http://192.168.1.1:3000') + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup3.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock3.json'), + {} + ) + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup4.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock4.json'), + {} + ) + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup5.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock5.json'), + {} + ); + + contextBrokerMock = nock('http://unexistenthost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer asd752e377680acd1349a3ed59db855a1db07ere') + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); + + contextBrokerMock2 = nock('http://unexistenthost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc') + .post( + '/v1/updateContext', + utils.readExampleFile( + './test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json' + ) + ); + + contextBrokerMock3 = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('authorization', 'Bearer zzz752e377680acd1349a3ed59db855a1db07bbb') + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext4.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + + iotAgentConfig.authentication.tokenPath = '/oauth2/token'; + iotAgentLib.activate(iotAgentConfig, function() { + done(); + }); }); - }); - it('should use the updated trust token in the following requests', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - oauth2Mock2.done(); - contextBrokerMock2.done(); - done(); + it('should not raise any error', function(done) { + request(deviceCreation, function(error, response, body) { + should.not.exist(error); + response.statusCode.should.equal(201); + contextBrokerMock.done(); + contextBrokerMock2.done(); + done(); + }); + }); + + it('should send the mixed data to the Context Broker', function(done) { + iotAgentLib.update('Light1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + contextBrokerMock3.done(); + done(); + }); }); }); - }); + } +); +describe( + 'Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + + 'configured through group provisioning. Permanent token', + function() { + var groupCreation = { + url: 'http://localhost:4041/iot/services', + method: 'POST', + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + } + }; - describe('When a device is provisioned for a configuration contains an OAuth2 trust token', function() { var values = [ { name: 'status', @@ -651,163 +846,56 @@ describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyr value: 'STARTING' } ]; - var deviceCreation = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionNewDevice2.json'), - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - } - }; - var contextBrokerMock2; - var contextBrokerMock3; - beforeEach(function(done) { - nock.cleanAll(); - - oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup3.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock3.json'), - {}) - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup4.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock4.json'), - {}) - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup5.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock5.json'), - {}); - - - contextBrokerMock = nock('http://unexistenthost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer asd752e377680acd1349a3ed59db855a1db07ere') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); - - contextBrokerMock2 = nock('http://unexistenthost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - contextBrokerMock3 = nock('http://unexistentHost:1026') - - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('authorization', 'Bearer zzz752e377680acd1349a3ed59db855a1db07bbb') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext4.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - - - iotAgentConfig.authentication.tokenPath = '/oauth2/token'; - iotAgentLib.activate(iotAgentConfig, function() { - done(); - }); - }); - - it('should not raise any error', function(done) { - request(deviceCreation, function(error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(201); - contextBrokerMock.done(); - contextBrokerMock2.done(); - done(); - }); - }); - it('should send the mixed data to the Context Broker', function(done) { - iotAgentLib.update('Light1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - contextBrokerMock3.done(); - done(); - }); + beforeEach(function() { + logger.setLevel('FATAL'); + iotAgentConfig.authentication.permanentToken = true; }); - }); -}); - -describe('Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + - 'configured through group provisioning. Permanent token', function() { - var groupCreation = { - url: 'http://localhost:4041/iot/services', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - } - }; - - var values = [ - { - name: 'status', - type: 'String', - value: 'STARTING' - } - ]; - - beforeEach(function() { - logger.setLevel('FATAL'); - iotAgentConfig.authentication.permanentToken = true; - }); - - afterEach(function(done) { - iotAgentLib.deactivate(done); - nock.cleanAll(); - }); - - describe('When a measure is sent to the Context Broker via an Update Context operation', function() { - beforeEach(function(done) { + afterEach(function(done) { + iotAgentLib.deactivate(done); nock.cleanAll(); + }); - contextBrokerMock = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer 999210dacf913772606c95dd0b895d5506cbc988') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + describe('When a measure is sent to the Context Broker via an Update Context operation', function() { + beforeEach(function(done) { + nock.cleanAll(); + contextBrokerMock = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer 999210dacf913772606c95dd0b895d5506cbc988') + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); - iotAgentConfig.authentication.tokenPath = '/oauth2/token'; - iotAgentLib.activate(iotAgentConfig, function() { - request(groupCreation, function(error, response, body) { - done(); + iotAgentConfig.authentication.tokenPath = '/oauth2/token'; + iotAgentLib.activate(iotAgentConfig, function() { + request(groupCreation, function(error, response, body) { + done(); + }); }); }); - }); - it('should send the permanent token in the auth header', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + it('should send the permanent token in the auth header', function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); - }); - it('should use the permanent trust token in the following requests', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + it('should use the permanent trust token in the following requests', function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); }); - }); -}); - + } +); diff --git a/test/unit/general/deviceService-test.js b/test/unit/general/deviceService-test.js index ebf65bce9..41c191b5b 100644 --- a/test/unit/general/deviceService-test.js +++ b/test/unit/general/deviceService-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -56,7 +56,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -71,7 +71,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -80,10 +80,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -95,15 +94,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -166,7 +165,6 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), contextBrokerMock, iotamMock; - /* jshint camelcase: false */ describe('NGSI-v1 - Device Service: utils', function() { beforeEach(function(done) { @@ -181,10 +179,7 @@ describe('NGSI-v1 - Device Service: utils', function() { afterEach(function(done) { nock.cleanAll(); - async.series([ - iotAgentLib.clearAll, - iotAgentLib.deactivate - ], done); + async.series([iotAgentLib.clearAll, iotAgentLib.deactivate], done); }); describe('When an existing device tries to be retrieved with retrieveOrCreate()', function() { @@ -193,20 +188,26 @@ describe('NGSI-v1 - Device Service: utils', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); - async.series([ - request.bind(request, groupCreation), - request.bind(request, deviceCreation) - ], function(error, results) { + async.series([request.bind(request, groupCreation), request.bind(request, deviceCreation)], function( + error, + results + ) { done(); }); }); @@ -228,46 +229,54 @@ describe('NGSI-v1 - Device Service: utils', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); - async.series([ - request.bind(request, groupCreation) - ], function(error, results) { + async.series([request.bind(request, groupCreation)], function(error, results) { done(); }); }); it('should register the device and return it', function(done) { - iotAgentLib.retrieveDevice('UNEXISTENT_DEV', '801230BJKL23Y9090DSFL123HJK09H324HV8732', - function(error, device) { - should.not.exist(error); - should.exist(device); + iotAgentLib.retrieveDevice('UNEXISTENT_DEV', '801230BJKL23Y9090DSFL123HJK09H324HV8732', function( + error, + device + ) { + should.not.exist(error); + should.exist(device); - device.id.should.equal('UNEXISTENT_DEV'); - should.exist(device.protocol); - device.protocol.should.equal('MQTT_UL'); - done(); - }); + device.id.should.equal('UNEXISTENT_DEV'); + should.exist(device.protocol); + device.protocol.should.equal('MQTT_UL'); + done(); + }); }); }); describe('When an unexisting device tries to be retrieved for an unexisting APIKey', function() { it('should raise an error', function(done) { - iotAgentLib.retrieveDevice('UNEXISTENT_DEV_AND_GROUP', 'H2332Y909DSF3H346yh20JK092', - function(error, device) { - should.exist(error); - error.name.should.equal('DEVICE_GROUP_NOT_FOUND'); - should.not.exist(device); - done(); - }); + iotAgentLib.retrieveDevice('UNEXISTENT_DEV_AND_GROUP', 'H2332Y909DSF3H346yh20JK092', function( + error, + device + ) { + should.exist(error); + error.name.should.equal('DEVICE_GROUP_NOT_FOUND'); + should.not.exist(device); + done(); + }); }); }); }); diff --git a/test/unit/general/https-support-test.js b/test/unit/general/https-support-test.js index 0de605597..e9fc35d2e 100644 --- a/test/unit/general/https-support-test.js +++ b/test/unit/general/https-support-test.js @@ -42,7 +42,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -59,7 +59,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), service: 'smartGondor', subservice: 'gardens' }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -67,8 +67,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], service: 'smartGondor', subservice: 'gardens' } @@ -121,18 +120,17 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), contextBrokerMock, iotamMock; - describe('NGSI-v1 - HTTPS support tests IOTAM', function() { - describe('When the IoT Agents is started with https "iotManager" config', function() { beforeEach(function(done) { nock.cleanAll(); iotamMock = nock('https://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); groupRegistryMemory.create(groupCreation, done); }); @@ -155,14 +153,14 @@ describe('NGSI-v1 - HTTPS support tests IOTAM', function() { }); describe('NGSI-v1 - HTTPS support tests', function() { - describe('When subscription is sent to HTTPS context broker', function() { beforeEach(function(done) { var optionsProvision = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -177,22 +175,34 @@ describe('NGSI-v1 - HTTPS support tests', function() { contextBrokerMock = nock('https://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', + .post( + '/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createMinimumProvisionedDevice.json')) - .reply(200, + './test/unit/examples/contextRequests/createMinimumProvisionedDevice.json' + ) + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock = nock('https://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', + .post( + '/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json')) - .reply(200, + './test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json' + ) + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); + './test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json' + ) + ); iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { @@ -232,17 +242,25 @@ describe('NGSI-v1 - HTTPS support tests', function() { contextBrokerMock = nock('https://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -251,20 +269,19 @@ describe('NGSI-v1 - HTTPS support tests', function() { it('should register as ContextProvider using HTTPS', function(done) { iotAgentLib.register(device1, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + should.not.exist(error); + contextBrokerMock.done(); + done(); }); }); afterEach(function(done) { - nock.cleanAll(); - iotAgentLib.clearAll(function() { - // We need to remove the registrationId so that the library does not consider next operatios as updates. - delete device1.registrationId; - iotAgentLib.deactivate(done); - }); + nock.cleanAll(); + iotAgentLib.clearAll(function() { + // We need to remove the registrationId so that the library does not consider next operatios as updates. + delete device1.registrationId; + iotAgentLib.deactivate(done); + }); }); - }); }); diff --git a/test/unit/general/iotam-autoregistration-test.js b/test/unit/general/iotam-autoregistration-test.js index ce87bb577..54ba5e0b8 100644 --- a/test/unit/general/iotam-autoregistration-test.js +++ b/test/unit/general/iotam-autoregistration-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -192,10 +192,8 @@ describe('NGSI-v1 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); }); afterEach(function(done) { @@ -218,10 +216,8 @@ describe('NGSI-v1 - IoT Manager autoregistration', function() { delete iotAgentConfig.providerUrl; iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); }); afterEach(function() { @@ -242,10 +238,11 @@ describe('NGSI-v1 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); groupRegistryMemory.create(groupCreation, done); }); @@ -270,16 +267,15 @@ describe('NGSI-v1 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotamMock - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotAgentLib.activate(iotAgentConfig, function(error) { done(); @@ -306,16 +302,15 @@ describe('NGSI-v1 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotamMock - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); groupRegistryMemory.create(groupCreation, function() { iotAgentLib.activate(iotAgentConfig, done); @@ -342,16 +337,15 @@ describe('NGSI-v1 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotamMock - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithStaticGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithStaticGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotAgentLib.activate(iotAgentConfig, function(error) { done(); diff --git a/test/unit/general/loglevel-api_test.js b/test/unit/general/loglevel-api_test.js index ce4311411..14ff5ca31 100644 --- a/test/unit/general/loglevel-api_test.js +++ b/test/unit/general/loglevel-api_test.js @@ -37,7 +37,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -92,7 +92,7 @@ describe('Log level API', function() { method: 'PUT', headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + Accept: 'application/json' }, qs: { level: 'ERROR' @@ -115,7 +115,7 @@ describe('Log level API', function() { method: 'GET', headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + Accept: 'application/json' } }; @@ -146,7 +146,7 @@ describe('Log level API', function() { method: 'PUT', headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + Accept: 'application/json' }, qs: { level: 'ALLRIGHT' @@ -176,7 +176,7 @@ describe('Log level API', function() { method: 'PUT', headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + Accept: 'application/json' } }; diff --git a/test/unit/general/migration-test.js b/test/unit/general/migration-test.js index 3a3843016..550a56d93 100644 --- a/test/unit/general/migration-test.js +++ b/test/unit/general/migration-test.js @@ -41,16 +41,27 @@ describe('MongoDB migration', function() { beforeEach(function(done) { logger.setLevel('FATAL'); - mongo.connect('mongodb://localhost:27017/iotOrigin', { useNewUrlParser: true }, function(err, client) { - originDb = client; - mongo.connect('mongodb://localhost:27017/iotTarget', { useNewUrlParser: true }, function(err, client) { - targetDb = client; - async.series([ - apply(mongoUtils.populate, 'localhost', 'iotOrigin', deviceCollection, 'DEVICE'), - apply(mongoUtils.populate, 'localhost', 'iotOrigin', configurationCollection, 'SERVICE') - ], done); - }); - }); + mongo.connect( + 'mongodb://localhost:27017/iotOrigin', + { useNewUrlParser: true }, + function(err, client) { + originDb = client; + mongo.connect( + 'mongodb://localhost:27017/iotTarget', + { useNewUrlParser: true }, + function(err, client) { + targetDb = client; + async.series( + [ + apply(mongoUtils.populate, 'localhost', 'iotOrigin', deviceCollection, 'DEVICE'), + apply(mongoUtils.populate, 'localhost', 'iotOrigin', configurationCollection, 'SERVICE') + ], + done + ); + } + ); + } + ); }); afterEach(function(done) { @@ -73,63 +84,79 @@ describe('MongoDB migration', function() { it('should migrate all the services', function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', null, null, function() { - targetDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(3); - done(); - }); + targetDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(3); + done(); + }); }); }); it('should migrate all the devices', function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', null, null, function() { - targetDb.db().collection('devices').find({}).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(4); - done(); - }); + targetDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(4); + done(); + }); }); }); it('should migrate all the fields for each device', function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', null, null, function() { - targetDb.db().collection('groups').find({ - service: 'dumb_mordor' - }).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(1); - should.exist(docs[0].apikey); - should.exist(docs[0].cbHost); - should.exist(docs[0].resource); - should.exist(docs[0].service); - should.exist(docs[0].subservice); - should.exist(docs[0].type); - should.exist(docs[0].staticAttributes); - done(); - }); + targetDb + .db() + .collection('groups') + .find({ + service: 'dumb_mordor' + }) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(1); + should.exist(docs[0].apikey); + should.exist(docs[0].cbHost); + should.exist(docs[0].resource); + should.exist(docs[0].service); + should.exist(docs[0].subservice); + should.exist(docs[0].type); + should.exist(docs[0].staticAttributes); + done(); + }); }); }); it('should migrate all the fields for each service', function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', null, null, function() { - targetDb.db().collection('devices').find({ - id: 'gk20' - }).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(1); - should.exist(docs[0].id); - should.exist(docs[0].name); - should.exist(docs[0].protocol); - should.exist(docs[0].service); - should.exist(docs[0].subservice); - should.exist(docs[0].type); - should.exist(docs[0].active); - should.exist(docs[0].staticAttributes); - docs[0].id = 'gk20'; - docs[0].name = 'The GK20 Entity'; - docs[0].protocol = 'PDI-IoTA-UltraLight'; - docs[0].service = 'smart_gondor'; - docs[0].subservice = '/gardens'; - docs[0].type = 'acme.lights.sensor'; - done(); - }); + targetDb + .db() + .collection('devices') + .find({ + id: 'gk20' + }) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(1); + should.exist(docs[0].id); + should.exist(docs[0].name); + should.exist(docs[0].protocol); + should.exist(docs[0].service); + should.exist(docs[0].subservice); + should.exist(docs[0].type); + should.exist(docs[0].active); + should.exist(docs[0].staticAttributes); + docs[0].id = 'gk20'; + docs[0].name = 'The GK20 Entity'; + docs[0].protocol = 'PDI-IoTA-UltraLight'; + docs[0].service = 'smart_gondor'; + docs[0].subservice = '/gardens'; + docs[0].type = 'acme.lights.sensor'; + done(); + }); }); }); }); @@ -140,22 +167,32 @@ describe('MongoDB migration', function() { port: '27017' }; - it('should migrate just the service\'s configurations', function(done) { + it(/*jshint quotmark: double */ + "should migrate just the service's configurations", /*jshint quotmark: single */ function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', 'smart_gondor', null, function() { - targetDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(1); - done(); - }); + targetDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(1); + done(); + }); }); }); - it('should migrate just the service\'s devices', function(done) { + it(/*jshint quotmark: double */ + "should migrate just the service's devices", /*jshint quotmark: single */ function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', 'smart_gondor', null, function() { - targetDb.db().collection('devices').find({}).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(3); - done(); - }); + targetDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(3); + done(); + }); }); }); }); @@ -168,12 +205,16 @@ describe('MongoDB migration', function() { it('should set the name as undefined', function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', 'dumb_mordor', null, function() { - targetDb.db().collection('devices').find({}).toArray(function(err, docs) { - docs.length.should.equal(1); - should.exist(docs[0].name); - docs[0].name.should.equal(docs[0].type + ':' + docs[0].id); - done(); - }); + targetDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + docs.length.should.equal(1); + should.exist(docs[0].name); + docs[0].name.should.equal(docs[0].type + ':' + docs[0].id); + done(); + }); }); }); }); @@ -184,13 +225,18 @@ describe('MongoDB migration', function() { port: '27017' }; - it('should migrate just the subservice\'s devices', function(done) { + it(/*jshint quotmark: double */ + "should migrate just the subservice's devices", /*jshint quotmark: single */ function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', 'smart_gondor', '/gardens', function() { - targetDb.db().collection('devices').find({}).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(1); - done(); - }); + targetDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(1); + done(); + }); }); }); }); @@ -206,12 +252,16 @@ describe('MongoDB migration', function() { it('should change the protocol to the translated one', function(done) { migration.migrate(config, 'iotOrigin', 'iotTarget', 'smart_gondor', '/gardens', function() { - targetDb.db().collection('devices').find({}).toArray(function(err, docs) { - should.not.exist(err); - docs.length.should.equal(1); - docs[0].protocol.should.equal('NODE-Ultralight'); - done(); - }); + targetDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + docs.length.should.equal(1); + docs[0].protocol.should.equal('NODE-Ultralight'); + done(); + }); }); }); }); diff --git a/test/unit/general/startup-test.js b/test/unit/general/startup-test.js index 2d84574a3..1da8bcf55 100644 --- a/test/unit/general/startup-test.js +++ b/test/unit/general/startup-test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ diff --git a/test/unit/general/statistics-persistence_test.js b/test/unit/general/statistics-persistence_test.js index 819ea948c..111d6cc16 100644 --- a/test/unit/general/statistics-persistence_test.js +++ b/test/unit/general/statistics-persistence_test.js @@ -57,9 +57,8 @@ var statsService = require('../../../lib/services/stats/statsRegistry'), oldConfig; describe('Statistics persistence service', function() { - function insertDummy(n, callback) { - iotAgentDb.collection('tests').insertOne({test: 'test'}, function() { + iotAgentDb.collection('tests').insertOne({ test: 'test' }, function() { callback(); }); } @@ -89,23 +88,29 @@ describe('Statistics persistence service', function() { describe('When a periodic persitence action is set', function() { beforeEach(function(done) { - statsService.globalLoad({ - stat1: 10 - }, function() { - statsService.add('stat1', 5, done); - }); + statsService.globalLoad( + { + stat1: 10 + }, + function() { + statsService.add('stat1', 5, done); + } + ); }); it('should store all the records in the database', function(done) { statsService.addTimerAction(statsService.mongodbPersistence, function() { setTimeout(function() { statsService.clearTimers(function() { - iotAgentDb.collection('kpis').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - docs.length.should.be.above(2); - done(); - }); + iotAgentDb + .collection('kpis') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + docs.length.should.be.above(2); + done(); + }); }); }, 200); }); diff --git a/test/unit/general/statistics-service_test.js b/test/unit/general/statistics-service_test.js index f29c3670d..042b7fb32 100644 --- a/test/unit/general/statistics-service_test.js +++ b/test/unit/general/statistics-service_test.js @@ -66,9 +66,12 @@ describe('Statistics service', function() { statValue = 2; beforeEach(function(done) { - statsService.globalLoad({ - fakeStat: 30 - }, done); + statsService.globalLoad( + { + fakeStat: 30 + }, + done + ); }); it('should appear the modified value in the getCurrent() statistics', function(done) { @@ -94,10 +97,13 @@ describe('Statistics service', function() { }); describe('When the global statistics are requested', function() { beforeEach(function(done) { - statsService.globalLoad({ - stat1: 82, - stat2: 38789 - }, done); + statsService.globalLoad( + { + stat1: 82, + stat2: 38789 + }, + done + ); }); it('should return all the statistics that were created', function(done) { @@ -141,11 +147,14 @@ describe('Statistics service', function() { times = 0; beforeEach(function(done) { - statsService.globalLoad({ - stat1: 10 - }, function() { - statsService.add('stat1', 5, done); - }); + statsService.globalLoad( + { + stat1: 10 + }, + function() { + statsService.add('stat1', 5, done); + } + ); }); function mockedAction(current, global, callback) { diff --git a/test/unit/lazyAndCommands/active-devices-attribute-update-test.js b/test/unit/lazyAndCommands/active-devices-attribute-update-test.js index 65cc544b2..8637e852d 100644 --- a/test/unit/lazyAndCommands/active-devices-attribute-update-test.js +++ b/test/unit/lazyAndCommands/active-devices-attribute-update-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { // commands are not defined active: [ { @@ -63,7 +63,6 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), }; describe('NGSI-v1 - Update attribute functionalities', function() { - beforeEach(function(done) { logger.setLevel('FATAL'); @@ -73,15 +72,19 @@ describe('NGSI-v1 - Update attribute functionalities', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -154,7 +157,6 @@ describe('NGSI-v1 - Update attribute functionalities', function() { }); }); - request(options, function(error, response, body) { should.not.exist(error); handlerCalled.should.equal(true); diff --git a/test/unit/lazyAndCommands/command-test.js b/test/unit/lazyAndCommands/command-test.js index ea5473100..ece8d39b5 100644 --- a/test/unit/lazyAndCommands/command-test.js +++ b/test/unit/lazyAndCommands/command-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -55,7 +55,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -63,10 +63,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Motion': { + Motion: { commands: [], lazy: [ { @@ -76,14 +75,14 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), ], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [] }, - 'Robot': { + Robot: { commands: [ { name: 'position', @@ -116,24 +115,29 @@ describe('NGSI-v1 - Command functionalities', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); afterEach(function(done) { - delete(device3.registrationId); + delete device3.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(function() { mongoUtils.cleanDbs(function() { @@ -186,10 +190,16 @@ describe('NGSI-v1 - Command functionalities', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json' + ) + ); iotAgentLib.register(device3, function(error) { done(); @@ -274,10 +284,16 @@ describe('NGSI-v1 - Command functionalities', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandFinish.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContextCommandFinishSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandFinish.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextCommandFinishSuccess.json' + ) + ); iotAgentLib.register(device3, function(error) { done(); @@ -285,12 +301,11 @@ describe('NGSI-v1 - Command functionalities', function() { }); it('should update its value and status in the Context Broker', function(done) { - iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', '[72, 368, 1]', 'FINISHED', - function(error) { - should.not.exist(error); - statusAttributeMock.done(); - done(); - }); + iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', '[72, 368, 1]', 'FINISHED', function(error) { + should.not.exist(error); + statusAttributeMock.done(); + done(); + }); }); }); describe('When an error command arrives from the south bound for a registered command', function() { @@ -298,10 +313,16 @@ describe('NGSI-v1 - Command functionalities', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandError.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandError.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json' + ) + ); iotAgentLib.register(device3, function(error) { done(); @@ -309,12 +330,11 @@ describe('NGSI-v1 - Command functionalities', function() { }); it('should update its status in the Context Broker', function(done) { - iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', 'Stalled', 'ERROR', - function(error) { - should.not.exist(error); - statusAttributeMock.done(); - done(); - }); + iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', 'Stalled', 'ERROR', function(error) { + should.not.exist(error); + statusAttributeMock.done(); + done(); + }); }); }); }); diff --git a/test/unit/lazyAndCommands/commandRegistry_test.js b/test/unit/lazyAndCommands/commandRegistry_test.js index 57594f076..4d2189460 100644 --- a/test/unit/lazyAndCommands/commandRegistry_test.js +++ b/test/unit/lazyAndCommands/commandRegistry_test.js @@ -148,13 +148,7 @@ function testRegistry(registryType) { }; commands.push( - async.apply( - iotAgentLib.addCommand, - 'smartGondor', - 'gardens', - 'devId' + i, - newCommand - ) + async.apply(iotAgentLib.addCommand, 'smartGondor', 'gardens', 'devId' + i, newCommand) ); } } @@ -206,15 +200,7 @@ function testRegistry(registryType) { value: commandTemplate.value + j }; - commands.push( - async.apply( - iotAgentLib.addCommand, - 'smartGondor', - 'gardens', - 'devId', - newCommand - ) - ); + commands.push(async.apply(iotAgentLib.addCommand, 'smartGondor', 'gardens', 'devId', newCommand)); } async.series(commands, function(error) { diff --git a/test/unit/lazyAndCommands/lazy-devices-test.js b/test/unit/lazyAndCommands/lazy-devices-test.js index c21a19583..e3f11ae44 100644 --- a/test/unit/lazyAndCommands/lazy-devices-test.js +++ b/test/unit/lazyAndCommands/lazy-devices-test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -56,7 +56,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -64,10 +64,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Motion': { + Motion: { commands: [], lazy: [ { @@ -77,14 +76,14 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), ], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [] }, - 'RobotPre': { + RobotPre: { commands: [], lazy: [ { @@ -147,7 +146,7 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { }); afterEach(function(done) { - delete(device1.registrationId); + delete device1.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(function() { mongoUtils.cleanDbs(done); @@ -188,28 +187,33 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); + + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should call the device handler with the received data', function(done) { - var expectedResponse = utils - .readExampleFile('./test/unit/examples/contextProviderResponses/updateInformationResponse.json'); + var expectedResponse = utils.readExampleFile( + './test/unit/examples/contextProviderResponses/updateInformationResponse.json' + ); iotAgentLib.setDataUpdateHandler(function(id, type, service, subservice, attributes, callback) { id.should.equal(device1.type + ':' + device1.id); @@ -242,9 +246,7 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { id: 'Light:light1' } ], - attributes: [ - 'dimming' - ] + attributes: ['dimming'] }, headers: { 'fiware-service': 'smartGondor', @@ -272,27 +274,33 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should return the information querying the underlying devices', function(done) { - var expectedResponse = utils - .readExampleFile('./test/unit/examples/contextProviderResponses/queryInformationResponse.json'); + var expectedResponse = utils.readExampleFile( + './test/unit/examples/contextProviderResponses/queryInformationResponse.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { id.should.equal(device1.type + ':' + device1.id); @@ -311,25 +319,23 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { describe('When a context query arrives to the IoT Agent and no handler is set', function() { var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v1/queryContext', - method: 'POST', - json: { - entities: [ - { - type: 'Light', - isPattern: 'false', - id: 'Light:light1' - } - ], - attributes: [ - 'dimming' - ] - }, - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': 'gardens' - } - }; + url: 'http://localhost:' + iotAgentConfig.server.port + '/v1/queryContext', + method: 'POST', + json: { + entities: [ + { + type: 'Light', + isPattern: 'false', + id: 'Light:light1' + } + ], + attributes: ['dimming'] + }, + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': 'gardens' + } + }; beforeEach(function(done) { nock.cleanAll(); @@ -337,23 +343,29 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], function(error) { + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); + + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], function( + error + ) { done(); }); }); @@ -414,27 +426,33 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should return the information of all the attributes', function(done) { var expectedResponse = utils.readExampleFile( - './test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json'); + './test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { should.exist(attributes); @@ -491,27 +509,33 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should return the information of all the attributes', function(done) { var expectedResponse = utils.readExampleFile( - './test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json'); + './test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { should.exist(attributes); @@ -540,10 +564,7 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { id: 'Motion:motion1' } ], - attributes: [ - 'moving', - 'location' - ] + attributes: ['moving', 'location'] }, headers: { 'fiware-service': 'smartGondor', @@ -570,27 +591,33 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent2.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device2) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device2)], done); }); it('should return the information adding the static attributes', function(done) { var expectedResponse = utils.readExampleFile( - './test/unit/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json'); + './test/unit/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { id.should.equal('Motion:motion1'); @@ -639,17 +666,25 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -716,17 +751,25 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -748,76 +791,85 @@ describe('NGSI-v1 - IoT Agent Lazy Devices', function() { }); }); - describe('When the IoT Agent receives an update on the device data in JSON format for a type with' + - 'internalAttributes', function() { - var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v1/updateContext', - method: 'POST', - json: { - contextElements: [ - { - type: 'RobotPre', - isPattern: 'false', - id: 'RobotPre:TestRobotPre', - attributes: [ - { - name: 'moving', - type: 'Boolean', - value: 'True' - } - ] - } - ], - updateAction: 'APPEND' - }, - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': 'gardens' - } - }; - - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent4.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); - - contextBrokerMock - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device3) - ], done); - }); - - it('should call the device handler with the received data', function(done) { - var expectedResponse = utils - .readExampleFile('./test/unit/examples/contextProviderResponses/updateInformationResponse2.json'); + describe( + 'When the IoT Agent receives an update on the device data in JSON format for a type with' + + 'internalAttributes', + function() { + var options = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/v1/updateContext', + method: 'POST', + json: { + contextElements: [ + { + type: 'RobotPre', + isPattern: 'false', + id: 'RobotPre:TestRobotPre', + attributes: [ + { + name: 'moving', + type: 'Boolean', + value: 'True' + } + ] + } + ], + updateAction: 'APPEND' + }, + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': 'gardens' + } + }; - iotAgentLib.setDataUpdateHandler(function(id, type, service, subservice, attributes, callback) { - id.should.equal(device3.type + ':' + device3.id); - type.should.equal(device3.type); - attributes[0].value.should.equal('True'); - callback(null); + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent4.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); + + contextBrokerMock + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post('/v1/updateContext') + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json' + ) + ); + + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device3)], done); }); - request(options, function(error, response, body) { - should.not.exist(error); - body.should.eql(expectedResponse); - done(); + it('should call the device handler with the received data', function(done) { + var expectedResponse = utils.readExampleFile( + './test/unit/examples/contextProviderResponses/updateInformationResponse2.json' + ); + + iotAgentLib.setDataUpdateHandler(function(id, type, service, subservice, attributes, callback) { + id.should.equal(device3.type + ':' + device3.id); + type.should.equal(device3.type); + attributes[0].value.should.equal('True'); + callback(null); + }); + + request(options, function(error, response, body) { + should.not.exist(error); + body.should.eql(expectedResponse); + done(); + }); }); - }); - }); - + } + ); }); diff --git a/test/unit/lazyAndCommands/polling-commands-test.js b/test/unit/lazyAndCommands/polling-commands-test.js index b138432dc..b87725696 100644 --- a/test/unit/lazyAndCommands/polling-commands-test.js +++ b/test/unit/lazyAndCommands/polling-commands-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -55,7 +55,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -63,10 +63,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Motion': { + Motion: { commands: [], lazy: [ { @@ -76,14 +75,14 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), ], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [] }, - 'Robot': { + Robot: { commands: [ { name: 'position', @@ -128,27 +127,29 @@ describe('NGSI-v1 - Polling commands', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); afterEach(function(done) { - delete(device3.registrationId); + delete device3.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(function() { mongoUtils.cleanDbs(function() { @@ -192,11 +193,16 @@ describe('NGSI-v1 - Polling commands', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json')); + './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json' + ) + ); iotAgentLib.register(device3, function(error) { done(); @@ -290,11 +296,16 @@ describe('NGSI-v1 - Polling commands', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json')); + './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json' + ) + ); iotAgentLib.register(device3, function(error) { done(); @@ -347,20 +358,30 @@ describe('NGSI-v1 - Polling commands', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandStatus.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json')); + './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json' + ) + ); statusAttributeMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandExpired.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCommandExpired.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json')); + './test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json' + ) + ); iotAgentLib.register(device3, function(error) { done(); diff --git a/test/unit/memoryRegistry/deviceRegistryMemory_test.js b/test/unit/memoryRegistry/deviceRegistryMemory_test.js index 6d0e1a322..2a413c197 100644 --- a/test/unit/memoryRegistry/deviceRegistryMemory_test.js +++ b/test/unit/memoryRegistry/deviceRegistryMemory_test.js @@ -65,9 +65,10 @@ describe('In memory device registry', function() { .times(10) .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); var devices = []; @@ -96,14 +97,16 @@ describe('In memory device registry', function() { iotAgentLib.clearRegistry(done); }); it('should return the appropriate device', function(done) { - iotAgentLib.getDevicesByAttribute('internalId', 'internal3', 'smartGondor', 'gardens', - function(error, devices) { - should.not.exist(error); - should.exist(devices); - devices.length.should.equal(1); - devices[0].id.should.equal('id3'); - done(); - }); + iotAgentLib.getDevicesByAttribute('internalId', 'internal3', 'smartGondor', 'gardens', function( + error, + devices + ) { + should.not.exist(error); + should.exist(devices); + devices.length.should.equal(1); + devices[0].id.should.equal('id3'); + done(); + }); }); }); @@ -112,18 +115,19 @@ describe('In memory device registry', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v1/updateContext') .times(10) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); var devices = []; for (var i = 0; i < 10; i++) { devices.push({ id: 'id' + i, - type: 'Light' + i % 2, + type: 'Light' + (i % 2), internalId: 'internal' + i, - service: 'smartGondor' + i % 3, + service: 'smartGondor' + (i % 3), subservice: 'gardens', active: [ { @@ -143,13 +147,12 @@ describe('In memory device registry', function() { iotAgentLib.clearRegistry(done); }); it('should return all the matching devices', function(done) { - iotAgentLib.getDevicesByAttribute('type', 'Light0', undefined, 'gardens', - function(error, devices) { - should.not.exist(error); - should.exist(devices); - devices.length.should.equal(5); - done(); - }); + iotAgentLib.getDevicesByAttribute('type', 'Light0', undefined, 'gardens', function(error, devices) { + should.not.exist(error); + should.exist(devices); + devices.length.should.equal(5); + done(); + }); }); }); @@ -158,9 +161,10 @@ describe('In memory device registry', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v1/updateContext') .times(10) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); var devices = []; @@ -169,7 +173,7 @@ describe('In memory device registry', function() { id: 'id' + i, type: 'Light', internalId: 'internal' + i, - service: 'smartGondor' + i % 3, + service: 'smartGondor' + (i % 3), subservice: 'gardens', active: [ { @@ -189,13 +193,12 @@ describe('In memory device registry', function() { iotAgentLib.clearRegistry(done); }); it('should return all the matching devices in that service', function(done) { - iotAgentLib.getDevicesByAttribute('type', 'Light', 'smartGondor0', 'gardens', - function(error, devices) { - should.not.exist(error); - should.exist(devices); - devices.length.should.equal(4); - done(); - }); + iotAgentLib.getDevicesByAttribute('type', 'Light', 'smartGondor0', 'gardens', function(error, devices) { + should.not.exist(error); + should.exist(devices); + devices.length.should.equal(4); + done(); + }); }); }); }); diff --git a/test/unit/mongodb/mongoDBUtils.js b/test/unit/mongodb/mongoDBUtils.js index 66cd1fb6a..0d53529b7 100644 --- a/test/unit/mongodb/mongoDBUtils.js +++ b/test/unit/mongodb/mongoDBUtils.js @@ -28,36 +28,43 @@ var MongoClient = require('mongodb').MongoClient, function cleanDb(host, name, callback) { var url = 'mongodb://' + host + ':27017/' + name; - MongoClient.connect(url, { useNewUrlParser: true }, function(err, db) { - if (db && db.db()) { - db.db().dropDatabase( function (err, result) { - db.close(); - callback(); - }); - + MongoClient.connect( + url, + { useNewUrlParser: true }, + function(err, db) { + if (db && db.db()) { + db.db().dropDatabase(function(err, result) { + db.close(); + callback(); + }); + } } - }); + ); } function cleanDbs(callback) { - async.series([ - async.apply(cleanDb, 'localhost', 'iotagent') - ], callback); + async.series([async.apply(cleanDb, 'localhost', 'iotagent')], callback); } function populate(host, dbName, entityList, collectionName, callback) { var url = 'mongodb://' + host + ':27017/' + dbName; - MongoClient.connect(url, { useNewUrlParser: true }, function(err, db) { - if (db) { - db.db().collection(collectionName).insertMany(entityList, function(err, r) { - db.close(); - callback(err); - }); - } else { - callback(); + MongoClient.connect( + url, + { useNewUrlParser: true }, + function(err, db) { + if (db) { + db.db() + .collection(collectionName) + .insertMany(entityList, function(err, r) { + db.close(); + callback(err); + }); + } else { + callback(); + } } - }); + ); } exports.cleanDb = cleanDb; diff --git a/test/unit/mongodb/mongodb-group-registry-test.js b/test/unit/mongodb/mongodb-group-registry-test.js index cf057ea3e..dea54142b 100644 --- a/test/unit/mongodb/mongodb-group-registry-test.js +++ b/test/unit/mongodb/mongodb-group-registry-test.js @@ -177,16 +177,18 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), iotAgentDb; describe('MongoDB Group Registry test', function() { - beforeEach(function(done) { mongoUtils.cleanDbs(function() { iotAgentLib.activate(iotAgentConfig, function() { - mongo.connect('mongodb://localhost:27017/iotagent', { useNewUrlParser: true }, function(err, db) { - iotAgentDb = db; - done(); - }); + mongo.connect( + 'mongodb://localhost:27017/iotagent', + { useNewUrlParser: true }, + function(err, db) { + iotAgentDb = db; + done(); + } + ); }); - }); }); @@ -200,35 +202,43 @@ describe('MongoDB Group Registry test', function() { describe('When a new device group creation request arrives', function() { it('should store it in the DB', function(done) { request(optionsCreation, function(error, response, body) { - iotAgentDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - should.exist(docs.length); - docs.length.should.equal(1); - should.exist(docs[0].type); - should.exist(docs[0].internalAttributes); - should.exist(docs[0].attributes); - should.exist(docs[0].apikey); - docs[0].type.should.equal('Light'); - docs[0].apikey.should.equal('801230BJKL23Y9090DSFL123HJK09H324HV8732'); - docs[0].internalAttributes.length.should.equal(1); - docs[0].internalAttributes[0].customField.should.equal('customValue'); - docs[0].attributes.length.should.equal(1); - docs[0].attributes[0].name.should.equal('status'); - done(); - }); + iotAgentDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + should.exist(docs.length); + docs.length.should.equal(1); + should.exist(docs[0].type); + should.exist(docs[0].internalAttributes); + should.exist(docs[0].attributes); + should.exist(docs[0].apikey); + docs[0].type.should.equal('Light'); + docs[0].apikey.should.equal('801230BJKL23Y9090DSFL123HJK09H324HV8732'); + docs[0].internalAttributes.length.should.equal(1); + docs[0].internalAttributes[0].customField.should.equal('customValue'); + docs[0].attributes.length.should.equal(1); + docs[0].attributes[0].name.should.equal('status'); + done(); + }); }); }); it('should store the service information from the headers into the DB', function(done) { request(optionsCreation, function(error, response, body) { - iotAgentDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs[0].service); - should.exist(docs[0].subservice); - docs[0].service.should.equal('TestService'); - docs[0].subservice.should.equal('/testingPath'); - done(); - }); + iotAgentDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs[0].service); + should.exist(docs[0].subservice); + docs[0].service.should.equal('TestService'); + docs[0].subservice.should.equal('/testingPath'); + done(); + }); }); }); }); @@ -252,13 +262,17 @@ describe('MongoDB Group Registry test', function() { it('should remove it from the database', function(done) { request(optionsDelete, function(error, response, body) { - iotAgentDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - should.exist(docs.length); - docs.length.should.equal(0); - done(); - }); + iotAgentDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + should.exist(docs.length); + docs.length.should.equal(0); + done(); + }); }); }); @@ -277,15 +291,19 @@ describe('MongoDB Group Registry test', function() { it('should update the values in the database', function(done) { request(optionsUpdate, function(error, response, body) { - iotAgentDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - should.exist(docs[0].cbHost); - docs[0].cbHost.should.equal('http://anotherUnexistentHost:1026'); - should.exist(docs[0].staticAttributes); - docs[0].staticAttributes.length.should.equal(1); - done(); - }); + iotAgentDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + should.exist(docs[0].cbHost); + docs[0].cbHost.should.equal('http://anotherUnexistentHost:1026'); + should.exist(docs[0].staticAttributes); + docs[0].staticAttributes.length.should.equal(1); + done(); + }); }); }); }); @@ -295,19 +313,24 @@ describe('MongoDB Group Registry test', function() { beforeEach(function(done) { optionsMultipleCreation.json = utils.readExampleFile( - './test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json'); + './test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json' + ); done(); }); it('should create the values in the database', function(done) { request(optionsMultipleCreation, function(error, response, body) { - iotAgentDb.db().collection('groups').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - docs.length.should.equal(2); - done(); - }); + iotAgentDb + .db() + .collection('groups') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + docs.length.should.equal(2); + done(); + }); }); }); }); @@ -318,7 +341,6 @@ describe('MongoDB Group Registry test', function() { optionsCreation2 = _.clone(optionsCreation), optionsCreation3 = _.clone(optionsCreation); - optionsCreation2.json = { services: [] }; optionsCreation3.json = { services: [] }; @@ -328,11 +350,14 @@ describe('MongoDB Group Registry test', function() { optionsCreation2.json.services[0].apikey = 'qwertyuiop'; optionsCreation3.json.services[0].apikey = 'lkjhgfds'; - async.series([ - async.apply(request, optionsCreation1), - async.apply(request, optionsCreation2), - async.apply(request, optionsCreation3) - ], done); + async.series( + [ + async.apply(request, optionsCreation1), + async.apply(request, optionsCreation2), + async.apply(request, optionsCreation3) + ], + done + ); }); it('should return all the configured device groups from the database', function(done) { @@ -383,9 +408,7 @@ describe('MongoDB Group Registry test', function() { describe('When a device info request arrives', function() { beforeEach(function(done) { - async.series([ - async.apply(request, optionsCreation) - ], done); + async.series([async.apply(request, optionsCreation)], done); }); it('should return all the configured device groups from the database', function(done) { diff --git a/test/unit/mongodb/mongodb-registry-test.js b/test/unit/mongodb/mongodb-registry-test.js index ee9cfda30..72f2ffce0 100644 --- a/test/unit/mongodb/mongodb-registry-test.js +++ b/test/unit/mongodb/mongodb-registry-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [ { name: 'position', @@ -71,7 +71,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), customAttribute: 'customValue' } }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -79,8 +79,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - attributes: [ - ], + attributes: [], service: 'smartGondor', subservice: 'gardens' } @@ -190,21 +189,28 @@ describe('MongoDB Device Registry', function() { logger.setLevel('FATAL'); mongoUtils.cleanDbs(function() { - mongo.connect('mongodb://localhost:27017/iotagent', { useNewUrlParser: true }, function(err, db) { - iotAgentDb = db; - done(); - }); + mongo.connect( + 'mongodb://localhost:27017/iotagent', + { useNewUrlParser: true }, + function(err, db) { + iotAgentDb = db; + done(); + } + ); }); }); afterEach(function(done) { - delete(device1.registrationId); + delete device1.registrationId; iotAgentLib.deactivate(function(error) { - iotAgentDb.db().collection('devices').deleteOne(function(error) { - iotAgentDb.close(function(error) { - mongoUtils.cleanDbs(done); + iotAgentDb + .db() + .collection('devices') + .deleteOne(function(error) { + iotAgentDb.close(function(error) { + mongoUtils.cleanDbs(done); + }); }); - }); }); }); @@ -215,16 +221,23 @@ describe('MongoDB Device Registry', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { done(); @@ -235,34 +248,38 @@ describe('MongoDB Device Registry', function() { iotAgentLib.register(device1, function(error) { should.not.exist(error); - iotAgentDb.db().collection('devices').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - should.exist(docs.length); - docs.length.should.equal(1); - should.exist(docs[0].internalAttributes); - should.exist(docs[0].staticAttributes); - should.exist(docs[0].internalAttributes.customAttribute); - should.exist(docs[0].active); - should.exist(docs[0].commands); - should.exist(docs[0].resource); - should.exist(docs[0].endpoint); - should.exist(docs[0].transport); - should.exist(docs[0].apikey); - should.exist(docs[0].protocol); - docs[0].active.length.should.equal(1); - docs[0].staticAttributes.length.should.equal(1); - docs[0].staticAttributes[0].name.should.equal('location'); - docs[0].active[0].name.should.equal('pressure'); - docs[0].commands[0].name.should.equal('position'); - docs[0].internalAttributes.customAttribute.should.equal('customValue'); - docs[0].resource.should.equal('/test'); - docs[0].endpoint.should.equal('http://testEndpoint.com'); - docs[0].transport.should.equal('HTTP'); - docs[0].protocol.should.equal('GENERIC_PROTOCOL'); - docs[0].apikey.should.equal('2345678ikjhgfr678i'); - done(); - }); + iotAgentDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + should.exist(docs.length); + docs.length.should.equal(1); + should.exist(docs[0].internalAttributes); + should.exist(docs[0].staticAttributes); + should.exist(docs[0].internalAttributes.customAttribute); + should.exist(docs[0].active); + should.exist(docs[0].commands); + should.exist(docs[0].resource); + should.exist(docs[0].endpoint); + should.exist(docs[0].transport); + should.exist(docs[0].apikey); + should.exist(docs[0].protocol); + docs[0].active.length.should.equal(1); + docs[0].staticAttributes.length.should.equal(1); + docs[0].staticAttributes[0].name.should.equal('location'); + docs[0].active[0].name.should.equal('pressure'); + docs[0].commands[0].name.should.equal('position'); + docs[0].internalAttributes.customAttribute.should.equal('customValue'); + docs[0].resource.should.equal('/test'); + docs[0].endpoint.should.equal('http://testEndpoint.com'); + docs[0].transport.should.equal('HTTP'); + docs[0].protocol.should.equal('GENERIC_PROTOCOL'); + docs[0].apikey.should.equal('2345678ikjhgfr678i'); + done(); + }); }); }); }); @@ -274,28 +291,44 @@ describe('MongoDB Device Registry', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { done(); @@ -318,26 +351,42 @@ describe('MongoDB Device Registry', function() { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { done(); @@ -356,54 +405,73 @@ describe('MongoDB Device Registry', function() { describe('When a device is removed from the IoT Agent', function() { beforeEach(function(done) { - var expectedPayload3 = utils - .readExampleFile('./test/unit/examples/contextAvailabilityRequests/unregisterDevice3.json'); + var expectedPayload3 = utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/unregisterDevice3.json' + ); nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext', expectedPayload3) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json' + ) + ); iotAgentLib.activate(iotAgentConfig, function(error) { - async.series([ - async.apply(iotAgentLib.register, device1), - async.apply(iotAgentLib.register, device2) - ], done); + async.series( + [async.apply(iotAgentLib.register, device1), async.apply(iotAgentLib.register, device2)], + done + ); }); }); it('should be removed from MongoDB', function(done) { iotAgentLib.unregister(device1.id, 'smartGondor', 'gardens', function(error) { - iotAgentDb.db().collection('devices').find({}).toArray(function(err, docs) { - should.not.exist(err); - should.exist(docs); - should.exist(docs.length); - docs.length.should.equal(1); - done(); - }); + iotAgentDb + .db() + .collection('devices') + .find({}) + .toArray(function(err, docs) { + should.not.exist(err); + should.exist(docs); + should.exist(docs.length); + docs.length.should.equal(1); + done(); + }); }); }); }); @@ -415,9 +483,10 @@ describe('MongoDB Device Registry', function() { .times(10) .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); var devices = []; @@ -448,14 +517,16 @@ describe('MongoDB Device Registry', function() { iotAgentLib.clearRegistry(done); }); it('should return the appropriate device', function(done) { - iotAgentLib.getDevicesByAttribute('internalId', 'internal3', 'smartGondor', 'gardens', - function(error, devices) { - should.not.exist(error); - should.exist(devices); - devices.length.should.equal(1); - devices[0].id.should.equal('id3'); - done(); - }); + iotAgentLib.getDevicesByAttribute('internalId', 'internal3', 'smartGondor', 'gardens', function( + error, + devices + ) { + should.not.exist(error); + should.exist(devices); + devices.length.should.equal(1); + devices[0].id.should.equal('id3'); + done(); + }); }); }); @@ -466,9 +537,10 @@ describe('MongoDB Device Registry', function() { .times(10) .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); var devices = []; diff --git a/test/unit/ngsiService/active-devices-test.js b/test/unit/ngsiService/active-devices-test.js index 5297d4da1..b34504512 100644 --- a/test/unit/ngsiService/active-devices-test.js +++ b/test/unit/ngsiService/active-devices-test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -54,7 +54,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -69,7 +69,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -78,10 +78,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -93,15 +92,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -147,10 +146,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -171,10 +171,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextAppendMode.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextAppendMode.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentConfig.appendMode = true; iotAgentLib.activate(iotAgentConfig, done); @@ -221,10 +222,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextTimestamp.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextTimestamp.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentConfig.timestamp = true; iotAgentLib.activate(iotAgentConfig, done); @@ -246,59 +248,67 @@ describe('NGSI-v1 - Active attributes test', function() { }); }); - describe('When the IoT Agent receives new information, the timestamp flag is on' + - 'and timezone is defined', function() { - var modifiedValues; - - beforeEach(function(done) { - var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - - modifiedValues = [ - { - name: 'state', - type: 'Boolean', - value: 'true' - }, - { - name: 'dimming', - type: 'Percentage', - value: '87' - } - ]; + describe( + 'When the IoT Agent receives new information, the timestamp flag is on' + 'and timezone is defined', + function() { + var modifiedValues; - timekeeper.freeze(time); + beforeEach(function(done) { + var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextTimestampTimezone.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - - iotAgentConfig.timestamp = true; - iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; - iotAgentLib.activate(iotAgentConfig, done); - }); - - afterEach(function(done) { - delete iotAgentConfig.timestamp; - delete iotAgentConfig.types.Light.timezone; - timekeeper.reset(); + modifiedValues = [ + { + name: 'state', + type: 'Boolean', + value: 'true' + }, + { + name: 'dimming', + type: 'Percentage', + value: '87' + } + ]; + + timekeeper.freeze(time); + + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v1/updateContext', + utils.readExampleFile( + './test/unit/examples/contextRequests/updateContextTimestampTimezone.json' + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + + iotAgentConfig.timestamp = true; + iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; + iotAgentLib.activate(iotAgentConfig, done); + }); - done(); - }); + afterEach(function(done) { + delete iotAgentConfig.timestamp; + delete iotAgentConfig.types.Light.timezone; + timekeeper.reset(); - it('should add the timestamp to the entity and all the attributes', function(done) { - iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { - should.not.exist(error); - contextBrokerMock.done(); done(); }); - }); - }); + + it('should add the timestamp to the entity and all the attributes', function(done) { + iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); describe('When the IoTA gets a set of values with a TimeInstant and the timestamp flag is on', function() { var modifiedValues; @@ -326,10 +336,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextTimestampOverride.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextTimestampOverride.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentConfig.timestamp = true; iotAgentLib.activate(iotAgentConfig, done); @@ -355,7 +366,6 @@ describe('NGSI-v1 - Active attributes test', function() { var modifiedValues; beforeEach(function(done) { - modifiedValues = [ { name: 'state', @@ -390,115 +400,130 @@ describe('NGSI-v1 - Active attributes test', function() { }); }); - describe('When the IoTA gets a set of values with a TimeInstant which are in ISO8601 format ' + - 'without milis', function() { - var modifiedValues; + describe( + 'When the IoTA gets a set of values with a TimeInstant which are in ISO8601 format ' + 'without milis', + function() { + var modifiedValues; - beforeEach(function(done) { - var time = new Date(1666477342000); // 2022-10-22T22:22:22Z + beforeEach(function(done) { + var time = new Date(1666477342000); // 2022-10-22T22:22:22Z - modifiedValues = [ - { - name: 'state', - type: 'Boolean', - value: 'true' - }, - { - name: 'TimeInstant', - type: 'ISO8601', - value: '2022-10-22T22:22:22Z' - } - ]; - - timekeeper.freeze(time); - - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/' + - 'updateContextTimestampOverrideWithoutMilis.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - - iotAgentConfig.timestamp = true; - iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; - iotAgentLib.activate(iotAgentConfig, done); - }); - - afterEach(function(done) { - delete iotAgentConfig.timestamp; - delete iotAgentConfig.types.Light.timezone; - timekeeper.reset(); - done(); - }); + modifiedValues = [ + { + name: 'state', + type: 'Boolean', + value: 'true' + }, + { + name: 'TimeInstant', + type: 'ISO8601', + value: '2022-10-22T22:22:22Z' + } + ]; + + timekeeper.freeze(time); + + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v1/updateContext', + utils.readExampleFile( + './test/unit/examples/contextRequests/' + 'updateContextTimestampOverrideWithoutMilis.json' + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + + iotAgentConfig.timestamp = true; + iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; + iotAgentLib.activate(iotAgentConfig, done); + }); - it('should not fail', function(done) { - iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { - should.not.exist(error); - contextBrokerMock.done(); + afterEach(function(done) { + delete iotAgentConfig.timestamp; + delete iotAgentConfig.types.Light.timezone; + timekeeper.reset(); done(); }); - }); - }); - - describe('When the IoTA gets a set of values with a TimeInstant, the timestamp flag is on' + - 'and timezone is defined', function() { - var modifiedValues; - - beforeEach(function(done) { - var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - modifiedValues = [ - { - name: 'state', - type: 'Boolean', - value: 'true' - }, - { - name: 'TimeInstant', - type: 'ISO8601', - value: '2015-12-14T08:06:01.468Z' - } - ]; - - timekeeper.freeze(time); + it('should not fail', function(done) { + iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); - nock.cleanAll(); + describe( + 'When the IoTA gets a set of values with a TimeInstant, the timestamp flag is on' + 'and timezone is defined', + function() { + var modifiedValues; - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextTimestampOverride.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - - iotAgentConfig.timestamp = true; - iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; - iotAgentLib.activate(iotAgentConfig, done); - }); + beforeEach(function(done) { + var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - afterEach(function(done) { - delete iotAgentConfig.timestamp; - delete iotAgentConfig.types.Light.timezone; - timekeeper.reset(); + modifiedValues = [ + { + name: 'state', + type: 'Boolean', + value: 'true' + }, + { + name: 'TimeInstant', + type: 'ISO8601', + value: '2015-12-14T08:06:01.468Z' + } + ]; + + timekeeper.freeze(time); + + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v1/updateContext', + utils.readExampleFile( + './test/unit/examples/contextRequests/updateContextTimestampOverride.json' + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + + iotAgentConfig.timestamp = true; + iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; + iotAgentLib.activate(iotAgentConfig, done); + }); - done(); - }); + afterEach(function(done) { + delete iotAgentConfig.timestamp; + delete iotAgentConfig.types.Light.timezone; + timekeeper.reset(); - it('should not override the received instant and should not add metadatas for this request', function(done) { - iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { - should.not.exist(error); - contextBrokerMock.done(); done(); }); - }); - }); + it('should not override the received instant and should not add metadatas for this request', function(done) { + iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); - describe('When the IoT Agent receives information from a device whose type doesn\'t have a type name', function() { + describe(/*jshint quotmark: double */ + "When the IoT Agent receives information from a device whose type doesn't have a type name" /*jshint quotmark: single */, function() { beforeEach(function(done) { nock.cleanAll(); @@ -522,10 +547,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Failed.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Failed.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -550,10 +576,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext2Failed.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext2Failed.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -575,10 +602,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply(500, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext2Failed.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply(500, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext2Failed.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -603,10 +631,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:3024') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext2.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext2.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -635,10 +664,11 @@ describe('NGSI-v1 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextStaticAttributes.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextStaticAttributes.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); @@ -651,35 +681,41 @@ describe('NGSI-v1 - Active attributes test', function() { }); }); - describe('When the IoT Agent receives new information from a device and CB' + - 'is defined using environment variables', function() { - beforeEach(function(done) { - process.env.IOTA_CB_HOST = 'cbhost'; - - nock.cleanAll(); - - contextBrokerMock = nock('http://cbhost:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + describe( + 'When the IoT Agent receives new information from a device and CB' + 'is defined using environment variables', + function() { + beforeEach(function(done) { + process.env.IOTA_CB_HOST = 'cbhost'; + + nock.cleanAll(); + + contextBrokerMock = nock('http://cbhost:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext1.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json') + ); + + iotAgentLib.activate(iotAgentConfig, done); + }); - iotAgentLib.activate(iotAgentConfig, done); - }); + it('should change the value of the corresponding attribute in the context broker', function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); - it('should change the value of the corresponding attribute in the context broker', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); + afterEach(function(done) { + process.env.IOTA_CB_HOST = ''; done(); }); - }); - - afterEach(function(done) { - process.env.IOTA_CB_HOST = ''; - done(); - }); - }); + } + ); }); diff --git a/test/unit/ngsiService/queryDeviceInformationInCb-test.js b/test/unit/ngsiService/queryDeviceInformationInCb-test.js index 20380c8b5..f1ff03c81 100644 --- a/test/unit/ngsiService/queryDeviceInformationInCb-test.js +++ b/test/unit/ngsiService/queryDeviceInformationInCb-test.js @@ -37,7 +37,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -53,7 +53,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -68,7 +68,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -77,10 +77,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -92,15 +91,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -118,15 +117,11 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), }; describe('Query device information in the Context Broker', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function(done) { logger.setLevel('FATAL'); - iotAgentLib.activate(iotAgentConfig, done); }); @@ -141,10 +136,11 @@ describe('Query device information in the Context Broker', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); }); it('should return the information about the desired attributes', function(done) { @@ -156,18 +152,19 @@ describe('Query device information in the Context Broker', function() { }); }); - describe('When the user requests information about a device that it\'s not in the CB', function() { + describe(/*jshint quotmark: double */ + "When the user requests information about a device that it's not in the CB", /*jshint quotmark: single */ function() { beforeEach(function() { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext2.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext2Error.json')); - + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext2.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext2Error.json')); }); it('should return a DEVICE_NOT_FOUND_ERROR', function(done) { @@ -186,11 +183,11 @@ describe('Query device information in the Context Broker', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext2.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext3Error.json')); - + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext2.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext3Error.json')); }); it('should return a ATTRIBUTE_NOT_FOUND_ERROR', function(done) { @@ -209,11 +206,14 @@ describe('Query device information in the Context Broker', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext2.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext2UnknownError.json')); - + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext2.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/queryContext2UnknownError.json') + ); }); it('should return a ENTITY_GENERIC_ERROR', function(done) { @@ -229,5 +229,4 @@ describe('Query device information in the Context Broker', function() { }); }); }); - }); diff --git a/test/unit/ngsiService/staticAttributes-test.js b/test/unit/ngsiService/staticAttributes-test.js index 747f1fe58..384655d44 100644 --- a/test/unit/ngsiService/staticAttributes-test.js +++ b/test/unit/ngsiService/staticAttributes-test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -69,7 +69,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), { name: 'attr4', type: 'type4' - }, + } ] } }, @@ -80,8 +80,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), deviceRegistrationDuration: 'P1M' }; - -describe('NGSI-v1 - Static attributes test', function() { +describe('Static attributes test', function() { var values = [ { name: 'state', @@ -112,8 +111,7 @@ describe('NGSI-v1 - Static attributes test', function() { .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') .times(4) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')) .post('/v1/updateContext', function(body) { var metadatas = 0; @@ -124,24 +122,26 @@ describe('NGSI-v1 - Static attributes test', function() { } return metadatas === body.contextElements[0].attributes.length - 1; }) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); iotAgentLib.activate(iotAgentConfig, done); }); it('should send a single TimeInstant per attribute', function(done) { - async.series([ - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values) - ], function(error, results) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); + async.series( + [ + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values) + ], + function(error, results) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + } + ); }); }); }); diff --git a/test/unit/ngsiService/subscriptions-test.js b/test/unit/ngsiService/subscriptions-test.js index 0975977cc..df4aa1fd1 100644 --- a/test/unit/ngsiService/subscriptions-test.js +++ b/test/unit/ngsiService/subscriptions-test.js @@ -62,18 +62,26 @@ describe('NGSI-v1 - Subscription tests', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', - utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json') + ); iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { @@ -124,10 +132,14 @@ describe('NGSI-v1 - Subscription tests', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/unsubscribeContext', - utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); + .post( + '/v1/unsubscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json') + ); done(); }); @@ -164,10 +176,14 @@ describe('NGSI-v1 - Subscription tests', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/unsubscribeContext', - utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json')); + .post( + '/v1/unsubscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json') + ); done(); }); @@ -202,7 +218,6 @@ describe('NGSI-v1 - Subscription tests', function() { 'fiware-servicepath': '/gardens' } }, - executedHandler = false; function mockedHandler(device, notification, callback) { @@ -274,8 +289,14 @@ describe('NGSI-v1 - Subscription tests', function() { rightFields = false; function mockedHandler(device, data, callback) { - if (device && device.id === 'MicroLight1' && device.name === 'FirstMicroLight' && - data && data.length === 1 && data[0].name === 'attr_name') { + if ( + device && + device.id === 'MicroLight1' && + device.name === 'FirstMicroLight' && + data && + data.length === 1 && + data[0].name === 'attr_name' + ) { rightFields = true; } @@ -303,7 +324,6 @@ describe('NGSI-v1 - Subscription tests', function() { 'fiware-servicepath': '/gardens' } }, - executedHandler = false; function mockedHandler(device, notification, callback) { diff --git a/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js b/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js index 52f213fef..811058c98 100644 --- a/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +++ b/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js @@ -43,7 +43,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [], @@ -61,22 +61,22 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), { object_id: 'a', name: 'alive', - type: 'None', + type: 'None' }, { object_id: 'u', name: 'updated', - type: 'Boolean', + type: 'Boolean' }, { object_id: 'm', name: 'manufacturer', - type: 'Object', + type: 'Object' }, { object_id: 'r', name: 'revisions', - type: 'Array', + type: 'Array' }, { object_id: 'x', @@ -86,7 +86,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'LightError': { + LightError: { commands: [], type: 'Light', lazy: [], @@ -99,7 +99,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStation': { + WeatherStation: { commands: [], type: 'WeatherStation', lazy: [], @@ -137,15 +137,14 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), name: 'updated', type: 'Boolean', expression: '${@updated * 20}' - }, + } ] }, - 'WeatherStationMultiple': { + WeatherStationMultiple: { commands: [], type: 'WeatherStation', lazy: [], active: [ - { object_id: 'p', name: 'pressure', @@ -184,7 +183,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), name: 'updated', type: 'Boolean', expression: '${trim(@updated)}' - }, + } ] } }, @@ -254,9 +253,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -291,9 +294,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -322,9 +329,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -353,9 +364,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -384,9 +399,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -416,9 +435,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -448,9 +471,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -480,9 +507,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -512,9 +543,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -544,9 +579,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -576,9 +615,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -608,9 +651,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -640,9 +687,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin10.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin10.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -671,9 +722,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/ws1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json')) - .query({type: 'WeatherStation'}) + .post( + '/v2/entities/ws1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json' + ) + ) + .query({ type: 'WeatherStation' }) .reply(204); }); @@ -702,9 +757,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -734,9 +793,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -750,7 +813,6 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { }); describe('When there are expressions including other attributes and they are not updated', function() { - var values = [ { name: 'x', @@ -765,9 +827,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -781,7 +847,6 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { }); describe('When there are expressions including other attributes and they are updated', function() { - var values = [ { name: 'p', @@ -796,9 +861,13 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -811,41 +880,45 @@ describe('NGSI-v2 - Expression-based transformations plugin', function() { }); }); - describe('When there are expressions including other attributes and they are updated' + - '(overriding situation)', function() { - - var values = [ - { - name: 'x', - type: 'Number', - value: 0.44 - }, - { - name: 'p', - type: 'Number', - value: 10 - } - ]; - - beforeEach(function() { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json')) - .query({type: 'Light'}) - .reply(204); - }); - - it('should apply the expression before sending the values', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + describe( + 'When there are expressions including other attributes and they are updated' + '(overriding situation)', + function() { + var values = [ + { + name: 'x', + type: 'Number', + value: 0.44 + }, + { + name: 'p', + type: 'Number', + value: 10 + } + ]; + + beforeEach(function() { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json' + ) + ) + .query({ type: 'Light' }) + .reply(204); }); - }); - }); + it('should apply the expression before sending the values', function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); }); diff --git a/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js b/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js index 929eb9d9a..b30748ba2 100644 --- a/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +++ b/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js @@ -52,7 +52,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), enabled: true }, types: { - 'Light': { + Light: { service: 'smartGondor', subservice: 'electricity', trust: 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3', @@ -71,7 +71,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], type: 'Termometer', lazy: [ @@ -80,8 +80,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] } }, service: 'smartGondor', @@ -117,20 +116,21 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') + ) + .query({ type: 'Light' }) .reply(204, {}); iotAgentLib.activate(iotAgentConfig, done); @@ -156,22 +156,22 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')) - .query({type: 'Light'}) - .reply( - 403, {}); + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') + ) + .query({ type: 'Light' }) + .reply(403, {}); iotAgentLib.activate(iotAgentConfig, done); }); @@ -188,19 +188,24 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', beforeEach(function(done) { nock.cleanAll(); - oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + oauth2Mock = nock('http://192.168.1.1:3000') + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( - 400, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorized.json')); + 400, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorized.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') + ) .reply(204, {}); iotAgentLib.activate(iotAgentConfig, done); @@ -216,29 +221,27 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', }); describe('When the user requests information about a device in a protected CB', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function(done) { nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') .get('/v2/entities/light1/attrs?attrs=state,dimming&type=Light') - .reply(200, - utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/queryContext1Success.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/queryContext1Success.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -252,51 +255,60 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', }); }); describe('When subscriptions are used on a protected Context Broker', function() { - beforeEach(function(done) { + beforeEach(function(done) { var optionsProvision = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice3.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice3.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': 'electricity' } }; - + nock.cleanAll(); - + iotAgentLib.activate(iotAgentConfig, function() { oauth2Mock = nock('http://192.168.1.1:3000') - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .times(3) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); - + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); contextBrokerMock = nock('http://192.168.1.1:1026'); contextBrokerMock - .post('/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock - .post('/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json')) - .reply(204, {}); + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json' + ) + ) + .reply(204, {}); contextBrokerMock - .post('/v2/subscriptions', - utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/subscriptionRequests/simpleSubscriptionRequest2.json')) + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/subscriptionRequests/simpleSubscriptionRequest2.json' + ) + ) .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' }); - iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { done(); @@ -318,18 +330,14 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', }); it('unsubscribe requests use auth header', function(done) { + oauth2Mock + .post( + '/auth/realms/default/protocol/openid-connect/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) + .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {}); - oauth2Mock - .post('/auth/realms/default/protocol/openid-connect/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) - .reply( - 201, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), - {}); - - contextBrokerMock - .delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8') - .reply(204); + contextBrokerMock.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8').reply(204); iotAgentLib.getDevice('Light1', 'smartGondor', 'electricity', function(error, device) { iotAgentLib.subscribe(device, ['dimming'], null, function(error) { @@ -340,12 +348,10 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', }); }); }); - }); }); describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)', function() { - var values = [ { name: 'state', @@ -373,20 +379,25 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( 200, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + {} + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') + ) + .query({ type: 'Light' }) .reply(204, {}); iotAgentConfig.authentication.tokenPath = '/oauth2/token'; @@ -410,29 +421,31 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F }); describe('When the user requests information about a device in a protected CB', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function(done) { nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( 200, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + {} + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') .get('/v2/entities/light1/attrs?attrs=state,dimming&type=Light') - .reply(200, - utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/queryContext1Success.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/queryContext1Success.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -451,11 +464,14 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( - 400, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorizedKeyrock.json')); + 400, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustUnauthorizedKeyrock.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -474,12 +490,17 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( - 400, - utils.readExampleFile('./test/unit/examples/oauthResponses/' + - 'tokenFromTrustInvalidCredentialsKeyrock.json'), {}); + 400, + utils.readExampleFile( + './test/unit/examples/oauthResponses/' + 'tokenFromTrustInvalidCredentialsKeyrock.json' + ), + {} + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -498,20 +519,25 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F nock.cleanAll(); oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)) + .post( + '/oauth2/token', + utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true) + ) .reply( 200, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + {} + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') + ) + .query({ type: 'Light' }) .reply(401, 'Auth-token not found in request header'); iotAgentLib.activate(iotAgentConfig, done); @@ -527,103 +553,270 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F }); }); -describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + - 'configured through group provisioning', function() { - var groupCreation = { - url: 'http://localhost:4041/iot/services', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - } - }; - - var values = [ - { - name: 'status', - type: 'String', - value: 'STARTING' - } - ]; +describe( + 'NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + + 'configured through group provisioning', + function() { + var groupCreation = { + url: 'http://localhost:4041/iot/services', + method: 'POST', + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + } + }; - beforeEach(function() { - logger.setLevel('FATAL'); - }); + var values = [ + { + name: 'status', + type: 'String', + value: 'STARTING' + } + ]; - afterEach(function(done) { - iotAgentLib.deactivate(done); - nock.cleanAll(); - }); + beforeEach(function() { + logger.setLevel('FATAL'); + }); - describe('When a measure is sent to the Context Broker via an Update Context operation', function() { - var oauth2Mock2; - var contextBrokerMock2; - beforeEach(function(done) { + afterEach(function(done) { + iotAgentLib.deactivate(done); nock.cleanAll(); - oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), - {}); + }); - oauth2Mock2 = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup2.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock2.json'), - {}); + describe('When a measure is sent to the Context Broker via an Update Context operation', function() { + var oauth2Mock2; + var contextBrokerMock2; + beforeEach(function(done) { + nock.cleanAll(); + oauth2Mock = nock('http://192.168.1.1:3000') + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock.json'), + {} + ); + + oauth2Mock2 = nock('http://192.168.1.1:3000') + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup2.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock2.json'), + {} + ); + + contextBrokerMock = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') + .post( + '/v2/entities/machine1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json' + ) + ) + .query({ type: 'SensorMachine' }) + .reply(204, {}); + + contextBrokerMock2 = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer bbb752e377680acd1349a3ed59db855a1db076aa') + .post( + '/v2/entities/machine1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json' + ) + ) + .query({ type: 'SensorMachine' }) + .reply(204, {}); + + iotAgentConfig.authentication.tokenPath = '/oauth2/token'; + iotAgentLib.activate(iotAgentConfig, function() { + request(groupCreation, function(error, response, body) { + done(); + }); + }); + }); + it( + 'should ask OAuth2 provider for a token based on the' + + 'trust token and send the generated token in the auth header', + function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + oauth2Mock.done(); + contextBrokerMock.done(); + done(); + }); + } + ); - contextBrokerMock = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') - .post('/v2/entities/machine1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json')) - .query({type: 'SensorMachine'}) - .reply(204, {}); + it('should use the updated trust token in the following requests', function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + oauth2Mock2.done(); + contextBrokerMock2.done(); + done(); + }); + }); + }); - contextBrokerMock2 = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer bbb752e377680acd1349a3ed59db855a1db076aa') - .post('/v2/entities/machine1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json')) - .query({type: 'SensorMachine'}) - .reply(204, {}); + describe('When a device is provisioned for a configuration contains an OAuth2 trust token', function() { + var values = [ + { + name: 'status', + type: 'String', + value: 'STARTING' + } + ]; + var deviceCreation = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', + method: 'POST', + json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionNewDevice2.json'), + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + } + }; + var contextBrokerMock2; + var contextBrokerMock3; + beforeEach(function(done) { + var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 + timekeeper.freeze(time); + nock.cleanAll(); - iotAgentConfig.authentication.tokenPath = '/oauth2/token'; - iotAgentLib.activate(iotAgentConfig, function() { - request(groupCreation, function(error, response, body) { + oauth2Mock = nock('http://192.168.1.1:3000') + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup3.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock3.json'), + {} + ) + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup4.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock4.json'), + {} + ) + .post( + '/oauth2/token', + utils.readExampleFile( + './test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup5.json', + true + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock5.json'), + {} + ); + + contextBrokerMock = nock('http://unexistenthost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer asd752e377680acd1349a3ed59db855a1db07ere') + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); + + contextBrokerMock2 = nock('http://unexistenthost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc') + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json' + ) + ) + .reply(204, {}); + + contextBrokerMock3 = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('authorization', 'Bearer zzz752e377680acd1349a3ed59db855a1db07bbb') + .post( + '/v2/entities/Light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext4.json') + ) + .query({ type: 'SensorMachine' }) + .reply(204, {}); + + iotAgentConfig.authentication.tokenPath = '/oauth2/token'; + iotAgentLib.activate(iotAgentConfig, function() { done(); }); }); - }); - it('should ask OAuth2 provider for a token based on the' + - 'trust token and send the generated token in the auth header', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - oauth2Mock.done(); - contextBrokerMock.done(); + + afterEach(function(done) { + timekeeper.reset(); + done(); }); - }); - it('should use the updated trust token in the following requests', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - oauth2Mock2.done(); - contextBrokerMock2.done(); - done(); + it('should not raise any error', function(done) { + request(deviceCreation, function(error, response, body) { + should.not.exist(error); + response.statusCode.should.equal(201); + contextBrokerMock.done(); + contextBrokerMock2.done(); + done(); + }); + }); + + it('should send the mixed data to the Context Broker', function(done) { + iotAgentLib.update('Light1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + contextBrokerMock3.done(); + done(); + }); }); }); - }); + } +); +describe( + 'NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + + 'configured through group provisioning. Permanent token', + function() { + var groupCreation = { + url: 'http://localhost:4041/iot/services', + method: 'POST', + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + } + }; - describe('When a device is provisioned for a configuration contains an OAuth2 trust token', function() { var values = [ { name: 'status', @@ -631,167 +824,56 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F value: 'STARTING' } ]; - var deviceCreation = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionNewDevice2.json'), - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - } - }; - var contextBrokerMock2; - var contextBrokerMock3; - beforeEach(function(done) { - var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - timekeeper.freeze(time); - nock.cleanAll(); - - oauth2Mock = nock('http://192.168.1.1:3000') - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup3.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock3.json'), - {}) - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup4.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock4.json'), - {}) - .post('/oauth2/token', - utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrustKeyrockGroup5.json', true)) - .reply( - 200, - utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrustKeyrock5.json'), - {}); - - - contextBrokerMock = nock('http://unexistenthost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer asd752e377680acd1349a3ed59db855a1db07ere') - .post('/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); - - contextBrokerMock2 = nock('http://unexistenthost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc') - .post('/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json')) - .reply(204, {}); - contextBrokerMock3 = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('authorization', 'Bearer zzz752e377680acd1349a3ed59db855a1db07bbb') - .post('/v2/entities/Light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContext4.json')) - .query({type: 'SensorMachine'}) - .reply(204, {}); - - - iotAgentConfig.authentication.tokenPath = '/oauth2/token'; - iotAgentLib.activate(iotAgentConfig, function() { - done(); - }); + beforeEach(function() { + logger.setLevel('FATAL'); + iotAgentConfig.authentication.permanentToken = true; }); afterEach(function(done) { - timekeeper.reset(); - - done(); - }); - - it('should not raise any error', function(done) { - request(deviceCreation, function(error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(201); - contextBrokerMock.done(); - contextBrokerMock2.done(); - done(); - }); + iotAgentLib.deactivate(done); + nock.cleanAll(); }); - it('should send the mixed data to the Context Broker', function(done) { - iotAgentLib.update('Light1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - contextBrokerMock3.done(); - done(); + describe('When a measure is sent to the Context Broker via an Update Context operation', function() { + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://unexistentHost:1026') + .matchHeader('fiware-service', 'TestService') + .matchHeader('fiware-servicepath', '/testingPath') + .matchHeader('Authorization', 'Bearer 999210dacf913772606c95dd0b895d5506cbc988') + .post( + '/v2/entities/machine1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json' + ) + ) + .query({ type: 'SensorMachine' }) + .reply(204, {}); + + iotAgentConfig.authentication.tokenPath = '/oauth2/token'; + iotAgentLib.activate(iotAgentConfig, function() { + request(groupCreation, function(error, response, body) { + done(); + }); + }); }); - }); - - }); -}); - -describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (FIWARE Keyrock IDM)' + - 'configured through group provisioning. Permanent token', function() { - var groupCreation = { - url: 'http://localhost:4041/iot/services', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/provisionFullGroup.json'), - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - } - }; - - var values = [ - { - name: 'status', - type: 'String', - value: 'STARTING' - } - ]; - - beforeEach(function() { - logger.setLevel('FATAL'); - iotAgentConfig.authentication.permanentToken = true; - }); - - afterEach(function(done) { - iotAgentLib.deactivate(done); - nock.cleanAll(); - }); - - describe('When a measure is sent to the Context Broker via an Update Context operation', function() { - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://unexistentHost:1026') - .matchHeader('fiware-service', 'TestService') - .matchHeader('fiware-servicepath', '/testingPath') - .matchHeader('Authorization', 'Bearer 999210dacf913772606c95dd0b895d5506cbc988') - .post('/v2/entities/machine1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json')) - .query({type: 'SensorMachine'}) - .reply(204, {}); - - - iotAgentConfig.authentication.tokenPath = '/oauth2/token'; - iotAgentLib.activate(iotAgentConfig, function() { - request(groupCreation, function(error, response, body) { + it('should send the permanent token in the auth header', function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); done(); }); }); - }); - it('should send the permanent token in the auth header', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); - it('should use the permanent trust token in the following requests', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + it('should use the permanent trust token in the following requests', function(done) { + iotAgentLib.update('machine1', 'SensorMachine', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); }); - }); -}); + } +); diff --git a/test/unit/ngsiv2/general/deviceService-test.js b/test/unit/ngsiv2/general/deviceService-test.js index 82d4bbcce..ce34a6d85 100644 --- a/test/unit/ngsiv2/general/deviceService-test.js +++ b/test/unit/ngsiv2/general/deviceService-test.js @@ -43,7 +43,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -59,7 +59,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -74,7 +74,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -83,10 +83,9 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -98,15 +97,15 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -168,7 +167,6 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), contextBrokerMock, iotamMock; - /* jshint camelcase: false */ describe('NGSI-v2 - Device Service: utils', function() { beforeEach(function(done) { @@ -183,15 +181,11 @@ describe('NGSI-v2 - Device Service: utils', function() { afterEach(function(done) { nock.cleanAll(); - async.series([ - iotAgentLib.clearAll, - iotAgentLib.deactivate - ], done); + async.series([iotAgentLib.clearAll, iotAgentLib.deactivate], done); }); describe('When an existing device tries to be retrieved with retrieveOrCreate()', function() { beforeEach(function(done) { - // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder @@ -201,10 +195,10 @@ describe('NGSI-v2 - Device Service: utils', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - request.bind(request, groupCreation), - request.bind(request, deviceCreation) - ], function(error, results) { + async.series([request.bind(request, groupCreation), request.bind(request, deviceCreation)], function( + error, + results + ) { done(); }); }); @@ -222,7 +216,6 @@ describe('NGSI-v2 - Device Service: utils', function() { describe('When an unexisting device tries to be retrieved for an existing APIKey', function() { beforeEach(function(done) { - // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder @@ -232,36 +225,38 @@ describe('NGSI-v2 - Device Service: utils', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - request.bind(request, groupCreation) - ], function(error, results) { + async.series([request.bind(request, groupCreation)], function(error, results) { done(); }); }); it('should register the device and return it', function(done) { - iotAgentLib.retrieveDevice('UNEXISTENT_DEV', '801230BJKL23Y9090DSFL123HJK09H324HV8732', - function(error, device) { - should.not.exist(error); - should.exist(device); + iotAgentLib.retrieveDevice('UNEXISTENT_DEV', '801230BJKL23Y9090DSFL123HJK09H324HV8732', function( + error, + device + ) { + should.not.exist(error); + should.exist(device); - device.id.should.equal('UNEXISTENT_DEV'); - should.exist(device.protocol); - device.protocol.should.equal('MQTT_UL'); - done(); - }); + device.id.should.equal('UNEXISTENT_DEV'); + should.exist(device.protocol); + device.protocol.should.equal('MQTT_UL'); + done(); + }); }); }); describe('When an unexisting device tries to be retrieved for an unexisting APIKey', function() { it('should raise an error', function(done) { - iotAgentLib.retrieveDevice('UNEXISTENT_DEV_AND_GROUP', 'H2332Y909DSF3H346yh20JK092', - function(error, device) { - should.exist(error); - error.name.should.equal('DEVICE_GROUP_NOT_FOUND'); - should.not.exist(device); - done(); - }); + iotAgentLib.retrieveDevice('UNEXISTENT_DEV_AND_GROUP', 'H2332Y909DSF3H346yh20JK092', function( + error, + device + ) { + should.exist(error); + error.name.should.equal('DEVICE_GROUP_NOT_FOUND'); + should.not.exist(device); + done(); + }); }); }); }); diff --git a/test/unit/ngsiv2/general/https-support-test.js b/test/unit/ngsiv2/general/https-support-test.js index c619665f5..ea1c674b0 100644 --- a/test/unit/ngsiv2/general/https-support-test.js +++ b/test/unit/ngsiv2/general/https-support-test.js @@ -43,7 +43,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -60,7 +60,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), service: 'smartGondor', subservice: 'gardens' }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -68,8 +68,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], service: 'smartGondor', subservice: 'gardens' } @@ -121,18 +120,17 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), contextBrokerMock, iotamMock; - describe('NGSI-v2 - HTTPS support tests IOTAM', function() { - describe('When the IoT Agents is started with https "iotManager" config', function() { beforeEach(function(done) { nock.cleanAll(); iotamMock = nock('https://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); groupRegistryMemory.create(groupCreation, done); }); @@ -155,14 +153,14 @@ describe('NGSI-v2 - HTTPS support tests IOTAM', function() { }); describe('NGSI-v2 - HTTPS support tests', function() { - describe('When subscription is sent to HTTPS context broker', function() { beforeEach(function(done) { var optionsProvision = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -175,18 +173,24 @@ describe('NGSI-v2 - HTTPS support tests', function() { contextBrokerMock = nock('https://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/' + - 'contextRequests/createMinimumProvisionedDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/' + 'contextRequests/createMinimumProvisionedDevice.json' + ) + ) .reply(204); contextBrokerMock = nock('https://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/subscriptionRequests/simpleSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); - + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/subscriptionRequests/simpleSubscriptionRequest.json' + ) + ) + .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' }); iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { @@ -231,13 +235,13 @@ describe('NGSI-v2 - HTTPS support tests', function() { .reply(204); var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/registrations', nockBody) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); - + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -246,9 +250,9 @@ describe('NGSI-v2 - HTTPS support tests', function() { it('should register as ContextProvider using HTTPS', function(done) { iotAgentLib.register(device1, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + should.not.exist(error); + contextBrokerMock.done(); + done(); }); }); diff --git a/test/unit/ngsiv2/general/iotam-autoregistration-test.js b/test/unit/ngsiv2/general/iotam-autoregistration-test.js index 2218a113f..64882edde 100644 --- a/test/unit/ngsiv2/general/iotam-autoregistration-test.js +++ b/test/unit/ngsiv2/general/iotam-autoregistration-test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -192,10 +192,8 @@ describe('NGSI-v2 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); }); afterEach(function(done) { @@ -218,10 +216,8 @@ describe('NGSI-v2 - IoT Manager autoregistration', function() { delete iotAgentConfig.providerUrl; iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); }); afterEach(function() { @@ -242,10 +238,11 @@ describe('NGSI-v2 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); groupRegistryMemory.create(groupCreation, done); }); @@ -270,16 +267,15 @@ describe('NGSI-v2 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotamMock - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotAgentLib.activate(iotAgentConfig, function(error) { done(); @@ -306,16 +302,15 @@ describe('NGSI-v2 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotamMock - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); groupRegistryMemory.create(groupCreation, function() { iotAgentLib.activate(iotAgentConfig, done); @@ -342,16 +337,15 @@ describe('NGSI-v2 - IoT Manager autoregistration', function() { nock.cleanAll(); iotamMock = nock('http://mockediotam.com:9876') - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json')) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotamMock - .post('/protocols', - utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithStaticGroups.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); + .post( + '/protocols', + utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithStaticGroups.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json')); iotAgentLib.activate(iotAgentConfig, function(error) { done(); diff --git a/test/unit/ngsiv2/general/startup-test.js b/test/unit/ngsiv2/general/startup-test.js index 27f7d2293..e1356629e 100644 --- a/test/unit/ngsiv2/general/startup-test.js +++ b/test/unit/ngsiv2/general/startup-test.js @@ -32,13 +32,13 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), logLevel: 'FATAL', contextBroker: { host: '192.168.1.1', - port: '1026', + port: '1026' }, server: { port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -60,7 +60,6 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), iotamMock; describe('NGSI-v2 - Startup tests', function() { - describe('When the IoT Agent is started with environment variables', function() { beforeEach(function() { process.env.IOTA_CB_HOST = 'cbhost'; @@ -87,8 +86,10 @@ describe('NGSI-v2 - Startup tests', function() { iotamMock = nock('http://iotamhost:4444') .post('/iotampath') - .reply(200, - utils.readExampleFile('./test/unit/ngsiv2/examples/iotamResponses/registrationSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/ngsiv2/examples/iotamResponses/registrationSuccess.json') + ); }); afterEach(function() { diff --git a/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js b/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js index 9ba5253ad..8e733c307 100644 --- a/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js @@ -42,7 +42,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { // commands are not defined active: [ { @@ -64,7 +64,6 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), }; describe('NGSI-v2 - Update attribute functionalities', function() { - beforeEach(function(done) { logger.setLevel('FATAL'); @@ -74,7 +73,7 @@ describe('NGSI-v2 - Update attribute functionalities', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -149,7 +148,6 @@ describe('NGSI-v2 - Update attribute functionalities', function() { }); }); - request(options, function(error, response, body) { should.not.exist(error); handlerCalled.should.equal(true); diff --git a/test/unit/ngsiv2/lazyAndCommands/command-test.js b/test/unit/ngsiv2/lazyAndCommands/command-test.js index aa409d1de..b6353f209 100644 --- a/test/unit/ngsiv2/lazyAndCommands/command-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/command-test.js @@ -38,13 +38,13 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), contextBroker: { host: '192.168.1.1', port: '1026', - ngsiVersion: 'v2' + ngsiVersion: 'v2' }, server: { port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -59,7 +59,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -67,10 +67,9 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Motion': { + Motion: { commands: [], lazy: [ { @@ -80,14 +79,14 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), ], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [] }, - 'Robot': { + Robot: { commands: [ { name: 'position', @@ -120,10 +119,13 @@ describe('NGSI-v2 - Command functionalities', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgentCommands.json')) - .reply(201, null,{'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgentCommands.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -136,7 +138,7 @@ describe('NGSI-v2 - Command functionalities', function() { afterEach(function(done) { timekeeper.reset(); - delete(device3.registrationId); + delete device3.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(function() { mongoUtils.cleanDbs(function() { @@ -170,7 +172,7 @@ describe('NGSI-v2 - Command functionalities', function() { type: 'Robot', position: { type: 'Array', - value:'[28, -104, 23]' + value: '[28, -104, 23]' } } ] @@ -182,7 +184,6 @@ describe('NGSI-v2 - Command functionalities', function() { }; beforeEach(function(done) { - iotAgentLib.register(device3, function(error) { done(); }); @@ -265,8 +266,10 @@ describe('NGSI-v2 - Command functionalities', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/r2d2/attrs?type=Robot', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json')) + .post( + '/v2/entities/r2d2/attrs?type=Robot', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json') + ) .reply(204); iotAgentLib.register(device3, function(error) { @@ -275,12 +278,11 @@ describe('NGSI-v2 - Command functionalities', function() { }); it('should update its value and status in the Context Broker', function(done) { - iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', '[72, 368, 1]', 'FINISHED', - function(error) { - should.not.exist(error); - statusAttributeMock.done(); - done(); - }); + iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', '[72, 368, 1]', 'FINISHED', function(error) { + should.not.exist(error); + statusAttributeMock.done(); + done(); + }); }); }); describe('When an error command arrives from the south bound for a registered command', function() { @@ -288,8 +290,10 @@ describe('NGSI-v2 - Command functionalities', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/r2d2/attrs?type=Robot', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json')) + .post( + '/v2/entities/r2d2/attrs?type=Robot', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json') + ) .reply(204); iotAgentLib.register(device3, function(error) { @@ -298,12 +302,11 @@ describe('NGSI-v2 - Command functionalities', function() { }); it('should update its status in the Context Broker', function(done) { - iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', 'Stalled', 'ERROR', - function(error) { - should.not.exist(error); - statusAttributeMock.done(); - done(); - }); + iotAgentLib.setCommandResult('r2d2', 'Robot', '', 'position', 'Stalled', 'ERROR', function(error) { + should.not.exist(error); + statusAttributeMock.done(); + done(); + }); }); }); }); diff --git a/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js b/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js index 6de60746e..51152c616 100644 --- a/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js @@ -45,7 +45,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -60,7 +60,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -68,10 +68,9 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Motion': { + Motion: { commands: [], lazy: [ { @@ -81,14 +80,14 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), ], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [] }, - 'RobotPre': { + RobotPre: { commands: [], lazy: [ { @@ -154,9 +153,9 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { afterEach(function(done) { timekeeper.reset(); - delete(device1.registrationId); - delete(device2.registrationId); - delete(device3.registrationId); + delete device1.registrationId; + delete device2.registrationId; + delete device3.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(function() { @@ -194,10 +193,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -205,19 +207,15 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should call the device handler with the received data', function(done) { - iotAgentLib.setDataUpdateHandler(function(id, type, service, subservice, attributes, callback) { id.should.equal(device1.type + ':' + device1.id); type.should.equal(device1.type); attributes[0].value.should.equal(12); - callback(null); + callback(null); }); request(options, function(error, response, body) { @@ -247,15 +245,14 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { id: 'Light:light1' } ], - attrs: [ 'dimming' ] + attrs: ['dimming'] } }, sensorData = [ { id: 'Light:light1', type: 'Light', - dimming: - { + dimming: { type: 'Percentage', value: 19 } @@ -268,10 +265,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -279,15 +279,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should return the information querying the underlying devices', function(done) { - var expectedResponse = utils - .readExampleFile('./test/unit/ngsiv2/examples/contextProviderResponses/queryInformationResponse.json'); + var expectedResponse = utils.readExampleFile( + './test/unit/ngsiv2/examples/contextProviderResponses/queryInformationResponse.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { id.should.equal(device1.type + ':' + device1.id); @@ -306,22 +304,22 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { describe('When a context query arrives to the IoT Agent and no handler is set', function() { var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', - method: 'POST', - json: true, - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': 'gardens' - }, - body: { - entities: [ - { - id: 'Light:light1' - } - ], - attrs: [ 'dimming' ] - } - }; + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', + method: 'POST', + json: true, + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': 'gardens' + }, + body: { + entities: [ + { + id: 'Light:light1' + } + ], + attrs: ['dimming'] + } + }; beforeEach(function(done) { nock.cleanAll(); @@ -329,10 +327,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -340,10 +341,9 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], function(error) { + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], function( + error + ) { done(); }); }); @@ -386,8 +386,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { { id: 'Light:light1', type: 'Light', - temperature: - { + temperature: { type: 'centigrades', value: 19 } @@ -400,10 +399,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -411,16 +413,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should return the information of all the attributes', function(done) { var expectedResponse = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextProviderResponses/' + - 'queryInformationResponseEmptyAttributes.json'); + './test/unit/ngsiv2/examples/contextProviderResponses/' + 'queryInformationResponseEmptyAttributes.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { should.exist(attributes); @@ -452,15 +451,14 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { id: 'Motion:motion1' } ], - attrs: [ 'moving', 'location'] + attrs: ['moving', 'location'] } }, sensorData = [ { id: 'Motion:motion1', type: 'Motion', - 'moving': - { + moving: { type: 'Boolean', value: true } @@ -473,10 +471,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -484,15 +485,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device2) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device2)], done); }); it('should return the information adding the static attributes', function(done) { var expectedResponse = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json'); + './test/unit/ngsiv2/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { id.should.equal('Motion:motion1'); @@ -510,87 +509,89 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { }); }); - describe('When the IoT Agent receives an update on the device data in JSON format for a type with' + - 'internalAttributes', function() { - var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', - method: 'POST', - json: { - actionType: 'update', - entities: [ - { - id: 'RobotPre:TestRobotPre', - type: 'RobotPre', - moving: { - type: 'Boolean', - value: true + describe( + 'When the IoT Agent receives an update on the device data in JSON format for a type with' + + 'internalAttributes', + function() { + var options = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + method: 'POST', + json: { + actionType: 'update', + entities: [ + { + id: 'RobotPre:TestRobotPre', + type: 'RobotPre', + moving: { + type: 'Boolean', + value: true + } } - } - ] - }, - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': 'gardens' - } - }; - - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', - utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); - - contextBrokerMock - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') - .reply(204); - - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device3) - ], done); - }); + ] + }, + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': 'gardens' + } + }; - it('should call the device handler with the received data', function(done) { - - iotAgentLib.setDataUpdateHandler(function(id, type, service, subservice, attributes, callback) { - id.should.equal(device3.type + ':' + device3.id); - type.should.equal(device3.type); - attributes[0].value.should.equal(true); - callback(null); + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); + + contextBrokerMock + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post('/v2/entities?options=upsert') + .reply(204); + + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device3)], done); }); - request(options, function(error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(204); - done(); + it('should call the device handler with the received data', function(done) { + iotAgentLib.setDataUpdateHandler(function(id, type, service, subservice, attributes, callback) { + id.should.equal(device3.type + ':' + device3.id); + type.should.equal(device3.type); + attributes[0].value.should.equal(true); + callback(null); + }); + + request(options, function(error, response, body) { + should.not.exist(error); + response.statusCode.should.equal(204); + done(); + }); }); - }); - }); + } + ); describe('When a context query arrives to the IoT Agent and id and type query params are not present', function() { var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', - method: 'POST', - json: true, - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': 'gardens' - }, - body: { - entities: [ - { - idPattern: '.*' - } - ] - } - }; + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', + method: 'POST', + json: true, + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': 'gardens' + }, + body: { + entities: [ + { + idPattern: '.*' + } + ] + } + }; beforeEach(function(done) { nock.cleanAll(); @@ -598,26 +599,35 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -626,16 +636,18 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .times(3) .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1), - apply(iotAgentLib.register, device2), - apply(iotAgentLib.register, device3), - ], done); + async.series( + [ + apply(iotAgentLib.activate, iotAgentConfig), + apply(iotAgentLib.register, device1), + apply(iotAgentLib.register, device2), + apply(iotAgentLib.register, device3) + ], + done + ); }); it('should return error as idPattern is not supported', function(done) { - request(options, function(error, response, body) { should.not.exist(error); response.statusCode.should.equal(400); @@ -648,22 +660,22 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { describe('When a context query arrives to the IoT Agent and id query param is not present', function() { var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', - method: 'POST', - json: true, - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': 'gardens' - }, - body: { - entities: [ - { - idPattern: '.*', - type: 'Light' - } - ] - } - }; + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', + method: 'POST', + json: true, + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': 'gardens' + }, + body: { + entities: [ + { + idPattern: '.*', + type: 'Light' + } + ] + } + }; beforeEach(function(done) { nock.cleanAll(); @@ -671,26 +683,35 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -699,16 +720,18 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .times(3) .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1), - apply(iotAgentLib.register, device2), - apply(iotAgentLib.register, device3), - ], done); + async.series( + [ + apply(iotAgentLib.activate, iotAgentConfig), + apply(iotAgentLib.register, device1), + apply(iotAgentLib.register, device2), + apply(iotAgentLib.register, device3) + ], + done + ); }); it('should return error as idPattern is not supported', function(done) { - request(options, function(error, response, body) { should.not.exist(error); response.statusCode.should.equal(400); @@ -721,7 +744,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { describe('When a query arrives to the IoT Agent with id, type and attributes', function() { var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query', method: 'POST', json: true, headers: { @@ -735,15 +758,14 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { type: 'Light' } ], - attrs: [ 'temperature' ] + attrs: ['temperature'] } }, sensorData = [ { id: 'Light:light1', type: 'Light', - temperature: - { + temperature: { type: 'centigrades', value: 19 } @@ -756,10 +778,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', + .post( + '/v2/registrations', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -767,16 +792,13 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function() { .post('/v2/entities?options=upsert') .reply(204); - async.series([ - apply(iotAgentLib.activate, iotAgentConfig), - apply(iotAgentLib.register, device1) - ], done); + async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); }); it('should return the information of all the attributes', function(done) { var expectedResponse = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextProviderResponses/' + - 'queryInformationResponseEmptyAttributes.json'); + './test/unit/ngsiv2/examples/contextProviderResponses/' + 'queryInformationResponseEmptyAttributes.json' + ); iotAgentLib.setDataQueryHandler(function(id, type, service, subservice, attributes, callback) { should.exist(attributes); diff --git a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js index d2bcf2ef9..011c2dfa8 100644 --- a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js @@ -43,7 +43,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -58,7 +58,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -66,10 +66,9 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Motion': { + Motion: { commands: [], lazy: [ { @@ -79,14 +78,14 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), ], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [] }, - 'Robot': { + Robot: { commands: [ { name: 'position', @@ -131,7 +130,7 @@ describe('NGSI-v2 - Polling commands', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') @@ -139,12 +138,11 @@ describe('NGSI-v2 - Polling commands', function() { .post('/v2/entities?options=upsert') .reply(204); - iotAgentLib.activate(iotAgentConfig, done); }); afterEach(function(done) { - delete(device3.registrationId); + delete device3.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(function() { mongoUtils.cleanDbs(function() { @@ -184,9 +182,10 @@ describe('NGSI-v2 - Polling commands', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/Robot:r2d2/attrs?type=Robot', - utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')) + .post( + '/v2/entities/Robot:r2d2/attrs?type=Robot', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json') + ) .reply(204); iotAgentLib.register(device3, function(error) { @@ -277,9 +276,10 @@ describe('NGSI-v2 - Polling commands', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/Robot:r2d2/attrs?type=Robot', - utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')) + .post( + '/v2/entities/Robot:r2d2/attrs?type=Robot', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json') + ) .reply(204); iotAgentLib.register(device3, function(error) { @@ -329,17 +329,21 @@ describe('NGSI-v2 - Polling commands', function() { statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/Robot:r2d2/attrs?type=Robot', - utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json')) + .post( + '/v2/entities/Robot:r2d2/attrs?type=Robot', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json') + ) .reply(204); statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/Robot:r2d2/attrs?type=Robot', + .post( + '/v2/entities/Robot:r2d2/attrs?type=Robot', utils.readExampleFile( - './test/unit//ngsiv2/examples/contextRequests/updateContextCommandExpired.json')) + './test/unit//ngsiv2/examples/contextRequests/updateContextCommandExpired.json' + ) + ) .reply(204); iotAgentLib.register(device3, function(error) { diff --git a/test/unit/ngsiv2/ngsiService/active-devices-test.js b/test/unit/ngsiv2/ngsiService/active-devices-test.js index 51a53e9a0..043dc6cd8 100644 --- a/test/unit/ngsiv2/ngsiService/active-devices-test.js +++ b/test/unit/ngsiv2/ngsiService/active-devices-test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -57,7 +57,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -72,7 +72,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -81,10 +81,9 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -96,15 +95,15 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'geo:point', - 'value': '153,523' + name: 'location', + type: 'geo:point', + value: '153,523' } ], active: [ @@ -114,17 +113,17 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Lamp': { + Lamp: { type: 'Lamp', commands: [], lazy: [], staticAttributes: [ { - 'name': 'controlledProperty', - 'type': 'text', - 'value': 'StaticValue', - 'metadata':{ - 'includes':{'type': 'Text', 'value' :'bell'} + name: 'controlledProperty', + type: 'text', + value: 'StaticValue', + metadata: { + includes: { type: 'Text', value: 'bell' } } } ], @@ -132,8 +131,8 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), { name: 'luminosity', type: 'text', - metadata:{ - unitCode:{type: 'Text', value :'CAL'} + metadata: { + unitCode: { type: 'Text', value: 'CAL' } } } ] @@ -173,9 +172,11 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') + ) + .query({ type: 'Light' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -216,9 +217,11 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json') + ) + .query({ type: 'Light' }) .reply(204); iotAgentConfig.timestamp = true; @@ -245,7 +248,6 @@ describe('NGSI-v2 - Active attributes test', function() { var modifiedValues; beforeEach(function(done) { - modifiedValues = [ { name: 'state', @@ -280,113 +282,123 @@ describe('NGSI-v2 - Active attributes test', function() { }); }); - describe('When the IoTA gets a set of values with a TimeInstant which are in ISO8601 format ' + - 'without milis', function() { - var modifiedValues; - - beforeEach(function(done) { - var time = new Date(1666477342000); // 2022-10-22T22:22:22Z - - modifiedValues = [ - { - name: 'state', - type: 'boolean', - value: true - }, - { - name: 'TimeInstant', - type: 'DateTime', - value: '2022-10-22T22:22:22Z' - } - ]; - - timekeeper.freeze(time); - - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json')) - .query({type: 'Light'}) - .reply(204); - - iotAgentConfig.timestamp = true; - iotAgentLib.activate(iotAgentConfig, done); + describe( + 'When the IoTA gets a set of values with a TimeInstant which are in ISO8601 format ' + 'without milis', + function() { + var modifiedValues; - }); + beforeEach(function(done) { + var time = new Date(1666477342000); // 2022-10-22T22:22:22Z - afterEach(function(done) { - delete iotAgentConfig.timestamp; - timekeeper.reset(); + modifiedValues = [ + { + name: 'state', + type: 'boolean', + value: true + }, + { + name: 'TimeInstant', + type: 'DateTime', + value: '2022-10-22T22:22:22Z' + } + ]; + + timekeeper.freeze(time); + + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json' + ) + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentConfig.timestamp = true; + iotAgentLib.activate(iotAgentConfig, done); + }); - done(); - }); + afterEach(function(done) { + delete iotAgentConfig.timestamp; + timekeeper.reset(); - it('should not fail', function(done) { - iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { - should.not.exist(error); - contextBrokerMock.done(); done(); }); - }); - }); - - describe('When the IoT Agent receives new information, the timestamp flag is on' + - 'and timezone is defined', function() { - var modifiedValues; - beforeEach(function(done) { - var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - - modifiedValues = [ - { - name: 'state', - type: 'boolean', - value: true - }, - { - name: 'dimming', - type: 'number', - value: 87 - } - ]; - - timekeeper.freeze(time); - - nock.cleanAll(); + it('should not fail', function(done) { + iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/' + - 'updateContextTimestampTimezone.json')) - .query({type: 'Light'}) - .reply(204); + describe( + 'When the IoT Agent receives new information, the timestamp flag is on' + 'and timezone is defined', + function() { + var modifiedValues; - iotAgentConfig.timestamp = true; - iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; - iotAgentLib.activate(iotAgentConfig, done); - }); + beforeEach(function(done) { + var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - afterEach(function(done) { - delete iotAgentConfig.timestamp; - delete iotAgentConfig.types.Light.timezone; - timekeeper.reset(); + modifiedValues = [ + { + name: 'state', + type: 'boolean', + value: true + }, + { + name: 'dimming', + type: 'number', + value: 87 + } + ]; + + timekeeper.freeze(time); + + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/' + 'updateContextTimestampTimezone.json' + ) + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentConfig.timestamp = true; + iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; + iotAgentLib.activate(iotAgentConfig, done); + }); - done(); - }); + afterEach(function(done) { + delete iotAgentConfig.timestamp; + delete iotAgentConfig.types.Light.timezone; + timekeeper.reset(); - it('should add the timestamp to the entity and all the attributes', function(done) { - iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { - should.not.exist(error); - contextBrokerMock.done(); done(); }); - }); - }); + + it('should add the timestamp to the entity and all the attributes', function(done) { + iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); describe('When the IoTA gets a set of values with a TimeInstant and the timestamp flag is on', function() { var modifiedValues; @@ -414,9 +426,13 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json' + ) + ) + .query({ type: 'Light' }) .reply(204); iotAgentConfig.timestamp = true; @@ -439,61 +455,68 @@ describe('NGSI-v2 - Active attributes test', function() { }); }); - describe('When the IoTA gets a set of values with a TimeInstant, the timestamp flag is on' + - 'and timezone is defined', function() { - var modifiedValues; + describe( + 'When the IoTA gets a set of values with a TimeInstant, the timestamp flag is on' + 'and timezone is defined', + function() { + var modifiedValues; - beforeEach(function(done) { - var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 + beforeEach(function(done) { + var time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00 - modifiedValues = [ - { - name: 'state', - type: 'boolean', - value: true - }, - { - name: 'TimeInstant', - type: 'DateTime', - value: '2015-12-14T08:06:01.468Z' - } - ]; - - timekeeper.freeze(time); - - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json')) - .query({type: 'Light'}) - .reply(204); - - iotAgentConfig.timestamp = true; - iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; - iotAgentLib.activate(iotAgentConfig, done); - }); - - afterEach(function(done) { - delete iotAgentConfig.timestamp; - delete iotAgentConfig.types.Light.timezone; - timekeeper.reset(); + modifiedValues = [ + { + name: 'state', + type: 'boolean', + value: true + }, + { + name: 'TimeInstant', + type: 'DateTime', + value: '2015-12-14T08:06:01.468Z' + } + ]; + + timekeeper.freeze(time); + + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json' + ) + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentConfig.timestamp = true; + iotAgentConfig.types.Light.timezone = 'America/Los_Angeles'; + iotAgentLib.activate(iotAgentConfig, done); + }); - done(); - }); + afterEach(function(done) { + delete iotAgentConfig.timestamp; + delete iotAgentConfig.types.Light.timezone; + timekeeper.reset(); - it('should not override the received instant and should not add metadatas for this request', function(done) { - iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { - should.not.exist(error); - contextBrokerMock.done(); done(); }); - }); - }); - describe('When the IoT Agent receives information from a device whose type doesn\'t have a type name', function() { + it('should not override the received instant and should not add metadatas for this request', function(done) { + iotAgentLib.update('light1', 'Light', '', modifiedValues, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); + + describe(/*jshint quotmark: double */ + "When the IoT Agent receives information from a device whose type doesn't have a type name" /*jshint quotmark: single */, function() { beforeEach(function(done) { nock.cleanAll(); @@ -517,11 +540,15 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')) - .query({type: 'Light'}) - .reply(413, - utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext1Failed.json')); + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') + ) + .query({ type: 'Light' }) + .reply( + 413, + utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext1Failed.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -546,11 +573,15 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')) - .query({type: 'Light'}) - .reply(400, - utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext2Failed.json')); + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') + ) + .query({ type: 'Light' }) + .reply( + 400, + utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext2Failed.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -572,11 +603,15 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')) - .query({type: 'Light'}) - .reply(500, - utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext2Failed.json')); + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') + ) + .query({ type: 'Light' }) + .reply( + 500, + utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext2Failed.json') + ); iotAgentLib.activate(iotAgentConfig, done); }); @@ -601,9 +636,11 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:3024') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/humSensor/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')) - .query({type: 'Humidity'}) + .post( + '/v2/entities/humSensor/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') + ) + .query({ type: 'Humidity' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -633,9 +670,13 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/motion1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json')) - .query({type: 'Motion'}) + .post( + '/v2/entities/motion1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json' + ) + ) + .query({ type: 'Motion' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -649,7 +690,6 @@ describe('NGSI-v2 - Active attributes test', function() { }); }); - describe('When an IoT Agent receives information for a type with static attributes with metadata', function() { var newValues = [ { @@ -666,9 +706,13 @@ describe('NGSI-v2 - Active attributes test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/lamp1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json')) - .query({type: 'Lamp'}) + .post( + '/v2/entities/lamp1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json' + ) + ) + .query({ type: 'Lamp' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); diff --git a/test/unit/ngsiv2/ngsiService/autocast-test.js b/test/unit/ngsiv2/ngsiService/autocast-test.js index da5517e26..ea0508cb2 100644 --- a/test/unit/ngsiv2/ngsiService/autocast-test.js +++ b/test/unit/ngsiv2/ngsiService/autocast-test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', active: [ @@ -90,144 +90,155 @@ describe('NGSI-v2 - JSON native types autocast test', function() { iotAgentLib.deactivate(done); }); - describe('When the IoT Agent receives new information from a device.' + - 'Observation with Number type and Integer value', function() { - - var values = [ - { - name: 'pressure', - type: 'Number', - value: '23' - } - ]; - - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json')) - .query({type: 'Light'}) - .reply(204); - - iotAgentLib.activate(iotAgentConfig, done); - }); - - it('should change the value of the corresponding attribute in the context broker', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + describe( + 'When the IoT Agent receives new information from a device.' + 'Observation with Number type and Integer value', + function() { + var values = [ + { + name: 'pressure', + type: 'Number', + value: '23' + } + ]; + + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json') + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentLib.activate(iotAgentConfig, done); }); - }); - }); - - describe('When the IoT Agent receives new information from a device.' + - 'Observation with Number type and Float value', function() { - var values = [ - { - name: 'temperature', - type: 'Number', - value: '14.4' - } - ]; - - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json')) - .query({type: 'Light'}) - .reply(204); - - iotAgentLib.activate(iotAgentConfig, done); - }); - - it('should change the value of the corresponding attribute in the context broker', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + it('should change the value of the corresponding attribute in the context broker', function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); - }); - }); - - describe('When the IoT Agent receives new information from a device.' + - 'Observation with Boolean type and True value', function() { - - var values = [ - { - name: 'status', - type: 'Boolean', - value: 'true' - } - ]; - - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json')) - .query({type: 'Light'}) - .reply(204); - - iotAgentLib.activate(iotAgentConfig, done); - }); - - it('should change the value of the corresponding attribute in the context broker', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + } + ); + + describe( + 'When the IoT Agent receives new information from a device.' + 'Observation with Number type and Float value', + function() { + var values = [ + { + name: 'temperature', + type: 'Number', + value: '14.4' + } + ]; + + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json') + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentLib.activate(iotAgentConfig, done); }); - }); - }); - - describe('When the IoT Agent receives new information from a device.' + - 'Observation with Boolean type and False value', function() { - var values = [ - { - name: 'status', - type: 'Boolean', - value: 'false' - } - ]; - - beforeEach(function(done) { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json')) - .query({type: 'Light'}) - .reply(204); + it('should change the value of the corresponding attribute in the context broker', function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); + + describe( + 'When the IoT Agent receives new information from a device.' + 'Observation with Boolean type and True value', + function() { + var values = [ + { + name: 'status', + type: 'Boolean', + value: 'true' + } + ]; + + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json') + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentLib.activate(iotAgentConfig, done); + }); - iotAgentLib.activate(iotAgentConfig, done); - }); + it('should change the value of the corresponding attribute in the context broker', function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); + + describe( + 'When the IoT Agent receives new information from a device.' + 'Observation with Boolean type and False value', + function() { + var values = [ + { + name: 'status', + type: 'Boolean', + value: 'false' + } + ]; + + beforeEach(function(done) { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json') + ) + .query({ type: 'Light' }) + .reply(204); + + iotAgentLib.activate(iotAgentConfig, done); + }); - it('should change the value of the corresponding attribute in the context broker', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + it('should change the value of the corresponding attribute in the context broker', function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); - }); - }); + } + ); describe('When the IoT Agent receives new information from a device. Observation with None type', function() { - var values = [ { name: 'keep_alive', @@ -242,9 +253,11 @@ describe('NGSI-v2 - JSON native types autocast test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json') + ) + .query({ type: 'Light' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -260,7 +273,6 @@ describe('NGSI-v2 - JSON native types autocast test', function() { }); describe('When the IoT Agent receives new information from a device. Observation with Array type', function() { - var values = [ { name: 'tags', @@ -275,9 +287,11 @@ describe('NGSI-v2 - JSON native types autocast test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json') + ) + .query({ type: 'Light' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -293,7 +307,6 @@ describe('NGSI-v2 - JSON native types autocast test', function() { }); describe('When the IoT Agent receives new information from a device. Observation with Object type', function() { - var values = [ { name: 'configuration', @@ -308,9 +321,11 @@ describe('NGSI-v2 - JSON native types autocast test', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json') + ) + .query({ type: 'Light' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); diff --git a/test/unit/ngsiv2/ngsiService/staticAttributes-test.js b/test/unit/ngsiv2/ngsiService/staticAttributes-test.js index 0181dbf15..0f6387b33 100644 --- a/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +++ b/test/unit/ngsiv2/ngsiService/staticAttributes-test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -71,7 +71,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), { name: 'attr4', type: 'type4' - }, + } ] } }, @@ -81,7 +81,6 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), providerUrl: 'http://smartGondor.com' }; - describe('NGSI-v2 - Static attributes test', function() { var values = [ { @@ -112,7 +111,7 @@ describe('NGSI-v2 - Static attributes test', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/entities/light1/attrs') - .query({type: 'Light'}) + .query({ type: 'Light' }) .times(4) .reply(204) .post('/v2/entities/light1/attrs', function(body) { @@ -124,24 +123,27 @@ describe('NGSI-v2 - Static attributes test', function() { } return metadatas === Object.keys(body).length - 1; }) - .query({type: 'Light'}) + .query({ type: 'Light' }) .reply(204); iotAgentLib.activate(iotAgentConfig, done); }); it('should send a single TimeInstant per attribute', function(done) { - async.series([ - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values), - async.apply(iotAgentLib.update, 'light1', 'Light', '', values) - ], function(error, results) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); + async.series( + [ + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values), + async.apply(iotAgentLib.update, 'light1', 'Light', '', values) + ], + function(error, results) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + } + ); }); }); }); diff --git a/test/unit/ngsiv2/ngsiService/subscriptions-test.js b/test/unit/ngsiv2/ngsiService/subscriptions-test.js index 320318f37..f5a376c9e 100644 --- a/test/unit/ngsiv2/ngsiService/subscriptions-test.js +++ b/test/unit/ngsiv2/ngsiService/subscriptions-test.js @@ -64,17 +64,24 @@ describe('NGSI-v2 - Subscription tests', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/' + - 'contextRequests/createMinimumProvisionedDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/' + 'contextRequests/createMinimumProvisionedDevice.json' + ) + ) .reply(204); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/subscriptionRequests/simpleSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/subscriptionRequests/simpleSubscriptionRequest.json' + ) + ) + .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' }); iotAgentLib.clearAll(function() { request(optionsProvision, function(error, result, body) { @@ -95,7 +102,6 @@ describe('NGSI-v2 - Subscription tests', function() { describe('When a client invokes the subscribe() function for device', function() { it('should send the appropriate request to the Context Broker', function(done) { iotAgentLib.getDevice('MicroLight1', 'smartGondor', '/gardens', function(error, device) { - iotAgentLib.subscribe(device, ['attr_name'], null, function(error) { should.not.exist(error); @@ -136,7 +142,6 @@ describe('NGSI-v2 - Subscription tests', function() { iotAgentLib.subscribe(device, ['attr_name'], null, function(error) { iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function(error) { iotAgentLib.getDevice('MicroLight1', 'smartGondor', '/gardens', function(error, device) { - contextBrokerMock.done(); done(); }); @@ -195,14 +200,14 @@ describe('NGSI-v2 - Subscription tests', function() { var notificationOptions = { url: 'http://localhost:' + iotAgentConfig.server.port + '/notify', method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/examples/subscriptionRequests' + - '/simpleNotification.json'), + json: utils.readExampleFile( + './test/unit/ngsiv2/examples/subscriptionRequests' + '/simpleNotification.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' } }, - executedHandler = false; function mockedHandler(device, notification, callback) { @@ -223,8 +228,9 @@ describe('NGSI-v2 - Subscription tests', function() { var notificationOptions = { url: 'http://localhost:' + iotAgentConfig.server.port + '/notify', method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/examples/subscriptionRequests' + - '/simpleNotification.json'), + json: utils.readExampleFile( + './test/unit/ngsiv2/examples/subscriptionRequests' + '/simpleNotification.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -266,8 +272,9 @@ describe('NGSI-v2 - Subscription tests', function() { var notificationOptions = { url: 'http://localhost:' + iotAgentConfig.server.port + '/notify', method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/examples/subscriptionRequests/' + - 'simpleNotification.json'), + json: utils.readExampleFile( + './test/unit/ngsiv2/examples/subscriptionRequests/' + 'simpleNotification.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -276,8 +283,14 @@ describe('NGSI-v2 - Subscription tests', function() { rightFields = false; function mockedHandler(device, data, callback) { - if (device && device.id === 'MicroLight1' && device.name === 'FirstMicroLight' && - data && data.length === 1 && data[0].name === 'attr_name') { + if ( + device && + device.id === 'MicroLight1' && + device.name === 'FirstMicroLight' && + data && + data.length === 1 && + data[0].name === 'attr_name' + ) { rightFields = true; } @@ -299,14 +312,14 @@ describe('NGSI-v2 - Subscription tests', function() { var notificationOptions = { url: 'http://localhost:' + iotAgentConfig.server.port + '/notify', method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/examples/subscriptionRequests/' + - 'errorNotification.json'), + json: utils.readExampleFile( + './test/unit/ngsiv2/examples/subscriptionRequests/' + 'errorNotification.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' } }, - executedHandler = false; function mockedHandler(device, notification, callback) { diff --git a/test/unit/ngsiv2/plugins/alias-plugin_test.js b/test/unit/ngsiv2/plugins/alias-plugin_test.js index 0a26c44dd..ad6ccc00c 100644 --- a/test/unit/ngsiv2/plugins/alias-plugin_test.js +++ b/test/unit/ngsiv2/plugins/alias-plugin_test.js @@ -43,7 +43,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -51,8 +51,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), object_id: 't', name: 'temperature', type: 'Number', - metadata: { type: 'Property', value:'CEL'} - + metadata: { type: 'Property', value: 'CEL' } } ], active: [ @@ -60,15 +59,13 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), object_id: 'p', name: 'pressure', type: 'Number', - metadata: { type: 'Property', value:'Hgmm'} - + metadata: { type: 'Property', value: 'Hgmm' } }, { object_id: 'l', name: 'luminance', type: 'Number', - metadata: { type: 'Property', value:'CAL'} - + metadata: { type: 'Property', value: 'CAL' } }, { object_id: 'ut', @@ -151,20 +148,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and a different type', function() { var values = [ @@ -181,20 +182,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and integer type', function() { var values = [ @@ -211,9 +216,11 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json') + ) + .query({ type: 'Light' }) .reply(204); }); @@ -241,20 +248,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and float type', function() { @@ -272,20 +283,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and boolean type', function() { @@ -303,20 +318,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and None type', function() { @@ -334,20 +353,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and Array type', function() { @@ -365,20 +388,24 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); describe('When an update comes for attributes with aliases and Object type', function() { @@ -396,23 +423,26 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); - describe('When an update comes for attributes with aliases and Object type, but value is String', function() { var values = [ { @@ -428,19 +458,23 @@ describe('NGSI-v2 - Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json') + ) + .query({ type: 'Light' }) .reply(204); }); - it('should rename the attributes as expected by the alias mappings' + - 'and cast values to JSON native types', function(done) { - iotAgentLib.update('light1', 'Light', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); - }); + it( + 'should rename the attributes as expected by the alias mappings' + 'and cast values to JSON native types', + function(done) { + iotAgentLib.update('light1', 'Light', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + } + ); }); }); diff --git a/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js b/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js index fa5f985b0..a42f54aa2 100644 --- a/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +++ b/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js @@ -41,8 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), server: { port: 4041 }, - types: { - }, + types: {}, service: 'smartGondor', subservice: 'gardens', providerUrl: 'http://smartGondor.com' @@ -52,8 +51,9 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json'), + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -65,12 +65,11 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { iotAgentLib.activate(iotAgentConfig, function() { iotAgentLib.clearAll(function() { - iotAgentLib.addDeviceProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); + iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); iotAgentLib.addConfigurationProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.groupProvision); - iotAgentLib.addNotificationMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.notification); + iotAgentLib.dataPlugins.bidirectionalData.groupProvision + ); + iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); done(); }); }); @@ -87,17 +86,22 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile( - './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples/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/examples/contextRequests/createBidirectionalDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json') + ) .reply(204); - }); it('should subscribe to the modification of the combined attribute with all the variables', function(done) { @@ -123,15 +127,21 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile( - './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples/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/examples/contextRequests/createBidirectionalDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json') + ) .reply(204); contextBrokerMock @@ -156,8 +166,9 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { var notificationOptions = { url: 'http://localhost:' + iotAgentConfig.server.port + '/notify', method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/examples/subscriptionRequests/' + - 'bidirectionalNotification.json'), + json: utils.readExampleFile( + './test/unit/ngsiv2/examples/subscriptionRequests/' + 'bidirectionalNotification.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -169,15 +180,21 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile( - './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples/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/examples/contextRequests/createBidirectionalDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json') + ) .reply(204); }); @@ -236,7 +253,7 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { } } - transformedHandler = (values.length >= 2 && longitudeFound && latitudeFound); + transformedHandler = values.length >= 2 && longitudeFound && latitudeFound; callback(); } @@ -256,8 +273,7 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { var provisionGroup = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -267,7 +283,8 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json'), + './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -278,17 +295,22 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile( - './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples/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/examples/contextRequests/createBidirectionalDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json') + ) .reply(204); - }); it('should subscribe to the modification of the combined attribute with all the variables', function(done) { request(provisionGroup, function(error, response, body) { @@ -305,8 +327,7 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { var provisionGroup = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -315,8 +336,9 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { notificationOptions = { url: 'http://localhost:' + iotAgentConfig.server.port + '/notify', method: 'POST', - json: utils.readExampleFile('./test/unit/ngsiv2/examples/subscriptionRequests/' + - 'bidirectionalNotification.json'), + json: utils.readExampleFile( + './test/unit/ngsiv2/examples/subscriptionRequests/' + 'bidirectionalNotification.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -326,7 +348,8 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json'), + './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -337,15 +360,21 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile( - './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples/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/examples/contextRequests/createBidirectionalDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json') + ) .reply(204); }); @@ -370,7 +399,7 @@ describe('NGSI-v2 - Bidirectional data plugin', function() { } } - transformedHandler = (values.length >= 2 && longitudeFound && latitudeFound); + transformedHandler = values.length >= 2 && longitudeFound && latitudeFound; callback(); } @@ -392,8 +421,9 @@ describe('NGSI-v2 - Bidirectional data plugin and CB is defined using environmen var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json'), + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -405,12 +435,11 @@ describe('NGSI-v2 - Bidirectional data plugin and CB is defined using environmen process.env.IOTA_CB_HOST = 'cbhost'; iotAgentLib.activate(iotAgentConfig, function() { iotAgentLib.clearAll(function() { - iotAgentLib.addDeviceProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); + iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); iotAgentLib.addConfigurationProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.groupProvision); - iotAgentLib.addNotificationMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.notification); + iotAgentLib.dataPlugins.bidirectionalData.groupProvision + ); + iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); done(); }); }); @@ -428,17 +457,22 @@ describe('NGSI-v2 - Bidirectional data plugin and CB is defined using environmen contextBrokerMock = nock('http://cbhost:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/subscriptions', utils.readExampleFile( - './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(201, null, {'Location': '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8'}); + .post( + '/v2/subscriptions', + utils.readExampleFile( + './test/unit/ngsiv2/examples/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/examples/contextRequests/createBidirectionalDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json') + ) .reply(204); - }); it('should subscribe to the modification of the combined attribute with all the variables', function(done) { @@ -449,5 +483,4 @@ describe('NGSI-v2 - Bidirectional data plugin and CB is defined using environmen }); }); }); - }); diff --git a/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js b/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js index 9a3ff883e..73c4cd63d 100644 --- a/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +++ b/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -57,7 +57,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -72,7 +72,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -81,10 +81,9 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -96,15 +95,15 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -157,9 +156,13 @@ describe('NGSI-v2 - Timestamp compression plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -179,12 +182,11 @@ describe('NGSI-v2 - Timestamp compression plugin', function() { type: 'Boolean', value: true, metadata: { - TimeInstant: { + TimeInstant: { type: 'DateTime', value: '20071103T131805' } } - }, { name: 'TheTargetValue', @@ -199,9 +201,13 @@ describe('NGSI-v2 - Timestamp compression plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); @@ -215,10 +221,7 @@ describe('NGSI-v2 - Timestamp compression plugin', function() { }); describe('When a query comes for a timestamp through the plugin', function() { - var values = [ - 'state', - 'TheTargetValue' - ]; + var values = ['state', 'TheTargetValue']; beforeEach(function() { nock.cleanAll(); @@ -227,8 +230,12 @@ describe('NGSI-v2 - Timestamp compression plugin', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .get('/v2/entities/light1/attrs?attrs=state,TheTargetValue&type=Light') - .reply(200, utils.readExampleFile( - './test/unit/ngsiv2/examples/contextResponses/queryContextCompressTimestamp1Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextResponses/queryContextCompressTimestamp1Success.json' + ) + ); }); it('should return an entity with all its timestamps without separators (basic format)', function(done) { @@ -242,5 +249,4 @@ describe('NGSI-v2 - Timestamp compression plugin', function() { }); }); }); - }); diff --git a/test/unit/ngsiv2/plugins/event-plugin_test.js b/test/unit/ngsiv2/plugins/event-plugin_test.js index 0fe9a242d..a5fad6055 100644 --- a/test/unit/ngsiv2/plugins/event-plugin_test.js +++ b/test/unit/ngsiv2/plugins/event-plugin_test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -105,7 +105,7 @@ describe('NGSI-v2 - Event plugin', function() { return body.activation.value.match(dateRegex); }) - .query({type: 'Light'}) + .query({ type: 'Light' }) .reply(204); }); diff --git a/test/unit/ngsiv2/plugins/multientity-plugin_test.js b/test/unit/ngsiv2/plugins/multientity-plugin_test.js index 05e08ad36..23fd585da 100644 --- a/test/unit/ngsiv2/plugins/multientity-plugin_test.js +++ b/test/unit/ngsiv2/plugins/multientity-plugin_test.js @@ -44,7 +44,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'WeatherStation': { + WeatherStation: { commands: [], type: 'WeatherStation', lazy: [], @@ -63,7 +63,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStation2': { + WeatherStation2: { commands: [], type: 'WeatherStation', lazy: [], @@ -77,11 +77,11 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), object_id: 'h', name: 'humidity', type: 'Percentage', - entity_name: 'Higro2000', + entity_name: 'Higro2000' } ] }, - 'WeatherStation3': { + WeatherStation3: { commands: [], type: 'WeatherStation', lazy: [], @@ -95,11 +95,11 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), object_id: 'h', name: 'humidity', type: 'Percentage', - entity_name: 'Station Number ${@sn * 10}', + entity_name: 'Station Number ${@sn * 10}' } ] }, - 'WeatherStation5': { + WeatherStation5: { commands: [], type: 'WeatherStation', lazy: [], @@ -118,7 +118,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStation6': { + WeatherStation6: { commands: [], type: 'WeatherStation', lazy: [], @@ -139,7 +139,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStation7': { + WeatherStation7: { commands: [], type: 'WeatherStation', lazy: [], @@ -149,7 +149,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), name: 'pressure', type: 'Hgmm', metadata: { - unitCode:{type: 'Text', value :'Hgmm'} + unitCode: { type: 'Text', value: 'Hgmm' } }, entity_name: 'Higro2002', entity_type: 'Higrometer' @@ -163,60 +163,58 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), } ] }, - 'Sensor001': { + Sensor001: { commands: [], type: 'Sensor', lazy: [], active: [ { - type : 'number', - name : 'vol', - object_id : 'cont1', - entity_name : 'SO1', - entity_type : 'WM' + type: 'number', + name: 'vol', + object_id: 'cont1', + entity_name: 'SO1', + entity_type: 'WM' }, { - type : 'number', - name : 'vol', - object_id : 'cont2', - entity_name : 'SO2', - entity_type : 'WM' + type: 'number', + name: 'vol', + object_id: 'cont2', + entity_name: 'SO2', + entity_type: 'WM' }, { - type : 'number', - name : 'vol', - object_id : 'cont3', - entity_name : 'SO3', - entity_type : 'WM' + type: 'number', + name: 'vol', + object_id: 'cont3', + entity_name: 'SO3', + entity_type: 'WM' }, { - type : 'number', - name : 'vol', - object_id : 'cont4', - entity_name : 'SO4', - entity_type : 'WM' + type: 'number', + name: 'vol', + object_id: 'cont4', + entity_name: 'SO4', + entity_type: 'WM' }, { - type : 'number', - name : 'vol', - object_id : 'cont5', - entity_name : 'SO5', - entity_type : 'WM' + type: 'number', + name: 'vol', + object_id: 'cont5', + entity_name: 'SO5', + entity_type: 'WM' } ] - }, - 'SensorCommand':{ + SensorCommand: { commands: [ { - name: 'PING', - type: 'command' + name: 'PING', + type: 'command' } ], type: 'SensorCommand', lazy: [] } - }, service: 'smartGondor', subservice: 'gardens', @@ -263,8 +261,12 @@ describe('NGSI-v2 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json' + ) + ) .reply(204); }); @@ -292,8 +294,12 @@ describe('NGSI-v2 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json' + ) + ) .reply(204); }); @@ -326,8 +332,12 @@ describe('NGSI-v2 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json' + ) + ) .reply(204); }); @@ -361,8 +371,12 @@ describe('NGSI-v2 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json' + ) + ) .reply(204); }); @@ -375,7 +389,6 @@ describe('NGSI-v2 - Multi-entity plugin', function() { }); }); - describe('When an update comes for a multientity defined with an expression', function() { var values = [ { @@ -401,8 +414,12 @@ describe('NGSI-v2 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json' + ) + ) .reply(204); }); @@ -435,8 +452,12 @@ describe('NGSI-v2 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json' + ) + ) .reply(204); }); @@ -449,81 +470,94 @@ describe('NGSI-v2 - Multi-entity plugin', function() { }); }); - describe('When an update comes for a multientity measurement and there are attributes with' + - ' the same name but different alias and mapped to different CB entities', function() { - var values = [ - { - name: 'cont1', - type: 'number', - value: '38' - } - ]; - - beforeEach(function() { - nock.cleanAll(); - - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json')) - .reply(204); - }); + describe( + 'When an update comes for a multientity measurement and there are attributes with' + + ' the same name but different alias and mapped to different CB entities', + function() { + var values = [ + { + name: 'cont1', + type: 'number', + value: '38' + } + ]; - it('should update only the appropriate CB entity', function(done) { - iotAgentLib.update('Sensor', 'Sensor001', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + beforeEach(function() { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json' + ) + ) + .reply(204); }); - }); - }); - - describe('When an update comes for a multientity multi measurement and there are attributes with' + - ' the same name but different alias and mapped to different CB entities', function() { - var values = [ - { - name: 'cont1', - type: 'number', - value: '38' - }, - { - name: 'cont2', - type: 'number', - value: '39' - }, - { - name: 'cont3', - type: 'number', - value: '40' - }, - { - name: 'cont5', - type: 'number', - value: '42' - } - ]; - beforeEach(function() { - nock.cleanAll(); + it('should update only the appropriate CB entity', function(done) { + iotAgentLib.update('Sensor', 'Sensor001', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); + }); + } + ); + + describe( + 'When an update comes for a multientity multi measurement and there are attributes with' + + ' the same name but different alias and mapped to different CB entities', + function() { + var values = [ + { + name: 'cont1', + type: 'number', + value: '38' + }, + { + name: 'cont2', + type: 'number', + value: '39' + }, + { + name: 'cont3', + type: 'number', + value: '40' + }, + { + name: 'cont5', + type: 'number', + value: '42' + } + ]; - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json')) - .reply(204); - }); + beforeEach(function() { + nock.cleanAll(); + + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', 'gardens') + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json' + ) + ) + .reply(204); + }); - it('should update only the appropriate CB entity', function(done) { - iotAgentLib.update('Sensor', 'Sensor001', '', values, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + it('should update only the appropriate CB entity', function(done) { + iotAgentLib.update('Sensor', 'Sensor001', '', values, function(error) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); - }); - }); - + } + ); }); describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plugin', function() { @@ -580,32 +614,30 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu }); it('should send two context elements, one for each entity', function(done) { - contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/op/update', function(body) { - var expectedBody = utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextRequests/updateContextMultientityTimestampPlugin1.json'); + var expectedBody = utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextRequests/updateContextMultientityTimestampPlugin1.json' + ); // Note that TimeInstant fields are not included in the json used by this mock as they are dynamic // fields. The following code just checks that TimeInstant fields are present. - if (!body.entities[1].TimeInstant || !body.entities[1].humidity.metadata.TimeInstant) - { + if (!body.entities[1].TimeInstant || !body.entities[1].humidity.metadata.TimeInstant) { return false; - } - else { + } else { var timeInstantEntity = body.entities[1].TimeInstant; var timeInstantAtt = body.entities[1].humidity.metadata.TimeInstant; - if (moment(timeInstantEntity, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid && - moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) { - + if ( + moment(timeInstantEntity, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid && + moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid + ) { delete body.entities[1].TimeInstant; delete body.entities[1].humidity.metadata.TimeInstant; delete expectedBody.entities[1].TimeInstant; delete expectedBody.entities[1].humidity.metadata.TimeInstant; return JSON.stringify(body) === JSON.stringify(expectedBody); - } else { return false; } @@ -625,28 +657,26 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/op/update', function(body) { - var expectedBody = utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextRequests/updateContextMultientityTimestampPlugin2.json'); + var expectedBody = utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextRequests/updateContextMultientityTimestampPlugin2.json' + ); // Note that TimeInstant fields are not included in the json used by this mock as they are dynamic // fields. The following code just checks that TimeInstant fields are present. - if (!body.entities[1].TimeInstant || - !body.entities[1].humidity.metadata.TimeInstant) - { + if (!body.entities[1].TimeInstant || !body.entities[1].humidity.metadata.TimeInstant) { return false; - } - else { + } else { var timeInstantEntity2 = body.entities[1].TimeInstant; var timeInstantAtt = body.entities[1].humidity.metadata.TimeInstant; - if (moment(timeInstantEntity2, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid && - moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) { - + if ( + moment(timeInstantEntity2, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid && + moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid + ) { delete body.entities[1].TimeInstant; delete body.entities[1].humidity.metadata.TimeInstant; delete expectedBody.entities[1].TimeInstant; delete expectedBody.entities[1].humidity.metadata.TimeInstant; return JSON.stringify(body) === JSON.stringify(expectedBody); - } else { return false; } @@ -665,8 +695,12 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextRequests/updateContextMultientityTimestampPlugin3.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextRequests/updateContextMultientityTimestampPlugin3.json' + ) + ) .reply(204); var tsValue = [ @@ -692,7 +726,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu }); }); -describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a regular entity ', function () { +describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a regular entity ', function() { beforeEach(function(done) { logger.setLevel('FATAL'); @@ -718,23 +752,26 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r }); it('Should send the update to the context broker', function(done) { - contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextRequests/updateContextMultientityTimestampPlugin4.json')) + .post( + '/v2/op/update', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextRequests/updateContextMultientityTimestampPlugin4.json' + ) + ) .reply(204); var commands = [ { name: 'PING_status', type: 'commandStatus', - value: 'OK', + value: 'OK' }, { name: 'PING_info', type: 'commandResult', - value:'1234567890' + value: '1234567890' } ]; @@ -744,4 +781,4 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r done(); }); }); -}); \ No newline at end of file +}); diff --git a/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js b/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js index ff5b9ed1d..7bd8a10a5 100644 --- a/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +++ b/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -100,9 +100,13 @@ describe('NGSI-v2 - Timestamp processing plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/light1/attrs', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json')) - .query({type: 'Light'}) + .post( + '/v2/entities/light1/attrs', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json' + ) + ) + .query({ type: 'Light' }) .reply(204); }); diff --git a/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js b/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js index b53afe606..ee42dd483 100644 --- a/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +++ b/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js @@ -56,9 +56,13 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/registrations', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -85,15 +89,21 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/registrations', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json') + ) .reply(204); }); @@ -237,8 +247,10 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json') + ) .reply(204); done(); @@ -252,7 +264,6 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { }); }); - describe('When a device provisioning request with a timestamp provision attribute arrives to the IoTA', function() { var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', @@ -280,8 +291,10 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json') + ) .reply(204); done(); @@ -322,8 +335,10 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json') + ) .reply(204); done(); }); @@ -336,68 +351,69 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { }); }); - describe('When a device provisioning request arrives to the IoTA' + - 'and timestamp is enabled in configuration', function() { - var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', - method: 'POST', - json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': '/gardens' - } - }; + describe( + 'When a device provisioning request arrives to the IoTA' + 'and timestamp is enabled in configuration', + function() { + var options = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', + method: 'POST', + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': '/gardens' + } + }; - beforeEach(function(done) { - iotAgentLib.deactivate(function() { - iotAgentConfig.timestamp = true; - iotAgentLib.activate(iotAgentConfig, done); + beforeEach(function(done) { + iotAgentLib.deactivate(function() { + iotAgentConfig.timestamp = true; + iotAgentLib.activate(iotAgentConfig, done); + }); }); - }); - afterEach(function() { - iotAgentConfig.timestamp = false; - }); + afterEach(function() { + iotAgentConfig.timestamp = false; + }); - beforeEach(function(done) { - nock.cleanAll(); - contextBrokerMock = nock('http://192.168.1.1:1026') - .matchHeader('fiware-service', 'smartGondor') - .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', function(body) { - var expectedBody = utils.readExampleFile('./test/unit/ngsiv2/examples/' + - 'contextRequests/createTimeInstantMinimumDevice.json'); - if (!body.TimeInstant.value) - { - return false; - } - else if (moment(body.TimeInstant.value, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid()) - { - var timeInstantDiff = moment().diff(body.TimeInstant.value, 'milliseconds'); - if (timeInstantDiff < 500) { - delete body.TimeInstant; - - return JSON.stringify(body) === JSON.stringify(expectedBody); + beforeEach(function(done) { + nock.cleanAll(); + contextBrokerMock = nock('http://192.168.1.1:1026') + .matchHeader('fiware-service', 'smartGondor') + .matchHeader('fiware-servicepath', '/gardens') + .post('/v2/entities?options=upsert', function(body) { + var expectedBody = utils.readExampleFile( + './test/unit/ngsiv2/examples/' + 'contextRequests/createTimeInstantMinimumDevice.json' + ); + if (!body.TimeInstant.value) { + return false; + } else if (moment(body.TimeInstant.value, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid()) { + var timeInstantDiff = moment().diff(body.TimeInstant.value, 'milliseconds'); + if (timeInstantDiff < 500) { + delete body.TimeInstant; + + return JSON.stringify(body) === JSON.stringify(expectedBody); + } + + return false; + } else { + return false; } + }) + .reply(204); - return false; - } - else { - return false; - } - }) - .reply(204); - - done(); - }); - - it('should send the appropriate requests to the Context Broker', function(done) { - request(options, function(error, response, body) { - contextBrokerMock.done(); done(); }); - }); - }); + + it('should send the appropriate requests to the Context Broker', function(done) { + request(options, function(error, response, body) { + contextBrokerMock.done(); + done(); + }); + }); + } + ); describe('When a device provisioning request with the minimum required data arrives to the IoT Agent', function() { var options = { @@ -415,9 +431,12 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/' + - 'contextRequests/createMinimumProvisionedDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/' + 'contextRequests/createMinimumProvisionedDevice.json' + ) + ) .reply(204); done(); @@ -471,9 +490,12 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', + .post( + '/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createGeopointProvisionedDevice.json')) + './test/unit/ngsiv2/examples/contextRequests/createGeopointProvisionedDevice.json' + ) + ) .reply(204); done(); @@ -503,9 +525,12 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', + .post( + '/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createDatetimeProvisionedDevice.json')) + './test/unit/ngsiv2/examples/contextRequests/createDatetimeProvisionedDevice.json' + ) + ) .reply(204); done(); @@ -519,13 +544,13 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { }); }); - describe('When two devices with the same ID but different services arrive to the agent', function() { var options1 = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -535,7 +560,8 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), headers: { 'fiware-service': 'smartMordor', 'fiware-servicepath': '/electricity' @@ -545,16 +571,21 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { beforeEach(function(done) { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/' + - 'contextRequests/createMinimumProvisionedDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/' + 'contextRequests/createMinimumProvisionedDevice.json' + ) + ) .reply(204); - contextBrokerMock - .post('/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/examples/' + - 'contextRequests/createMinimumProvisionedDevice.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/' + 'contextRequests/createMinimumProvisionedDevice.json' + ) + ) .reply(204); done(); @@ -607,7 +638,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -616,7 +647,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/entities?options=upsert') - .replyWithError({'message': 'Description of the error', 'code': 'STRING_CODE'}); + .replyWithError({ message: 'Description of the error', code: 'STRING_CODE' }); done(); }); @@ -649,7 +680,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -658,7 +689,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/entities?options=upsert') - .replyWithError({'message': 'Description of the error', 'code': 123456789}); + .replyWithError({ message: 'Description of the error', code: 123456789 }); done(); }); @@ -682,7 +713,8 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json') + './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json' + ) }; it('should raise a MISSING_ATTRIBUTES error, indicating the missing attributes', function(done) { @@ -711,7 +743,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -741,7 +773,8 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json'), + './test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -799,7 +832,8 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { method: 'POST', headers: {}, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json') + './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json' + ) }; it('should raise a MISSING_HEADERS error, indicating the missing attributes', function(done) { @@ -812,21 +846,21 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { }); }); describe('When a device delete request arrives to the Agent for a not existing device', function() { - var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices/Light84', - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': '/gardens' - }, - method: 'DELETE' - }; - - it('should return a 404 error', function(done) { - request(options, function(error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(404); - done(); - }); - }); + var options = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices/Light84', + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': '/gardens' + }, + method: 'DELETE' + }; + + it('should return a 404 error', function(done) { + request(options, function(error, response, body) { + should.not.exist(error); + response.statusCode.should.equal(404); + done(); + }); + }); }); }); diff --git a/test/unit/ngsiv2/provisioning/device-registration_test.js b/test/unit/ngsiv2/provisioning/device-registration_test.js index d1f8c9bec..5f69418a6 100644 --- a/test/unit/ngsiv2/provisioning/device-registration_test.js +++ b/test/unit/ngsiv2/provisioning/device-registration_test.js @@ -41,7 +41,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -58,7 +58,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), service: 'smartGondor', subservice: 'gardens' }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -66,8 +66,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], service: 'smartGondor', subservice: 'gardens' } @@ -117,13 +116,13 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { .reply(204); var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/registrations', nockBody) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); - + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -132,9 +131,9 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { it('should register as ContextProvider of its lazy attributes', function(done) { iotAgentLib.register(device1, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + should.not.exist(error); + contextBrokerMock.done(); + done(); }); }); }); @@ -144,7 +143,8 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { nock.cleanAll(); var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') @@ -170,7 +170,8 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { beforeEach(function(done) { nock.cleanAll(); var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') @@ -199,12 +200,13 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { nock.cleanAll(); var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/registrations', nockBody) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -220,7 +222,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { }); }); - it('should return all the device\'s information', function(done) { + it(/*jshint quotmark: double */ "should return all the device's information" /*jshint quotmark: single */, function(done) { iotAgentLib.register(device1, function(error) { iotAgentLib.getDevice('light1', 'smartGondor', 'gardens', function(error, data) { should.not.exist(error); @@ -238,12 +240,13 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { nock.cleanAll(); var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v2/registrations', nockBody) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -265,41 +268,38 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { describe('When a device is removed from the IoT Agent', function() { beforeEach(function(done) { - nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); contextBrokerMock .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); contextBrokerMock .delete('/v2/registrations/6319a7f5254b05844116584d') - .reply(204, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); - + .reply(204, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); iotAgentLib.activate(iotAgentConfig, function(error) { - async.series([ - async.apply(iotAgentLib.clearAll), - async.apply(iotAgentLib.register, device1), - async.apply(iotAgentLib.register, device2) - ], done); + async.series( + [ + async.apply(iotAgentLib.clearAll), + async.apply(iotAgentLib.register, device1), + async.apply(iotAgentLib.register, device2) + ], + done + ); }); }); @@ -317,36 +317,33 @@ describe('NGSI-v2 - IoT Agent Device Registration', function() { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/8254b65a7d11650f45844319'}); + .reply(201, null, { Location: '/v2/registrations/8254b65a7d11650f45844319' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); - contextBrokerMock - .delete('/v2/registrations/6319a7f5254b05844116584d') - .reply(500); + contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d').reply(500); iotAgentLib.activate(iotAgentConfig, function(error) { - async.series([ - async.apply(iotAgentLib.clearAll), - async.apply(iotAgentLib.register, device1), - async.apply(iotAgentLib.register, device2) - ], done); + async.series( + [ + async.apply(iotAgentLib.clearAll), + async.apply(iotAgentLib.register, device1), + async.apply(iotAgentLib.register, device2) + ], + done + ); }); }); diff --git a/test/unit/ngsiv2/provisioning/device-update-registration_test.js b/test/unit/ngsiv2/provisioning/device-update-registration_test.js index 0d7b96240..2424a8e54 100644 --- a/test/unit/ngsiv2/provisioning/device-update-registration_test.js +++ b/test/unit/ngsiv2/provisioning/device-update-registration_test.js @@ -40,7 +40,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -57,7 +57,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), service: 'smartGondor', subservice: 'gardens' }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -65,8 +65,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], service: 'smartGondor', subservice: 'gardens' } @@ -79,7 +78,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), id: 'light1', type: 'Light', service: 'smartGondor', - subservice: 'gardens', + subservice: 'gardens' }, deviceUpdated = { id: 'light1', @@ -143,8 +142,8 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post('/v2/registrations') + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -174,8 +173,12 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/Light:light1/attrs?type=Light', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateProvisionActiveAttributes1.json')) + .post( + '/v2/entities/Light:light1/attrs?type=Light', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateProvisionActiveAttributes1.json' + ) + ) .reply(204); // FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch, @@ -190,10 +193,13 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextAvailabilityRequests/updateIoTAgent1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); - + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextAvailabilityRequests/updateIoTAgent1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); }); it('should register as ContextProvider of its lazy attributes', function(done) { @@ -219,13 +225,14 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { describe('When a device is preregistered and it is updated with new commands', function() { beforeEach(function() { - delete deviceCommandUpdated.registrationId; contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities/Light:light1/attrs?type=Light', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateProvisionCommands1.json')) + .post( + '/v2/entities/Light:light1/attrs?type=Light', + utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateProvisionCommands1.json') + ) .reply(204); // FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch, @@ -241,9 +248,13 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/registrations', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextAvailabilityRequests/updateCommands1.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextAvailabilityRequests/updateCommands1.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); }); it('should register as ContextProvider of its commands and create the additional attributes', function(done) { @@ -268,7 +279,6 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { }); describe('When a update action is executed in a non registered device', function() { - it('should return a DEVICE_NOT_FOUND error', function(done) { iotAgentLib.updateRegister(unknownDevice, function(error) { should.exist(error); @@ -279,13 +289,10 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function() { }); describe('When a device register is updated in the Context Broker and the request fail to connect', function() { beforeEach(function() { - // FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch, // this function should use the new API. This is just a temporary solution which implies deleting the // registration and creating a new one. - contextBrokerMock - .delete('/v2/registrations/6319a7f5254b05844116584d') - .reply(500, {}); + contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d').reply(500, {}); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') diff --git a/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js b/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js index f8b89a70c..7e36c5c0e 100644 --- a/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +++ b/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js @@ -23,7 +23,7 @@ * Modified by: Daniel Calvo - ATOS Research & Innovation */ - /* jshint camelcase: false */ +/* jshint camelcase: false */ 'use strict'; @@ -52,10 +52,7 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), }; describe('NGSI-v2 - Device provisioning API: List provisioned devices', function() { - var provisioning1Options, - provisioning2Options, - provisioning3Options, - provisioning4Options; + var provisioning1Options, provisioning2Options, provisioning3Options, provisioning4Options; beforeEach(function(done) { provisioning1Options = { @@ -91,45 +88,42 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function iotAgentLib.activate(iotAgentConfig, function() { contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); contextBrokerMock .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); contextBrokerMock .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock - .post('/v2/entities?options=upsert') - .reply(204); - - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning1Options), - async.apply(request, provisioning2Options), - async.apply(request, provisioning4Options) - ], function(error, results) { - done(); - }); + contextBrokerMock.post('/v2/entities?options=upsert').reply(204); + + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, provisioning1Options), + async.apply(request, provisioning2Options), + async.apply(request, provisioning4Options) + ], + function(error, results) { + done(); + } + ); }); }); @@ -188,7 +182,6 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function request(options, function(error, response, body) { var parsedBody = JSON.parse(body); - should.exist(parsedBody.devices[2].attributes[0].entity_name); should.exist(parsedBody.devices[2].attributes[0].entity_type); should.exist(parsedBody.devices[2].attributes[1].expression); @@ -331,7 +324,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations') .times(10) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -404,7 +397,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations') .times(10) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); iotAgentLib.clearAll(function() { async.timesSeries(10, createDeviceRequest, function(error, results) { @@ -446,12 +439,13 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionYetAnotherDevice.json') + './test/unit/examples/deviceProvisioningRequests/provisionYetAnotherDevice.json' + ) }; contextBrokerMock .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); request(provisioning3Options, function(error) { done(); diff --git a/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js b/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js index 2c2750cd7..fad5154d5 100644 --- a/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +++ b/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js @@ -26,7 +26,6 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), utils = require('../../../tools/utils'), - should = require('should'), nock = require('nock'), request = require('request'), @@ -70,23 +69,32 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/registrations', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + '/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json' + ) + ) .reply(204); }); var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', - json: utils.readExampleFile('./test/unit/examples/' + - 'deviceProvisioningRequests/provisionNewDeviceMultientity.json'), + json: utils.readExampleFile( + './test/unit/examples/' + 'deviceProvisioningRequests/provisionNewDeviceMultientity.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -104,8 +112,5 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function() { }); }); }); - }); }); - - diff --git a/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js b/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js index b6104b4e0..a548fe589 100644 --- a/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +++ b/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js @@ -74,19 +74,21 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' }, - json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/' + - 'provisionDeviceActiveAtts.json') + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/' + 'provisionDeviceActiveAtts.json' + ) }; beforeEach(function(done) { iotAgentLib.activate(iotAgentConfig, function() { var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations', nockBody) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -98,12 +100,13 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi .reply(204); var nockBody2 = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations', nockBody2) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -129,14 +132,17 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi .post('/v2/entities?options=upsert') .reply(204); - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning1Options), - async.apply(request, provisioning2Options), - async.apply(request, provisioning3Options) - ], function(error, results) { - done(); - }); + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, provisioning1Options), + async.apply(request, provisioning2Options), + async.apply(request, provisioning3Options) + ], + function(error, results) { + done(); + } + ); }); }); diff --git a/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js b/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js index 3b0bad02a..8560cfa86 100644 --- a/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +++ b/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js @@ -28,7 +28,6 @@ var iotAgentLib = require('../../../../lib/fiware-iotagent-lib'), utils = require('../../../tools/utils'), - should = require('should'), nock = require('nock'), contextBrokerMock, @@ -127,7 +126,7 @@ describe('NGSI-v2 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -182,7 +181,7 @@ describe('NGSI-v2 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -197,7 +196,7 @@ describe('NGSI-v2 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'AlternateService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -243,7 +242,7 @@ describe('NGSI-v2 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v2/registrations') - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -283,15 +282,24 @@ describe('NGSI-v2 - Provisioning API: Single service mode', function() { contextBrokerMock = nock('http://unexistentHost:1026') .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/registrations', utils.readExampleFile('./test/unit/ngsiv2/examples' + - '/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json')) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples' + + '/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json')) + .post( + '/v2/entities?options=upsert', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json' + ) + ) .reply(204); request(groupCreation, done); @@ -311,6 +319,5 @@ describe('NGSI-v2 - Provisioning API: Single service mode', function() { done(); }); }); - }); }); diff --git a/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js b/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js index a17ba8f07..752561161 100644 --- a/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +++ b/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js @@ -81,12 +81,13 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi nock.cleanAll(); iotAgentLib.activate(iotAgentConfig, function() { var nockBody = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations', nockBody) - .reply(201, null, {'Location': '/v2/registrations/6319a7f5254b05844116584d'}); + .reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -98,13 +99,14 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi .reply(204); var nockBody2 = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json' + ); nockBody2.expires = /.+/i; contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations', nockBody2) - .reply(201, null, {'Location': '/v2/registrations/6719a7f5254b058441165849'}); + .reply(201, null, { Location: '/v2/registrations/6719a7f5254b058441165849' }); // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under @@ -112,7 +114,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert') .reply(204); // FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch, @@ -125,19 +127,23 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi .reply(204); var nockBody3 = utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json'); + './test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json' + ); nockBody3.expires = /.+/i; contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v2/registrations', nockBody3) - .reply(201, null, {'Location': '/v2/registrations/4419a7f5254b058441165849'}); - - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning1Options), - async.apply(request, provisioning2Options) - ], done); + .reply(201, null, { Location: '/v2/registrations/4419a7f5254b058441165849' }); + + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, provisioning1Options), + async.apply(request, provisioning2Options) + ], + done + ); }); }); @@ -178,18 +184,24 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/registrations', - utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json')) - .reply(201, null, {'Location': '/v2/registrations/4419a7f5254b058441165849'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/4419a7f5254b058441165849' }); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/registrations', - utils.readExampleFile( - './test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent3.json')) - .reply(201, null, {'Location': '/v2/registrations/4419a7f52546658441165849'}); + .post( + '/v2/registrations', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent3.json' + ) + ) + .reply(201, null, { Location: '/v2/registrations/4419a7f52546658441165849' }); }); it('should return a 200 OK and no errors', function(done) { @@ -253,7 +265,8 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWithId.json') + './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWithId.json' + ) }; it('should raise a 400 error', function(done) { @@ -273,7 +286,8 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWrong.json') + './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWrong.json' + ) }; it('should raise a 400 error', function(done) { @@ -319,14 +333,15 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities/SecondMicroLight/attrs?type=MicroLights', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateProvisionMinimumDevice.json')) + .post( + '/v2/entities/SecondMicroLight/attrs?type=MicroLights', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateProvisionMinimumDevice.json' + ) + ) .reply(204); - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning3Options) - ], done); + async.series([iotAgentLib.clearAll, async.apply(request, provisioning3Options)], done); }); it('should not raise any error', function(done) { @@ -396,14 +411,15 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities/SecondMicroLight/attrs?type=MicroLights', utils.readExampleFile( - './test/unit/ngsiv2/examples/contextRequests/updateProvisionDeviceStatic.json')) + .post( + '/v2/entities/SecondMicroLight/attrs?type=MicroLights', + utils.readExampleFile( + './test/unit/ngsiv2/examples/contextRequests/updateProvisionDeviceStatic.json' + ) + ) .reply(204); - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning3Options) - ], done); + async.series([iotAgentLib.clearAll, async.apply(request, provisioning3Options)], done); }); it('should provision the attributes appropriately', function(done) { diff --git a/test/unit/plugins/alias-plugin_test.js b/test/unit/plugins/alias-plugin_test.js index 035bc1f35..a93da3528 100644 --- a/test/unit/plugins/alias-plugin_test.js +++ b/test/unit/plugins/alias-plugin_test.js @@ -39,7 +39,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -107,10 +107,14 @@ describe('Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextAliasPlugin.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextAliasPluginSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextAliasPlugin.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContextAliasPluginSuccess.json') + ); }); it('should rename the attributes as expected by the mappings', function(done) { @@ -136,10 +140,14 @@ describe('Attribute alias plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextAliasPlugin2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextAliasPlugin2Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextAliasPlugin2.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContextAliasPlugin2Success.json') + ); }); it('should rename the attributes as expected by the mappings', function(done) { diff --git a/test/unit/plugins/bidirectional-plugin_test.js b/test/unit/plugins/bidirectional-plugin_test.js index 471df057f..81384a7dc 100644 --- a/test/unit/plugins/bidirectional-plugin_test.js +++ b/test/unit/plugins/bidirectional-plugin_test.js @@ -39,7 +39,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -66,8 +66,9 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json'), + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -79,12 +80,11 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { iotAgentLib.activate(iotAgentConfig, function() { iotAgentLib.clearAll(function() { - iotAgentLib.addDeviceProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); + iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); iotAgentLib.addConfigurationProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.groupProvision); - iotAgentLib.addNotificationMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.notification); + iotAgentLib.dataPlugins.bidirectionalData.groupProvision + ); + iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); done(); }); }); @@ -101,19 +101,30 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile( + './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createBidirectionalDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json')); - + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createBidirectionalDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json') + ); }); it('should subscribe to the modification of the combined attribute with all the variables', function(done) { @@ -139,26 +150,44 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile( + './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createBidirectionalDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createBidirectionalDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/unsubscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/unsubscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); }); it('should remove its subscriptions from the Context Broker', function(done) { @@ -188,26 +217,44 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile( + './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createBidirectionalDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createBidirectionalDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/unsubscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/unsubscribeContext', + utils.readExampleFile('./test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); }); afterEach(function() { @@ -263,7 +310,7 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { } } - transformedHandler = (values.length >= 2 && longitudeFound && latitudeFound); + transformedHandler = values.length >= 2 && longitudeFound && latitudeFound; callback(); } @@ -282,8 +329,7 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { var provisionGroup = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -293,7 +339,8 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json'), + './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -304,19 +351,30 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile( + './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createBidirectionalDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json')); - + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createBidirectionalDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json') + ); }); it('should subscribe to the modification of the combined attribute with all the variables', function(done) { request(provisionGroup, function(error, response, body) { @@ -333,8 +391,7 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { var provisionGroup = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), + json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -353,7 +410,8 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json'), + './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -364,19 +422,30 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile( + './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createBidirectionalDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json')); - + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createBidirectionalDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json') + ); }); afterEach(function() { @@ -400,7 +469,7 @@ describe('NGSI-v1 - Bidirectional data plugin', function() { } } - transformedHandler = (values.length >= 2 && longitudeFound && latitudeFound); + transformedHandler = values.length >= 2 && longitudeFound && latitudeFound; callback(); } @@ -422,8 +491,9 @@ describe('Bidirectional data plugin and CB is defined using environment variable var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', - json: - utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json'), + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -435,12 +505,11 @@ describe('Bidirectional data plugin and CB is defined using environment variable process.env.IOTA_CB_HOST = 'cbhost'; iotAgentLib.activate(iotAgentConfig, function() { iotAgentLib.clearAll(function() { - iotAgentLib.addDeviceProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); + iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision); iotAgentLib.addConfigurationProvisionMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.groupProvision); - iotAgentLib.addNotificationMiddleware( - iotAgentLib.dataPlugins.bidirectionalData.notification); + iotAgentLib.dataPlugins.bidirectionalData.groupProvision + ); + iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification); done(); }); }); @@ -458,19 +527,30 @@ describe('Bidirectional data plugin and CB is defined using environment variable contextBrokerMock = nock('http://cbhost:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/subscribeContext', utils.readExampleFile( - './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json')); + .post( + '/v1/subscribeContext', + utils.readExampleFile( + './test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createBidirectionalDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json')); - + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createBidirectionalDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json') + ); }); it('should subscribe to the modification of the combined attribute with all the variables', function(done) { diff --git a/test/unit/plugins/capture-configuration-inPlugins_test.js b/test/unit/plugins/capture-configuration-inPlugins_test.js index d244162cc..6a1e0957b 100644 --- a/test/unit/plugins/capture-configuration-inPlugins_test.js +++ b/test/unit/plugins/capture-configuration-inPlugins_test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -114,7 +114,6 @@ describe('Data Mapping Plugins: configuration provision', function() { }); }); - afterEach(function(done) { iotAgentLib.clearAll(function() { iotAgentLib.deactivate(done); diff --git a/test/unit/plugins/capture-provision-inPlugins_test.js b/test/unit/plugins/capture-provision-inPlugins_test.js index ad192f2ab..a36a2badd 100644 --- a/test/unit/plugins/capture-provision-inPlugins_test.js +++ b/test/unit/plugins/capture-provision-inPlugins_test.js @@ -39,7 +39,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -81,25 +81,34 @@ describe('Data Mapping Plugins: device provision', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); }); }); - afterEach(function(done) { iotAgentLib.clearAll(function() { iotAgentLib.deactivate(done); @@ -156,7 +165,6 @@ describe('Data Mapping Plugins: device provision', function() { executed.should.equal(true); done(); }); - }); }); @@ -193,7 +201,6 @@ describe('Data Mapping Plugins: device provision', function() { executed.should.equal(false); done(); }); - }); }); }); diff --git a/test/unit/plugins/compress-timestamp-plugin_test.js b/test/unit/plugins/compress-timestamp-plugin_test.js index 699ed40d1..736bdc37d 100644 --- a/test/unit/plugins/compress-timestamp-plugin_test.js +++ b/test/unit/plugins/compress-timestamp-plugin_test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -54,7 +54,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -69,7 +69,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -78,10 +78,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -93,15 +92,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -156,10 +155,16 @@ describe('NGSI-v1 - Timestamp compression plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextCompressTimestamp1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextCompressTimestamp1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCompressTimestamp1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextCompressTimestamp1Success.json' + ) + ); }); it('should return an entity with all its timestamps expanded to have separators', function(done) { @@ -198,10 +203,16 @@ describe('NGSI-v1 - Timestamp compression plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextCompressTimestamp2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextCompressTimestamp2Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextCompressTimestamp2.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextCompressTimestamp2Success.json' + ) + ); }); it('should return an entity with all its timestamps expanded to have separators', function(done) { @@ -214,10 +225,7 @@ describe('NGSI-v1 - Timestamp compression plugin', function() { }); describe('When a query comes for a timestamp through the plugin', function() { - var values = [ - 'state', - 'The Target Value' - ]; + var values = ['state', 'The Target Value']; beforeEach(function() { nock.cleanAll(); @@ -225,10 +233,16 @@ describe('NGSI-v1 - Timestamp compression plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/queryContext', utils.readExampleFile( - './test/unit/examples/contextRequests/queryContextCompressTimestamp1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/queryContextCompressTimestamp1Success.json')); + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContextCompressTimestamp1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/queryContextCompressTimestamp1Success.json' + ) + ); }); it('should return an entity with all its timestamps without separators (basic format)', function(done) { diff --git a/test/unit/plugins/event-plugin_test.js b/test/unit/plugins/event-plugin_test.js index 69222e3bd..54f989b87 100644 --- a/test/unit/plugins/event-plugin_test.js +++ b/test/unit/plugins/event-plugin_test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -104,8 +104,10 @@ describe('NGSI-v1 - Event plugin', function() { return body.contextElements['0'].attributes['1'].value.match(dateRegex); }) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextEvents1Success.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateContextEvents1Success.json') + ); }); it('should return an entity with all its timestamps expanded to have separators', function(done) { diff --git a/test/unit/plugins/multientity-plugin_test.js b/test/unit/plugins/multientity-plugin_test.js index 06ea97751..15d61767d 100644 --- a/test/unit/plugins/multientity-plugin_test.js +++ b/test/unit/plugins/multientity-plugin_test.js @@ -39,7 +39,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'WeatherStation': { + WeatherStation: { commands: [], type: 'WeatherStation', lazy: [], @@ -58,7 +58,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'WeatherStation2': { + WeatherStation2: { commands: [], type: 'WeatherStation', lazy: [], @@ -72,11 +72,11 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), object_id: 'h', name: 'humidity', type: 'Percentage', - entity_name: 'Higro2000', + entity_name: 'Higro2000' } ] }, - 'WeatherStation3': { + WeatherStation3: { commands: [], type: 'WeatherStation', lazy: [], @@ -90,7 +90,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), object_id: 'h', name: 'humidity', type: 'Percentage', - entity_name: 'Station Number ${@sn * 10}', + entity_name: 'Station Number ${@sn * 10}' } ] } @@ -141,10 +141,16 @@ describe('NGSI-v1 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextMultientityPlugin1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextMultientityPlugin1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextMultientityPlugin1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextMultientityPlugin1Success.json' + ) + ); }); it('should send two context elements, one for each entity', function(done) { @@ -156,9 +162,6 @@ describe('NGSI-v1 - Multi-entity plugin', function() { }); }); - - - describe('When an update comes for a multientity defined with an expression', function() { var values = [ { @@ -184,10 +187,16 @@ describe('NGSI-v1 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextMultiEntityPlugin3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextMultientityPlugin3Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextMultiEntityPlugin3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextMultientityPlugin3Success.json' + ) + ); }); it('should send the update value to the resulting value of the expression', function(done) { @@ -199,7 +208,6 @@ describe('NGSI-v1 - Multi-entity plugin', function() { }); }); - describe('When an update comes for a multientity measurement without type for one entity', function() { var values = [ { @@ -220,10 +228,16 @@ describe('NGSI-v1 - Multi-entity plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextMultientityPlugin2.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextMultientityPlugin2Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextMultientityPlugin2.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextMultientityPlugin2Success.json' + ) + ); }); it('should use the device type as a default value', function(done) { diff --git a/test/unit/plugins/timestamp-processing-plugin_test.js b/test/unit/plugins/timestamp-processing-plugin_test.js index 2ad00aee3..e346862ff 100644 --- a/test/unit/plugins/timestamp-processing-plugin_test.js +++ b/test/unit/plugins/timestamp-processing-plugin_test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -98,10 +98,16 @@ describe('NGSI-v1 - Timestamp processing plugin', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateContextProcessTimestamp1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateContextProcessTimestamp1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextProcessTimestamp1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextResponses/updateContextProcessTimestamp1Success.json' + ) + ); }); it('should return an entity with all its timestamps expanded to have separators', function(done) { diff --git a/test/unit/plugins/translation-inPlugins_test.js b/test/unit/plugins/translation-inPlugins_test.js index 620bf79cc..a93bccc94 100644 --- a/test/unit/plugins/translation-inPlugins_test.js +++ b/test/unit/plugins/translation-inPlugins_test.js @@ -37,7 +37,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], type: 'Light', lazy: [ @@ -53,7 +53,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'BrokenLight': { + BrokenLight: { commands: [], lazy: [ { @@ -68,7 +68,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Termometer': { + Termometer: { type: 'Termometer', commands: [], lazy: [ @@ -77,10 +77,9 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ] + active: [] }, - 'Humidity': { + Humidity: { type: 'Humidity', cbHost: 'http://192.168.1.1:3024', commands: [], @@ -92,15 +91,15 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), } ] }, - 'Motion': { + Motion: { type: 'Motion', commands: [], lazy: [], staticAttributes: [ { - 'name': 'location', - 'type': 'Vector', - 'value': '(123,523)' + name: 'location', + type: 'Vector', + value: '(123,523)' } ], active: [ @@ -139,10 +138,11 @@ describe('Data Mapping Plugins: translation', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContextMiddleware1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContextMiddleware1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); }); it('should execute the translation middlewares', function(done) { @@ -205,12 +205,8 @@ describe('Data Mapping Plugins: translation', function() { }); }); - describe('When a new query translation middleware is added to the IoT Agent', function() { - var attributes = [ - 'state', - 'dimming' - ]; + var attributes = ['state', 'dimming']; beforeEach(function() { nock.cleanAll(); @@ -218,10 +214,11 @@ describe('Data Mapping Plugins: translation', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/queryContext', - utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); + .post( + '/v1/queryContext', + utils.readExampleFile('./test/unit/examples/contextRequests/queryContext1.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/queryContext1Success.json')); }); it('should call the middleware', function(done) { @@ -245,8 +242,7 @@ describe('Data Mapping Plugins: translation', function() { }); }); it('should call the middleware', function(done) { - function testMiddleware(entity, typeInformation, - callback) { + function testMiddleware(entity, typeInformation, callback) { entity.contextResponses[0].contextElement.attributes[1].value = entity.contextResponses[0].contextElement.attributes[1].value + '%'; diff --git a/test/unit/provisioning/device-group-api-test.js b/test/unit/provisioning/device-group-api-test.js index 45f9b70dc..80b362db7 100644 --- a/test/unit/provisioning/device-group-api-test.js +++ b/test/unit/provisioning/device-group-api-test.js @@ -190,7 +190,6 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), }; describe('Device Group Configuration API', function() { - beforeEach(function(done) { iotAgentLib.activate(iotAgentConfig, function() { groupRegistryMemory.clear(done); @@ -377,63 +376,92 @@ describe('Device Group Configuration API', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/unregisterProvisionedDevice.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/unregisterProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - async.series([ - iotAgentLib.clearAll, - async.apply(request, optionsCreation), - async.apply(request, optionsDeviceCreation) - ], done); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); + + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, optionsCreation), + async.apply(request, optionsDeviceCreation) + ], + done + ); }); it('should remove all associated devices', function(done) { - var options = { - url: 'http://localhost:4041/iot/devices/Light1', - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/testingPath' - }, - method: 'GET' - }; - - function test (error, response, body) { - response.statusCode.should.equal(404); - done(); - } - - async.series([ - async.apply(request, optionsDeleteDevice), - async.apply(request, options), - async.apply(request, options, test), - ], done); + var options = { + url: 'http://localhost:4041/iot/devices/Light1', + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/testingPath' + }, + method: 'GET' + }; + + function test(error, response, body) { + response.statusCode.should.equal(404); + done(); + } + + async.series( + [ + async.apply(request, optionsDeleteDevice), + async.apply(request, options), + async.apply(request, options, test) + ], + done + ); }); it('should call the remove configuration handler', function(done) { @@ -502,7 +530,7 @@ describe('Device Group Configuration API', function() { }); }); }); - + describe('When a device group removal arrives to a DB with three groups', function() { beforeEach(function(done) { var optionsCreation1 = _.clone(optionsCreation), @@ -518,11 +546,14 @@ describe('Device Group Configuration API', function() { optionsCreation1.json.services[0].apikey = 'qwertyuiop'; optionsCreation3.json.services[0].apikey = 'lkjhgfds'; - async.series([ - async.apply(request, optionsCreation1), - async.apply(request, optionsCreation2), - async.apply(request, optionsCreation3) - ], done); + async.series( + [ + async.apply(request, optionsCreation1), + async.apply(request, optionsCreation2), + async.apply(request, optionsCreation3) + ], + done + ); }); it('should remove just the selected group', function(done) { @@ -587,7 +618,6 @@ describe('Device Group Configuration API', function() { optionsCreation2 = _.clone(optionsCreation), optionsCreation3 = _.clone(optionsCreation); - optionsCreation1.json = { services: [] }; optionsCreation3.json = { services: [] }; @@ -597,11 +627,14 @@ describe('Device Group Configuration API', function() { optionsCreation1.json.services[0].apikey = 'qwertyuiop'; optionsCreation3.json.services[0].apikey = 'lkjhgfds'; - async.series([ - async.apply(request, optionsCreation1), - async.apply(request, optionsCreation2), - async.apply(request, optionsCreation3) - ], done); + async.series( + [ + async.apply(request, optionsCreation1), + async.apply(request, optionsCreation2), + async.apply(request, optionsCreation3) + ], + done + ); }); it('should return a 204 OK', function(done) { @@ -619,8 +652,10 @@ describe('Device Group Configuration API', function() { body.count.should.equal(3); for (var i = 0; i < body.services.length; i++) { - if (body.services[i].apikey === '801230BJKL23Y9090DSFL123HJK09H324HV8732' && - body.services[i].resource === '/deviceTest') { + if ( + body.services[i].apikey === '801230BJKL23Y9090DSFL123HJK09H324HV8732' && + body.services[i].resource === '/deviceTest' + ) { body.services[i].cbHost.should.equal('http://anotherUnexistentHost:1026'); body.services[i].static_attributes.length.should.equal(1); found = true; @@ -665,7 +700,6 @@ describe('Device Group Configuration API', function() { optionsUpdate.headers['fiware-service'] = 'TestService'; }); - it('should return a 200 OK', function(done) { request(optionsUpdate, function(error, response, body) { should.not.exist(error); @@ -686,7 +720,6 @@ describe('Device Group Configuration API', function() { optionsUpdate.headers['fiware-servicepath'] = '/testingPath'; }); - it('should return a 200 OK', function(done) { request(optionsUpdate, function(error, response, body) { should.not.exist(error); @@ -741,7 +774,6 @@ describe('Device Group Configuration API', function() { optionsCreation2 = _.clone(optionsCreation), optionsCreation3 = _.clone(optionsCreation); - optionsCreation2.json = { services: [] }; optionsCreation3.json = { services: [] }; @@ -751,11 +783,14 @@ describe('Device Group Configuration API', function() { optionsCreation2.json.services[0].apikey = 'qwertyuiop'; optionsCreation3.json.services[0].apikey = 'lkjhgfds'; - async.series([ - async.apply(request, optionsCreation1), - async.apply(request, optionsCreation2), - async.apply(request, optionsCreation3) - ], done); + async.series( + [ + async.apply(request, optionsCreation1), + async.apply(request, optionsCreation2), + async.apply(request, optionsCreation3) + ], + done + ); }); it('should return a 200 OK', function(done) { @@ -778,9 +813,7 @@ describe('Device Group Configuration API', function() { describe('When a device info request arrives', function() { beforeEach(function(done) { - async.series([ - async.apply(request, optionsCreation) - ], done); + async.series([async.apply(request, optionsCreation)], done); }); it('should return a 200 OK', function(done) { @@ -814,14 +847,13 @@ describe('Device Group Configuration API', function() { contextBrokerMock = nock('http://unexistentHost:1026') .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateContext3WithStatic.json') + ) + .reply(200, utils.readExampleFile('./test/unit/examples/contextResponses/updateContext1Success.json')); - async.series([ - async.apply(request, optionsCreation) - ], done); + async.series([async.apply(request, optionsCreation)], done); }); afterEach(function(done) { @@ -830,29 +862,30 @@ describe('Device Group Configuration API', function() { }); it('should use the configured data', function(done) { - iotAgentLib.update('machine1', 'SensorMachine', '801230BJKL23Y9090DSFL123HJK09H324HV8732', values, - function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); - }); + iotAgentLib.update('machine1', 'SensorMachine', '801230BJKL23Y9090DSFL123HJK09H324HV8732', values, function( + error + ) { + should.not.exist(error); + contextBrokerMock.done(); + done(); + }); }); }); describe('When a group listing request arrives with offset and limit parameters', function() { var optConstrainedList = { - url: 'http://localhost:4041/iot/services', - method: 'GET', - qs: { - limit: 3, - offset: 2 - }, - json: {}, - headers: { - 'fiware-service': 'TestService', - 'fiware-servicepath': '/*' - } - }; + url: 'http://localhost:4041/iot/services', + method: 'GET', + qs: { + limit: 3, + offset: 2 + }, + json: {}, + headers: { + 'fiware-service': 'TestService', + 'fiware-servicepath': '/*' + } + }; beforeEach(function(done) { var optionsCreationList = [], diff --git a/test/unit/provisioning/device-group-utils_test.js b/test/unit/provisioning/device-group-utils_test.js index fa2f5a2b9..08b53b991 100644 --- a/test/unit/provisioning/device-group-utils_test.js +++ b/test/unit/provisioning/device-group-utils_test.js @@ -59,7 +59,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), baseRoot: '/' }, types: { - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -67,8 +67,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], apikey: '1234567890asdfghjkl', service: 'TestService', subservice: '/testingPath' @@ -90,11 +89,14 @@ describe('Device Group utils', function() { describe('When an API Key is requested for a device in a group without the SingleConfiguration mode', function() { beforeEach(function(done) { - async.series([ - async.apply(iotAgentLib.activate, iotAgentConfig), - async.apply(request, alternateGroupCreation), - async.apply(request, groupCreation) - ], done); + async.series( + [ + async.apply(iotAgentLib.activate, iotAgentConfig), + async.apply(request, alternateGroupCreation), + async.apply(request, groupCreation) + ], + done + ); }); it('should return the API Key of the group', function(done) { iotAgentLib.getEffectiveApiKey('TestService', '/testingPath', 'AnotherMachine', function(error, apiKey) { diff --git a/test/unit/provisioning/device-provisioning-api_test.js b/test/unit/provisioning/device-provisioning-api_test.js index 964ff03ee..3140c6173 100644 --- a/test/unit/provisioning/device-provisioning-api_test.js +++ b/test/unit/provisioning/device-provisioning-api_test.js @@ -24,7 +24,6 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), utils = require('../../tools/utils'), - should = require('should'), nock = require('nock'), request = require('request'), @@ -54,17 +53,27 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.clearAll(done); }); @@ -83,18 +92,30 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); }); var options = { @@ -237,10 +258,14 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/createTimeinstantDevice.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/createTimeinstantSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createTimeinstantDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createTimeinstantSuccess.json') + ); done(); }); @@ -269,10 +294,14 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); done(); }); @@ -325,12 +354,16 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', - utils.readExampleFile( - './test/unit/examples/contextRequests/createGeopointProvisionedDevice.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createGeopointProvisionedDevice.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/createGeopointProvisionedDeviceSuccess.json')); + './test/unit/examples/contextResponses/createGeopointProvisionedDeviceSuccess.json' + ) + ); done(); }); @@ -359,12 +392,16 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createDatetimeProvisionedDevice.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextRequests/createDatetimeProvisionedDevice.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createDatetimeProvisionedDeviceSuccess.json')); + './test/unit/examples/contextResponses/createDatetimeProvisionedDeviceSuccess.json' + ) + ); done(); }); @@ -377,13 +414,13 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { }); }); - describe('When two devices with the same ID but different services arrive to the agent', function() { var options1 = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -393,7 +430,8 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'), + './test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json' + ), headers: { 'fiware-service': 'smartMordor', 'fiware-servicepath': '/electricity' @@ -403,17 +441,24 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { beforeEach(function(done) { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock - .post('/v1/updateContext', - utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json')) - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/createMinimumProvisionedDevice.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); done(); }); @@ -465,15 +510,18 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/NGSI9/registerContext') - .reply(200, + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .replyWithError({'message': 'Description of the error', 'code': 'STRING_CODE'}); + .replyWithError({ message: 'Description of the error', code: 'STRING_CODE' }); done(); }); @@ -506,15 +554,18 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/NGSI9/registerContext') - .reply(200, + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .replyWithError({'message': 'Description of the error', 'code': 123456789}); + .replyWithError({ message: 'Description of the error', code: 123456789 }); done(); }); @@ -538,7 +589,8 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json') + './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json' + ) }; it('should raise a MISSING_ATTRIBUTES error, indicating the missing attributes', function(done) { @@ -566,18 +618,27 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); done(); }); @@ -598,7 +659,8 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json'), + './test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -656,7 +718,8 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { method: 'POST', headers: {}, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json') + './test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json' + ) }; it('should raise a MISSING_HEADERS error, indicating the missing attributes', function(done) { @@ -669,21 +732,21 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { }); }); describe('When a device delete request arrives to the Agent for a not existing device', function() { - var options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices/Light84', - headers: { - 'fiware-service': 'smartGondor', - 'fiware-servicepath': '/gardens' - }, - method: 'DELETE' - }; - - it('should return a 404 error', function(done) { - request(options, function(error, response, body) { - should.not.exist(error); - response.statusCode.should.equal(404); - done(); - }); - }); + var options = { + url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices/Light84', + headers: { + 'fiware-service': 'smartGondor', + 'fiware-servicepath': '/gardens' + }, + method: 'DELETE' + }; + + it('should return a 404 error', function(done) { + request(options, function(error, response, body) { + should.not.exist(error); + response.statusCode.should.equal(404); + done(); + }); + }); }); }); diff --git a/test/unit/provisioning/device-registration_test.js b/test/unit/provisioning/device-registration_test.js index f4afdfd16..71f9e49d1 100644 --- a/test/unit/provisioning/device-registration_test.js +++ b/test/unit/provisioning/device-registration_test.js @@ -38,7 +38,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -55,7 +55,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), service: 'smartGondor', subservice: 'gardens' }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -63,8 +63,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], service: 'smartGondor', subservice: 'gardens' } @@ -93,7 +92,7 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { }); afterEach(function(done) { - delete(device1.registrationId); + delete device1.registrationId; iotAgentLib.clearAll(function() { iotAgentLib.deactivate(done); }); @@ -106,17 +105,25 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -125,9 +132,9 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { it('should register as ContextProvider of its lazy attributes', function(done) { iotAgentLib.register(device1, function(error) { - should.not.exist(error); - contextBrokerMock.done(); - done(); + should.not.exist(error); + contextBrokerMock.done(); + done(); }); }); }); @@ -139,10 +146,16 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json' + ) + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -166,10 +179,16 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(500, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 500, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json' + ) + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -195,24 +214,33 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); }); }); - it('should return all the device\'s information', function(done) { + it(/*jshint quotmark: double */ + "should return all the device's information" /*jshint quotmark: single */, function(done) { iotAgentLib.register(device1, function(error) { iotAgentLib.getDevice('light1', 'smartGondor', 'gardens', function(error, data) { should.not.exist(error); @@ -232,10 +260,16 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json' + ) + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.clearAll(done); @@ -257,44 +291,61 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { describe('When a device is removed from the IoT Agent', function() { beforeEach(function(done) { - var expectedPayload3 = utils - .readExampleFile('./test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json'); + var expectedPayload3 = utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json' + ); nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext', expectedPayload3) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json')); - + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json' + ) + ); iotAgentLib.activate(iotAgentConfig, function(error) { - async.series([ - async.apply(iotAgentLib.clearAll), - async.apply(iotAgentLib.register, device1), - async.apply(iotAgentLib.register, device2) - ], done); + async.series( + [ + async.apply(iotAgentLib.clearAll), + async.apply(iotAgentLib.register, device1), + async.apply(iotAgentLib.register, device2) + ], + done + ); }); }); @@ -309,43 +360,61 @@ describe('NGSI-v1 - IoT Agent Device Registration', function() { describe('When the Context Broker returns an error while unregistering a device', function() { beforeEach(function(done) { - var expectedPayload3 = utils - .readExampleFile('./test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json'); + var expectedPayload3 = utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json' + ); nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext', expectedPayload3) - .reply(500, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Failed.json')); + .reply( + 500, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Failed.json' + ) + ); iotAgentLib.activate(iotAgentConfig, function(error) { - async.series([ - async.apply(iotAgentLib.clearAll), - async.apply(iotAgentLib.register, device1), - async.apply(iotAgentLib.register, device2) - ], done); + async.series( + [ + async.apply(iotAgentLib.clearAll), + async.apply(iotAgentLib.register, device1), + async.apply(iotAgentLib.register, device2) + ], + done + ); }); }); diff --git a/test/unit/provisioning/device-update-registration_test.js b/test/unit/provisioning/device-update-registration_test.js index fac26d653..bb49c08b4 100644 --- a/test/unit/provisioning/device-update-registration_test.js +++ b/test/unit/provisioning/device-update-registration_test.js @@ -37,7 +37,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), port: 4041 }, types: { - 'Light': { + Light: { commands: [], lazy: [ { @@ -54,7 +54,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), service: 'smartGondor', subservice: 'gardens' }, - 'Termometer': { + Termometer: { commands: [], lazy: [ { @@ -62,8 +62,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), type: 'kelvin' } ], - active: [ - ], + active: [], service: 'smartGondor', subservice: 'gardens' } @@ -77,7 +76,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), id: 'light1', type: 'Light', service: 'smartGondor', - subservice: 'gardens', + subservice: 'gardens' }, deviceUpdated = { id: 'light1', @@ -141,15 +140,19 @@ describe('NGSI-v1 - IoT Agent Device Update Registration', function() { .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.activate(iotAgentConfig, function(error) { iotAgentLib.register(device1, function(error) { @@ -168,19 +171,30 @@ describe('NGSI-v1 - IoT Agent Device Update Registration', function() { describe('When a device is preregistered and its registration information updated', function() { beforeEach(function() { contextBrokerMock - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateProvisionActiveAttributes1Success.json')); + './test/unit/examples/contextResponses/updateProvisionActiveAttributes1Success.json' + ) + ); }); it('should register as ContextProvider of its lazy attributes', function(done) { @@ -209,17 +223,26 @@ describe('NGSI-v1 - IoT Agent Device Update Registration', function() { contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateProvisionCommands1.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/updateProvisionCommands1Success.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateProvisionCommands1.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateProvisionCommands1Success.json') + ); contextBrokerMock - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/updateCommands1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/updateCommands1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateCommands1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/updateCommands1Success.json' + ) + ); }); it('should register as ContextProvider of its commands and create the additional attributes', function(done) { @@ -246,10 +269,16 @@ describe('NGSI-v1 - IoT Agent Device Update Registration', function() { describe('When a update action is executed in a non registered device', function() { beforeEach(function() { contextBrokerMock - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json' + ) + ); }); it('should return a DEVICE_NOT_FOUND error', function(done) { @@ -263,16 +292,20 @@ describe('NGSI-v1 - IoT Agent Device Update Registration', function() { describe('When a device register is updated in the Context Broker and the request fail to connect', function() { beforeEach(function() { contextBrokerMock - .post('/NGSI9/registerContext', - utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json')) + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json') + ) .reply(500, {}); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', 'gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); }); it('should return a REGISTRATION_ERROR error in the update action', function(done) { diff --git a/test/unit/provisioning/listProvisionedDevices-test.js b/test/unit/provisioning/listProvisionedDevices-test.js index d8ce019d0..2c6a9113b 100644 --- a/test/unit/provisioning/listProvisionedDevices-test.js +++ b/test/unit/provisioning/listProvisionedDevices-test.js @@ -49,10 +49,7 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), }; describe('NGSI-v1 - Device provisioning API: List provisioned devices', function() { - var provisioning1Options, - provisioning2Options, - provisioning3Options, - provisioning4Options; + var provisioning1Options, provisioning2Options, provisioning3Options, provisioning4Options; beforeEach(function(done) { provisioning1Options = { @@ -88,48 +85,63 @@ describe('NGSI-v1 - Device provisioning API: List provisioned devices', function iotAgentLib.activate(iotAgentConfig, function() { contextBrokerMock = nock('http://192.168.1.1:1026') .post('/NGSI9/registerContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .post('/NGSI9/registerContext') - .reply(200, + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning1Options), - async.apply(request, provisioning2Options), - async.apply(request, provisioning4Options) - ], function(error, results) { - done(); - }); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); + + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, provisioning1Options), + async.apply(request, provisioning2Options), + async.apply(request, provisioning4Options) + ], + function(error, results) { + done(); + } + ); }); }); @@ -188,7 +200,6 @@ describe('NGSI-v1 - Device provisioning API: List provisioned devices', function request(options, function(error, response, body) { var parsedBody = JSON.parse(body); - should.exist(parsedBody.devices[2].attributes[0].entity_name); should.exist(parsedBody.devices[2].attributes[0].entity_type); should.exist(parsedBody.devices[2].attributes[1].expression); @@ -331,16 +342,20 @@ describe('NGSI-v1 - Device provisioning API: List provisioned devices', function .matchHeader('fiware-servicepath', '/gardens') .post('/NGSI9/registerContext') .times(10) - .reply(200, + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .post('/v1/updateContext') .times(10) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); iotAgentLib.clearAll(function() { async.times(10, createDeviceRequest, function(error, results) { @@ -405,9 +420,12 @@ describe('NGSI-v1 - Device provisioning API: List provisioned devices', function .matchHeader('fiware-servicepath', '/gardens') .post('/NGSI9/registerContext') .times(10) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); iotAgentLib.clearAll(function() { async.timesSeries(10, createDeviceRequest, function(error, results) { @@ -449,14 +467,18 @@ describe('NGSI-v1 - Device provisioning API: List provisioned devices', function 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/provisionYetAnotherDevice.json') + './test/unit/examples/deviceProvisioningRequests/provisionYetAnotherDevice.json' + ) }; contextBrokerMock .post('/NGSI9/registerContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); request(provisioning3Options, function(error) { done(); diff --git a/test/unit/provisioning/provisionDeviceMultientity-test.js b/test/unit/provisioning/provisionDeviceMultientity-test.js index 0bf4992eb..afcc802e8 100644 --- a/test/unit/provisioning/provisionDeviceMultientity-test.js +++ b/test/unit/provisioning/provisionDeviceMultientity-test.js @@ -24,7 +24,6 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), utils = require('../../tools/utils'), - should = require('should'), nock = require('nock'), request = require('request'), @@ -68,25 +67,40 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile( + './test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json' + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); }); var options = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices', method: 'POST', - json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/' + - 'provisionNewDeviceMultientity.json'), + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/' + 'provisionNewDeviceMultientity.json' + ), headers: { 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' @@ -106,6 +120,3 @@ describe('NGSI-v1 - Device provisioning API: Provision devices', function() { }); }); }); - - - diff --git a/test/unit/provisioning/removeProvisionedDevice-test.js b/test/unit/provisioning/removeProvisionedDevice-test.js index 8b0cb32a7..ea868c8e1 100644 --- a/test/unit/provisioning/removeProvisionedDevice-test.js +++ b/test/unit/provisioning/removeProvisionedDevice-test.js @@ -72,8 +72,9 @@ describe('NGSI-v1 - Device provisioning API: Remove provisioned devices', functi 'fiware-service': 'smartGondor', 'fiware-servicepath': '/gardens' }, - json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/' + - 'provisionDeviceActiveAtts.json') + json: utils.readExampleFile( + './test/unit/examples/deviceProvisioningRequests/' + 'provisionDeviceActiveAtts.json' + ) }; beforeEach(function(done) { @@ -81,63 +82,84 @@ describe('NGSI-v1 - Device provisioning API: Remove provisioned devices', functi contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/NGSI9/registerContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); - - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning1Options), - async.apply(request, provisioning2Options), - async.apply(request, provisioning3Options) - ], function(error, results) { - done(); - }); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); + + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, provisioning1Options), + async.apply(request, provisioning2Options), + async.apply(request, provisioning3Options) + ], + function(error, results) { + done(); + } + ); }); }); diff --git a/test/unit/provisioning/singleConfigurationMode-test.js b/test/unit/provisioning/singleConfigurationMode-test.js index 11d44df2f..43ac45ca8 100644 --- a/test/unit/provisioning/singleConfigurationMode-test.js +++ b/test/unit/provisioning/singleConfigurationMode-test.js @@ -26,7 +26,6 @@ var iotAgentLib = require('../../../lib/fiware-iotagent-lib'), utils = require('../../tools/utils'), - should = require('should'), nock = require('nock'), contextBrokerMock, @@ -125,15 +124,21 @@ describe('NGSI-v1 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); request(groupCreation, function(error) { request(deviceCreation, function(error, response, body) { @@ -179,29 +184,41 @@ describe('NGSI-v1 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'AlternateService') .matchHeader('fiware-servicepath', '/testingPath') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'AlternateService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); request(groupCreation, function(error) { request(deviceCreation, function(error, response, body) { @@ -238,15 +255,21 @@ describe('NGSI-v1 - Provisioning API: Single service mode', function() { .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/NGSI9/registerContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') .post('/v1/updateContext') - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); oldType = deviceCreation.json.devices[0].entity_type; delete deviceCreation.json.devices[0].entity_type; @@ -278,18 +301,32 @@ describe('NGSI-v1 - Provisioning API: Single service mode', function() { contextBrokerMock = nock('http://unexistentHost:1026') .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'TestService') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile( + './test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json' + ) + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); request(groupCreation, done); }); @@ -308,6 +345,5 @@ describe('NGSI-v1 - Provisioning API: Single service mode', function() { done(); }); }); - }); }); diff --git a/test/unit/provisioning/updateProvisionedDevices-test.js b/test/unit/provisioning/updateProvisionedDevices-test.js index 3f19e44ef..708b56290 100644 --- a/test/unit/provisioning/updateProvisionedDevices-test.js +++ b/test/unit/provisioning/updateProvisionedDevices-test.js @@ -81,54 +81,75 @@ describe('NGSI-v1 - Device provisioning API: Update provisioned devices', functi contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile( + './test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json' + ) + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json' + ) + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/NGSI9/registerContext', - utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/updateIoTAgent2.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json')); - - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning1Options), - async.apply(request, provisioning2Options) - ], done); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateIoTAgent2.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json' + ) + ); + + async.series( + [ + iotAgentLib.clearAll, + async.apply(request, provisioning1Options), + async.apply(request, provisioning2Options) + ], + done + ); }); }); @@ -153,17 +174,26 @@ describe('NGSI-v1 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateActiveAttributes.json')) - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/updateActiveAttributesSuccess.json')); + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateActiveAttributes.json') + ) + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/updateActiveAttributesSuccess.json') + ); contextBrokerMock - .post('/NGSI9/registerContext', utils.readExampleFile( - './test/unit/examples/contextAvailabilityRequests/updateIoTAgent3.json')) - .reply(200, utils.readExampleFile( - './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json')); + .post( + '/NGSI9/registerContext', + utils.readExampleFile('./test/unit/examples/contextAvailabilityRequests/updateIoTAgent3.json') + ) + .reply( + 200, + utils.readExampleFile( + './test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json' + ) + ); }); it('should return a 200 OK and no errors', function(done) { @@ -227,7 +257,8 @@ describe('NGSI-v1 - Device provisioning API: Update provisioned devices', functi 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWithId.json') + './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWithId.json' + ) }; it('should raise a 400 error', function(done) { @@ -247,7 +278,8 @@ describe('NGSI-v1 - Device provisioning API: Update provisioned devices', functi 'fiware-servicepath': '/gardens' }, json: utils.readExampleFile( - './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWrong.json') + './test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWrong.json' + ) }; it('should raise a 400 error', function(done) { @@ -284,23 +316,26 @@ describe('NGSI-v1 - Device provisioning API: Update provisioned devices', functi .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateProvisionMinimumDevice.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateProvisionMinimumDevice.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json')); + './test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json' + ) + ); - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning3Options) - ], done); + async.series([iotAgentLib.clearAll, async.apply(request, provisioning3Options)], done); }); it('should not raise any error', function(done) { @@ -361,23 +396,26 @@ describe('NGSI-v1 - Device provisioning API: Update provisioned devices', functi .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') .post('/v1/updateContext') - .reply(200, - utils.readExampleFile( - './test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json')); + .reply( + 200, + utils.readExampleFile('./test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json') + ); contextBrokerMock .matchHeader('fiware-service', 'smartGondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v1/updateContext', utils.readExampleFile( - './test/unit/examples/contextRequests/updateProvisionDeviceStatic.json')) - .reply(200, + .post( + '/v1/updateContext', + utils.readExampleFile('./test/unit/examples/contextRequests/updateProvisionDeviceStatic.json') + ) + .reply( + 200, utils.readExampleFile( - './test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json')); + './test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json' + ) + ); - async.series([ - iotAgentLib.clearAll, - async.apply(request, provisioning3Options) - ], done); + async.series([iotAgentLib.clearAll, async.apply(request, provisioning3Options)], done); }); it('should provision the attributes appropriately', function(done) {