Avoid calling Object.prototype methods directly on object instances

This commit is contained in:
Daniel García Aubert 2019-10-21 23:33:27 +02:00
parent d89e785440
commit 7a1d2ca205
42 changed files with 166 additions and 166 deletions

View File

@ -9,7 +9,7 @@
// "camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"forin" : true, // true: Require filtering for..in loops with Object.prototype.hasOwnProperty.call(obj, )
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
// "indent" : 4, // {int} Number of spaces to use for indentation

View File

@ -82,7 +82,7 @@ function prepareResponse () {
}, {});
const analysisCatalog = catalog.map(analysis => {
if (analysisIdToTable.hasOwnProperty(analysis.node_id)) {
if (Object.prototype.hasOwnProperty.call(analysisIdToTable, analysis.node_id)) {
analysis.table = analysisIdToTable[analysis.node_id];
}

View File

@ -175,7 +175,7 @@ function errorMessageWithContext (err) {
for (var prop in err) {
// type & message are properties from Error's prototype and will be skipped
if (err.hasOwnProperty(prop) && shouldBeExposed(prop)) {
if (Object.prototype.hasOwnProperty.call(err, prop) && shouldBeExposed(prop)) {
error[prop] = err[prop];
}
}

View File

@ -6,7 +6,7 @@ module.exports = function lzma () {
const lzmaWorker = new LZMA();
return function lzmaMiddleware (req, res, next) {
if (!req.query.hasOwnProperty('lzma')) {
if (!Object.prototype.hasOwnProperty.call(req.query, 'lzma')) {
return next();
}

View File

@ -55,7 +55,7 @@ function _featureCount (ctx) {
}
function _aggrFeatureCount (ctx) {
if (ctx.metaOptions.hasOwnProperty('aggrFeatureCount')) {
if (Object.prototype.hasOwnProperty.call(ctx.metaOptions, 'aggrFeatureCount')) {
// We expect as zoom level as the value of aggrFeatureCount
// TODO: it'd be nice to admit an array of zoom levels to
// return metadata for multiple levels.
@ -115,7 +115,7 @@ function mergeColumns (results) {
return results.reduce((a, b) => {
const c = Object.assign({}, b || {}, a || {});
Object.keys(c).forEach(key => {
if (b.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(b, key)) {
c[key] = Object.assign(c[key], b[key]);
}
});
@ -186,7 +186,7 @@ function _columnStats (ctx, columns, dimensions) {
);
if (columns[name].type === 'string') {
const topN = ctx.metaOptions.columnStats.topCategories || 1024;
const includeNulls = ctx.metaOptions.columnStats.hasOwnProperty('includeNulls')
const includeNulls = Object.prototype.hasOwnProperty.call(ctx.metaOptions.columnStats, 'includeNulls')
? ctx.metaOptions.columnStats.includeNulls
: true;

View File

@ -110,10 +110,10 @@ TemplateMaps.prototype._checkInvalidTemplate = function (template) {
if (!placeholderKey.match(_reValidPlaceholderIdentifier)) {
return new Error("Invalid characters in placeholder name '" + placeholderKey + "'");
}
if (!placeholders[placeholderKey].hasOwnProperty('default')) {
if (!Object.prototype.hasOwnProperty.call(placeholders[placeholderKey], 'default')) {
return new Error("Missing default for placeholder '" + placeholderKey + "'");
}
if (!placeholders[placeholderKey].hasOwnProperty('type')) {
if (!Object.prototype.hasOwnProperty.call(placeholders[placeholderKey], 'type')) {
return new Error("Missing type for placeholder '" + placeholderKey + "'");
}
}
@ -449,7 +449,7 @@ TemplateMaps.prototype.instance = function (template, params) {
var all_params = {};
var phold = template.placeholders || {};
Object.keys(phold).forEach(function (k) {
var val = params.hasOwnProperty(k) ? params[k] : phold[k].default;
var val = Object.prototype.hasOwnProperty.call(params, k) ? params[k] : phold[k].default;
var type = phold[k].type;
// properly escape
if (type === 'sql_literal') {

View File

@ -68,7 +68,7 @@ PostgresDatasource.prototype.getName = function () {
};
PostgresDatasource.prototype.getRamp = function (column, buckets, method, callback) {
if (method && !methodTemplates.hasOwnProperty(method)) {
if (method && !Object.prototype.hasOwnProperty.call(methodTemplates, method)) {
return callback(new Error(
'Invalid method "' + method + '", valid methods: [' + Object.keys(methodTemplates).join(',') + ']'
));

View File

@ -34,7 +34,7 @@ module.exports = class NamedMapProviderCache {
const namedMapProviders = this.providerCache.get(namedMapKey) || {};
const providerKey = createProviderKey(config, authToken, params);
if (namedMapProviders.hasOwnProperty(providerKey)) {
if (Object.prototype.hasOwnProperty.call(namedMapProviders, providerKey)) {
return callback(null, namedMapProviders[providerKey]);
}

View File

@ -218,7 +218,7 @@ module.exports = class Aggregation extends BaseDataview {
}
const requiredOptions = VALID_OPERATIONS[options.aggregation];
const missingOptions = requiredOptions.filter(requiredOption => !options.hasOwnProperty(requiredOption));
const missingOptions = requiredOptions.filter(requiredOption => !Object.prototype.hasOwnProperty.call(options, requiredOption));
if (missingOptions.length > 0) {
throw new Error(

View File

@ -16,8 +16,8 @@ const columnTypeQueryTpl = ctx => `SELECT pg_typeof(${ctx.column})::oid FROM (${
function getPGTypeName (pgType) {
return {
float: FLOAT_OIDS.hasOwnProperty(pgType),
date: DATE_OIDS.hasOwnProperty(pgType)
float: Object.prototype.hasOwnProperty.call(FLOAT_OIDS, pgType),
date: Object.prototype.hasOwnProperty.call(DATE_OIDS, pgType)
};
}

View File

@ -44,7 +44,7 @@ module.exports = class Histogram {
}
_isDateHistogram (override = {}) {
return (this.options.hasOwnProperty('aggregation') || override.hasOwnProperty('aggregation'));
return (Object.prototype.hasOwnProperty.call(this.options, 'aggregation') || override.hasOwnProperty('aggregation'));
}
getResult (psql, override, callback) {

View File

@ -62,7 +62,7 @@ module.exports = class BaseHistogram extends BaseDataview {
}
_hasOverridenRange (override) {
return override && override.hasOwnProperty('start') && override.hasOwnProperty('end');
return override && Object.prototype.hasOwnProperty.call(override, 'start') && Object.prototype.hasOwnProperty.call(override, 'end');
}
_getBinStart (override = {}) {

View File

@ -237,7 +237,7 @@ ORDER BY bin ASC;
}
_isValidAggregation (override) {
return DATE_AGGREGATIONS.hasOwnProperty(this._getAggregation(override));
return Object.prototype.hasOwnProperty.call(DATE_AGGREGATIONS, this._getAggregation(override));
}
_getAutomaticAggregation (psql, callback) {

View File

@ -138,7 +138,7 @@ ORDER BY 10;`;
}
_hasOverridenBins (override) {
return override && override.hasOwnProperty('bins');
return override && Object.prototype.hasOwnProperty.call(override, 'bins');
}
_getSummary (result, override) {
@ -179,7 +179,7 @@ ORDER BY 10;`;
_populateBinStart (firstRow, override = {}) {
let binStart;
if (override.hasOwnProperty('start')) {
if (Object.prototype.hasOwnProperty.call(override, 'start')) {
binStart = this._getBinStart(override);
} else {
binStart = firstRow.min;

View File

@ -7,7 +7,7 @@ var filters = {
function createFilter (filterDefinition) {
var filterType = filterDefinition.type.toLowerCase();
if (!filters.hasOwnProperty(filterType)) {
if (!Object.prototype.hasOwnProperty.call(filters, filterType)) {
throw new Error('Unknown filter type: ' + filterType);
}
return new filters[filterType](filterDefinition.column, filterDefinition.params);
@ -23,7 +23,7 @@ AnalysisFilters.prototype.sql = function (rawSql) {
return Object.keys(filters)
.filter(function (filterName) {
return applyFilters.hasOwnProperty(filterName) ? applyFilters[filterName] : true;
return Object.prototype.hasOwnProperty.call(applyFilters, filterName) ? applyFilters[filterName] : true;
})
.map(function (filterName) {
var filterDefinition = filters[filterName];

View File

@ -45,7 +45,7 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function (user, requestMapConf
var dataview = dataviews[dataviewName];
if (dataview) {
var sourceId = dataview.source.id;
if (!bySourceId.hasOwnProperty(sourceId)) {
if (!Object.prototype.hasOwnProperty.call(bySourceId, sourceId)) {
bySourceId[sourceId] = {};
}
@ -291,7 +291,7 @@ function getDataviewColumns (dataview) {
var columns = [];
var options = dataview.options;
['column', 'aggregationColumn'].forEach(function (opt) {
if (options.hasOwnProperty(opt) && !!options[opt]) {
if (Object.prototype.hasOwnProperty.call(options, opt) && !!options[opt]) {
columns.push(options[opt]);
}
});
@ -316,7 +316,7 @@ function getDataviewsErrors (dataviews) {
Object.keys(dataviews).forEach(function (dataviewName) {
var dataview = dataviews[dataviewName];
if (!dataview.hasOwnProperty('source') || !dataview.source.id) {
if (!Object.prototype.hasOwnProperty.call(dataview, 'source') || !dataview.source.id) {
errors.push(new Error('Dataview "' + dataviewName + '" is missing `source.id` attribute'));
}
@ -333,7 +333,7 @@ function getMissingDataviewsSourceIds (dataviews, sourceId2Node) {
Object.keys(dataviews).forEach(function (dataviewName) {
var dataview = dataviews[dataviewName];
var dataviewSourceId = getDataviewSourceId(dataview);
if (!sourceId2Node.hasOwnProperty(dataviewSourceId)) {
if (!Object.prototype.hasOwnProperty.call(sourceId2Node, dataviewSourceId)) {
missingDataviewsSourceIds.push(new AnalysisError('Node with `source.id="' + dataviewSourceId + '"`' +
' not found in analyses for dataview "' + dataviewName + '"'));
}

View File

@ -63,7 +63,7 @@ DataviewsWidgetsMapConfigAdapter.prototype.getMapConfig = function (user, reques
layersFilters.forEach(function (layerFilters) {
Object.keys(layerFilters).forEach(function (filterName) {
if (!filters.dataviews.hasOwnProperty(filterName)) {
if (!Object.prototype.hasOwnProperty.call(filters.dataviews, filterName)) {
filters.dataviews[filterName] = layerFilters[filterName];
}
});

View File

@ -80,7 +80,7 @@ ResourceLocator.prototype.urlForTemplate = function (tpl, username, cdnDomain, r
if (templated) {
return {
urlTemplate: tpl({
cdn_url: (cdnDomain.hasOwnProperty('urlTemplate') ? cdnDomain.urlTemplate : cdnDomain),
cdn_url: (Object.prototype.hasOwnProperty.call(cdnDomain, 'urlTemplate') ? cdnDomain.urlTemplate : cdnDomain),
user: username,
port: this.environment.port,
resource: resource.getPath()

View File

@ -14,7 +14,7 @@ const ServerInfoController = require('./server-info-controller');
const StatsClient = require('./stats/client');
module.exports = function createServer (serverOptions) {
if (!serverOptions.hasOwnProperty('routes')) {
if (!Object.prototype.hasOwnProperty.call(serverOptions, 'routes')) {
throw new Error('Must initialise server with "routes" as base paths configuration');
}

View File

@ -25,7 +25,7 @@ function wrapDates (originalQuery, fields) {
* @param {object} field
*/
function _isDateType (field) {
return DATE_OIDS.hasOwnProperty(field.dataTypeID);
return Object.prototype.hasOwnProperty.call(DATE_OIDS, field.dataTypeID);
}
/**

View File

@ -44,7 +44,7 @@ function overviews_view_for_table (table, overviews_metadata, indent) {
indent = indent || ' ';
for (var z in overviews_metadata) {
if (overviews_metadata.hasOwnProperty(z) && z !== 'schema') {
if (Object.prototype.hasOwnProperty.call(overviews_metadata, z) && z !== 'schema') {
sorted_overviews.push([z, overviews_metadata[z].table]);
}
}

View File

@ -1865,7 +1865,7 @@ describe('aggregation', function () {
const feature = geojsonTile.features[0];
assert.ok(feature.properties.hasOwnProperty('value'), 'Missing value property');
assert.ok(Object.prototype.hasOwnProperty.call(feature.properties, 'value'), 'Missing value property');
done();
});

View File

@ -204,9 +204,9 @@ describe('analysis-layers', function () {
assert.deepStrictEqual(nodesIds, ['HEAD', '2570e105-7b37-40d2-bdf4-1af889598745']);
nodesIds.forEach(function (nodeId) {
var node = nodes[nodeId];
assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node');
assert.ok(node.hasOwnProperty('status'), 'Missing "status" attribute in node');
assert.ok(node.hasOwnProperty('query'), 'Missing "status" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'url'), 'Missing "url" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'status'), 'Missing "status" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'query'), 'Missing "status" attribute in node');
});
testClient.drain(done);
@ -295,9 +295,9 @@ describe('analysis-layers', function () {
assert.deepStrictEqual(nodesIds, ['2570e105-7b37-40d2-bdf4-1af889598745']);
nodesIds.forEach(function (nodeId) {
var node = nodes[nodeId];
assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node');
assert.ok(node.hasOwnProperty('status'), 'Missing "status" attribute in node');
assert.ok(node.hasOwnProperty('query'), 'Missing "status" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'url'), 'Missing "url" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'status'), 'Missing "status" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'query'), 'Missing "status" attribute in node');
});
testClient.drain(done);

View File

@ -136,7 +136,7 @@ describe('named-maps analysis', function () {
assert.ifError(err);
layergroup = JSON.parse(res.body);
assert.ok(layergroup.hasOwnProperty('layergroupid'), "Missing 'layergroupid' from: " + res.body);
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'), "Missing 'layergroupid' from: " + res.body);
layergroupid = layergroup.layergroupid;
assert.ok(
@ -150,9 +150,9 @@ describe('named-maps analysis', function () {
assert.deepStrictEqual(nodesIds, ['HEAD', '2570e105-7b37-40d2-bdf4-1af889598745']);
nodesIds.forEach(function (nodeId) {
var node = nodes[nodeId];
assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node');
assert.ok(node.hasOwnProperty('status'), 'Missing "status" attribute in node');
assert.ok(!node.hasOwnProperty('query'), 'Unexpected "query" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'url'), 'Missing "url" attribute in node');
assert.ok(Object.prototype.hasOwnProperty.call(node, 'status'), 'Missing "status" attribute in node');
assert.ok(!Object.prototype.hasOwnProperty.call(node, 'query'), 'Unexpected "query" attribute in node');
});
keysToDelete['map_cfg|' + LayergroupToken.parse(layergroup.layergroupid).token] = 0;

View File

@ -104,7 +104,7 @@ describe('analysis-layers regressions', function () {
var expectedIds = ['customer_home_locations', 'b0', 'b1', 'a2', 'a3', 'a4'];
expectedIds.forEach(function (expectedId) {
assert.ok(
analyses[0].nodes.hasOwnProperty(expectedId),
Object.prototype.hasOwnProperty.call(analyses[0].nodes, expectedId),
'Missing "' + expectedId + '" from node list.'
);
});

View File

@ -115,7 +115,7 @@ describe('Basic authorization use cases', function () {
function (res, err) {
assert.ifError(err);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'));
assert.strictEqual(parsed.errors.length, 1);
assert.ok(parsed.errors[0].match(/Unauthorized/));
done();

View File

@ -70,7 +70,7 @@ describe('authorization', function () {
testClientGet.getTile(0, 0, 0, params, function (err, res, body) {
assert.ifError(err);
assert.ok(body.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(body, 'errors'));
assert.strictEqual(body.errors.length, 1);
assert.ok(body.errors[0].match(/permission denied/), body.errors[0]);
@ -98,7 +98,7 @@ describe('authorization', function () {
testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) {
assert.ifError(err);
assert.ok(layergroupResult.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroupResult, 'errors'));
assert.strictEqual(layergroupResult.errors.length, 1);
assert.ok(layergroupResult.errors[0].match(/permission denied/), layergroupResult.errors[0]);
@ -175,7 +175,7 @@ describe('authorization', function () {
testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) { // TODO 401
assert.ifError(err);
assert.ok(layergroupResult.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroupResult, 'errors'));
assert.strictEqual(layergroupResult.errors.length, 1);
assert.ok(layergroupResult.errors[0].match(/permission denied/), layergroupResult.errors[0]);
@ -202,7 +202,7 @@ describe('authorization', function () {
testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) {
assert.ifError(err);
assert.ok(layergroupResult.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroupResult, 'errors'));
assert.strictEqual(layergroupResult.errors.length, 1);
assert.ok(layergroupResult.errors[0].match(/Forbidden/), layergroupResult.errors[0]);

View File

@ -267,7 +267,7 @@ describe('tests from old api translated to multilayer', function () {
var parsed = JSON.parse(res.body);
assert.ok(parsed.layergroupid);
assert.ok(res.headers.hasOwnProperty('x-cache-channel'));
assert.ok(Object.prototype.hasOwnProperty.call(res.headers, 'x-cache-channel'));
assert.strictEqual(res.headers['x-cache-channel'], expectedCacheChannel);
assert.strictEqual(res.headers['x-layergroup-id'], parsed.layergroupid);
@ -305,7 +305,7 @@ describe('tests from old api translated to multilayer', function () {
var parsed = JSON.parse(res.body);
assert.ok(parsed.layergroupid);
assert.ok(res.headers.hasOwnProperty('x-cache-channel'));
assert.ok(Object.prototype.hasOwnProperty.call(res.headers, 'x-cache-channel'));
assert.strictEqual(res.headers['x-cache-channel'], expectedCacheChannel);
assert.strictEqual(res.headers['x-layergroup-id'], parsed.layergroupid);
@ -337,7 +337,7 @@ describe('tests from old api translated to multilayer', function () {
function (res) {
PgQueryRunner.prototype.run = runQueryFn;
assert.ok(!res.headers.hasOwnProperty('x-cache-channel'));
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'x-cache-channel'));
var parsed = JSON.parse(res.body);
assert.deepStrictEqual(parsed.errors, ['fake error message']);
@ -392,7 +392,7 @@ describe('tests from old api translated to multilayer', function () {
},
function (res) {
QueryTables.getQueryMetadataModel = affectedFn;
assert.ok(!res.headers.hasOwnProperty('x-cache-channel'));
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'x-cache-channel'));
done();
}
);

View File

@ -146,7 +146,7 @@ function mvt (usePostGIS) {
assert.ok(Array.isArray(geojsonTile.features));
assert.ok(geojsonTile.features.length > 0);
var feature = geojsonTile.features[0];
assert.ok(feature.properties.hasOwnProperty('pop_max'), 'Missing pop_max property');
assert.ok(Object.prototype.hasOwnProperty.call(feature.properties, 'pop_max'), 'Missing pop_max property');
testClient.drain(done);
});
@ -231,7 +231,7 @@ function mvt (usePostGIS) {
const feature = geojsonTile.features[0];
assert.ok(feature.properties.hasOwnProperty('_feature_count'), 'Missing _feature_count property');
assert.ok(Object.prototype.hasOwnProperty.call(feature.properties, '_feature_count'), 'Missing _feature_count property');
assert.strictEqual(feature.properties.cartodb_id, 1);
assert.strictEqual(feature.properties.name, 'Hawai');
assert.strictEqual(feature.properties._feature_count, 5); // original table has _feature_count = 1

View File

@ -1105,12 +1105,12 @@ describe('multilayer', function () {
assert.strictEqual(res.headers['content-type'], 'application/json; charset=utf-8');
var grid = JSON.parse(res.body);
assert.ok(grid);
assert.ok(grid.hasOwnProperty('data'));
assert.ok(grid.data.hasOwnProperty('1'));
assert.ok(Object.prototype.hasOwnProperty.call(grid, 'data'));
assert.ok(Object.prototype.hasOwnProperty.call(grid.data, '1'));
var data = grid.data[1];
assert.ok(data.hasOwnProperty('n'), "Missing 'n' from grid data keys: " + _.keys(data));
assert.ok(data.hasOwnProperty('i'), "Missing 'i' from grid data keys: " + _.keys(data));
assert.ok(data.hasOwnProperty('t'), "Missing 't' from grid data keys: " + _.keys(data));
assert.ok(Object.prototype.hasOwnProperty.call(data, 'n'), "Missing 'n' from grid data keys: " + _.keys(data));
assert.ok(Object.prototype.hasOwnProperty.call(data, 'i'), "Missing 'i' from grid data keys: " + _.keys(data));
assert.ok(Object.prototype.hasOwnProperty.call(data, 't'), "Missing 't' from grid data keys: " + _.keys(data));
next();
},
function finish (err) {

View File

@ -98,7 +98,7 @@ describe('server_gettile', function () {
function validateLayergroup (res) {
// cache is hit because we create a renderer to validate the map config
assert.ok(!res.headers.hasOwnProperty('x-windshaft-cache'), 'Did hit renderer cache on first time');
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'x-windshaft-cache'), 'Did hit renderer cache on first time');
}
testClient.withLayergroup(mapConfig, validateLayergroup, function (err, requestTile, finish) {
@ -108,7 +108,7 @@ describe('server_gettile', function () {
requestTile(tileUrl, function (err, res) {
assert.ok(
res.headers.hasOwnProperty('x-windshaft-cache'),
Object.prototype.hasOwnProperty.call(res.headers, 'x-windshaft-cache'),
'Did not hit renderer cache on second time'
);
assert.ok(parseInt(res.headers['x-windshaft-cache'], 10) >= 0);

View File

@ -49,10 +49,10 @@ describe('server', function () {
status: 200
}, function (res) {
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('windshaft'), "No 'windshaft' version in " + parsed);
assert.ok(parsed.hasOwnProperty('grainstore'), "No 'grainstore' version in " + parsed);
assert.ok(parsed.hasOwnProperty('node_mapnik'), "No 'node_mapnik' version in " + parsed);
assert.ok(parsed.hasOwnProperty('mapnik'), "No 'mapnik' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'windshaft'), "No 'windshaft' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'grainstore'), "No 'grainstore' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'node_mapnik'), "No 'node_mapnik' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'mapnik'), "No 'mapnik' version in " + parsed);
// TODO: check actual versions ?
done();
});

View File

@ -48,11 +48,11 @@ describe('server', function () {
status: 200
}, function (res) {
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('windshaft_cartodb'), "No 'windshaft_cartodb' version in " + parsed);
assert.ok(parsed.hasOwnProperty('windshaft'), "No 'windshaft' version in " + parsed);
assert.ok(parsed.hasOwnProperty('grainstore'), "No 'grainstore' version in " + parsed);
assert.ok(parsed.hasOwnProperty('node_mapnik'), "No 'node_mapnik' version in " + parsed);
assert.ok(parsed.hasOwnProperty('mapnik'), "No 'mapnik' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'windshaft_cartodb'), "No 'windshaft_cartodb' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'windshaft'), "No 'windshaft' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'grainstore'), "No 'grainstore' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'node_mapnik'), "No 'node_mapnik' version in " + parsed);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'mapnik'), "No 'mapnik' version in " + parsed);
done();
});
});

View File

@ -298,7 +298,7 @@ suites.forEach(({ desc, usePostGIS }) => {
assert.ifError(err);
assert.strictEqual(layergroup.metadata.layers[0].id, mapnikBasicLayerId(0));
// we don't care about stats here as is an aliased column
assert.ok(layergroup.metadata.layers[0].meta.stats.hasOwnProperty('estimatedFeatureCount'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup.metadata.layers[0].meta.stats, 'estimatedFeatureCount'));
testClient.drain(done);
});
});
@ -320,7 +320,7 @@ suites.forEach(({ desc, usePostGIS }) => {
assert.strictEqual(layergroup.metadata.layers[0].type, 'http');
assert.strictEqual(layergroup.metadata.layers[1].id, mapnikBasicLayerId(0));
assert.strictEqual(layergroup.metadata.layers[1].type, 'mapnik');
assert.ok(!layergroup.metadata.layers[1].meta.hasOwnProperty('stats'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup.metadata.layers[1].meta, 'stats'));
assert.strictEqual(layergroup.metadata.layers[2].id, typeLayerId('http', 1));
assert.strictEqual(layergroup.metadata.layers[2].type, 'http');
global.environment.enabledFeatures.layerStats = true;
@ -377,7 +377,7 @@ suites.forEach(({ desc, usePostGIS }) => {
const sorted = {};
Object.keys(columns).forEach(name => {
let data = columns[name];
if (data.hasOwnProperty('categories')) {
if (Object.prototype.hasOwnProperty.call(data, 'categories')) {
data = Object.assign(data, { categories: data.categories.sort(catOrder) });
}
sorted[name] = data;

View File

@ -126,7 +126,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 403);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'), res.body);
err = parsed.errors[0];
assert.ok(err.match(/only.*authenticated.*user/i),
'Unexpected error response: ' + err);
@ -152,7 +152,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 400, res.body);
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsedBody, 'errors'), res.body);
assert.ok(parsedBody.errors[0].match(/already exists/i),
'Unexpected error for pre-existing template name: ' + parsedBody.errors);
@ -186,7 +186,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 400, res.body);
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsedBody, 'errors'), res.body);
var re = /invalid.*authentication.*missing/i;
assert.ok(parsedBody.errors[0].match(re),
'Error for invalid authentication does not match ' + re + ': ' + parsedBody.errors);
@ -214,7 +214,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 400, res.body);
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsedBody, 'errors'), res.body);
var re = new RegExp(/invalid.*authentication.*missing/i);
assert.ok(parsedBody.errors[0].match(re),
'Error for invalid authentication does not match ' + re + ': ' + parsedBody.errors);
@ -239,7 +239,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
// clone the valid one and rename it
@ -262,7 +262,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 400, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
var re = /invalid.*authentication.*missing/i;
assert.ok(parsed.errors[0].match(re),
@ -389,7 +389,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tplid1 = parsed.template_id;
@ -410,7 +410,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tplid2 = parsed.template_id;
var next = this;
@ -426,7 +426,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 403, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
'Missing error from response: ' + res.body);
err = parsed.errors[0];
assert.ok(err.match(/authenticated user/), err);
@ -443,7 +443,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_ids'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_ids'),
"Missing 'template_ids' from response body: " + res.body);
var ids = parsed.template_ids;
assert.strictEqual(ids.length, 2);
@ -477,7 +477,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var backup_name = template_acceptance1.name;
@ -497,7 +497,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 400, res.statusCode + ': ' + res.body);
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsedBody, 'errors'), res.body);
assert.ok(parsedBody.errors[0].match(/cannot update name/i),
'Unexpected error for invalid update: ' + parsedBody.errors);
var put_request = {
@ -514,7 +514,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 400, res.statusCode + ': ' + res.body);
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsedBody, 'errors'), res.body);
assert.ok(parsedBody.errors[0].match(/cannot update name/i),
'Unexpected error for invalid update: ' + parsedBody.errors);
var put_request = {
@ -531,7 +531,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
assert.strictEqual(tpl_id, parsed.template_id);
@ -560,7 +560,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var get_request = {
@ -576,7 +576,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 403, res.statusCode + ': ' + res.body);
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.hasOwnProperty('errors'), res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsedBody, 'errors'), res.body);
assert.ok(parsedBody.errors[0].match(/only.*authenticated.*user/i),
'Unexpected error for unauthenticated template get: ' + parsedBody.errors);
var get_request = {
@ -592,7 +592,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template'),
"Missing 'template' from response body: " + res.body);
assert.deepStrictEqual(extendDefaultsTemplate(makeTemplate()), parsed.template);
@ -621,7 +621,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var get_request = {
@ -637,7 +637,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template'),
"Missing 'template' from response body: " + res.body);
assert.deepStrictEqual(extendDefaultsTemplate(makeTemplate()), parsed.template);
var del_request = {
@ -653,7 +653,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 403, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/only.*authenticated.*user/i),
'Unexpected error for unauthenticated template get: ' + parsed.errors);
@ -683,7 +683,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 404, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/cannot find/i),
'Unexpected error for missing template: ' + parsed.errors);
@ -734,7 +734,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -753,7 +753,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Unexpected success instanciating template with no auth: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/unauthorized/i),
'Unexpected error for unauthorized instance : ' + parsed.errors);
@ -771,7 +771,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 404, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'), "Missing 'errors' from response body: " + res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'), "Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/not found/i), 'Unexpected error for forbidden instance : ' + parsed.errors);
var post_request = {
url: '/api/v1/map/named/' + tpl_id + '?auth_token=valid2',
@ -788,12 +788,12 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 200,
'Instantiating template: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('layergroupid'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'),
"Missing 'layergroupid' from response body: " + res.body);
layergroupid = parsed.layergroupid;
assert.ok(layergroupid.match(/^localhost@/),
'Returned layergroupid does not start with signer name: ' + layergroupid);
assert.ok(parsed.hasOwnProperty('last_updated'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'last_updated'),
"Missing 'last_updated' from response body: " + res.body);
keysToDelete['user:localhost:mapviews:global'] = 5;
@ -815,7 +815,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Fetching tile with no auth: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/permission denied/i),
'Unexpected error for unauthorized instance (expected /permission denied/): ' + parsed.errors);
@ -855,7 +855,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Unexpected error for authorized instance: ' + res.statusCode + ' -- ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/cannot use/i),
'Unexpected error for unauthorized instance (expected /cannot use/): ' + parsed.errors);
@ -937,7 +937,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -955,7 +955,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Unexpected success instanciating template with no auth: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/unauthorized/i),
'Unexpected error for unauthorized instance : ' + parsed.errors);
@ -974,12 +974,12 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 200,
'Instantiating template: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('layergroupid'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'),
"Missing 'layergroupid' from response body: " + res.body);
layergroupid = parsed.layergroupid;
assert.ok(layergroupid.match(/^localhost@/),
'Returned layergroupid does not start with signer name: ' + layergroupid);
assert.ok(parsed.hasOwnProperty('last_updated'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'last_updated'),
"Missing 'last_updated' from response body: " + res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsed.layergroupid).token] = 0;
@ -1001,7 +1001,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Fetching tile with no auth: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/permission denied/i),
'Unexpected error for unauthorized instance (expected /permission denied): ' + parsed.errors);
@ -1124,7 +1124,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -1142,7 +1142,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Unexpected success instanciating template with no auth: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/unauthorized/i),
'Unexpected error for unauthorized instance : ' + parsed.errors);
@ -1161,13 +1161,13 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 200,
'Instantiating template: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('layergroupid'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'),
"Missing 'layergroupid' from response body: " + res.body);
layergroupid = parsed.layergroupid;
assert.ok(layergroupid.match(/^localhost@/),
'Returned layergroupid does not start with signer name: ' + layergroupid);
assert.strictEqual(res.headers['x-layergroup-id'], parsed.layergroupid);
assert.ok(parsed.hasOwnProperty('last_updated'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'last_updated'),
"Missing 'last_updated' from response body: " + res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsed.layergroupid).token] = 0;
@ -1189,7 +1189,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 403,
'Fetching tile with no auth: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('errors'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'errors'),
"Missing 'errors' from response body: " + res.body);
assert.ok(parsed.errors[0].match(/permission denied/i),
'Unexpected error for unauthorized getAttributes (expected /permission denied/): ' + parsed.errors);
@ -1285,7 +1285,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -1351,7 +1351,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -1436,7 +1436,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -1545,7 +1545,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 200,
'Instantiating template: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('layergroupid'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'),
"Missing 'layergroupid' from response body: " + res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsed.layergroupid).token] = 0;
redis_stats_client.ZSCORE(statskey + ':global', now, this);
@ -1630,7 +1630,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
tpl_id = parsed.template_id;
var post_request = {
@ -1648,7 +1648,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 200,
'Instantiating template: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('layergroupid'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'),
"Missing 'layergroupid' from response body: " + res.body);
layergroupid = parsed.layergroupid;
helper.checkSurrogateKey(res, new NamedMapsCacheEntry('localhost', template_acceptance2.name).key());
@ -1675,7 +1675,7 @@ describe('template_api', function () {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'),
"Missing 'template_id' from response body: " + res.body);
assert.strictEqual(tpl_id, parsed.template_id);
var post_request = {
@ -1693,7 +1693,7 @@ describe('template_api', function () {
assert.strictEqual(res.statusCode, 200,
'Instantiating template: ' + res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('layergroupid'),
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'),
"Missing 'layergroupid' from response body: " + res.body);
assert.ok(layergroupid !== parsed.layergroupid);
helper.checkSurrogateKey(res, new NamedMapsCacheEntry('localhost', template_acceptance2.name).key());
@ -1799,7 +1799,7 @@ describe('template_api', function () {
var parsed = JSON.parse(res.body);
assert.ok(
parsed.hasOwnProperty('layergroupid'), "Missing 'layergroupid' from response body: " + res.body);
Object.prototype.hasOwnProperty.call(parsed, 'layergroupid'), "Missing 'layergroupid' from response body: " + res.body);
layergroupid = parsed.layergroupid;
keysToDelete['map_cfg|' + LayergroupToken.parse(parsed.layergroupid).token] = 0;
@ -1984,7 +1984,7 @@ describe('template_api', function () {
function instantiateTemplate (err, res) {
assert.ifError(err);
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('template_id'), "Missing 'template_id' from response: " + res.body);
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'template_id'), "Missing 'template_id' from response: " + res.body);
var templateId = parsed.template_id;
var instantiatePostRequest = {
url: '/api/v1/map/named/' + templateId,

View File

@ -63,8 +63,8 @@ describe('turbo-carto for anonymous maps', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
done();
});

View File

@ -56,7 +56,7 @@ describe('turbo-carto error cases', function () {
this.testClient.getLayergroup({ response: ERROR_RESPONSE }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
assert.strictEqual(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/), layergroup.errors[0]);
assert.ok(layergroup.errors[0].match(/invalid\sramp\slength/i), layergroup.errors[0]);
@ -70,7 +70,7 @@ describe('turbo-carto error cases', function () {
this.testClient.getLayergroup({ response: ERROR_RESPONSE }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
assert.strictEqual(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
@ -85,7 +85,7 @@ describe('turbo-carto error cases', function () {
this.testClient.getLayergroup({ response: ERROR_RESPONSE }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
assert.strictEqual(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
@ -100,7 +100,7 @@ describe('turbo-carto error cases', function () {
this.testClient.getLayergroup({ response: ERROR_RESPONSE }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
assert.strictEqual(layergroup.errors.length, 1);
assert.ok(!layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/invalid\scode/i));
@ -114,7 +114,7 @@ describe('turbo-carto error cases', function () {
this.testClient.getLayergroup({ response: ERROR_RESPONSE }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
assert.strictEqual(layergroup.errors_with_context.length, 1);
assert.strictEqual(layergroup.errors_with_context[0].type, 'layer');
assert.strictEqual(layergroup.errors_with_context[0].subtype, 'turbo-carto');
@ -168,7 +168,7 @@ describe('turbo-carto error cases', function () {
this.testClient.getLayergroup({ response: ERROR_RESPONSE }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
assert.strictEqual(layergroup.errors_with_context.length, 2);
assert.strictEqual(layergroup.errors_with_context[0].type, 'layer');

View File

@ -60,8 +60,8 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
done();
});
@ -83,8 +83,8 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup({ response: TestClient.RESPONSE.ERROR }, function (err, layergroup) {
assert.ok(!err, err);
assert.ok(!layergroup.hasOwnProperty('layergroupid'));
assert.ok(layergroup.hasOwnProperty('errors'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
var turboCartoError = layergroup.errors_with_context[0];
assert.ok(turboCartoError);
@ -111,8 +111,8 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
done();
});
@ -150,8 +150,8 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
done();
});
@ -215,8 +215,8 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
done();
});
@ -278,8 +278,8 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.ok(!Object.prototype.hasOwnProperty.call(layergroup, 'errors'));
done();
});
@ -372,7 +372,7 @@ describe('turbo-carto regressions', function () {
this.testClient.getLayergroup(function (err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'));
assert.deepStrictEqual(layergroup.metadata.layers[0].meta.cartocss, scenario.expected);
done();

View File

@ -122,7 +122,7 @@ describe('named-maps widgets', function () {
assert.ifError(err);
layergroup = JSON.parse(res.body);
assert.ok(layergroup.hasOwnProperty('layergroupid'), "Missing 'layergroupid' from: " + res.body);
assert.ok(Object.prototype.hasOwnProperty.call(layergroup, 'layergroupid'), "Missing 'layergroupid' from: " + res.body);
layergroupid = layergroup.layergroupid;
keysToDelete['map_cfg|' + LayergroupToken.parse(layergroup.layergroupid).token] = 0;

View File

@ -199,10 +199,10 @@ TestClient.prototype.getWidget = function (widgetName, params, callback) {
self.keysToDelete['user:localhost:mapviews:global'] = 5;
var urlParams = {
own_filter: params.hasOwnProperty('own_filter') ? params.own_filter : 1
own_filter: Object.prototype.hasOwnProperty.call(params, 'own_filter') ? params.own_filter : 1
};
['bbox', 'bins', 'start', 'end'].forEach(function (extraParam) {
if (params.hasOwnProperty(extraParam)) {
if (Object.prototype.hasOwnProperty.call(params, extraParam)) {
urlParams[extraParam] = params[extraParam];
}
});
@ -309,7 +309,7 @@ TestClient.prototype.widgetSearch = function (widgetName, userQuery, params, cal
var urlParams = {
q: userQuery,
own_filter: params.hasOwnProperty('own_filter') ? params.own_filter : 1
own_filter: Object.prototype.hasOwnProperty.call(params, 'own_filter') ? params.own_filter : 1
};
if (params && params.bbox) {
urlParams.bbox = params.bbox;
@ -478,15 +478,15 @@ TestClient.prototype.getDataview = function (dataviewName, params, callback) {
self.keysToDelete['user:localhost:mapviews:global'] = 5;
var urlParams = {};
if (params.hasOwnProperty('no_filters')) {
if (Object.prototype.hasOwnProperty.call(params, 'no_filters')) {
urlParams.no_filters = params.no_filters;
}
if (params.hasOwnProperty('own_filter')) {
if (Object.prototype.hasOwnProperty.call(params, 'own_filter')) {
urlParams.own_filter = params.own_filter;
}
['bbox', 'bins', 'start', 'end', 'aggregation', 'offset', 'categories'].forEach(function (extraParam) {
if (params.hasOwnProperty(extraParam)) {
if (Object.prototype.hasOwnProperty.call(params, extraParam)) {
urlParams[extraParam] = params[extraParam];
}
});

View File

@ -45,10 +45,10 @@ function lzma_compress_to_base64 (payload, mode, callback) {
// Check that the response headers do not request caching
// Throws on failure
function checkNoCache (res) {
assert.ok(!res.headers.hasOwnProperty('x-cache-channel'));
assert.ok(!res.headers.hasOwnProperty('surrogate-key'));
assert.ok(!res.headers.hasOwnProperty('cache-control')); // is this correct ?
assert.ok(!res.headers.hasOwnProperty('last-modified')); // is this correct ?
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'x-cache-channel'));
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'surrogate-key'));
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'cache-control')); // is this correct ?
assert.ok(!Object.prototype.hasOwnProperty.call(res.headers, 'last-modified')); // is this correct ?
}
/**
@ -57,13 +57,13 @@ function checkNoCache (res) {
* @param res
*/
function checkCache (res) {
assert.ok(res.headers.hasOwnProperty('x-cache-channel'));
assert.ok(res.headers.hasOwnProperty('cache-control'));
assert.ok(res.headers.hasOwnProperty('last-modified'));
assert.ok(Object.prototype.hasOwnProperty.call(res.headers, 'x-cache-channel'));
assert.ok(Object.prototype.hasOwnProperty.call(res.headers, 'cache-control'));
assert.ok(Object.prototype.hasOwnProperty.call(res.headers, 'last-modified'));
}
function checkSurrogateKey (res, expectedKey) {
assert.ok(res.headers.hasOwnProperty('surrogate-key'));
assert.ok(Object.prototype.hasOwnProperty.call(res.headers, 'surrogate-key'));
function createSet (keys, key) {
keys[key] = true;

View File

@ -72,9 +72,9 @@ describe('prepare-context', function () {
cleanUpQueryParams(prepareRequest(req), prepareResponse(res), function (err) {
if (err) { done(err); return; }
assert.ok(_.isObject(req.query), 'request has query');
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
assert.ok(res.hasOwnProperty('locals'), 'response has locals');
assert.ok(!res.locals.hasOwnProperty('interactivity'), 'response locals do not have interactivity');
assert.ok(!Object.prototype.hasOwnProperty.call(req.query, 'dbuser'), 'dbuser was removed from query');
assert.ok(Object.prototype.hasOwnProperty.call(res, 'locals'), 'response has locals');
assert.ok(!Object.prototype.hasOwnProperty.call(res.locals, 'interactivity'), 'response locals do not have interactivity');
done();
});
});
@ -86,9 +86,9 @@ describe('prepare-context', function () {
dbConnSetup(prepareRequest(req), prepareResponse(res), function (err) {
if (err) { done(err); return; }
assert.ok(_.isObject(req.query), 'request has query');
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
assert.ok(res.hasOwnProperty('locals'), 'response has locals');
assert.ok(!res.locals.hasOwnProperty('interactivity'), 'response locals do not have interactivity');
assert.ok(!Object.prototype.hasOwnProperty.call(req.query, 'dbuser'), 'dbuser was removed from query');
assert.ok(Object.prototype.hasOwnProperty.call(res, 'locals'), 'response has locals');
assert.ok(!Object.prototype.hasOwnProperty.call(res.locals, 'interactivity'), 'response locals do not have interactivity');
assert.strictEqual(res.locals.dbname, test_database);
assert.ok(res.locals.dbuser === test_pubuser, 'could inject dbuser (' + res.locals.dbuser + ')');
done();
@ -117,9 +117,9 @@ describe('prepare-context', function () {
dbConnSetup(req, res, function (err) {
if (err) { done(err); return; }
assert.ok(_.isObject(req.query), 'request has query');
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
assert.ok(res.hasOwnProperty('locals'), 'response has locals');
assert.ok(!res.locals.hasOwnProperty('interactivity'), 'request params do not have interactivity');
assert.ok(!Object.prototype.hasOwnProperty.call(req.query, 'dbuser'), 'dbuser was removed from query');
assert.ok(Object.prototype.hasOwnProperty.call(res, 'locals'), 'response has locals');
assert.ok(!Object.prototype.hasOwnProperty.call(res.locals, 'interactivity'), 'request params do not have interactivity');
assert.strictEqual(res.locals.dbname, test_database);
assert.strictEqual(res.locals.dbuser, test_user);