From c884deba05458f3687ba730efda2903ffccf2230 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 9 Jul 2012 19:20:49 +0200 Subject: [PATCH] Remove duplicated server_options.js file --- test/acceptance/server.js | 2 +- test/support/server_options.js | 126 --------------------------------- 2 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 test/support/server_options.js diff --git a/test/acceptance/server.js b/test/acceptance/server.js index 744e6811..078ff076 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server.js @@ -5,7 +5,7 @@ var querystring = require('querystring'); require(__dirname + '/../test_helper'); var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft'); -var serverOptions = require(__dirname + '/../support/server_options'); +var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); var server = new CartodbWindshaft(serverOptions); suite('server', function() { diff --git a/test/support/server_options.js b/test/support/server_options.js deleted file mode 100644 index aac0f1ca..00000000 --- a/test/support/server_options.js +++ /dev/null @@ -1,126 +0,0 @@ -var _ = require('underscore') - , Step = require('step') - , cartoData = require('../../lib/cartodb/carto_data'); - -module.exports = function(){ - var me = { - base_url: '/tiles/:table', - grainstore: {datasource: global.environment.postgres}, - redis: global.environment.redis, - enable_cors: global.environment.enable_cors, - varnish_host: global.environment.varnish.host, - varnish_port: global.environment.varnish.port, - cache_enabled: global.environment.cache_enabled, - log_format: '[:date] :req[X-Real-IP] \033[90m:method\033[0m \033[36m:req[Host]:url\033[0m \033[90m:status :response-time ms -> :res[Content-Type]\033[0m' - }; - - /** - * Whitelist input and get database name & default geometry type from - * subdomain/user metadata held in CartoDB Redis - * @param req - standard express request obj. Should have host & table - * @param callback - */ - me.req2params = function(req, callback){ - - // Whitelist query parameters and attach format - var good_query = ['sql', 'geom_type', 'cache_buster','callback', 'interactivity', 'map_key', 'style']; - var bad_query = _.difference(_.keys(req.query), good_query); - - _.each(bad_query, function(key){ delete req.query[key]; }); - req.params = _.extend({}, req.params); // shuffle things as request is a strange array/object - - // bring all query values onto req.params object - _.extend(req.params, req.query); - - // for cartodb, ensure interactivity is cartodb_id or user specified - req.params.interactivity = req.params.interactivity || 'cartodb_id'; - - Step( - function getPrivacy(){ - cartoData.authorize(req, this); - }, - function gatekeep(err, data){ - if(err) throw err; - if(data === "0") throw new Error("Sorry, you are unauthorized"); - return data; - }, - function getDatabase(err, data){ - if(err) throw err; - - cartoData.getDatabase(req, this); - }, - function getGeometryType(err, data){ - if (err) throw err; - _.extend(req.params, {dbname:data}); - - cartoData.getGeometryType(req, this); - }, - function finishSetup(err, data){ - if (!_.isNull(data)) - _.extend(req.params, {geom_type: data}); - - callback(err, req); - } - ); - }; - - /** - * Little helper method to get the current list of infowindow variables and return to client - * @param req - * @param callback - */ - me.getInfowindow = function(req, callback){ - var that = this; - - Step( - function(){ - that.req2params(req, this); - }, - function(err, data){ - if (err) throw err; - cartoData.getInfowindow(data, callback); - } - ); - }; - - /** - * Little helper method to get map metadata and return to client - * @param req - * @param callback - */ - me.getMapMetadata = function(req, callback){ - var that = this; - - Step( - function(){ - that.req2params(req, this); - }, - function(err, data){ - if (err) throw err; - cartoData.getMapMetadata(data, callback); - } - ); - }; - - /** - * Helper to clear out tile cache on request - * @param req - * @param callback - */ - me.flushCache = function(req, Cache, callback){ - var that = this; - - Step( - function(){ - that.req2params(req, this); - }, - function(err, data){ - if (err) throw err; - Cache.invalidate_db(req.params.dbname, req.params.table); - callback(null, true); - } - ); - }; - - return me; -}();