Let "style_convert" pass by, add tests for GET and POST with it
This commit is contained in:
@@ -65,7 +65,7 @@ module.exports = function(){
|
||||
me.req2params = function(req, callback){
|
||||
|
||||
// Whitelist query parameters and attach format
|
||||
var good_query = ['sql', 'geom_type', 'cache_buster', 'cache_policy', 'callback', 'interactivity', 'map_key', 'api_key', 'style', 'style_version'];
|
||||
var good_query = ['sql', 'geom_type', 'cache_buster', 'cache_policy', 'callback', 'interactivity', 'map_key', 'api_key', 'style', 'style_version', 'style_convert' ];
|
||||
var bad_query = _.difference(_.keys(req.query), good_query);
|
||||
|
||||
_.each(bad_query, function(key){ delete req.query[key]; });
|
||||
|
||||
@@ -275,8 +275,7 @@ suite('server', function() {
|
||||
method: 'POST',
|
||||
headers: {host: 'localhost', 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
data: querystring.stringify({style: style, style_version: '2.0.2'})
|
||||
},{
|
||||
}, function(res) {
|
||||
},{}, function(res) {
|
||||
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
|
||||
@@ -284,19 +283,54 @@ suite('server', function() {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/my_table5/style',
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200,
|
||||
}, function(res) {
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
var parsed = JSON.parse(res.body);
|
||||
assert.equal(parsed.style, style);
|
||||
assert.equal(parsed.style_version, '2.0.2');
|
||||
done();
|
||||
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/my_table5/style?style_convert=true',
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
var parsed = JSON.parse(res.body);
|
||||
assert.equal(parsed.style, style);
|
||||
assert.equal(parsed.style_version, mapnik.versions.mapnik);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test("post'ing good style with style_convert returns 200 then getting returns converted style", function(done){
|
||||
var style = 'Map {background-color:#fff;}';
|
||||
assert.response(server, {
|
||||
url: '/tiles/my_table5/style?map_key=1234',
|
||||
method: 'POST',
|
||||
headers: {host: 'localhost', 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
data: querystring.stringify({style: style, style_version: '2.0.2', style_convert: true})
|
||||
},{}, function(res) {
|
||||
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
assert.response(server, {
|
||||
headers: {host: 'localhost'},
|
||||
url: '/tiles/my_table5/style',
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
var parsed = JSON.parse(res.body);
|
||||
// NOTE: no transform expected for the specific style
|
||||
assert.equal(parsed.style, style);
|
||||
assert.equal(parsed.style_version, mapnik.versions.mapnik);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DELETE STYLE
|
||||
|
||||
Reference in New Issue
Block a user