diff --git a/app.js b/app.js index ce79b463..9d5eac2b 100755 --- a/app.js +++ b/app.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + /* * SQL API loader * =============== diff --git a/app/auth/apikey.js b/app/auth/apikey.js index a4534432..f1176cb6 100644 --- a/app/auth/apikey.js +++ b/app/auth/apikey.js @@ -1,3 +1,5 @@ +'use strict'; + /** * this module allows to auth user using an pregenerated api key */ @@ -32,7 +34,7 @@ ApikeyAuth.prototype.verifyCredentials = function (callback) { return callback(usernameError); } - + if (!apikey.grantsSql) { const forbiddenError = new Error('forbidden'); forbiddenError.http_status = 403; @@ -47,8 +49,8 @@ ApikeyAuth.prototype.verifyCredentials = function (callback) { apiKeyNotFoundError.subtype = 'api-key-not-found'; apiKeyNotFoundError.http_status = 401; - return callback(apiKeyNotFoundError); - } + return callback(apiKeyNotFoundError); + } }); }; diff --git a/app/auth/auth_api.js b/app/auth/auth_api.js index 821ff933..fe6c3275 100644 --- a/app/auth/auth_api.js +++ b/app/auth/auth_api.js @@ -1,3 +1,5 @@ +'use strict'; + var ApiKeyAuth = require('./apikey'), OAuthAuth = require('./oauth'); diff --git a/app/auth/oauth.js b/app/auth/oauth.js index 0cafb627..8f7959f7 100644 --- a/app/auth/oauth.js +++ b/app/auth/oauth.js @@ -1,3 +1,5 @@ +'use strict'; + // too bound to the request object, but ok for now var _ = require('underscore'); var OAuthUtil = require('oauth-client'); diff --git a/app/controllers/job_controller.js b/app/controllers/job_controller.js index 27da106e..a169684c 100644 --- a/app/controllers/job_controller.js +++ b/app/controllers/job_controller.js @@ -1,3 +1,5 @@ +'use strict'; + const util = require('util'); const bodyParserMiddleware = require('../middlewares/body-parser'); @@ -30,25 +32,25 @@ JobController.prototype.route = function (app) { ); app.get( - `${base_url}/jobs-wip`, + `${base_url}/jobs-wip`, bodyParserMiddleware(), - listWorkInProgressJobs(this.jobService), - sendResponse(), + listWorkInProgressJobs(this.jobService), + sendResponse(), errorMiddleware() ); app.post( - `${base_url}/sql/job`, + `${base_url}/sql/job`, bodyParserMiddleware(), - checkBodyPayloadSize(), + checkBodyPayloadSize(), jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE) ); app.get( - `${base_url}/sql/job/:job_id`, + `${base_url}/sql/job/:job_id`, bodyParserMiddleware(), jobMiddlewares('retrieve', getJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_GET) ); app.delete( - `${base_url}/sql/job/:job_id`, + `${base_url}/sql/job/:job_id`, bodyParserMiddleware(), jobMiddlewares('cancel', cancelJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_DELETE) ); diff --git a/app/middlewares/authorization.js b/app/middlewares/authorization.js index 020d6728..cbed5455 100644 --- a/app/middlewares/authorization.js +++ b/app/middlewares/authorization.js @@ -1,3 +1,5 @@ +'use strict'; + const AuthApi = require('../auth/auth_api'); const basicAuth = require('basic-auth'); diff --git a/app/middlewares/body-parser.js b/app/middlewares/body-parser.js index 6c44e295..f23c4512 100644 --- a/app/middlewares/body-parser.js +++ b/app/middlewares/body-parser.js @@ -1,3 +1,4 @@ +'use strict'; /*! * Connect - bodyParser diff --git a/app/middlewares/connection-params.js b/app/middlewares/connection-params.js index e6320a6c..f0500552 100644 --- a/app/middlewares/connection-params.js +++ b/app/middlewares/connection-params.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = function connectionParams (userDatabaseService) { return function connectionParamsMiddleware (req, res, next) { const { user, api_key: apikeyToken, authorizationLevel } = res.locals; diff --git a/app/middlewares/db-quota.js b/app/middlewares/db-quota.js index a3507576..42fb8961 100644 --- a/app/middlewares/db-quota.js +++ b/app/middlewares/db-quota.js @@ -1,3 +1,5 @@ +'use strict'; + const PSQL = require('cartodb-psql'); const remainingQuotaQuery = 'SELECT _CDB_UserQuotaInBytes() - CDB_UserDataSize(current_schema()) AS remaining_quota'; diff --git a/app/middlewares/error.js b/app/middlewares/error.js index f59fd83d..b3dd4fd6 100644 --- a/app/middlewares/error.js +++ b/app/middlewares/error.js @@ -1,3 +1,5 @@ +'use strict'; + const errorHandlerFactory = require('../services/error_handler_factory'); module.exports = function error() { diff --git a/app/middlewares/profiler.js b/app/middlewares/profiler.js index a0a522bf..fac63a93 100644 --- a/app/middlewares/profiler.js +++ b/app/middlewares/profiler.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports.initializeProfilerMiddleware = function initializeProfiler (label) { return function initializeProfilerMiddleware (req, res, next) { if (req.profiler) { diff --git a/app/middlewares/timeout-limits.js b/app/middlewares/timeout-limits.js index 076ba6ad..cd0275be 100644 --- a/app/middlewares/timeout-limits.js +++ b/app/middlewares/timeout-limits.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = function timeoutLimits (metadataBackend) { return function timeoutLimitsMiddleware (req, res, next) { const { user, authorizationLevel } = res.locals; diff --git a/app/middlewares/user.js b/app/middlewares/user.js index a22edb82..87e71d0b 100644 --- a/app/middlewares/user.js +++ b/app/middlewares/user.js @@ -1,3 +1,5 @@ +'use strict'; + const CdbRequest = require('../models/cartodb_request'); module.exports = function user(metadataBackend) { diff --git a/app/models/bin_encoder.js b/app/models/bin_encoder.js index 0f8c693f..c764a447 100644 --- a/app/models/bin_encoder.js +++ b/app/models/bin_encoder.js @@ -1,3 +1,4 @@ +'use strict'; function ArrayBufferSer(type, data, options) { if(type === undefined) { @@ -83,7 +84,7 @@ ArrayBufferSer.prototype = { s = 0; if(this.type === ArrayBufferSer.STRING) { // calculate size with padding - t.forEach(function(arr) { + t.forEach(function(arr) { var pad = self._paddingFor(offset, ArrayBufferSer.MAX_PADDING); s += pad; offset += pad; diff --git a/app/models/cartodb_request.js b/app/models/cartodb_request.js index dc3a0316..8ba9b890 100644 --- a/app/models/cartodb_request.js +++ b/app/models/cartodb_request.js @@ -1,3 +1,5 @@ +'use strict'; + /** * this module provides cartodb-specific interpretation * of request headers diff --git a/app/models/formats/index.js b/app/models/formats/index.js index 25af88f6..68e65c69 100644 --- a/app/models/formats/index.js +++ b/app/models/formats/index.js @@ -1,3 +1,5 @@ +'use strict'; + var fs = require("fs"); var formats = {}; diff --git a/app/models/formats/ogr.js b/app/models/formats/ogr.js index f428b580..f13b31d4 100644 --- a/app/models/formats/ogr.js +++ b/app/models/formats/ogr.js @@ -1,3 +1,5 @@ +'use strict'; + var crypto = require('crypto'); var step = require('step'); var fs = require('fs'); diff --git a/app/models/formats/ogr/csv.js b/app/models/formats/ogr/csv.js index 1fa4ae15..655ff289 100644 --- a/app/models/formats/ogr/csv.js +++ b/app/models/formats/ogr/csv.js @@ -1,3 +1,5 @@ +'use strict'; + var ogr = require('./../ogr'); function CsvFormat() {} diff --git a/app/models/formats/ogr/geopackage.js b/app/models/formats/ogr/geopackage.js index bc287b89..0702b6b9 100644 --- a/app/models/formats/ogr/geopackage.js +++ b/app/models/formats/ogr/geopackage.js @@ -1,3 +1,5 @@ +'use strict'; + var ogr = require('./../ogr'); function GeoPackageFormat() {} diff --git a/app/models/formats/ogr/kml.js b/app/models/formats/ogr/kml.js index 9430f647..d7a2929f 100644 --- a/app/models/formats/ogr/kml.js +++ b/app/models/formats/ogr/kml.js @@ -1,3 +1,5 @@ +'use strict'; + var ogr = require('./../ogr'); function KmlFormat() {} diff --git a/app/models/formats/ogr/shp.js b/app/models/formats/ogr/shp.js index 999133a6..04ba414f 100644 --- a/app/models/formats/ogr/shp.js +++ b/app/models/formats/ogr/shp.js @@ -1,3 +1,5 @@ +'use strict'; + var step = require('step'); var fs = require('fs'); var spawn = require('child_process').spawn; diff --git a/app/models/formats/ogr/spatialite.js b/app/models/formats/ogr/spatialite.js index 1c3d7fb6..89120829 100644 --- a/app/models/formats/ogr/spatialite.js +++ b/app/models/formats/ogr/spatialite.js @@ -1,3 +1,5 @@ +'use strict'; + var ogr = require('./../ogr'); function SpatiaLiteFormat() {} diff --git a/app/models/formats/pg.js b/app/models/formats/pg.js index bc82b263..3a98bd59 100644 --- a/app/models/formats/pg.js +++ b/app/models/formats/pg.js @@ -1,3 +1,5 @@ +'use strict'; + var step = require('step'); var PSQL = require('cartodb-psql'); var assert = require('assert'); diff --git a/app/models/formats/pg/arraybuffer.js b/app/models/formats/pg/arraybuffer.js index 41bdbb23..c4a947cc 100644 --- a/app/models/formats/pg/arraybuffer.js +++ b/app/models/formats/pg/arraybuffer.js @@ -1,3 +1,5 @@ +'use strict'; + var _ = require('underscore'); var pg = require('./../pg'); @@ -22,7 +24,7 @@ BinaryFormat.prototype.transform = function(result, options, callback) { var total_rows = result.rowCount; var rows = result.rows; - // get headers + // get headers if(!total_rows) { callback(null, new Buffer(0)); return; @@ -62,7 +64,7 @@ BinaryFormat.prototype.transform = function(result, options, callback) { var d = []; var n = headersNames[i]; for(var r = 0; r < total_rows; ++r) { - var row = rows[r][n]; + var row = rows[r][n]; if(headerTypes[i] > ArrayBufferSer.BUFFER) { row = new ArrayBufferSer(headerTypes[i] - ArrayBufferSer.BUFFER, row); } diff --git a/app/models/formats/pg/geojson.js b/app/models/formats/pg/geojson.js index b0f07791..fde457f9 100644 --- a/app/models/formats/pg/geojson.js +++ b/app/models/formats/pg/geojson.js @@ -1,3 +1,5 @@ +'use strict'; + var _ = require('underscore'); var pg = require('./../pg'); diff --git a/app/models/formats/pg/json.js b/app/models/formats/pg/json.js index 9583f6b3..acdb11c7 100644 --- a/app/models/formats/pg/json.js +++ b/app/models/formats/pg/json.js @@ -1,3 +1,5 @@ +'use strict'; + var _ = require('underscore'); var pg = require('./../pg'); diff --git a/app/models/formats/pg/svg.js b/app/models/formats/pg/svg.js index 489a8a45..442c041a 100644 --- a/app/models/formats/pg/svg.js +++ b/app/models/formats/pg/svg.js @@ -1,3 +1,5 @@ +'use strict'; + var pg = require('./../pg'); var svg_width = 1024.0; diff --git a/app/models/formats/pg/topojson.js b/app/models/formats/pg/topojson.js index 7ee267b3..08e4f94b 100644 --- a/app/models/formats/pg/topojson.js +++ b/app/models/formats/pg/topojson.js @@ -1,3 +1,5 @@ +'use strict'; + var pg = require('./../pg'); var _ = require('underscore'); var geojson = require('./geojson'); diff --git a/app/monitoring/health_check.js b/app/monitoring/health_check.js index 5e5e4b81..5aa068d1 100644 --- a/app/monitoring/health_check.js +++ b/app/monitoring/health_check.js @@ -1,3 +1,5 @@ +'use strict'; + var step = require('step'), fs = require('fs'); diff --git a/app/postgresql/error_codes.js b/app/postgresql/error_codes.js index 42f4da86..cd673d85 100644 --- a/app/postgresql/error_codes.js +++ b/app/postgresql/error_codes.js @@ -1,3 +1,5 @@ +'use strict'; + var _ = require('underscore'); // reference http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html diff --git a/app/server.js b/app/server.js index 38609924..e3529d4c 100644 --- a/app/server.js +++ b/app/server.js @@ -1,3 +1,5 @@ +'use strict'; + // CartoDB SQL API // // all requests expect the following URL args: diff --git a/app/services/cached-query-tables.js b/app/services/cached-query-tables.js index caa65584..cdda8051 100644 --- a/app/services/cached-query-tables.js +++ b/app/services/cached-query-tables.js @@ -1,3 +1,5 @@ +'use strict'; + var QueryTables = require('cartodb-query-tables'); var generateMD5 = require('../utils/md5'); diff --git a/app/services/error_handler.js b/app/services/error_handler.js index f72949b7..0f147403 100644 --- a/app/services/error_handler.js +++ b/app/services/error_handler.js @@ -1,3 +1,5 @@ +'use strict'; + class ErrorHandler extends Error { constructor({ message, context, detail, hint, http_status, name }) { super(message); diff --git a/app/services/error_handler_factory.js b/app/services/error_handler_factory.js index acb920cc..8dc86835 100644 --- a/app/services/error_handler_factory.js +++ b/app/services/error_handler_factory.js @@ -1,3 +1,5 @@ +'use strict'; + const ErrorHandler = require('./error_handler'); const { codeToCondition } = require('../postgresql/error_codes'); diff --git a/app/services/pg-entities-access-validator.js b/app/services/pg-entities-access-validator.js index e2d90262..bf0ed369 100644 --- a/app/services/pg-entities-access-validator.js +++ b/app/services/pg-entities-access-validator.js @@ -1,3 +1,5 @@ +'use strict'; + const FORBIDDEN_ENTITIES = { carto: ['*'], cartodb: [ @@ -56,6 +58,6 @@ const Validator = { return true; } -}; +}; module.exports = Validator; diff --git a/app/services/stream_copy.js b/app/services/stream_copy.js index cbaa3ada..34f91d23 100644 --- a/app/services/stream_copy.js +++ b/app/services/stream_copy.js @@ -1,3 +1,5 @@ +'use strict'; + const PSQL = require('cartodb-psql'); const copyTo = require('pg-copy-streams').to; const copyFrom = require('pg-copy-streams').from; diff --git a/app/services/stream_copy_metrics.js b/app/services/stream_copy_metrics.js index 46c9eb33..295b3c70 100644 --- a/app/services/stream_copy_metrics.js +++ b/app/services/stream_copy_metrics.js @@ -1,3 +1,5 @@ +'use strict'; + const { getFormatFromCopyQuery } = require('../utils/query_info'); module.exports = class StreamCopyMetrics { diff --git a/app/services/user_database_service.js b/app/services/user_database_service.js index 23ecf89a..26790a2f 100644 --- a/app/services/user_database_service.js +++ b/app/services/user_database_service.js @@ -1,3 +1,5 @@ +'use strict'; + function isApiKeyFound(apikey) { return apikey.type !== null && apikey.user !== null && @@ -43,7 +45,7 @@ UserDatabaseService.prototype.getConnectionParams = function (username, apikeyTo }; this.metadataBackend.getMasterApikey(username, (err, masterApikey) => { - + if (err) { err.http_status = 404; err.message = errorUserNotFoundMessageTemplate(username); diff --git a/app/services/user_limits.js b/app/services/user_limits.js index 837e7e83..91faa2e2 100644 --- a/app/services/user_limits.js +++ b/app/services/user_limits.js @@ -1,7 +1,9 @@ +'use strict'; + /** * UserLimits - * @param {cartodb-redis} metadataBackend - * @param {object} options + * @param {cartodb-redis} metadataBackend + * @param {object} options */ class UserLimits { constructor(metadataBackend, options = {}) { diff --git a/app/stats/client.js b/app/stats/client.js index 614344cb..be6f6c13 100644 --- a/app/stats/client.js +++ b/app/stats/client.js @@ -1,3 +1,5 @@ +'use strict'; + var _ = require('underscore'); var debug = require('debug')('windshaft:stats_client'); var StatsD = require('node-statsd').StatsD; @@ -70,4 +72,4 @@ module.exports = { return this.instance; } -}; \ No newline at end of file +}; diff --git a/app/stats/profiler-proxy.js b/app/stats/profiler-proxy.js index 1e1f91e7..5ac60d57 100644 --- a/app/stats/profiler-proxy.js +++ b/app/stats/profiler-proxy.js @@ -1,3 +1,5 @@ +'use strict'; + var Profiler = require('step-profiler'); /** diff --git a/app/utils/query_info.js b/app/utils/query_info.js index c605c785..d1ad0b96 100644 --- a/app/utils/query_info.js +++ b/app/utils/query_info.js @@ -1,3 +1,5 @@ +'use strict'; + const COPY_FORMATS = ['TEXT', 'CSV', 'BINARY']; module.exports = { @@ -9,11 +11,11 @@ module.exports = { if (!copyQuery.startsWith("COPY ")) { return false; } - + if(copyQuery.includes(' WITH') && copyQuery.includes('FORMAT ')) { const regex = /\bFORMAT\s+(\w+)/; const result = regex.exec(copyQuery); - + if (result && result.length === 2) { if (COPY_FORMATS.includes(result[1])) { format = result[1]; diff --git a/client/bin_decoder.js b/client/bin_decoder.js index 98997599..81ac1262 100644 --- a/client/bin_decoder.js +++ b/client/bin_decoder.js @@ -1,4 +1,4 @@ - +'use strict'; function ArrayBufferSer(arrayBuffer) { this.buffer = arrayBuffer; diff --git a/test/acceptance/app-configuration.js b/test/acceptance/app-configuration.js index c4b92209..f7bf847b 100644 --- a/test/acceptance/app-configuration.js +++ b/test/acceptance/app-configuration.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/app.auth.test.js b/test/acceptance/app.auth.test.js index c63338a0..34bdc2f5 100644 --- a/test/acceptance/app.auth.test.js +++ b/test/acceptance/app.auth.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/app.test.js b/test/acceptance/app.test.js index a7b8c0ba..9f649815 100644 --- a/test/acceptance/app.test.js +++ b/test/acceptance/app.test.js @@ -1,3 +1,5 @@ +'use strict'; + /** * * Requires the database and tables setup in config/environments/test.js to exist diff --git a/test/acceptance/auth-api.js b/test/acceptance/auth-api.js index a0b8ece7..d7642749 100644 --- a/test/acceptance/auth-api.js +++ b/test/acceptance/auth-api.js @@ -1,3 +1,5 @@ +'use strict'; + const assert = require('../support/assert'); const TestClient = require('../support/test-client'); const BatchTestClient = require('../support/batch-test-client'); diff --git a/test/acceptance/backend_crash.js b/test/acceptance/backend_crash.js index 5a104a41..7da4bd64 100644 --- a/test/acceptance/backend_crash.js +++ b/test/acceptance/backend_crash.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var assert = require('../support/assert'); diff --git a/test/acceptance/batch/batch-drain.test.js b/test/acceptance/batch/batch-drain.test.js index 570949fa..4d23189d 100644 --- a/test/acceptance/batch/batch-drain.test.js +++ b/test/acceptance/batch/batch-drain.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); var redisUtils = require('../../support/redis_utils'); diff --git a/test/acceptance/batch/batch-limits.test.js b/test/acceptance/batch/batch-limits.test.js index 5d46872c..fa83d8f4 100644 --- a/test/acceptance/batch/batch-limits.test.js +++ b/test/acceptance/batch/batch-limits.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/batch.test.js b/test/acceptance/batch/batch.test.js index f0cd704e..6b3d4bba 100644 --- a/test/acceptance/batch/batch.test.js +++ b/test/acceptance/batch/batch.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/batch.wip.test.js b/test/acceptance/batch/batch.wip.test.js index 7da79572..e41e3ab5 100644 --- a/test/acceptance/batch/batch.wip.test.js +++ b/test/acceptance/batch/batch.wip.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/job.callback-template.test.js b/test/acceptance/batch/job.callback-template.test.js index fdba11e2..9514e7be 100644 --- a/test/acceptance/batch/job.callback-template.test.js +++ b/test/acceptance/batch/job.callback-template.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/job.fallback.test.js b/test/acceptance/batch/job.fallback.test.js index 905f357d..dc9e7244 100644 --- a/test/acceptance/batch/job.fallback.test.js +++ b/test/acceptance/batch/job.fallback.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/job.query.limit.test.js b/test/acceptance/batch/job.query.limit.test.js index 5587ecda..b02959f5 100644 --- a/test/acceptance/batch/job.query.limit.test.js +++ b/test/acceptance/batch/job.query.limit.test.js @@ -1,3 +1,5 @@ +'use strict'; + /** * * Requires the database and tables setup in config/environments/test.js to exist diff --git a/test/acceptance/batch/job.query.order.test.js b/test/acceptance/batch/job.query.order.test.js index 2b26be33..709692ab 100644 --- a/test/acceptance/batch/job.query.order.test.js +++ b/test/acceptance/batch/job.query.order.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/job.query.timeout.test.js b/test/acceptance/batch/job.query.timeout.test.js index 65df00d2..e55fe1ce 100644 --- a/test/acceptance/batch/job.query.timeout.test.js +++ b/test/acceptance/batch/job.query.timeout.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/job.test.js b/test/acceptance/batch/job.test.js index a7e8512c..d8d8288f 100644 --- a/test/acceptance/batch/job.test.js +++ b/test/acceptance/batch/job.test.js @@ -1,3 +1,5 @@ +'use strict'; + /** * * Requires the database and tables setup in config/environments/test.js to exist diff --git a/test/acceptance/batch/job.timing.test.js b/test/acceptance/batch/job.timing.test.js index a9605f03..d2482ca4 100644 --- a/test/acceptance/batch/job.timing.test.js +++ b/test/acceptance/batch/job.timing.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var BatchTestClient = require('../../support/batch-test-client'); diff --git a/test/acceptance/batch/leader-multiple-users-query-order.test.js b/test/acceptance/batch/leader-multiple-users-query-order.test.js index 782dee19..0a5c3609 100644 --- a/test/acceptance/batch/leader-multiple-users-query-order.test.js +++ b/test/acceptance/batch/leader-multiple-users-query-order.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/leader.job.query.order.test.js b/test/acceptance/batch/leader.job.query.order.test.js index 962ebda9..e80b2047 100644 --- a/test/acceptance/batch/leader.job.query.order.test.js +++ b/test/acceptance/batch/leader.job.query.order.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/queued-jobs-limit.test.js b/test/acceptance/batch/queued-jobs-limit.test.js index 0e47c397..35a0aa5a 100644 --- a/test/acceptance/batch/queued-jobs-limit.test.js +++ b/test/acceptance/batch/queued-jobs-limit.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/scheduler-basic.test.js b/test/acceptance/batch/scheduler-basic.test.js index ba5decbd..7cee1e01 100644 --- a/test/acceptance/batch/scheduler-basic.test.js +++ b/test/acceptance/batch/scheduler-basic.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/batch/use-cases.test.js b/test/acceptance/batch/use-cases.test.js index 41404e64..255d9056 100644 --- a/test/acceptance/batch/use-cases.test.js +++ b/test/acceptance/batch/use-cases.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('../../support/assert'); diff --git a/test/acceptance/cache.js b/test/acceptance/cache.js index ac32a481..f8914ca9 100644 --- a/test/acceptance/cache.js +++ b/test/acceptance/cache.js @@ -1,4 +1,4 @@ -'use const'; +'use strict'; var server = require('../../app/server')(); const assert = require('../support/assert'); diff --git a/test/acceptance/copy-abort.js b/test/acceptance/copy-abort.js index 1bc5adcf..c47368bb 100644 --- a/test/acceptance/copy-abort.js +++ b/test/acceptance/copy-abort.js @@ -1,3 +1,5 @@ +'use strict'; + const querystring = require('querystring'); const StatsClient = require('../../app/stats/client'); const statsClient = StatsClient.getInstance(global.settings.statsd); diff --git a/test/acceptance/copy-endpoints.js b/test/acceptance/copy-endpoints.js index 2a647f38..76e74e2f 100644 --- a/test/acceptance/copy-endpoints.js +++ b/test/acceptance/copy-endpoints.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); const fs = require('fs'); diff --git a/test/acceptance/copy-statements.js b/test/acceptance/copy-statements.js index 75928d5b..4a2c37ad 100644 --- a/test/acceptance/copy-statements.js +++ b/test/acceptance/copy-statements.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/error-handler.js b/test/acceptance/error-handler.js index 4a6ea563..c6d97542 100644 --- a/test/acceptance/error-handler.js +++ b/test/acceptance/error-handler.js @@ -1,7 +1,9 @@ +'use strict'; + var server = require('../../app/server')(); var assert = require('../support/assert'); -describe('error handler', function () { +describe('error handler', function () { it('should returns a errors header', function (done) { const errorHeader = { detail: undefined, @@ -22,7 +24,7 @@ describe('error handler', function () { 'Content-Type': 'application/json; charset=utf-8', 'X-SQLAPI-Errors': JSON.stringify(errorHeader) } - }, + }, function(err){ assert.ifError(err); done(); diff --git a/test/acceptance/export/arraybuffer.js b/test/acceptance/export/arraybuffer.js index 2a297b85..8e42679d 100644 --- a/test/acceptance/export/arraybuffer.js +++ b/test/acceptance/export/arraybuffer.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); require('../../support/assert'); diff --git a/test/acceptance/export/csv.js b/test/acceptance/export/csv.js index adeb9a5f..9d75ac44 100644 --- a/test/acceptance/export/csv.js +++ b/test/acceptance/export/csv.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); require('../../support/assert'); diff --git a/test/acceptance/export/folder.js b/test/acceptance/export/folder.js index f3f85876..9aebb8c7 100644 --- a/test/acceptance/export/folder.js +++ b/test/acceptance/export/folder.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); require('../../support/assert'); diff --git a/test/acceptance/export/geojson.js b/test/acceptance/export/geojson.js index e8a475e4..725d8678 100644 --- a/test/acceptance/export/geojson.js +++ b/test/acceptance/export/geojson.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); @@ -34,7 +36,7 @@ it('GET /api/v1/sql with SQL parameter, ensuring content-disposition set to geoj it('POST /api/v1/sql with SQL parameter, ensuring content-disposition set to geojson', function(done) { assert.response(server, { - url: '/api/v1/sql', + url: '/api/v1/sql', data: querystring.stringify({q: "SELECT * FROM untitle_table_4", format: 'geojson' }), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' diff --git a/test/acceptance/export/geopackage.js b/test/acceptance/export/geopackage.js index 981b0fdc..392171c2 100644 --- a/test/acceptance/export/geopackage.js +++ b/test/acceptance/export/geopackage.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); diff --git a/test/acceptance/export/kml.js b/test/acceptance/export/kml.js index a7a3c6e4..4447363d 100644 --- a/test/acceptance/export/kml.js +++ b/test/acceptance/export/kml.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); diff --git a/test/acceptance/export/shapefile.js b/test/acceptance/export/shapefile.js index ad7e3213..7fd8d1e9 100644 --- a/test/acceptance/export/shapefile.js +++ b/test/acceptance/export/shapefile.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); diff --git a/test/acceptance/export/spatialite.js b/test/acceptance/export/spatialite.js index 7b116cb3..e8b245cb 100644 --- a/test/acceptance/export/spatialite.js +++ b/test/acceptance/export/spatialite.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); diff --git a/test/acceptance/export/svg.js b/test/acceptance/export/svg.js index 6f9b2e9b..2c452df3 100644 --- a/test/acceptance/export/svg.js +++ b/test/acceptance/export/svg.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); diff --git a/test/acceptance/export/timeout.js b/test/acceptance/export/timeout.js index 2cc5a558..3590da1e 100644 --- a/test/acceptance/export/timeout.js +++ b/test/acceptance/export/timeout.js @@ -1,3 +1,5 @@ +'use strict'; + const TestClient = require('../../support/test-client'); require('../../support/assert'); diff --git a/test/acceptance/export/topojson.js b/test/acceptance/export/topojson.js index 8316d86b..61dd6d79 100644 --- a/test/acceptance/export/topojson.js +++ b/test/acceptance/export/topojson.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var server = require('../../../app/server')(); @@ -46,7 +48,7 @@ it('GET two polygons sharing an edge as topojson', function(done){ var trans = topojson.transform; assert.equal(_.keys(trans).length, 2); // only scale and translate assert.equal(trans.scale.length, 2); // scalex, scaley - assert.equal(Math.round(trans.scale[0]*1e6), 1000); + assert.equal(Math.round(trans.scale[0]*1e6), 1000); assert.equal(Math.round(trans.scale[1]*1e6), 1000); assert.equal(trans.translate.length, 2); // translatex, translatey assert.equal(trans.translate[0], -5); @@ -58,7 +60,7 @@ it('GET two polygons sharing an edge as topojson', function(done){ var obj = topojson.objects[0]; //console.dir(obj); - // Expected: + // Expected: // { type: 'Polygon', // arcs: [ [ 0, 1 ] ], // properties: { gid: 1, nam: 'U' } } @@ -74,9 +76,9 @@ it('GET two polygons sharing an edge as topojson', function(done){ assert.equal(props.gid, 1); assert.equal(props.name, 'U'); - obj = topojson.objects[1]; + obj = topojson.objects[1]; //console.dir(obj); - // Expected: + // Expected: // { type: 'Polygon', // arcs: [ [ 0, 2 ] ], // properties: { gid: 2, nam: 'D' } } @@ -94,37 +96,37 @@ it('GET two polygons sharing an edge as topojson', function(done){ // Check arcs assert.ok(topojson.hasOwnProperty('arcs')); - assert.equal(topojson.arcs.length, 3); // one shared, two non-shared + assert.equal(topojson.arcs.length, 3); // one shared, two non-shared var arc = topojson.arcs[0]; // shared arc assert.equal(arc.length, 2); // shared arc has two vertices var p = arc[0]; - assert.equal(Math.round(p[0]*trans.scale[0]), 0); - assert.equal(Math.round(p[1]*trans.scale[1]), 5); + assert.equal(Math.round(p[0]*trans.scale[0]), 0); + assert.equal(Math.round(p[1]*trans.scale[1]), 5); p = arc[1]; - assert.equal(Math.round(p[0]*trans.scale[0]), 5); - assert.equal(Math.round(p[1]*trans.scale[1]), 5); + assert.equal(Math.round(p[0]*trans.scale[0]), 5); + assert.equal(Math.round(p[1]*trans.scale[1]), 5); arc = topojson.arcs[1]; // non shared arc assert.equal(arc.length, 3); // non shared arcs have three vertices p = arc[0]; - assert.equal(Math.round(p[0]*trans.scale[0]), 5); - assert.equal(Math.round(p[1]*trans.scale[1]), 10); + assert.equal(Math.round(p[0]*trans.scale[0]), 5); + assert.equal(Math.round(p[1]*trans.scale[1]), 10); p = arc[1]; - assert.equal(Math.round(p[0]*trans.scale[0]), 5); - assert.equal(Math.round(p[1]*trans.scale[1]), -5); + assert.equal(Math.round(p[0]*trans.scale[0]), 5); + assert.equal(Math.round(p[1]*trans.scale[1]), -5); p = arc[2]; - assert.equal(Math.round(p[0]*trans.scale[0]), -10); - assert.equal(Math.round(p[1]*trans.scale[1]), 0); + assert.equal(Math.round(p[0]*trans.scale[0]), -10); + assert.equal(Math.round(p[1]*trans.scale[1]), 0); arc = topojson.arcs[2]; // non shared arc assert.equal(arc.length, 3); // non shared arcs have three vertices p = arc[0]; - assert.equal(Math.round(p[0]*trans.scale[0]), 5); - assert.equal(Math.round(p[1]*trans.scale[1]), 10); + assert.equal(Math.round(p[0]*trans.scale[0]), 5); + assert.equal(Math.round(p[1]*trans.scale[1]), 10); p = arc[1]; - assert.equal(Math.round(p[0]*trans.scale[0]), 0); - assert.equal(Math.round(p[1]*trans.scale[1]), -10); + assert.equal(Math.round(p[0]*trans.scale[0]), 0); + assert.equal(Math.round(p[1]*trans.scale[1]), -10); p = arc[2]; - assert.equal(Math.round(p[0]*trans.scale[0]), -5); - assert.equal(Math.round(p[1]*trans.scale[1]), 5); + assert.equal(Math.round(p[0]*trans.scale[0]), -5); + assert.equal(Math.round(p[1]*trans.scale[1]), 5); done(); }); @@ -151,7 +153,7 @@ it('null geometries', function(done){ var trans = topojson.transform; assert.equal(_.keys(trans).length, 2); // only scale and translate assert.equal(trans.scale.length, 2); // scalex, scaley - assert.equal(Math.round(trans.scale[0]*1e6), 1000); + assert.equal(Math.round(trans.scale[0]*1e6), 1000); assert.equal(Math.round(trans.scale[1]*1e6), 500); assert.equal(trans.translate.length, 2); // translatex, translatey assert.equal(trans.translate[0], -5); @@ -163,7 +165,7 @@ it('null geometries', function(done){ var obj = topojson.objects[0]; //console.dir(obj); - // Expected: + // Expected: // { type: 'Polygon', // arcs: [ [ 0, 1 ] ], // properties: { gid: 1, nam: 'U' } } @@ -180,8 +182,8 @@ it('null geometries', function(done){ // Check arcs assert.ok(topojson.hasOwnProperty('arcs')); - assert.equal(topojson.arcs.length, 1); - var arc = topojson.arcs[0]; + assert.equal(topojson.arcs.length, 1); + var arc = topojson.arcs[0]; assert.deepEqual(arc, [ [ 0, 0 ], [ 4999, 9999 ], [ 5000, -9999 ], [ -9999, 0 ] ]); done(); diff --git a/test/acceptance/frontend_abort.js b/test/acceptance/frontend_abort.js index 16cb1080..7ba7f63a 100644 --- a/test/acceptance/frontend_abort.js +++ b/test/acceptance/frontend_abort.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var assert = require('../support/assert'); diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index 7a94e6cb..bd29eb1f 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); require('../support/assert'); diff --git a/test/acceptance/last-modified-header.js b/test/acceptance/last-modified-header.js index 09e0c606..0760da64 100644 --- a/test/acceptance/last-modified-header.js +++ b/test/acceptance/last-modified-header.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/logging.js b/test/acceptance/logging.js index 65a308d6..b12b0189 100644 --- a/test/acceptance/logging.js +++ b/test/acceptance/logging.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var appServer = require('../../app/server'); diff --git a/test/acceptance/pagination.js b/test/acceptance/pagination.js index 02384549..b371e3f9 100644 --- a/test/acceptance/pagination.js +++ b/test/acceptance/pagination.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/pg-entities-access-validator.js b/test/acceptance/pg-entities-access-validator.js index 98740713..4470495b 100644 --- a/test/acceptance/pg-entities-access-validator.js +++ b/test/acceptance/pg-entities-access-validator.js @@ -1,3 +1,5 @@ +'use strict'; + const assert = require('../support/assert'); const TestClient = require('../support/test-client'); @@ -26,25 +28,25 @@ describe('PG entities access validator', function () { describe('validatePGEntitiesAccess enabled', function() { before(function(){ - global.settings.validatePGEntitiesAccess = true; + global.settings.validatePGEntitiesAccess = true; }); forbiddenQueries.forEach(query => { it(`testClientApiKey: query: ${query}`, function(done) { assertQuery(query, testClientApiKey, done); }); - + it(`testClientAuthorized: query: ${query}`, function(done) { assertQuery(query, testClientAuthorized, done); - }); + }); }); }); - + describe('validatePGEntitiesAccess disabled', function() { before(function(){ - global.settings.validatePGEntitiesAccess = false; + global.settings.validatePGEntitiesAccess = false; }); - + forbiddenQueries.forEach(query => { it(`testClientApiKey: query: ${query}`, function(done) { testClientApiKey.getResult(query, err => { @@ -52,13 +54,13 @@ describe('PG entities access validator', function () { done(); }); }); - + it(`testClientAuthorized: query: ${query}`, function(done) { testClientAuthorized.getResult(query, err => { assert.ifError(err); done(); }); - }); + }); }); }); }); diff --git a/test/acceptance/query-float-values.js b/test/acceptance/query-float-values.js index fc499b8c..5e0a632b 100644 --- a/test/acceptance/query-float-values.js +++ b/test/acceptance/query-float-values.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/query-multipart.js b/test/acceptance/query-multipart.js index 27f4c3c6..a048fae1 100644 --- a/test/acceptance/query-multipart.js +++ b/test/acceptance/query-multipart.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); const server = require('../../app/server')(); diff --git a/test/acceptance/query-returning.js b/test/acceptance/query-returning.js index 4250d1f7..cfbf9212 100644 --- a/test/acceptance/query-returning.js +++ b/test/acceptance/query-returning.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/query-tables-api-cache.js b/test/acceptance/query-tables-api-cache.js index 8a9af9a1..e18375f3 100644 --- a/test/acceptance/query-tables-api-cache.js +++ b/test/acceptance/query-tables-api-cache.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var qs = require('querystring'); diff --git a/test/acceptance/rate-limit.js b/test/acceptance/rate-limit.js index f8b8f4d2..afb3cd97 100644 --- a/test/acceptance/rate-limit.js +++ b/test/acceptance/rate-limit.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); const qs = require('querystring'); @@ -30,7 +32,7 @@ function setLimit(count, period, burst) { return; } - const key = `limits:rate:store:${user}:sql:${RATE_LIMIT_ENDPOINTS_GROUPS.QUERY}`; + const key = `limits:rate:store:${user}:sql:${RATE_LIMIT_ENDPOINTS_GROUPS.QUERY}`; redisClient.rpush(key, burst); redisClient.rpush(key, count); redisClient.rpush(key, period); @@ -40,9 +42,9 @@ function setLimit(count, period, burst) { function assertRequest (status, limit, remaining, reset, retry, done = null) { assert.response( - server, - request, - { status }, + server, + request, + { status }, function(err, res) { assert.ifError(err); assert.equal(res.headers['carto-rate-limit-limit'], limit); @@ -53,10 +55,10 @@ function assertRequest (status, limit, remaining, reset, retry, done = null) { assert.equal(res.headers['retry-after'], retry); } - if(status === 429) { - const expectedResponse = { + if(status === 429) { + const expectedResponse = { error: ["You are over platform\'s limits. Please contact us to know more details"], - context: "limit", + context: "limit", detail: "rate-limit" }; @@ -74,7 +76,7 @@ describe('rate limit', function() { before(function() { global.settings.ratelimits.rateLimitsEnabled = true; global.settings.ratelimits.endpoints.query = true; - + server = app(); redisClient = redis.createClient(global.settings.redis_port); @@ -94,7 +96,7 @@ describe('rate limit', function() { }); it("1 req/sec: 2 req/seg should be limited", function(done) { - assertRequest(200, 2, 1, 1); + assertRequest(200, 2, 1, 1); setTimeout( () => assertRequest(200, 2, 0, 1, null), 250 ); setTimeout( () => assertRequest(429, 2, 0, 1, 1), 500 ); setTimeout( () => assertRequest(429, 2, 0, 1, 1), 750 ); diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions.js index f81f08e0..adb27e66 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/skipfields.js b/test/acceptance/skipfields.js index 553945b4..7524f22b 100644 --- a/test/acceptance/skipfields.js +++ b/test/acceptance/skipfields.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/stream-responses.js b/test/acceptance/stream-responses.js index 237cc9de..7a47ffa5 100644 --- a/test/acceptance/stream-responses.js +++ b/test/acceptance/stream-responses.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/surrogate-key.js b/test/acceptance/surrogate-key.js index f460f556..aac3569d 100644 --- a/test/acceptance/surrogate-key.js +++ b/test/acceptance/surrogate-key.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); @@ -64,7 +66,7 @@ describe('Surrogate-Key header', function() { {dbname: 'cartodb_test_user_1_db', schema_name: 'public', table_name: 'untitle_table_4'} ], done)); }); - + it('supports explicit transactions', function(done) { var sql = "BEGIN; SELECT * FROM untitle_table_4; COMMIT; BEGIN; SELECT * FROM private_table; COMMIT;"; diff --git a/test/acceptance/system-queries.js b/test/acceptance/system-queries.js index fcccb50a..8526aade 100644 --- a/test/acceptance/system-queries.js +++ b/test/acceptance/system-queries.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/acceptance/timeout.js b/test/acceptance/timeout.js index 24464cf1..99c2d7e5 100644 --- a/test/acceptance/timeout.js +++ b/test/acceptance/timeout.js @@ -1,3 +1,5 @@ +'use strict'; + /** * * Requires the database and tables setup in config/environments/test.js to exist diff --git a/test/acceptance/transaction.js b/test/acceptance/transaction.js index 8a831853..0ee54d5a 100644 --- a/test/acceptance/transaction.js +++ b/test/acceptance/transaction.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var assert = require('../support/assert'); diff --git a/test/acceptance/x-cache-channel.js b/test/acceptance/x-cache-channel.js index d6effc9e..dfcc0599 100644 --- a/test/acceptance/x-cache-channel.js +++ b/test/acceptance/x-cache-channel.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var server = require('../../app/server')(); diff --git a/test/helper.js b/test/helper.js index 1b2e6b6d..a19de981 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,2 +1,4 @@ +'use strict'; + global.settings = require('../config/environments/test'); process.env.NODE_ENV = 'test'; diff --git a/test/integration/stream_copy.test.js b/test/integration/stream_copy.test.js index 232e3212..0e235662 100644 --- a/test/integration/stream_copy.test.js +++ b/test/integration/stream_copy.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); const assert = require('assert'); diff --git a/test/integration/utils/table_cache_factory.test.js b/test/integration/utils/table_cache_factory.test.js index 60067145..546152c1 100644 --- a/test/integration/utils/table_cache_factory.test.js +++ b/test/integration/utils/table_cache_factory.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('assert'); var LRU = require('lru-cache'); diff --git a/test/support/assert.js b/test/support/assert.js index 3541f278..b6813354 100644 --- a/test/support/assert.js +++ b/test/support/assert.js @@ -1,3 +1,5 @@ +'use strict'; + var assert = module.exports = exports = require('assert'); var request = require('request'); var debug = require('debug')('assert-response'); diff --git a/test/unit/apikeyauth.test.js b/test/unit/apikeyauth.test.js index 72a886cb..1c47c2fe 100644 --- a/test/unit/apikeyauth.test.js +++ b/test/unit/apikeyauth.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var ApikeyAuth = require('../../app/auth/apikey'); diff --git a/test/unit/batch/job_publisher.js b/test/unit/batch/job_publisher.js index 17eb1919..82f3bf89 100644 --- a/test/unit/batch/job_publisher.js +++ b/test/unit/batch/job_publisher.js @@ -1,3 +1,5 @@ +'use strict'; + var Channel = require('../../../batch/pubsub/channel'); var JobPublisher = require('../../../batch/pubsub/job-publisher'); var assert = require('assert'); diff --git a/test/unit/batch/job_queue.js b/test/unit/batch/job_queue.js index e001e736..6af5e88d 100644 --- a/test/unit/batch/job_queue.js +++ b/test/unit/batch/job_queue.js @@ -1,3 +1,5 @@ +'use strict'; + var JobQueue = require('../../../batch/job_queue'); var assert = require('assert'); diff --git a/test/unit/batch/job_subscriber.js b/test/unit/batch/job_subscriber.js index 45f2931c..6c63b148 100644 --- a/test/unit/batch/job_subscriber.js +++ b/test/unit/batch/job_subscriber.js @@ -1,3 +1,5 @@ +'use strict'; + var Channel = require('../../../batch/pubsub/channel'); var JobSubscriber = require('../../../batch/pubsub/job-subscriber'); var assert = require('assert'); diff --git a/test/unit/health_check.js b/test/unit/health_check.js index a228670e..1920e977 100644 --- a/test/unit/health_check.js +++ b/test/unit/health_check.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var assert = require('assert'); @@ -30,7 +32,7 @@ describe('health checks', function() { it('does not err if disabled file does not exists', function(done) { var fs = require('fs'); - + var readFileFn = fs.readFile; fs.readFile = function(filename, callback) { callback(new Error("ENOENT"), null); diff --git a/test/unit/model/bin_encoder.js b/test/unit/model/bin_encoder.js index d53df7bb..a0f7bf4f 100644 --- a/test/unit/model/bin_encoder.js +++ b/test/unit/model/bin_encoder.js @@ -1,3 +1,5 @@ +'use strict'; + require('../../helper'); var assert = require('assert'); diff --git a/test/unit/oauth.test.js b/test/unit/oauth.test.js index b60db866..6b629478 100644 --- a/test/unit/oauth.test.js +++ b/test/unit/oauth.test.js @@ -1,3 +1,5 @@ +'use strict'; + require('../helper'); var _ = require('underscore'); diff --git a/test/unit/pg-entities-access-validator.test.js b/test/unit/pg-entities-access-validator.test.js index 80d15e59..f28a1d67 100644 --- a/test/unit/pg-entities-access-validator.test.js +++ b/test/unit/pg-entities-access-validator.test.js @@ -1,3 +1,5 @@ +'use strict'; + const assert = require('assert'); const pgEntitiesAccessValidator = require('../../app/services/pg-entities-access-validator'); @@ -99,54 +101,54 @@ describe('pg entities access validator with validatePGEntitiesAccess enabled', f it('validate function: should not be validated', function () { let authorizationLevel = 'master'; assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCarto }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCarto }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCartodbKO }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCartodbKO }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPgcatalog }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPgcatalog }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesInfo }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesInfo }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPublicKO }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPublicKO }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesTopologyKO }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesTopologyKO }, authorizationLevel), false ); - + authorizationLevel = 'regular'; assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCarto }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCarto }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCartodbKO }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesCartodbKO }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPgcatalog }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPgcatalog }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesInfo }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesInfo }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPublicKO }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesPublicKO }, authorizationLevel), false ); assert.strictEqual( - pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesTopologyKO }, authorizationLevel), + pgEntitiesAccessValidator.validate({ tables: fakeAffectedTablesTopologyKO }, authorizationLevel), false ); }); diff --git a/test/unit/query_info.test.js b/test/unit/query_info.test.js index d3216b99..05945b61 100644 --- a/test/unit/query_info.test.js +++ b/test/unit/query_info.test.js @@ -1,3 +1,5 @@ +'use strict'; + const assert = require('assert'); const queryInfo = require('../../app/utils/query_info'); diff --git a/test/websocket_test/app.js b/test/websocket_test/app.js index f731127e..b8ec604e 100644 --- a/test/websocket_test/app.js +++ b/test/websocket_test/app.js @@ -1,3 +1,5 @@ +'use strict'; + // this is a test to understand accessing sql api via websockets var express = require('express') , app = express.createServer( @@ -54,4 +56,4 @@ io.sockets.on('connection', function (socket) { socket.emit("sql_result", {r:row, id:id, state:-1}) }); }); -}); \ No newline at end of file +}); diff --git a/test/websocket_test/public/gmaps_mercator.js b/test/websocket_test/public/gmaps_mercator.js index 2ea6c2e1..a236508a 100644 --- a/test/websocket_test/public/gmaps_mercator.js +++ b/test/websocket_test/public/gmaps_mercator.js @@ -1,3 +1,4 @@ +'use strict'; function Point(x, y) { this.x = x; diff --git a/test/websocket_test/public/map.js b/test/websocket_test/public/map.js index b46f9dc8..04bdd26d 100644 --- a/test/websocket_test/public/map.js +++ b/test/websocket_test/public/map.js @@ -1,17 +1,18 @@ +'use strict'; window.requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; })(); function Event() {} -Event.prototype.on = function(evt, callback) { +Event.prototype.on = function(evt, callback) { var cb = this.callbacks = this.callbacks || {}; var l = cb[evt] || (cb[evt] = []); l.push(callback); @@ -263,4 +264,3 @@ function Map(el, opts) { this.model.emit('center_changed'); */ } - diff --git a/test/websocket_test/public/test/map.test.js b/test/websocket_test/public/test/map.test.js index 356fe10e..ccbeaddb 100644 --- a/test/websocket_test/public/test/map.test.js +++ b/test/websocket_test/public/test/map.test.js @@ -1,3 +1,5 @@ +'use strict'; + describe("Event", function() { before_each(function() { @@ -23,7 +25,7 @@ describe("MapModel", function() { before_each(function() { this.map_model = new MapModel(new LatLng(0, 0)); - }); + }); it("center_changed should be called", function() { var c = 0;