Merge pull request #909 from CartoDB/spread-prepare-context-middleware
Spread `prepareContext` middleware
This commit is contained in:
commit
771eaf97c8
@ -1,23 +1,37 @@
|
|||||||
var PSQL = require('cartodb-psql');
|
const PSQL = require('cartodb-psql');
|
||||||
var cors = require('../middleware/cors');
|
const cors = require('../middleware/cors');
|
||||||
var userMiddleware = require('../middleware/user');
|
const user = require('../middleware/user');
|
||||||
|
const locals = require('../middleware/locals');
|
||||||
|
const cleanUpQueryParams = require('../middleware/clean-up-query-params');
|
||||||
|
const layergroupToken = require('../middleware/layergroup-token');
|
||||||
|
const credentials = require('../middleware/credentials');
|
||||||
|
const authorize = require('../middleware/authorize');
|
||||||
|
const dbConnSetup = require('../middleware/db-conn-setup');
|
||||||
const rateLimit = require('../middleware/rate-limit');
|
const rateLimit = require('../middleware/rate-limit');
|
||||||
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
||||||
|
|
||||||
function AnalysesController(prepareContext, userLimitsApi) {
|
function AnalysesController(pgConnection, authApi, userLimitsApi) {
|
||||||
this.prepareContext = prepareContext;
|
this.pgConnection = pgConnection;
|
||||||
|
this.authApi = authApi;
|
||||||
this.userLimitsApi = userLimitsApi;
|
this.userLimitsApi = userLimitsApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = AnalysesController;
|
module.exports = AnalysesController;
|
||||||
|
|
||||||
AnalysesController.prototype.register = function (app) {
|
AnalysesController.prototype.register = function (app) {
|
||||||
|
const { base_url_mapconfig: mapconfigBasePath } = app;
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${app.base_url_mapconfig}/analyses/catalog`,
|
`${mapconfigBasePath}/analyses/catalog`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS_CATALOG),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS_CATALOG),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createPGClient(),
|
createPGClient(),
|
||||||
getDataFromQuery({ queryTemplate: catalogQueryTpl, key: 'catalog' }),
|
getDataFromQuery({ queryTemplate: catalogQueryTpl, key: 'catalog' }),
|
||||||
getDataFromQuery({ queryTemplate: tablesQueryTpl, key: 'tables' }),
|
getDataFromQuery({ queryTemplate: tablesQueryTpl, key: 'tables' }),
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
const cors = require('../middleware/cors');
|
const cors = require('../middleware/cors');
|
||||||
const userMiddleware = require('../middleware/user');
|
const user = require('../middleware/user');
|
||||||
const allowQueryParams = require('../middleware/allow-query-params');
|
|
||||||
const vectorError = require('../middleware/vector-error');
|
const vectorError = require('../middleware/vector-error');
|
||||||
|
const locals = require('../middleware/locals');
|
||||||
|
const cleanUpQueryParams = require('../middleware/clean-up-query-params');
|
||||||
|
const layergroupToken = require('../middleware/layergroup-token');
|
||||||
|
const credentials = require('../middleware/credentials');
|
||||||
|
const dbConnSetup = require('../middleware/db-conn-setup');
|
||||||
|
const authorize = require('../middleware/authorize');
|
||||||
const rateLimit = require('../middleware/rate-limit');
|
const rateLimit = require('../middleware/rate-limit');
|
||||||
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
||||||
const DataviewBackend = require('../backends/dataview');
|
const DataviewBackend = require('../backends/dataview');
|
||||||
@ -31,7 +36,6 @@ const SUPPORTED_FORMATS = {
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function LayergroupController(
|
function LayergroupController(
|
||||||
prepareContext,
|
|
||||||
pgConnection,
|
pgConnection,
|
||||||
mapStore,
|
mapStore,
|
||||||
tileBackend,
|
tileBackend,
|
||||||
@ -40,7 +44,8 @@ function LayergroupController(
|
|||||||
surrogateKeysCache,
|
surrogateKeysCache,
|
||||||
userLimitsApi,
|
userLimitsApi,
|
||||||
layergroupAffectedTables,
|
layergroupAffectedTables,
|
||||||
analysisBackend
|
analysisBackend,
|
||||||
|
authApi
|
||||||
) {
|
) {
|
||||||
this.pgConnection = pgConnection;
|
this.pgConnection = pgConnection;
|
||||||
this.mapStore = mapStore;
|
this.mapStore = mapStore;
|
||||||
@ -53,21 +58,25 @@ function LayergroupController(
|
|||||||
|
|
||||||
this.dataviewBackend = new DataviewBackend(analysisBackend);
|
this.dataviewBackend = new DataviewBackend(analysisBackend);
|
||||||
this.analysisStatusBackend = new AnalysisStatusBackend();
|
this.analysisStatusBackend = new AnalysisStatusBackend();
|
||||||
|
this.authApi = authApi;
|
||||||
this.prepareContext = prepareContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = LayergroupController;
|
module.exports = LayergroupController;
|
||||||
|
|
||||||
LayergroupController.prototype.register = function(app) {
|
LayergroupController.prototype.register = function(app) {
|
||||||
const { base_url_mapconfig: basePath } = app;
|
const { base_url_mapconfig: mapconfigBasePath } = app;
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/:z/:x/:y@:scale_factor?x.:format`,
|
`${mapconfigBasePath}/:token/:z/:x/:y@:scale_factor?x.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
getTile(this.tileBackend, 'map_tile'),
|
getTile(this.tileBackend, 'map_tile'),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -83,11 +92,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/:z/:x/:y.:format`,
|
`${mapconfigBasePath}/:token/:z/:x/:y.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
getTile(this.tileBackend, 'map_tile'),
|
getTile(this.tileBackend, 'map_tile'),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -103,12 +117,17 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/:layer/:z/:x/:y.(:format)`,
|
`${mapconfigBasePath}/:token/:layer/:z/:x/:y.(:format)`,
|
||||||
distinguishLayergroupFromStaticRoute(),
|
distinguishLayergroupFromStaticRoute(),
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
getTile(this.tileBackend, 'maplayer_tile'),
|
getTile(this.tileBackend, 'maplayer_tile'),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -124,11 +143,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/:layer/attributes/:fid`,
|
`${mapconfigBasePath}/:token/:layer/attributes/:fid`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ATTRIBUTES),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ATTRIBUTES),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
getFeatureAttributes(this.attributesBackend),
|
getFeatureAttributes(this.attributesBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -142,12 +166,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
const forcedFormat = 'png';
|
const forcedFormat = 'png';
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`,
|
`${mapconfigBasePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(['layer']),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC),
|
||||||
allowQueryParams(['layer']),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi, forcedFormat),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi, forcedFormat),
|
||||||
getPreviewImageByCenter(this.previewBackend),
|
getPreviewImageByCenter(this.previewBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -159,12 +187,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`,
|
`${mapconfigBasePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(['layer']),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC),
|
||||||
allowQueryParams(['layer']),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi, forcedFormat),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi, forcedFormat),
|
||||||
getPreviewImageByBoundingBox(this.previewBackend),
|
getPreviewImageByBoundingBox(this.previewBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -194,12 +226,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/dataview/:dataviewName`,
|
`${mapconfigBasePath}/:token/dataview/:dataviewName`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW),
|
||||||
allowQueryParams(allowedDataviewQueryParams),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
getDataview(this.dataviewBackend),
|
getDataview(this.dataviewBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -211,12 +247,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/:layer/widget/:dataviewName`,
|
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW),
|
||||||
allowQueryParams(allowedDataviewQueryParams),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
getDataview(this.dataviewBackend),
|
getDataview(this.dataviewBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -228,12 +268,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/dataview/:dataviewName/search`,
|
`${mapconfigBasePath}/:token/dataview/:dataviewName/search`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW_SEARCH),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW_SEARCH),
|
||||||
allowQueryParams(allowedDataviewQueryParams),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
dataviewSearch(this.dataviewBackend),
|
dataviewSearch(this.dataviewBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -245,12 +289,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/:layer/widget/:dataviewName/search`,
|
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName/search`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW_SEARCH),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW_SEARCH),
|
||||||
allowQueryParams(allowedDataviewQueryParams),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
createMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
|
||||||
dataviewSearch(this.dataviewBackend),
|
dataviewSearch(this.dataviewBackend),
|
||||||
setCacheControlHeader(),
|
setCacheControlHeader(),
|
||||||
@ -262,11 +310,16 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${basePath}/:token/analysis/node/:nodeId`,
|
`${mapconfigBasePath}/:token/analysis/node/:nodeId`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
analysisNodeStatus(this.analysisStatusBackend),
|
analysisNodeStatus(this.analysisStatusBackend),
|
||||||
sendResponse()
|
sendResponse()
|
||||||
);
|
);
|
||||||
|
@ -5,8 +5,13 @@ const Datasource = windshaft.model.Datasource;
|
|||||||
const QueryTables = require('cartodb-query-tables');
|
const QueryTables = require('cartodb-query-tables');
|
||||||
const ResourceLocator = require('../models/resource-locator');
|
const ResourceLocator = require('../models/resource-locator');
|
||||||
const cors = require('../middleware/cors');
|
const cors = require('../middleware/cors');
|
||||||
const userMiddleware = require('../middleware/user');
|
const user = require('../middleware/user');
|
||||||
const allowQueryParams = require('../middleware/allow-query-params');
|
const locals = require('../middleware/locals');
|
||||||
|
const cleanUpQueryParams = require('../middleware/clean-up-query-params');
|
||||||
|
const layergroupToken = require('../middleware/layergroup-token');
|
||||||
|
const credentials = require('../middleware/credentials');
|
||||||
|
const dbConnSetup = require('../middleware/db-conn-setup');
|
||||||
|
const authorize = require('../middleware/authorize');
|
||||||
const NamedMapsCacheEntry = require('../cache/model/named_maps_entry');
|
const NamedMapsCacheEntry = require('../cache/model/named_maps_entry');
|
||||||
const NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider');
|
const NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider');
|
||||||
const CreateLayergroupMapConfigProvider = require('../models/mapconfig/provider/create-layergroup-provider');
|
const CreateLayergroupMapConfigProvider = require('../models/mapconfig/provider/create-layergroup-provider');
|
||||||
@ -27,9 +32,18 @@ const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
|||||||
* @param {StatsBackend} statsBackend
|
* @param {StatsBackend} statsBackend
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MapController(prepareContext, pgConnection, templateMaps, mapBackend, metadataBackend,
|
function MapController (
|
||||||
surrogateKeysCache, userLimitsApi, layergroupAffectedTables, mapConfigAdapter,
|
pgConnection,
|
||||||
statsBackend) {
|
templateMaps,
|
||||||
|
mapBackend,
|
||||||
|
metadataBackend,
|
||||||
|
surrogateKeysCache,
|
||||||
|
userLimitsApi,
|
||||||
|
layergroupAffectedTables,
|
||||||
|
mapConfigAdapter,
|
||||||
|
statsBackend,
|
||||||
|
authApi
|
||||||
|
) {
|
||||||
this.pgConnection = pgConnection;
|
this.pgConnection = pgConnection;
|
||||||
this.templateMaps = templateMaps;
|
this.templateMaps = templateMaps;
|
||||||
this.mapBackend = mapBackend;
|
this.mapBackend = mapBackend;
|
||||||
@ -43,35 +57,37 @@ function MapController(prepareContext, pgConnection, templateMaps, mapBackend, m
|
|||||||
this.layergroupMetadata = new LayergroupMetadata(resourceLocator);
|
this.layergroupMetadata = new LayergroupMetadata(resourceLocator);
|
||||||
|
|
||||||
this.statsBackend = statsBackend;
|
this.statsBackend = statsBackend;
|
||||||
this.prepareContext = prepareContext;
|
this.authApi = authApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MapController;
|
module.exports = MapController;
|
||||||
|
|
||||||
MapController.prototype.register = function(app) {
|
MapController.prototype.register = function(app) {
|
||||||
const { base_url_mapconfig, base_url_templated } = app;
|
const { base_url_mapconfig: mapconfigBasePath, base_url_templated: templateBasePath } = app;
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
`${mapconfigBasePath}`,
|
||||||
|
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.ANONYMOUS)
|
||||||
|
);
|
||||||
|
|
||||||
|
app.post(
|
||||||
|
`${mapconfigBasePath}`,
|
||||||
|
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.ANONYMOUS)
|
||||||
|
);
|
||||||
|
|
||||||
const useTemplate = true;
|
const useTemplate = true;
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
base_url_mapconfig,
|
`${templateBasePath}/:template_id/jsonp`,
|
||||||
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.ANONYMOUS)
|
|
||||||
);
|
|
||||||
app.post(
|
|
||||||
base_url_mapconfig,
|
|
||||||
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.ANONYMOUS)
|
|
||||||
);
|
|
||||||
app.get(
|
|
||||||
`${base_url_templated}/:template_id/jsonp`,
|
|
||||||
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.NAMED, useTemplate)
|
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.NAMED, useTemplate)
|
||||||
);
|
);
|
||||||
|
|
||||||
app.post(
|
app.post(
|
||||||
`${base_url_templated}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.NAMED, useTemplate)
|
this.composeCreateMapMiddleware(RATE_LIMIT_ENDPOINTS_GROUPS.NAMED, useTemplate)
|
||||||
);
|
);
|
||||||
app.options(
|
|
||||||
app.base_url_mapconfig,
|
app.options(app.base_url_mapconfig, cors('Content-Type'));
|
||||||
cors('Content-Type')
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MapController.prototype.composeCreateMapMiddleware = function (endpointGroup, useTemplate = false) {
|
MapController.prototype.composeCreateMapMiddleware = function (endpointGroup, useTemplate = false) {
|
||||||
@ -83,10 +99,14 @@ MapController.prototype.composeCreateMapMiddleware = function (endpointGroup, us
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(['aggregation']),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, endpointGroup),
|
rateLimit(this.userLimitsApi, endpointGroup),
|
||||||
allowQueryParams(['aggregation']),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
initProfiler(isTemplateInstantiation),
|
initProfiler(isTemplateInstantiation),
|
||||||
checkJsonContentType(),
|
checkJsonContentType(),
|
||||||
this.getCreateMapMiddlewares(useTemplate),
|
this.getCreateMapMiddlewares(useTemplate),
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
const NamedMapsCacheEntry = require('../cache/model/named_maps_entry');
|
const NamedMapsCacheEntry = require('../cache/model/named_maps_entry');
|
||||||
const cors = require('../middleware/cors');
|
const cors = require('../middleware/cors');
|
||||||
const userMiddleware = require('../middleware/user');
|
const user = require('../middleware/user');
|
||||||
const allowQueryParams = require('../middleware/allow-query-params');
|
const locals = require('../middleware/locals');
|
||||||
|
const cleanUpQueryParams = require('../middleware/clean-up-query-params');
|
||||||
|
const layergroupToken = require('../middleware/layergroup-token');
|
||||||
|
const credentials = require('../middleware/credentials');
|
||||||
|
const dbConnSetup = require('../middleware/db-conn-setup');
|
||||||
|
const authorize = require('../middleware/authorize');
|
||||||
const vectorError = require('../middleware/vector-error');
|
const vectorError = require('../middleware/vector-error');
|
||||||
const rateLimit = require('../middleware/rate-limit');
|
const rateLimit = require('../middleware/rate-limit');
|
||||||
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
||||||
@ -29,14 +34,15 @@ function getRequestParams(locals) {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
function NamedMapsController(
|
function NamedMapsController (
|
||||||
prepareContext,
|
|
||||||
namedMapProviderCache,
|
namedMapProviderCache,
|
||||||
tileBackend,
|
tileBackend,
|
||||||
previewBackend,
|
previewBackend,
|
||||||
surrogateKeysCache,
|
surrogateKeysCache,
|
||||||
tablesExtentApi,
|
tablesExtentApi,
|
||||||
metadataBackend,
|
metadataBackend,
|
||||||
|
pgConnection,
|
||||||
|
authApi,
|
||||||
userLimitsApi
|
userLimitsApi
|
||||||
) {
|
) {
|
||||||
this.namedMapProviderCache = namedMapProviderCache;
|
this.namedMapProviderCache = namedMapProviderCache;
|
||||||
@ -45,21 +51,27 @@ function NamedMapsController(
|
|||||||
this.surrogateKeysCache = surrogateKeysCache;
|
this.surrogateKeysCache = surrogateKeysCache;
|
||||||
this.tablesExtentApi = tablesExtentApi;
|
this.tablesExtentApi = tablesExtentApi;
|
||||||
this.metadataBackend = metadataBackend;
|
this.metadataBackend = metadataBackend;
|
||||||
|
this.pgConnection = pgConnection;
|
||||||
|
this.authApi = authApi;
|
||||||
this.userLimitsApi = userLimitsApi;
|
this.userLimitsApi = userLimitsApi;
|
||||||
this.prepareContext = prepareContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = NamedMapsController;
|
module.exports = NamedMapsController;
|
||||||
|
|
||||||
NamedMapsController.prototype.register = function(app) {
|
NamedMapsController.prototype.register = function(app) {
|
||||||
const { base_url_mapconfig, base_url_templated } = app;
|
const { base_url_mapconfig: mapconfigBasePath, base_url_templated: templateBasePath } = app;
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${base_url_templated}/:template_id/:layer/:z/:x/:y.(:format)`,
|
`${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_TILES),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_TILES),
|
||||||
this.prepareContext,
|
layergroupToken(),
|
||||||
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
getNamedMapProvider({
|
getNamedMapProvider({
|
||||||
namedMapProviderCache: this.namedMapProviderCache,
|
namedMapProviderCache: this.namedMapProviderCache,
|
||||||
label: 'NAMED_MAP_TILE'
|
label: 'NAMED_MAP_TILE'
|
||||||
@ -79,12 +91,16 @@ NamedMapsController.prototype.register = function(app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${base_url_mapconfig}/static/named/:template_id/:width/:height.:format`,
|
`${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
||||||
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC_NAMED),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC_NAMED),
|
||||||
allowQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
layergroupToken(),
|
||||||
this.prepareContext,
|
credentials(),
|
||||||
|
authorize(this.authApi),
|
||||||
|
dbConnSetup(this.pgConnection),
|
||||||
getNamedMapProvider({
|
getNamedMapProvider({
|
||||||
namedMapProviderCache: this.namedMapProviderCache,
|
namedMapProviderCache: this.namedMapProviderCache,
|
||||||
label: 'STATIC_VIZ_MAP', forcedFormat: 'png'
|
label: 'STATIC_VIZ_MAP', forcedFormat: 'png'
|
||||||
@ -222,9 +238,11 @@ function getTile ({ tileBackend, label }) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.locals.body = tile;
|
if (headers) {
|
||||||
res.locals.headers = headers;
|
res.set(headers);
|
||||||
res.locals.stats = stats;
|
}
|
||||||
|
|
||||||
|
res.body = tile;
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
@ -348,28 +366,36 @@ function getImage({ previewBackend, label }) {
|
|||||||
if (zoom !== undefined && center) {
|
if (zoom !== undefined && center) {
|
||||||
return previewBackend.getImage(namedMapProvider, format, width, height, zoom, center,
|
return previewBackend.getImage(namedMapProvider, format, width, height, zoom, center,
|
||||||
(err, image, headers, stats) => {
|
(err, image, headers, stats) => {
|
||||||
|
req.profiler.add(stats);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
err.label = label;
|
err.label = label;
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.locals.body = image;
|
if (headers) {
|
||||||
res.locals.headers = headers;
|
res.set(headers);
|
||||||
res.locals.stats = stats;
|
}
|
||||||
|
|
||||||
|
res.body = image;
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
previewBackend.getImage(namedMapProvider, format, width, height, bounds, (err, image, headers, stats) => {
|
previewBackend.getImage(namedMapProvider, format, width, height, bounds, (err, image, headers, stats) => {
|
||||||
|
req.profiler.add(stats);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
err.label = label;
|
err.label = label;
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.locals.body = image;
|
if (headers) {
|
||||||
res.locals.headers = headers;
|
res.set(headers);
|
||||||
res.locals.stats = stats;
|
}
|
||||||
|
|
||||||
|
res.body = image;
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
@ -496,9 +522,8 @@ function setCacheControlHeader () {
|
|||||||
|
|
||||||
function setContentTypeHeader () {
|
function setContentTypeHeader () {
|
||||||
return function setContentTypeHeaderMiddleware(req, res, next) {
|
return function setContentTypeHeaderMiddleware(req, res, next) {
|
||||||
const { headers = {} } = res.locals;
|
|
||||||
|
|
||||||
res.set('Content-Type', headers['content-type'] || headers['Content-Type'] || 'image/png');
|
res.set('Content-Type', res.get('content-type') || res.get('Content-Type') || 'image/png');
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
@ -506,12 +531,11 @@ function setContentTypeHeader () {
|
|||||||
|
|
||||||
function sendResponse () {
|
function sendResponse () {
|
||||||
return function sendResponseMiddleware (req, res) {
|
return function sendResponseMiddleware (req, res) {
|
||||||
const { body, stats = {}, format } = res.locals;
|
const { format } = res.locals;
|
||||||
|
|
||||||
req.profiler.done('render-' + format);
|
req.profiler.done('render-' + format);
|
||||||
req.profiler.add(stats);
|
|
||||||
|
|
||||||
res.status(200);
|
res.status(200);
|
||||||
res.send(body);
|
res.send(res.body);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const { templateName } = require('../backends/template_maps');
|
const { templateName } = require('../backends/template_maps');
|
||||||
const cors = require('../middleware/cors');
|
const cors = require('../middleware/cors');
|
||||||
const userMiddleware = require('../middleware/user');
|
const user = require('../middleware/user');
|
||||||
|
const locals = require('../middleware/locals');
|
||||||
|
const credentials = require('../middleware/credentials');
|
||||||
const rateLimit = require('../middleware/rate-limit');
|
const rateLimit = require('../middleware/rate-limit');
|
||||||
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
||||||
const localsMiddleware = require('../middleware/context/locals');
|
|
||||||
const credentialsMiddleware = require('../middleware/context/credentials');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {AuthApi} authApi
|
* @param {AuthApi} authApi
|
||||||
@ -21,15 +21,15 @@ function NamedMapsAdminController(authApi, templateMaps, userLimitsApi) {
|
|||||||
module.exports = NamedMapsAdminController;
|
module.exports = NamedMapsAdminController;
|
||||||
|
|
||||||
NamedMapsAdminController.prototype.register = function (app) {
|
NamedMapsAdminController.prototype.register = function (app) {
|
||||||
const { base_url_templated } = app;
|
const { base_url_templated: templateBasePath } = app;
|
||||||
|
|
||||||
app.post(
|
app.post(
|
||||||
`${base_url_templated}/`,
|
`${templateBasePath}/`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_CREATE),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_CREATE),
|
||||||
localsMiddleware(),
|
credentials(),
|
||||||
credentialsMiddleware(),
|
|
||||||
checkContentType({ action: 'POST', label: 'POST TEMPLATE' }),
|
checkContentType({ action: 'POST', label: 'POST TEMPLATE' }),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'create', label: 'POST TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'create', label: 'POST TEMPLATE' }),
|
||||||
createTemplate({ templateMaps: this.templateMaps }),
|
createTemplate({ templateMaps: this.templateMaps }),
|
||||||
@ -37,12 +37,12 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.put(
|
app.put(
|
||||||
`${base_url_templated}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_UPDATE),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_UPDATE),
|
||||||
localsMiddleware(),
|
credentials(),
|
||||||
credentialsMiddleware(),
|
|
||||||
checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }),
|
checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'update', label: 'PUT TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'update', label: 'PUT TEMPLATE' }),
|
||||||
updateTemplate({ templateMaps: this.templateMaps }),
|
updateTemplate({ templateMaps: this.templateMaps }),
|
||||||
@ -50,43 +50,43 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${base_url_templated}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_GET),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_GET),
|
||||||
localsMiddleware(),
|
credentials(),
|
||||||
credentialsMiddleware(),
|
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'get', label: 'GET TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'get', label: 'GET TEMPLATE' }),
|
||||||
retrieveTemplate({ templateMaps: this.templateMaps }),
|
retrieveTemplate({ templateMaps: this.templateMaps }),
|
||||||
sendResponse()
|
sendResponse()
|
||||||
);
|
);
|
||||||
|
|
||||||
app.delete(
|
app.delete(
|
||||||
`${base_url_templated}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_DELETE),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_DELETE),
|
||||||
localsMiddleware(),
|
credentials(),
|
||||||
credentialsMiddleware(),
|
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'delete', label: 'DELETE TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'delete', label: 'DELETE TEMPLATE' }),
|
||||||
destroyTemplate({ templateMaps: this.templateMaps }),
|
destroyTemplate({ templateMaps: this.templateMaps }),
|
||||||
sendResponse()
|
sendResponse()
|
||||||
);
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`${base_url_templated}/`,
|
`${templateBasePath}/`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
locals(),
|
||||||
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_LIST),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_LIST),
|
||||||
localsMiddleware(),
|
credentials(),
|
||||||
credentialsMiddleware(),
|
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'list', label: 'GET TEMPLATE LIST' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'list', label: 'GET TEMPLATE LIST' }),
|
||||||
listTemplates({ templateMaps: this.templateMaps }),
|
listTemplates({ templateMaps: this.templateMaps }),
|
||||||
sendResponse()
|
sendResponse()
|
||||||
);
|
);
|
||||||
|
|
||||||
app.options(
|
app.options(
|
||||||
`${base_url_templated}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors('Content-Type')
|
cors('Content-Type')
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
module.exports = function allowQueryParams (params) {
|
|
||||||
if (!Array.isArray(params)) {
|
|
||||||
throw new Error('allowQueryParams must receive an Array of params');
|
|
||||||
}
|
|
||||||
|
|
||||||
return function allowQueryParamsMiddleware (req, res, next) {
|
|
||||||
res.locals.allowedQueryParams = params;
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
};
|
|
@ -14,19 +14,16 @@ const REQUEST_QUERY_PARAMS_WHITELIST = [
|
|||||||
'filters' // json
|
'filters' // json
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = function cleanUpQueryParamsMiddleware () {
|
module.exports = function cleanUpQueryParamsMiddleware (customQueryParams = []) {
|
||||||
return function cleanUpQueryParams (req, res, next) {
|
if (!Array.isArray(customQueryParams)) {
|
||||||
var allowedQueryParams = REQUEST_QUERY_PARAMS_WHITELIST;
|
throw new Error('customQueryParams must receive an Array of params');
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(res.locals.allowedQueryParams)) {
|
return function cleanUpQueryParams (req, res, next) {
|
||||||
allowedQueryParams = allowedQueryParams.concat(res.locals.allowedQueryParams);
|
const allowedQueryParams = [...REQUEST_QUERY_PARAMS_WHITELIST, ...customQueryParams];
|
||||||
}
|
|
||||||
|
|
||||||
req.query = _.pick(req.query, allowedQueryParams);
|
req.query = _.pick(req.query, allowedQueryParams);
|
||||||
|
|
||||||
// bring all query values onto res.locals object
|
|
||||||
_.extend(res.locals, req.query);
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
};
|
};
|
@ -1,17 +0,0 @@
|
|||||||
const locals = require('./locals');
|
|
||||||
const cleanUpQueryParams = require('./clean-up-query-params');
|
|
||||||
const layergroupToken = require('./layergroup-token');
|
|
||||||
const credentials = require('./credentials');
|
|
||||||
const authorize = require('./authorize');
|
|
||||||
const dbConnSetup = require('./db-conn-setup');
|
|
||||||
|
|
||||||
module.exports = function prepareContextMiddleware(authApi, pgConnection) {
|
|
||||||
return [
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
|
||||||
layergroupToken(),
|
|
||||||
credentials(),
|
|
||||||
authorize(authApi),
|
|
||||||
dbConnSetup(pgConnection)
|
|
||||||
];
|
|
||||||
};
|
|
@ -1,4 +1,4 @@
|
|||||||
const LayergroupToken = require('../../models/layergroup-token');
|
const LayergroupToken = require('../models/layergroup-token');
|
||||||
const authErrorMessageTemplate = function (signer, user) {
|
const authErrorMessageTemplate = function (signer, user) {
|
||||||
return `Cannot use map signature of user "${signer}" on db of user "${user}"`;
|
return `Cannot use map signature of user "${signer}" on db of user "${user}"`;
|
||||||
};
|
};
|
@ -1,6 +1,6 @@
|
|||||||
module.exports = function locals () {
|
module.exports = function locals () {
|
||||||
return function localsMiddleware (req, res, next) {
|
return function localsMiddleware (req, res, next) {
|
||||||
res.locals = Object.assign(req.params || {}, res.locals);
|
res.locals = Object.assign({}, req.query, req.params);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
@ -49,8 +49,6 @@ var StatsBackend = require('./backends/stats');
|
|||||||
const lzmaMiddleware = require('./middleware/lzma');
|
const lzmaMiddleware = require('./middleware/lzma');
|
||||||
const errorMiddleware = require('./middleware/error-middleware');
|
const errorMiddleware = require('./middleware/error-middleware');
|
||||||
|
|
||||||
const prepareContextMiddleware = require('./middleware/context');
|
|
||||||
|
|
||||||
module.exports = function(serverOptions) {
|
module.exports = function(serverOptions) {
|
||||||
// Make stats client globally accessible
|
// Make stats client globally accessible
|
||||||
global.statsClient = StatsClient.getInstance(serverOptions.statsd);
|
global.statsClient = StatsClient.getInstance(serverOptions.statsd);
|
||||||
@ -216,16 +214,11 @@ module.exports = function(serverOptions) {
|
|||||||
|
|
||||||
var versions = getAndValidateVersions(serverOptions);
|
var versions = getAndValidateVersions(serverOptions);
|
||||||
|
|
||||||
const prepareContext = typeof serverOptions.req2params === 'function' ?
|
|
||||||
serverOptions.req2params :
|
|
||||||
prepareContextMiddleware(authApi, pgConnection);
|
|
||||||
|
|
||||||
/*******************************************************************************************************************
|
/*******************************************************************************************************************
|
||||||
* Routing
|
* Routing
|
||||||
******************************************************************************************************************/
|
******************************************************************************************************************/
|
||||||
|
|
||||||
new controller.Layergroup(
|
new controller.Layergroup(
|
||||||
prepareContext,
|
|
||||||
pgConnection,
|
pgConnection,
|
||||||
mapStore,
|
mapStore,
|
||||||
tileBackend,
|
tileBackend,
|
||||||
@ -234,11 +227,11 @@ module.exports = function(serverOptions) {
|
|||||||
surrogateKeysCache,
|
surrogateKeysCache,
|
||||||
userLimitsApi,
|
userLimitsApi,
|
||||||
layergroupAffectedTablesCache,
|
layergroupAffectedTablesCache,
|
||||||
analysisBackend
|
analysisBackend,
|
||||||
|
authApi
|
||||||
).register(app);
|
).register(app);
|
||||||
|
|
||||||
new controller.Map(
|
new controller.Map(
|
||||||
prepareContext,
|
|
||||||
pgConnection,
|
pgConnection,
|
||||||
templateMaps,
|
templateMaps,
|
||||||
mapBackend,
|
mapBackend,
|
||||||
@ -247,23 +240,25 @@ module.exports = function(serverOptions) {
|
|||||||
userLimitsApi,
|
userLimitsApi,
|
||||||
layergroupAffectedTablesCache,
|
layergroupAffectedTablesCache,
|
||||||
mapConfigAdapter,
|
mapConfigAdapter,
|
||||||
statsBackend
|
statsBackend,
|
||||||
|
authApi
|
||||||
).register(app);
|
).register(app);
|
||||||
|
|
||||||
new controller.NamedMaps(
|
new controller.NamedMaps(
|
||||||
prepareContext,
|
|
||||||
namedMapProviderCache,
|
namedMapProviderCache,
|
||||||
tileBackend,
|
tileBackend,
|
||||||
previewBackend,
|
previewBackend,
|
||||||
surrogateKeysCache,
|
surrogateKeysCache,
|
||||||
tablesExtentApi,
|
tablesExtentApi,
|
||||||
metadataBackend,
|
metadataBackend,
|
||||||
|
pgConnection,
|
||||||
|
authApi,
|
||||||
userLimitsApi
|
userLimitsApi
|
||||||
).register(app);
|
).register(app);
|
||||||
|
|
||||||
new controller.NamedMapsAdmin(authApi, templateMaps, userLimitsApi).register(app);
|
new controller.NamedMapsAdmin(authApi, templateMaps, userLimitsApi).register(app);
|
||||||
|
|
||||||
new controller.Analyses(prepareContext, userLimitsApi).register(app);
|
new controller.Analyses(pgConnection, authApi, userLimitsApi).register(app);
|
||||||
|
|
||||||
new controller.ServerInfo(versions).register(app);
|
new controller.ServerInfo(versions).register(app);
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
var testHelper = require('../../support/test_helper');
|
var testHelper = require('../../support/test_helper');
|
||||||
|
|
||||||
var assert = require('../../support/assert');
|
var assert = require('../../support/assert');
|
||||||
var step = require('step');
|
var step = require('step');
|
||||||
var cartodbServer = require('../../../lib/cartodb/server');
|
var cartodbServer = require('../../../lib/cartodb/server');
|
||||||
var PortedServerOptions = require('./support/ported_server_options');
|
var PortedServerOptions = require('./support/ported_server_options');
|
||||||
|
|
||||||
var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
|
var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
|
||||||
|
|
||||||
describe('attributes', function() {
|
describe('attributes', function() {
|
||||||
@ -47,132 +46,147 @@ describe('attributes', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("can only be fetched from layer having an attributes spec", function(done) {
|
it("can only be fetched from layer having an attributes spec", function(done) {
|
||||||
|
var expected_token;
|
||||||
var expected_token;
|
step(
|
||||||
step(
|
function do_post()
|
||||||
function do_post()
|
{
|
||||||
{
|
var next = this;
|
||||||
var next = this;
|
assert.response(server, {
|
||||||
assert.response(server, {
|
url: '/database/windshaft_test/layergroup',
|
||||||
url: '/database/windshaft_test/layergroup',
|
method: 'POST',
|
||||||
method: 'POST',
|
headers: {
|
||||||
headers: {'Content-Type': 'application/json' },
|
host: 'localhost',
|
||||||
data: JSON.stringify(test_mapconfig_1)
|
'Content-Type': 'application/json'
|
||||||
}, {}, function(res, err) { next(err, res); });
|
},
|
||||||
},
|
data: JSON.stringify(test_mapconfig_1)
|
||||||
function checkPost(err, res) {
|
}, {}, function(res, err) { next(err, res); });
|
||||||
assert.ifError(err);
|
},
|
||||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
function checkPost(err, res) {
|
||||||
// CORS headers should be sent with response
|
assert.ifError(err);
|
||||||
// from layergroup creation via POST
|
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||||
checkCORSHeaders(res);
|
// CORS headers should be sent with response
|
||||||
var parsedBody = JSON.parse(res.body);
|
// from layergroup creation via POST
|
||||||
if ( expected_token ) {
|
checkCORSHeaders(res);
|
||||||
assert.deepEqual(parsedBody, {layergroupid: expected_token, layercount: 2});
|
var parsedBody = JSON.parse(res.body);
|
||||||
} else {
|
if ( expected_token ) {
|
||||||
expected_token = parsedBody.layergroupid;
|
assert.deepEqual(parsedBody, {layergroupid: expected_token, layercount: 2});
|
||||||
}
|
} else {
|
||||||
return null;
|
expected_token = parsedBody.layergroupid;
|
||||||
},
|
|
||||||
function do_get_attr_0(err)
|
|
||||||
{
|
|
||||||
assert.ifError(err);
|
|
||||||
var next = this;
|
|
||||||
assert.response(server, {
|
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/attributes/1',
|
|
||||||
method: 'GET'
|
|
||||||
}, {}, function(res, err) { next(err, res); });
|
|
||||||
},
|
|
||||||
function check_error_0(err, res) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(
|
|
||||||
res.statusCode,
|
|
||||||
400,
|
|
||||||
res.statusCode + ( res.statusCode !== 200 ? (': ' + res.body) : '' )
|
|
||||||
);
|
|
||||||
var parsed = JSON.parse(res.body);
|
|
||||||
assert.equal(parsed.errors[0], "Layer 0 has no exposed attributes");
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
function do_get_attr_1(err)
|
|
||||||
{
|
|
||||||
assert.ifError(err);
|
|
||||||
var next = this;
|
|
||||||
assert.response(server, {
|
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/1',
|
|
||||||
method: 'GET'
|
|
||||||
}, {}, function(res, err) { next(err, res); });
|
|
||||||
},
|
|
||||||
function check_attr_1(err, res) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
|
||||||
var parsed = JSON.parse(res.body);
|
|
||||||
assert.deepEqual(parsed, {"n":6});
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
function do_get_attr_1_404(err)
|
|
||||||
{
|
|
||||||
assert.ifError(err);
|
|
||||||
var next = this;
|
|
||||||
assert.response(server, {
|
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/-666',
|
|
||||||
method: 'GET'
|
|
||||||
}, {}, function(res, err) { next(err, res); });
|
|
||||||
},
|
|
||||||
function check_attr_1_404(err, res) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body);
|
|
||||||
var parsed = JSON.parse(res.body);
|
|
||||||
assert.ok(parsed.errors);
|
|
||||||
var msg = parsed.errors[0];
|
|
||||||
assert.equal(msg, "Multiple features (0) identified by 'i' = -666 in layer 1");
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
function finish(err) {
|
|
||||||
keysToDelete['map_cfg|' + LayergroupToken.parse(expected_token).token] = 0;
|
|
||||||
keysToDelete['user:localhost:mapviews:global'] = 5;
|
|
||||||
|
|
||||||
done(err);
|
|
||||||
}
|
}
|
||||||
);
|
return null;
|
||||||
});
|
},
|
||||||
|
function do_get_attr_0(err)
|
||||||
|
{
|
||||||
|
assert.ifError(err);
|
||||||
|
var next = this;
|
||||||
|
assert.response(server, {
|
||||||
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/attributes/1',
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
},
|
||||||
|
}, {}, function(res, err) { next(err, res); });
|
||||||
|
},
|
||||||
|
function check_error_0(err, res) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(
|
||||||
|
res.statusCode,
|
||||||
|
400,
|
||||||
|
res.statusCode + ( res.statusCode !== 200 ? (': ' + res.body) : '' )
|
||||||
|
);
|
||||||
|
var parsed = JSON.parse(res.body);
|
||||||
|
assert.equal(parsed.errors[0], "Layer 0 has no exposed attributes");
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
function do_get_attr_1(err)
|
||||||
|
{
|
||||||
|
assert.ifError(err);
|
||||||
|
var next = this;
|
||||||
|
assert.response(server, {
|
||||||
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/1',
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
|
}, {}, function(res, err) { next(err, res); });
|
||||||
|
},
|
||||||
|
function check_attr_1(err, res) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||||
|
var parsed = JSON.parse(res.body);
|
||||||
|
assert.deepEqual(parsed, {"n":6});
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
function do_get_attr_1_404(err)
|
||||||
|
{
|
||||||
|
assert.ifError(err);
|
||||||
|
var next = this;
|
||||||
|
assert.response(server, {
|
||||||
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/-666',
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
|
}, {}, function(res, err) { next(err, res); });
|
||||||
|
},
|
||||||
|
function check_attr_1_404(err, res) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body);
|
||||||
|
var parsed = JSON.parse(res.body);
|
||||||
|
assert.ok(parsed.errors);
|
||||||
|
var msg = parsed.errors[0];
|
||||||
|
assert.equal(msg, "Multiple features (0) identified by 'i' = -666 in layer 1");
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
function finish(err) {
|
||||||
|
keysToDelete['map_cfg|' + LayergroupToken.parse(expected_token).token] = 0;
|
||||||
|
keysToDelete['user:localhost:mapviews:global'] = 5;
|
||||||
|
|
||||||
|
|
||||||
|
done(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// See https://github.com/CartoDB/Windshaft/issues/131
|
// See https://github.com/CartoDB/Windshaft/issues/131
|
||||||
it("are checked at map creation time", function(done) {
|
it("are checked at map creation time", function(done) {
|
||||||
|
|
||||||
// clone the mapconfig test
|
// clone the mapconfig test
|
||||||
var mapconfig = JSON.parse(JSON.stringify(test_mapconfig_1));
|
var mapconfig = JSON.parse(JSON.stringify(test_mapconfig_1));
|
||||||
// append unexistant attribute name
|
// append unexistant attribute name
|
||||||
mapconfig.layers[1].options.sql = 'SELECT * FROM test_table';
|
mapconfig.layers[1].options.sql = 'SELECT * FROM test_table';
|
||||||
mapconfig.layers[1].options.attributes.id = 'unexistant';
|
mapconfig.layers[1].options.attributes.id = 'unexistant';
|
||||||
mapconfig.layers[1].options.attributes.columns = ['cartodb_id'];
|
mapconfig.layers[1].options.attributes.columns = ['cartodb_id'];
|
||||||
|
|
||||||
step(
|
step(
|
||||||
function do_post()
|
function do_post()
|
||||||
{
|
{
|
||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
data: JSON.stringify(mapconfig)
|
host: 'localhost',
|
||||||
}, {}, function(res, err) { next(err, res); });
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
function checkPost(err, res) {
|
data: JSON.stringify(mapconfig)
|
||||||
assert.ifError(err);
|
}, {}, function(res, err) { next(err, res); });
|
||||||
assert.equal(res.statusCode, 404, res.statusCode + ': ' + (res.statusCode===200?'...':res.body));
|
},
|
||||||
var parsed = JSON.parse(res.body);
|
function checkPost(err, res) {
|
||||||
assert.ok(parsed.errors);
|
assert.ifError(err);
|
||||||
assert.equal(parsed.errors.length, 1);
|
assert.equal(res.statusCode, 404, res.statusCode + ': ' + (res.statusCode===200?'...':res.body));
|
||||||
var msg = parsed.errors[0];
|
var parsed = JSON.parse(res.body);
|
||||||
assert.equal(msg, 'column "unexistant" does not exist');
|
assert.ok(parsed.errors);
|
||||||
return null;
|
assert.equal(parsed.errors.length, 1);
|
||||||
},
|
var msg = parsed.errors[0];
|
||||||
function finish(err) {
|
assert.equal(msg, 'column "unexistant" does not exist');
|
||||||
done(err);
|
return null;
|
||||||
}
|
},
|
||||||
);
|
function finish(err) {
|
||||||
});
|
done(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("can be used with jsonp", function(done) {
|
it("can be used with jsonp", function(done) {
|
||||||
|
|
||||||
@ -184,7 +198,10 @@ describe('attributes', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: JSON.stringify(test_mapconfig_1)
|
data: JSON.stringify(test_mapconfig_1)
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
@ -209,7 +226,10 @@ describe('attributes', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/0/attributes/1?callback=test',
|
'/0/attributes/1?callback=test',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_error_0(err, res) {
|
function check_error_0(err, res) {
|
||||||
@ -232,7 +252,10 @@ describe('attributes', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/1',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/1',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_attr_1(err, res) {
|
function check_attr_1(err, res) {
|
||||||
@ -270,7 +293,10 @@ describe('attributes', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: JSON.stringify(mapconfig)
|
data: JSON.stringify(mapconfig)
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json; charset=utf-8' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
@ -85,7 +85,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
@ -101,7 +101,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -154,7 +155,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||||
@ -177,7 +178,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -194,7 +196,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -212,7 +215,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -266,7 +270,7 @@ describe('multilayer', function() {
|
|||||||
config: JSON.stringify(layergroup)
|
config: JSON.stringify(layergroup)
|
||||||
}),
|
}),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {'Content-Type': 'application/json' }
|
headers: { host: 'localhost', 'Content-Type': 'application/json' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
// CORS headers should be sent with response
|
// CORS headers should be sent with response
|
||||||
@ -289,7 +293,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -307,7 +312,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/0/0/0/0.grid.json?interactivity=cartodb_id',
|
'/0/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -325,7 +331,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -380,7 +387,7 @@ describe('multilayer', function() {
|
|||||||
callback: 'jsonp_test'
|
callback: 'jsonp_test'
|
||||||
}),
|
}),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {'Content-Type': 'application/json' }
|
headers: { host: 'localhost', 'Content-Type': 'application/json' }
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function do_check_token(err, res) {
|
function do_check_token(err, res) {
|
||||||
@ -413,7 +420,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -431,7 +439,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/0/0/0/0.grid.json?interactivity=cartodb_id',
|
'/0/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -449,7 +458,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -510,7 +520,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res, err) {
|
}, {}, function(res, err) {
|
||||||
next(err, res);
|
next(err, res);
|
||||||
@ -530,7 +540,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -548,7 +559,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/0/0/0/0.grid.json?interactivity=cartodb_id',
|
'/0/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -566,7 +578,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token +
|
url: '/database/windshaft_test/layergroup/' + expected_token +
|
||||||
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
'/1/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -583,7 +596,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/4',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/4',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res, err) {
|
}, {}, function(res, err) {
|
||||||
next(err, res);
|
next(err, res);
|
||||||
});
|
});
|
||||||
@ -602,7 +616,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/2/0/0/0.json.torque',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/2/0/0/0.json.torque',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function do_check_torque2(err, res) {
|
function do_check_torque2(err, res) {
|
||||||
@ -624,7 +639,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/0/0/0.json.torque',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/1/0/0/0.json.torque',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function do_check_torque1(err, res) {
|
function do_check_torque1(err, res) {
|
||||||
@ -684,7 +700,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup1)
|
data: JSON.stringify(layergroup1)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
@ -700,7 +716,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup2)
|
data: JSON.stringify(layergroup2)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
@ -717,7 +733,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -734,7 +751,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0/0.grid.json?interactivity=cartodb_id',
|
url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -752,7 +770,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + token2 + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + token2 + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -769,7 +788,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + token2 + '/0/0/0/0.grid.json?interactivity=cartodb_id',
|
url: '/database/windshaft_test/layergroup/' + token2 + '/0/0/0/0.grid.json?interactivity=cartodb_id',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
|
||||||
@ -826,7 +846,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
try {
|
try {
|
||||||
@ -848,7 +868,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
@ -893,7 +914,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {host: 'localhost', 'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||||
@ -922,7 +943,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {host: 'localhost', 'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||||
@ -957,7 +978,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {host: 'localhost', 'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: _.template(tpl, {font:'bogus'})
|
data: _.template(tpl, {font:'bogus'})
|
||||||
}, function(res) { next(null, res); });
|
}, function(res) { next(null, res); });
|
||||||
},
|
},
|
||||||
@ -977,7 +998,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {host: 'localhost', 'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: _.template(tpl, {font:available_system_fonts[0]})
|
data: _.template(tpl, {font:available_system_fonts[0]})
|
||||||
}, function(res) { next(null, res); });
|
}, function(res) { next(null, res); });
|
||||||
},
|
},
|
||||||
@ -1040,7 +1061,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
try {
|
try {
|
||||||
@ -1061,7 +1082,8 @@ describe('multilayer', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
next(null, res);
|
next(null, res);
|
||||||
});
|
});
|
||||||
@ -1093,63 +1115,8 @@ describe('multilayer', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// See http://github.com/CartoDB/Windshaft/issues/157
|
|
||||||
it("req2params is called only once for a multilayer post", function(done) {
|
|
||||||
|
|
||||||
var layergroup = {
|
|
||||||
version: '1.0.1',
|
|
||||||
layers: [
|
|
||||||
{ options: {
|
|
||||||
sql: 'select cartodb_id, ST_Translate(the_geom, 50, 0) as the_geom from test_table limit 2',
|
|
||||||
cartocss: '#layer { marker-fill:red; marker-width:32; marker-allow-overlap:true; }',
|
|
||||||
cartocss_version: '2.0.1',
|
|
||||||
interactivity: [ 'cartodb_id' ],
|
|
||||||
geom_column: 'the_geom'
|
|
||||||
} },
|
|
||||||
{ options: {
|
|
||||||
sql: 'select cartodb_id, ST_Translate(the_geom, -50, 0) as the_geom from test_table limit 2 offset 2',
|
|
||||||
cartocss: '#layer { marker-fill:blue; marker-allow-overlap:true; }',
|
|
||||||
cartocss_version: '2.0.2',
|
|
||||||
interactivity: [ 'cartodb_id' ],
|
|
||||||
geom_column: 'the_geom'
|
|
||||||
} }
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
var expected_token;
|
|
||||||
step(
|
|
||||||
function do_post()
|
|
||||||
{
|
|
||||||
global.req2params_calls = 0;
|
|
||||||
var next = this;
|
|
||||||
assert.response(server, {
|
|
||||||
url: '/database/windshaft_test/layergroup',
|
|
||||||
method: 'POST',
|
|
||||||
headers: {'Content-Type': 'application/json' },
|
|
||||||
data: JSON.stringify(layergroup)
|
|
||||||
}, {}, function(res, err) { next(err,res); });
|
|
||||||
},
|
|
||||||
function check_post(err, res) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
|
||||||
var parsedBody = JSON.parse(res.body);
|
|
||||||
expected_token = LayergroupToken.parse(parsedBody.layergroupid).token;
|
|
||||||
assert.equal(global.req2params_calls, 1);
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
function finish(err) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
var keysToDelete = {'user:localhost:mapviews:global': 5};
|
|
||||||
keysToDelete['map_cfg|' + expected_token] = 0;
|
|
||||||
testHelper.deleteRedisKeys(keysToDelete, done);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// See https://github.com/CartoDB/Windshaft/issues/163
|
// See https://github.com/CartoDB/Windshaft/issues/163
|
||||||
it("has different token for different database", function(done) {
|
it.skip("has different token for different database", function(done) {
|
||||||
var layergroup = {
|
var layergroup = {
|
||||||
version: '1.0.1',
|
version: '1.0.1',
|
||||||
layers: [
|
layers: [
|
||||||
@ -1170,7 +1137,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res, err) { next(err,res); });
|
}, {}, function(res, err) { next(err,res); });
|
||||||
},
|
},
|
||||||
@ -1187,7 +1154,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test2/layergroup',
|
url: '/database/windshaft_test2/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'cartodb250user', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res, err) { next(err,res); });
|
}, {}, function(res, err) { next(err,res); });
|
||||||
},
|
},
|
||||||
@ -1233,7 +1200,7 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res, err) { next(err,res); });
|
}, {}, function(res, err) { next(err,res); });
|
||||||
},
|
},
|
||||||
@ -1251,7 +1218,8 @@ describe('multilayer', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
assert.equal(res.statusCode, 200, res.body);
|
||||||
assert.equal(res.headers['content-type'], "image/png");
|
assert.equal(res.headers['content-type'], "image/png");
|
||||||
|
@ -24,7 +24,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded' }
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 400, res.body);
|
assert.equal(res.statusCode, 400, res.body);
|
||||||
var parsedBody = JSON.parse(res.body);
|
var parsedBody = JSON.parse(res.body);
|
||||||
@ -37,7 +40,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' }
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 400, res.body);
|
assert.equal(res.statusCode, 400, res.body);
|
||||||
var parsedBody = JSON.parse(res.body);
|
var parsedBody = JSON.parse(res.body);
|
||||||
@ -50,7 +56,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup?callback=test',
|
url: '/database/windshaft_test/layergroup?callback=test',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' }
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 200);
|
assert.equal(res.statusCode, 200);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@ -65,27 +74,30 @@ describe('multilayer error cases', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("layergroup with no cartocss_version", function(done) {
|
it("layergroup with no cartocss_version", function(done) {
|
||||||
var layergroup = {
|
var layergroup = {
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
layers: [
|
layers: [
|
||||||
{ options: {
|
{ options: {
|
||||||
sql: 'select cartodb_id, ST_Translate(the_geom, 50, 0) as the_geom from test_table limit 2',
|
sql: 'select cartodb_id, ST_Translate(the_geom, 50, 0) as the_geom from test_table limit 2',
|
||||||
cartocss: '#layer { marker-fill:red; marker-width:32; marker-allow-overlap:true; }',
|
cartocss: '#layer { marker-fill:red; marker-width:32; marker-allow-overlap:true; }',
|
||||||
geom_column: 'the_geom'
|
geom_column: 'the_geom'
|
||||||
} }
|
} }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
data: JSON.stringify(layergroup)
|
host: 'localhost',
|
||||||
}, {}, function(res) {
|
'Content-Type': 'application/json'
|
||||||
assert.equal(res.statusCode, 400, res.body);
|
},
|
||||||
var parsedBody = JSON.parse(res.body);
|
data: JSON.stringify(layergroup)
|
||||||
assert.deepEqual(parsedBody.errors, ["Missing cartocss_version for layer 0 options"]);
|
}, {}, function(res) {
|
||||||
done();
|
assert.equal(res.statusCode, 400, res.body);
|
||||||
});
|
var parsedBody = JSON.parse(res.body);
|
||||||
|
assert.deepEqual(parsedBody.errors, ["Missing cartocss_version for layer 0 options"]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sql/cartocss combination errors", function(done) {
|
it("sql/cartocss combination errors", function(done) {
|
||||||
@ -98,17 +110,18 @@ describe('multilayer error cases', function() {
|
|||||||
geom_column: 'the_geom'
|
geom_column: 'the_geom'
|
||||||
}}]
|
}}]
|
||||||
};
|
};
|
||||||
ServerOptions.afterLayergroupCreateCalls = 0;
|
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
try {
|
try {
|
||||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||||
// See http://github.com/CartoDB/Windshaft/issues/159
|
// See http://github.com/CartoDB/Windshaft/issues/159
|
||||||
assert.equal(ServerOptions.afterLayergroupCreateCalls, 0);
|
|
||||||
var parsed = JSON.parse(res.body);
|
var parsed = JSON.parse(res.body);
|
||||||
assert.ok(parsed);
|
assert.ok(parsed);
|
||||||
assert.equal(parsed.errors.length, 1);
|
assert.equal(parsed.errors.length, 1);
|
||||||
@ -149,12 +162,9 @@ describe('multilayer error cases', function() {
|
|||||||
}}
|
}}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
ServerOptions.afterLayergroupCreateCalls = 0;
|
|
||||||
this.client = new TestClient(layergroup);
|
this.client = new TestClient(layergroup);
|
||||||
this.client.getLayergroup({ response: { status: 400 } }, function(err, parsed) {
|
this.client.getLayergroup({ response: { status: 400 } }, function(err, parsed) {
|
||||||
assert.ok(!err, err);
|
assert.ok(!err, err);
|
||||||
// See http://github.com/CartoDB/Windshaft/issues/159
|
|
||||||
assert.equal(ServerOptions.afterLayergroupCreateCalls, 0);
|
|
||||||
assert.ok(parsed);
|
assert.ok(parsed);
|
||||||
assert.equal(parsed.errors.length, 1);
|
assert.equal(parsed.errors.length, 1);
|
||||||
var error = parsed.errors[0];
|
var error = parsed.errors[0];
|
||||||
@ -186,7 +196,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
try {
|
try {
|
||||||
@ -222,7 +235,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
try {
|
try {
|
||||||
@ -264,7 +280,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) {
|
}, {}, function(res) {
|
||||||
assert.equal(res.statusCode, 400, res.body);
|
assert.equal(res.statusCode, 400, res.body);
|
||||||
@ -367,7 +386,10 @@ describe('multilayer error cases', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/deadbeef/0/0/0/0.grid.json',
|
url: '/database/windshaft_test/layergroup/deadbeef/0/0/0/0.grid.json',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function checkResponse(err, res) {
|
function checkResponse(err, res) {
|
||||||
|
@ -23,13 +23,12 @@ describe('multilayer interactivity and layers order', function() {
|
|||||||
layers: testScenario.layers
|
layers: testScenario.layers
|
||||||
};
|
};
|
||||||
|
|
||||||
PortedServerOptions.afterLayergroupCreateCalls = 0;
|
|
||||||
|
|
||||||
assert.response(server,
|
assert.response(server,
|
||||||
{
|
{
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
@ -49,8 +48,6 @@ describe('multilayer interactivity and layers order', function() {
|
|||||||
'\n\tLayer types: ' + layergroup.layers.map(layerType).join(', ')
|
'\n\tLayer types: ' + layergroup.layers.map(layerType).join(', ')
|
||||||
);
|
);
|
||||||
|
|
||||||
// assert.equal(PortedServerOptions.afterLayergroupCreateCalls, 1);
|
|
||||||
|
|
||||||
var layergroupResponse = JSON.parse(response.body);
|
var layergroupResponse = JSON.parse(response.body);
|
||||||
assert.ok(layergroupResponse);
|
assert.ok(layergroupResponse);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ describe('raster', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(mapconfig)
|
data: JSON.stringify(mapconfig)
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
@ -66,7 +66,8 @@ describe('raster', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: { host: 'localhost' }
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_response(err, res) {
|
function check_response(err, res) {
|
||||||
@ -124,6 +125,7 @@ describe('raster', function() {
|
|||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: JSON.stringify(mapconfig)
|
data: JSON.stringify(mapconfig)
|
||||||
|
@ -8,21 +8,6 @@ describe('regressions', function() {
|
|||||||
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
||||||
});
|
});
|
||||||
|
|
||||||
// See https://github.com/Vizzuality/Windshaft/issues/65
|
|
||||||
it("#65 catching non-Error exception doesn't kill the backend", function(done) {
|
|
||||||
var mapConfig = testClient.defaultTableMapConfig('test_table');
|
|
||||||
testClient.withLayergroup(mapConfig, function(err, requestTile, finish) {
|
|
||||||
var options = {
|
|
||||||
statusCode: 400,
|
|
||||||
contentType: 'application/json; charset=utf-8'
|
|
||||||
};
|
|
||||||
requestTile('/0/0/0.png?testUnexpectedError=1', options, function(err, res) {
|
|
||||||
assert.deepEqual(JSON.parse(res.body).errors, ["test unexpected error"]);
|
|
||||||
finish(done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Test that you cannot write to the database from a tile request
|
// Test that you cannot write to the database from a tile request
|
||||||
//
|
//
|
||||||
// See http://github.com/CartoDB/Windshaft/issues/130
|
// See http://github.com/CartoDB/Windshaft/issues/130
|
||||||
|
@ -38,6 +38,7 @@ describe('retina support', function() {
|
|||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: JSON.stringify(retinaSampleMapConfig)
|
data: JSON.stringify(retinaSampleMapConfig)
|
||||||
@ -67,7 +68,10 @@ describe('retina support', function() {
|
|||||||
{
|
{
|
||||||
url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/0/0' + scaleFactor + '.png',
|
url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/0/0' + scaleFactor + '.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
responseHead,
|
responseHead,
|
||||||
assertFn
|
assertFn
|
||||||
|
@ -59,7 +59,7 @@ describe('server_gettile', function() {
|
|||||||
assert.ok(xwc > 0);
|
assert.ok(xwc > 0);
|
||||||
assert.ok(xwc >= lastXwc);
|
assert.ok(xwc >= lastXwc);
|
||||||
|
|
||||||
requestTile(tileUrl + '?cache_buster=wadus', function (err, res) {
|
requestTile(tileUrl, { cache_buster: 'wadus' }, function (err, res) {
|
||||||
var xwc = res.headers['x-windshaft-cache'];
|
var xwc = res.headers['x-windshaft-cache'];
|
||||||
assert.ok(!xwc);
|
assert.ok(!xwc);
|
||||||
|
|
||||||
@ -99,18 +99,25 @@ describe('server_gettile', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClient.withLayergroup(mapConfig, validateLayergroup, function(err, requestTile, finish) {
|
testClient.withLayergroup(mapConfig, validateLayergroup, function(err, requestTile, finish) {
|
||||||
|
|
||||||
requestTile(tileUrl, function(err, res) {
|
requestTile(tileUrl, function(err, res) {
|
||||||
assert.ok(res.headers.hasOwnProperty('x-windshaft-cache'), "Did not hit renderer cache on second time");
|
var xwc = res.headers['x-windshaft-cache'];
|
||||||
assert.ok(res.headers['x-windshaft-cache'] >= 0);
|
assert.ok(!xwc);
|
||||||
|
|
||||||
assert.imageBufferIsSimilarToFile(res.body, imageFixture, IMAGE_EQUALS_TOLERANCE_PER_MIL,
|
requestTile(tileUrl, function (err, res) {
|
||||||
function(err) {
|
assert.ok(
|
||||||
finish(function(finishErr) {
|
res.headers.hasOwnProperty('x-windshaft-cache'),
|
||||||
done(err || finishErr);
|
"Did not hit renderer cache on second time"
|
||||||
});
|
);
|
||||||
}
|
assert.ok(res.headers['x-windshaft-cache'] >= 0);
|
||||||
);
|
|
||||||
|
assert.imageBufferIsSimilarToFile(res.body, imageFixture, IMAGE_EQUALS_TOLERANCE_PER_MIL,
|
||||||
|
function(err) {
|
||||||
|
finish(function(finishErr) {
|
||||||
|
done(err || finishErr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -62,6 +62,7 @@ describe('server_png8_format', function() {
|
|||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
@ -81,7 +82,10 @@ describe('server_png8_format', function() {
|
|||||||
var requestPayload = {
|
var requestPayload = {
|
||||||
url: '/database/windshaft_test/layergroup/' + layergroupId + tilePartialUrl,
|
url: '/database/windshaft_test/layergroup/' + layergroupId + tilePartialUrl,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var requestHeaders = {
|
var requestHeaders = {
|
||||||
@ -179,4 +183,3 @@ describe('server_png8_format', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var serverOptions = require('../../../../lib/cartodb/server_options');
|
var serverOptions = require('../../../../lib/cartodb/server_options');
|
||||||
var mapnik = require('windshaft').mapnik;
|
var mapnik = require('windshaft').mapnik;
|
||||||
var LayergroupToken = require('../../../../lib/cartodb/models/layergroup-token');
|
|
||||||
var OverviewsQueryRewriter = require('../../../../lib/cartodb/utils/overviews_query_rewriter');
|
var OverviewsQueryRewriter = require('../../../../lib/cartodb/utils/overviews_query_rewriter');
|
||||||
var overviewsQueryRewriter = new OverviewsQueryRewriter({
|
var overviewsQueryRewriter = new OverviewsQueryRewriter({
|
||||||
zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)'
|
zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)'
|
||||||
@ -47,48 +46,5 @@ module.exports = _.extend({}, serverOptions, {
|
|||||||
enable_cors: global.environment.enable_cors,
|
enable_cors: global.environment.enable_cors,
|
||||||
unbuffered_logging: true, // for smoother teardown from tests
|
unbuffered_logging: true, // for smoother teardown from tests
|
||||||
log_format: null, // do not log anything
|
log_format: null, // do not log anything
|
||||||
afterLayergroupCreateCalls: 0,
|
useProfiler: true
|
||||||
useProfiler: true,
|
|
||||||
req2params: function(req, res, callback){
|
|
||||||
|
|
||||||
if ( req.query.testUnexpectedError ) {
|
|
||||||
return callback('test unexpected error');
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is in case you want to test sql parameters eg ...png?sql=select * from my_table limit 10
|
|
||||||
req.params = _.extend({}, req.params);
|
|
||||||
|
|
||||||
if (req.params.token) {
|
|
||||||
req.params.token = LayergroupToken.parse(req.params.token).token;
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(req.params, req.query);
|
|
||||||
req.params.user = 'localhost';
|
|
||||||
res.locals.user = 'localhost';
|
|
||||||
|
|
||||||
req.params.dbhost = global.environment.postgres.host;
|
|
||||||
req.params.dbport = req.params.dbport || global.environment.postgres.port;
|
|
||||||
|
|
||||||
req.params.dbuser = 'test_windshaft_publicuser';
|
|
||||||
if (req.params.dbname !== 'windshaft_test2') {
|
|
||||||
req.params.dbuser = 'test_windshaft_cartodb_user_1';
|
|
||||||
}
|
|
||||||
req.params.dbname = 'test_windshaft_cartodb_user_1_db';
|
|
||||||
|
|
||||||
// add all params to res.locals
|
|
||||||
res.locals = _.extend({}, req.params);
|
|
||||||
|
|
||||||
|
|
||||||
// increment number of calls counter
|
|
||||||
global.req2params_calls = global.req2params_calls ? global.req2params_calls + 1 : 1;
|
|
||||||
|
|
||||||
// send the finished req object on
|
|
||||||
callback(null,req);
|
|
||||||
},
|
|
||||||
afterLayergroupCreate: function(req, cfg, res, callback) {
|
|
||||||
res.layercount = cfg.layers.length;
|
|
||||||
// config.afterLayergroupCreateCalls++;
|
|
||||||
callback(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -72,7 +72,7 @@ function createLayergroup(layergroupConfig, options, callback) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
function validateLayergroup(err, res) {
|
function validateLayergroup(err, res) {
|
||||||
assert.ok(!err, 'Failed to request layergroup');
|
assert.ifError(err);
|
||||||
|
|
||||||
var parsedBody;
|
var parsedBody;
|
||||||
var layergroupid;
|
var layergroupid;
|
||||||
@ -129,6 +129,7 @@ function layergroupRequest(layergroupConfig, method, callbackName, extraParams)
|
|||||||
var request = {
|
var request = {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
headers: {
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -337,6 +338,7 @@ function getGeneric(layergroupConfig, url, expectedResponse, callback) {
|
|||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
host: 'localhost',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: JSON.stringify(layergroupConfig)
|
data: JSON.stringify(layergroupConfig)
|
||||||
@ -372,7 +374,10 @@ function getGeneric(layergroupConfig, url, expectedResponse, callback) {
|
|||||||
|
|
||||||
var request = {
|
var request = {
|
||||||
url: finalUrl,
|
url: finalUrl,
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (contentType === pngContentType) {
|
if (contentType === pngContentType) {
|
||||||
@ -449,12 +454,28 @@ function withLayergroup(layergroupConfig, options, callback) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseUrlTpl = '/database/windshaft_test/layergroup/<%= layergroupid %>';
|
const signerTpl = function ({ signer }) {
|
||||||
var finalUrl = _.template(baseUrlTpl, { layergroupid: layergroupid }) + layergroupUrl;
|
return `${signer ? `:${signer}@` : ''}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const cacheTpl = function ({ cache_buster, cacheBuster }) {
|
||||||
|
return `${cache_buster ? `:${cache_buster}` : `:${cacheBuster}`}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const urlTpl = function ({layergroupid, cache_buster = null, tile }) {
|
||||||
|
const { signer, token , cacheBuster } = LayergroupToken.parse(layergroupid);
|
||||||
|
const base = '/database/windshaft_test/layergroup/';
|
||||||
|
return `${base}${signerTpl({signer})}${token}${cacheTpl({cache_buster, cacheBuster})}${tile}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const finalUrl = urlTpl({ layergroupid, cache_buster: options.cache_buster, tile: layergroupUrl });
|
||||||
|
|
||||||
var request = {
|
var request = {
|
||||||
url: finalUrl,
|
url: finalUrl,
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.contentType === pngContentType) {
|
if (options.contentType === pngContentType) {
|
||||||
|
@ -48,7 +48,7 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) { next(null, res); });
|
}, {}, function(res) { next(null, res); });
|
||||||
},
|
},
|
||||||
@ -71,7 +71,7 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) { next(null, res); });
|
}, {}, function(res) { next(null, res); });
|
||||||
},
|
},
|
||||||
@ -94,7 +94,7 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) { next(null, res); });
|
}, {}, function(res) { next(null, res); });
|
||||||
},
|
},
|
||||||
@ -136,7 +136,7 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) { next(null, res); });
|
}, {}, function(res) { next(null, res); });
|
||||||
},
|
},
|
||||||
@ -179,7 +179,7 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(mapconfig)
|
data: JSON.stringify(mapconfig)
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
@ -218,7 +218,10 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_mapnik_error_1(err, res) {
|
function check_mapnik_error_1(err, res) {
|
||||||
@ -235,7 +238,10 @@ describe('torque', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_mapnik_error_2(err, res) {
|
function check_mapnik_error_2(err, res) {
|
||||||
@ -252,7 +258,10 @@ describe('torque', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.json.torque',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.json.torque',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_torque0_response(err, res) {
|
function check_torque0_response(err, res) {
|
||||||
@ -270,7 +279,10 @@ describe('torque', function() {
|
|||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.torque.json',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.torque.json',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function check_torque0_response_1(err, res) {
|
function check_torque0_response_1(err, res) {
|
||||||
@ -315,7 +327,7 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(mapconfig)
|
data: JSON.stringify(mapconfig)
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
@ -354,19 +366,25 @@ describe('torque', function() {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let defautlPort = global.environment.postgres.port;
|
||||||
|
|
||||||
step(
|
step(
|
||||||
function do_post()
|
function do_post()
|
||||||
{
|
{
|
||||||
var next = this;
|
var next = this;
|
||||||
|
global.environment.postgres.port = 54777;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup?dbport=54777',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(mapconfig)
|
data: JSON.stringify(mapconfig)
|
||||||
}, {}, function(res, err) { next(err, res); });
|
}, {}, function(res, err) { next(err, res); });
|
||||||
},
|
},
|
||||||
function checkPost(err, res) {
|
function checkPost(err, res) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|
||||||
|
global.environment.postgres.port = defautlPort;
|
||||||
|
|
||||||
assert.equal(res.statusCode, 500, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 500, res.statusCode + ': ' + res.body);
|
||||||
var parsed = JSON.parse(res.body);
|
var parsed = JSON.parse(res.body);
|
||||||
assert.ok(parsed.errors, parsed);
|
assert.ok(parsed.errors, parsed);
|
||||||
@ -407,9 +425,9 @@ describe('torque', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(layergroup)
|
data: JSON.stringify(layergroup)
|
||||||
}, {}, function(res) { next(null, res); });
|
}, {}, function (res) { next(null, res); });
|
||||||
},
|
},
|
||||||
function checkResponse(err, res) {
|
function checkResponse(err, res) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
@ -237,7 +237,7 @@ describe('torque boundary points', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(boundaryPointsMapConfig)
|
data: JSON.stringify(boundaryPointsMapConfig)
|
||||||
}, {}, function (res, err) {
|
}, {}, function (res, err) {
|
||||||
|
|
||||||
@ -250,7 +250,10 @@ describe('torque boundary points', function() {
|
|||||||
var partialUrl = tileRequest.z + '/' + tileRequest.x + '/' + tileRequest.y;
|
var partialUrl = tileRequest.z + '/' + tileRequest.x + '/' + tileRequest.y;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/' + partialUrl + '.json.torque',
|
url: '/database/windshaft_test/layergroup/' + expected_token + '/0/' + partialUrl + '.json.torque',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function (res, err) {
|
}, {}, function (res, err) {
|
||||||
assert.ok(!err, 'Failed to get json');
|
assert.ok(!err, 'Failed to get json');
|
||||||
|
|
||||||
@ -351,7 +354,7 @@ describe('torque boundary points', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(londonPointMapConfig)
|
data: JSON.stringify(londonPointMapConfig)
|
||||||
}, {}, function (res, err) {
|
}, {}, function (res, err) {
|
||||||
assert.ok(!err, 'Failed to create layergroup');
|
assert.ok(!err, 'Failed to create layergroup');
|
||||||
@ -363,7 +366,10 @@ describe('torque boundary points', function() {
|
|||||||
|
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/2/1/1.json.torque',
|
url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/2/1/1.json.torque',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function (res, err) {
|
}, {}, function (res, err) {
|
||||||
assert.ok(!err, 'Failed to request torque.json');
|
assert.ok(!err, 'Failed to request torque.json');
|
||||||
|
|
||||||
@ -414,7 +420,7 @@ describe('torque boundary points', function() {
|
|||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup',
|
url: '/database/windshaft_test/layergroup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json' },
|
headers: { host: 'localhost', 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify(londonPointMapConfig)
|
data: JSON.stringify(londonPointMapConfig)
|
||||||
}, {}, function (res, err) {
|
}, {}, function (res, err) {
|
||||||
assert.ok(!err, 'Failed to create layergroup');
|
assert.ok(!err, 'Failed to create layergroup');
|
||||||
@ -426,7 +432,10 @@ describe('torque boundary points', function() {
|
|||||||
|
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/13/4255/2765.json.torque',
|
url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/13/4255/2765.json.torque',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
host: 'localhost'
|
||||||
|
}
|
||||||
}, {}, function (res, err) {
|
}, {}, function (res, err) {
|
||||||
assert.ok(!err, 'Failed to request torque.json');
|
assert.ok(!err, 'Failed to request torque.json');
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ var PgConnection = require('../../../lib/cartodb/backends/pg_connection');
|
|||||||
var AuthApi = require('../../../lib/cartodb/api/auth_api');
|
var AuthApi = require('../../../lib/cartodb/api/auth_api');
|
||||||
var TemplateMaps = require('../../../lib/cartodb/backends/template_maps');
|
var TemplateMaps = require('../../../lib/cartodb/backends/template_maps');
|
||||||
|
|
||||||
const cleanUpQueryParamsMiddleware = require('../../../lib/cartodb/middleware/context/clean-up-query-params');
|
const cleanUpQueryParamsMiddleware = require('../../../lib/cartodb/middleware/clean-up-query-params');
|
||||||
const authorizeMiddleware = require('../../../lib/cartodb/middleware/context/authorize');
|
const authorizeMiddleware = require('../../../lib/cartodb/middleware/authorize');
|
||||||
const dbConnSetupMiddleware = require('../../../lib/cartodb/middleware/context/db-conn-setup');
|
const dbConnSetupMiddleware = require('../../../lib/cartodb/middleware/db-conn-setup');
|
||||||
const credentialsMiddleware = require('../../../lib/cartodb/middleware/context/credentials');
|
const credentialsMiddleware = require('../../../lib/cartodb/middleware/credentials');
|
||||||
const localsMiddleware = require('../../../lib/cartodb/middleware/context/locals');
|
const localsMiddleware = require('../../../lib/cartodb/middleware/locals');
|
||||||
|
|
||||||
var windshaft = require('windshaft');
|
var windshaft = require('windshaft');
|
||||||
|
|
||||||
@ -178,10 +178,9 @@ describe('prepare-context', function() {
|
|||||||
return done(err);
|
return done(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = res.locals;
|
assert.deepEqual(config, req.query.config);
|
||||||
assert.deepEqual(config, query.config);
|
assert.equal('test', req.query.api_key);
|
||||||
assert.equal('test', query.api_key);
|
assert.equal(undefined, req.query.non_included);
|
||||||
assert.equal(undefined, query.non_included);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user