From c1c6d493b728484c82e963df335d224e1ff80657 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 15:54:05 +0100 Subject: [PATCH 1/8] allow urls like /u/:user/ --- config/environments/development.js.example | 4 ++-- config/environments/production.js.example | 4 ++-- config/environments/staging.js.example | 4 ++-- lib/cartodb/server_options.js | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 1c036f67..4757f7d8 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 28f2ee95..2aaf6d60 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 88a0d8e7..77da9151 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/maps/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/maps/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "/api/v1/maps" is the the new API, // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/maps|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index ff052586..951f2d7f 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -377,6 +377,9 @@ module.exports = function(redisPool) { me.userByReq = function(req) { var host = req.headers.host; + if (req.params.user) { + return req.params.user; + } var mat = host.match(this.re_userFromHost); if ( ! mat ) { console.error("ERROR: user pattern '" + this.re_userFromHost + "' does not match hostname '" + host + "'"); From 5af09fc2bff7ce6bf29d3269c64c99a7fe64fb1d Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 17:04:25 +0100 Subject: [PATCH 2/8] small refactor in tests --- test/acceptance/multilayer.js | 68 ++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 84b1e220..650272fc 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -22,6 +22,7 @@ serverOptions = ServerOptions(); var server = new CartodbWindshaft(serverOptions); server.setMaxListeners(0); +['/tiles/layergroup'].forEach(function(layergroup_url) { [true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() { @@ -66,7 +67,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -94,7 +95,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -135,7 +136,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/localhost@' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + '/localhost@' + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -152,7 +153,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/0/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -170,7 +171,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/1/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -222,7 +223,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res, err) { next(err, res); }); @@ -255,7 +256,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res, err) { next(err, res); }); @@ -299,7 +300,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res) { @@ -321,7 +322,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res) { @@ -352,7 +353,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -379,7 +380,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb10/1/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb10/1/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -418,7 +419,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb11/4/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb11/4/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -457,7 +458,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/0/1/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -475,7 +476,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/0/4/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -539,7 +540,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -561,7 +562,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( + statskey + ":stat_tag:" + layergroup.stat_tag + " to be 1, got " + val); var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -620,7 +621,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -648,7 +649,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -716,7 +717,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -737,7 +738,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/0/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -751,7 +752,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/1/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -766,7 +767,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -782,7 +783,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/0/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -798,7 +799,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/1/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -878,7 +879,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -908,7 +909,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1044,7 +1045,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1068,7 +1069,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1146,7 +1147,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?api_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?api_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1211,7 +1212,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( assert.ok(data.length > 1024*64); var next = this; assert.response(server, { - url: '/tiles/layergroup?api_key=1234', + url: layergroup_url + '?api_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: data @@ -1268,7 +1269,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1310,7 +1311,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1334,7 +1335,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( } var layergroupTtlRequest = { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify({ + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify({ version: '1.0.0', layers: [ { options: { @@ -1442,3 +1443,4 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( }); }); +}); From 72294fbd25e86fe28626a36870e87780594c4a7b Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 17:26:33 +0100 Subject: [PATCH 3/8] refined tests --- test/acceptance/multilayer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 650272fc..ac380ac1 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -689,7 +689,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?map_key=1234', + url: layergroup_url + '?map_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -850,7 +850,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?map_key=1234', + url: layergroup_url + '?map_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1069,7 +1069,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1121,7 +1121,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?api_key=1234', + url: layergroup_url + '?api_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1147,7 +1147,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?api_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?api_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' From 00cf83dc454a598b1c0e1bec7a2e7dc46e2a95cd Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 17:53:49 +0100 Subject: [PATCH 4/8] try to fix test, take 3 --- test/acceptance/multilayer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index ac380ac1..6de5520b 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -717,7 +717,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -738,7 +738,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/0/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -752,7 +752,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/1/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -767,7 +767,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -783,7 +783,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/0/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -799,7 +799,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/1/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -879,7 +879,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -909,7 +909,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' From b891ae19f450e47dae49ec717660c02fe61576d5 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 18:15:26 +0100 Subject: [PATCH 5/8] adding a bunch of test for layer group url --- test/acceptance/multilayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 6de5520b..ad92a583 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -22,10 +22,10 @@ serverOptions = ServerOptions(); var server = new CartodbWindshaft(serverOptions); server.setMaxListeners(0); -['/tiles/layergroup'].forEach(function(layergroup_url) { +['/tiles/layergroup', '/u/rambo/tiles/layergroup'].forEach(function(layergroup_url) { [true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { -suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() { +suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + "layergroup_url=" + layergroup_url, function() { var redis_client = redis.createClient(global.environment.redis.port); var sqlapi_server; From 2f44dfe1dadc5feb6ee76463699d77801bb3b4f2 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 18:36:44 +0100 Subject: [PATCH 6/8] updated test config --- config/environments/test.js.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 066bf1d0..056e8394 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' From 9ba53dc4cf8670a6cb78db69a11d0d468e2ce187 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Fri, 20 Mar 2015 00:30:56 +0100 Subject: [PATCH 7/8] Adds user param to params whitelist and uses localhost user for tests --- lib/cartodb/server_options.js | 1 + test/acceptance/multilayer.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 951f2d7f..5863f211 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -18,6 +18,7 @@ if ( _.isUndefined(global.environment.sqlapi.domain) ) { // Whitelist query parameters and attach format var REQUEST_QUERY_PARAMS_WHITELIST = [ + 'user', 'sql', 'geom_type', 'cache_buster', diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index ad92a583..3af4d95a 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -22,10 +22,11 @@ serverOptions = ServerOptions(); var server = new CartodbWindshaft(serverOptions); server.setMaxListeners(0); -['/tiles/layergroup', '/u/rambo/tiles/layergroup'].forEach(function(layergroup_url) { +['/tiles/layergroup', '/u/localhost/tiles/layergroup'].forEach(function(layergroup_url) { [true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { -suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + "layergroup_url=" + layergroup_url, function() { +var suiteName = 'multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + ";layergroup_url=" + layergroup_url; +suite(suiteName, function() { var redis_client = redis.createClient(global.environment.redis.port); var sqlapi_server; From 9b4acf99d5d42c4777e986cafea34a9e27ff40aa Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Fri, 20 Mar 2015 00:34:30 +0100 Subject: [PATCH 8/8] Adds example configuration to accept user param in /tiles/layergroup That is used in testing. Tests should start moving to /api/v1/map. --- config/environments/development.js.example | 4 ++-- config/environments/production.js.example | 4 ++-- config/environments/staging.js.example | 4 ++-- config/environments/test.js.example | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 4757f7d8..d6bfba7f 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 2aaf6d60..e58aea66 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 77da9151..8f4b0941 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/maps/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "/api/v1/maps" is the the new API, // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 056e8394..64c40ffd 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table'