Require interactivity param in single-layer grid fetching request
Closes #69
This commit is contained in:
parent
aea107f1af
commit
3383c44eb7
9
NEWS.md
9
NEWS.md
@ -1,9 +1,9 @@
|
||||
1.2.0
|
||||
-----
|
||||
|
||||
WARNING: starting from this commit the grid fetching route changed
|
||||
to NOT include layer name nor interactivity (which is now
|
||||
specified solely as part of layergroup configuration)
|
||||
WARNING: starting from this commit the multilayer grid fetching
|
||||
route changed to NOT include layer name nor interactivity
|
||||
(now specified solely as part of layergroup configuration)
|
||||
|
||||
* Handle SQL API errors by requesting no Varnish cache
|
||||
* Fix X-Cache-Channel for multilayer (by token) responses
|
||||
@ -11,7 +11,8 @@ WARNING: starting from this commit the grid fetching route changed
|
||||
* Deprecate signal handler for USR1, add handler for USR2 (#71)
|
||||
* Fix support for ampersend characters in CartoCSS
|
||||
* Add support for LZMA compressed GET parameters
|
||||
* Remove interactivity parameters from grid fetching route
|
||||
* Remove interactivity config from multilayer grid fetching route
|
||||
* Require interactivity param in single-layer grid fetching request (#69)
|
||||
|
||||
1.1.8
|
||||
-----
|
||||
|
@ -303,7 +303,8 @@ module.exports = function(){
|
||||
_.extend(req.params, req.query);
|
||||
|
||||
// for cartodb, ensure interactivity is cartodb_id or user specified
|
||||
req.params.interactivity = req.params.interactivity || 'cartodb_id';
|
||||
// Don't: https://github.com/Vizzuality/Windshaft-cartodb/issues/69
|
||||
//req.params.interactivity = req.params.interactivity || 'cartodb_id';
|
||||
|
||||
req.params.processXML = function(req, xml, callback) {
|
||||
var dbuser = req.dbuser ? req.dbuser : global.settings.postgres.user;
|
||||
|
@ -530,11 +530,24 @@ suite('server', function() {
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
test("get'ing a json with default style should return an grid", function(done){
|
||||
test("get'ing a grid with no interactivity should fail", function(done){
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/gadm4/6/31/24.grid.json',
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||
assert.deepEqual(JSON.parse(res.body), {"error":"Missing interactivity parameter"});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test("get'ing a json with default style should return an grid", function(done){
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/gadm4/6/31/24.grid.json?interactivity=cartodb_id',
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/javascript; charset=utf-8; charset=utf-8',
|
||||
@ -545,7 +558,7 @@ suite('server', function() {
|
||||
test("get'ing a json with default style should return an grid", function(done){
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/gadm4/6/31/24.grid.json',
|
||||
url: '/tiles/gadm4/6/31/24.grid.json?interactivity=cartodb_id',
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200,
|
||||
@ -554,10 +567,13 @@ suite('server', function() {
|
||||
});
|
||||
|
||||
test("get'ing a json with default style and sql should return a constrained grid", function(done){
|
||||
var sql = querystring.stringify({sql: "SELECT * FROM gadm4 WHERE codineprov = '08'"})
|
||||
var q = querystring.stringify({
|
||||
interactivity: 'cartodb_id',
|
||||
sql: "SELECT * FROM gadm4 WHERE codineprov = '08'"
|
||||
})
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/gadm4/6/31/24.grid.json?' + sql,
|
||||
url: '/tiles/gadm4/6/31/24.grid.json?' + q,
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200,
|
||||
@ -569,7 +585,7 @@ suite('server', function() {
|
||||
function(done) {
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/test_table_private_1/6/31/24.grid.json',
|
||||
url: '/tiles/test_table_private_1/6/31/24.grid.json?interactivity=cartodb_id',
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
// 401 Unauthorized
|
||||
@ -583,7 +599,7 @@ suite('server', function() {
|
||||
function(done) {
|
||||
assert.response(server, {
|
||||
headers: {host: 'unknown_user'},
|
||||
url: '/tiles/test_table_private_1/6/31/24.grid.json',
|
||||
url: '/tiles/test_table_private_1/6/31/24.grid.json?interactivity=cartodb_id',
|
||||
method: 'GET'
|
||||
},{
|
||||
}, function(res) {
|
||||
@ -599,7 +615,7 @@ suite('server', function() {
|
||||
function(done) {
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/test_table_private_1/6/31/24.grid.json?map_key=1234',
|
||||
url: '/tiles/test_table_private_1/6/31/24.grid.json?map_key=1234&interactivity=cartodb_id',
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
|
@ -19,7 +19,7 @@ suite('req2params', function() {
|
||||
assert.ok(_.isObject(req.query), 'request has query');
|
||||
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
||||
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
||||
assert.ok(req.params.hasOwnProperty('interactivity'), 'request params have interactivity');
|
||||
assert.ok(!req.params.hasOwnProperty('interactivity'), 'request params have interactivity');
|
||||
assert.equal(req.params.dbname, 'cartodb_test_user_1_db', 'could forge dbname: '+ req.params.dbname);
|
||||
assert.ok(!req.hasOwnProperty('dbuser'), 'could inject dbuser ('+req.params.dbuser+')');
|
||||
done();
|
||||
@ -33,7 +33,7 @@ suite('req2params', function() {
|
||||
assert.ok(_.isObject(req.query), 'request has query');
|
||||
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
||||
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
||||
assert.ok(req.params.hasOwnProperty('interactivity'), 'request params have interactivity');
|
||||
assert.ok(!req.params.hasOwnProperty('interactivity'), 'request params have interactivity');
|
||||
// database_name for user "localhost" (see test/support/prepare_db.sh)
|
||||
assert.equal(req.params.dbname, 'cartodb_test_user_1_db');
|
||||
// unauthenticated request gets no dbuser
|
||||
@ -49,7 +49,7 @@ suite('req2params', function() {
|
||||
assert.ok(_.isObject(req.query), 'request has query');
|
||||
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
||||
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
||||
assert.ok(req.params.hasOwnProperty('interactivity'), 'request params have interactivity');
|
||||
assert.ok(!req.params.hasOwnProperty('interactivity'), 'request params have interactivity');
|
||||
// database_name for user "localhost" (see test/support/prepare_db.sh)
|
||||
assert.equal(req.params.dbname, 'cartodb_test_user_1_db');
|
||||
// id for user "localhost" (see test/support/prepare_db.sh)
|
||||
@ -62,5 +62,17 @@ suite('req2params', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('retains interactivity', function(done){
|
||||
opts.req2params({headers: { host:'localhost' }, query: {interactivity: 'fld'} }, function(err, req) {
|
||||
if ( err ) { console.log(err); throw new Error(err); }
|
||||
//console.dir(req);
|
||||
assert.ok(_.isObject(req.query), 'request has query');
|
||||
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
||||
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
||||
assert.ok(req.params.hasOwnProperty('interactivity'), 'request params has no interactivity');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user