diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index a1682377..5bdecdf5 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -135,8 +135,8 @@ module.exports = function(){ that.req2params(req, this); }, function(err, data){ - if (err) throw err; - cartoData.getMapMetadata(data, callback); + if (err) callback(err, null); + else cartoData.getMapMetadata(data, callback); } ); }; diff --git a/test/acceptance/server.js b/test/acceptance/server.js index 0c895bf0..0f30db81 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server.js @@ -569,6 +569,59 @@ suite('server', function() { }); }); + ///////////////////////////////////////////////////////////////////////////////// + // + // GET METADATA + // + ///////////////////////////////////////////////////////////////////////////////// + + test("does not provide metadata of private table to unauthenticated requests", function(done){ + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/test_table_private_1/map_metadata', + method: 'GET' + },{}, function(res) { + // FIXME: should be 401 instead + assert.equal(res.statusCode, 500, res.statusCode + ': ' + res.body); + done(); + }); + }); + + test("does provide metadata of private table to authenticated requests", function(done){ + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/test_table_private_1/map_metadata?map_key=1234', + method: 'GET' + },{}, function(res) { + assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); + done(); + }); + }); + + test("does provide metadata of public table to unauthenticated requests", function(done){ + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/gadm4/map_metadata', + method: 'GET' + },{}, function(res) { + assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); + // TODO: show metadata ? + done(); + }); + }); + + test("does provide metadata of public table to authenticated requests", function(done){ + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/gadm4/map_metadata?map_key=1234', + method: 'GET' + },{}, function(res) { + assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); + // TODO: show metadata ? + done(); + }); + }); + ///////////////////////////////////////////////////////////////////////////////// // // DELETE CACHE