Removes tests as they are covered in multilayer suite

This commit is contained in:
Raul Ochoa 2015-03-30 13:35:20 +02:00
parent 70d1a30c64
commit 2b9f2ee66c

View File

@ -76,292 +76,6 @@ suite.skip('server old_api', function() {
var test_style_black_200 = "#test_table{marker-fill:black;marker-line-color:red;marker-width:10}";
var test_style_black_210 = "#test_table{marker-fill:black;marker-line-color:red;marker-width:20}";
/////////////////////////////////////////////////////////////////////////////////
//
// GET GRID
//
/////////////////////////////////////////////////////////////////////////////////
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',
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'application/json; charset=utf-8',
'X-Cache-Channel': test_database+':gadm4' }
}, function() { 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',
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'application/json; charset=utf-8' }
}, function() { done(); });
});
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'"});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.grid.json?' + sql,
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'application/json; charset=utf-8' }
}, function() { done(); });
});
test("get'ing the grid of a private table should fail when unauthenticated",
function(done) {
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table_private_1/6/31/24.grid.json',
method: 'GET'
},{}, function(res) {
// 403 Forbidden
assert.equal(res.statusCode, 403, res.statusCode + ': ' + res.body);
done();
});
});
// See http://github.com/CartoDB/Windshaft-cartodb/issues/186
test("get'ing the grid of a private table should fail when unauthenticated (jsonp)",
function(done) {
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table_private_1/6/31/24.grid.json?callback=x',
method: 'GET'
},{}, function(res) {
// It's forbidden, but jsonp calls for status = 200
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
// Still, we do NOT want to add caching headers here
// See https://github.com/CartoDB/Windshaft-cartodb/issues/186
assert.ok(!res.headers.hasOwnProperty('cache-control'),
"Unexpected Cache-Control: " + res.headers['cache-control']);
done();
});
});
// See http://github.com/Vizzuality/Windshaft-cartodb/issues/55
test("get'ing grid of private table should fail on unknown username",
function(done) {
assert.response(server, {
headers: {host: 'unknown_user'},
url: '/tiles/test_table_private_1/6/31/24.grid.json',
method: 'GET'
},{
}, function(res) {
// FIXME: should be 403 Forbidden
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
assert.deepEqual(JSON.parse(res.body),
{error:"missing unknown_user's database_name in redis (try CARTODB/script/restore_redis)"});
done();
});
});
test("get'ing the grid of a private table should succeed when authenticated",
function(done) {
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table_private_1/6/31/24.grid.json?map_key=1234',
method: 'GET'
},{}, function(res) {
assert.equal(res.statusCode, 200, res.body);
done();
});
});
/////////////////////////////////////////////////////////////////////////////////
//
// GET TILE
//
/////////////////////////////////////////////////////////////////////////////////
test("should send Cache-Control header with short expiration by default", function(done){
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png',
method: 'GET'
},{
status: 200
}, function(res) {
var cc = res.headers['cache-control'];
assert.ok(cc);
//assert.equal(cc, 'public,max-age=31536000'); // 1 year
assert.ok(cc.match('no-cache'), cc);
assert.ok(cc.match('must-revalidate'), cc);
assert.ok(cc.match('public'), cc);
done();
});
});
test("should send Cache-Control header with long expiration when requested", function(done){
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?cache_policy=persist',
method: 'GET'
},{
status: 200
}, function(res) {
var cc = res.headers['cache-control'];
assert.ok(cc);
assert.equal(cc, 'public,max-age=31536000'); // 1 year
done();
});
});
test("get'ing a tile with default style should return an image", function(done){
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?geom_type=polygon',
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'image/png', 'X-Cache-Channel': test_database+':gadm4' }
}, function() { done(); });
});
test("get'ing a tile with default style and sql should return a constrained image", function(done){
var sql = querystring.stringify({sql: "SELECT * FROM gadm4 WHERE codineprov = '08'"});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function() { done(); });
});
test("get'ing a tile with default style and complex sql should return a constrained image", function(done){
var sql = querystring.stringify({sql: "SELECT * FROM gadm4 WHERE codineprov = '08' AND codccaa > 60"});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function() { done(); });
});
test("get'ing a tile with data from private table should succeed when authenticated", function(done){
// NOTE: may fail if grainstore < 0.3.0 is used by Windshaft
var sql = querystring.stringify({sql: "SELECT * FROM test_table_private_1", map_key: 1234});
assert.response(server, {
headers: {host: 'localhost'},
// NOTE: we encode a public table in the URL !
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function() { done(); });
});
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/38
test("get'ing a tile with data from private table should succeed when authenticated with api_key", function(done){
// NOTE: may fail if grainstore < 0.3.0 is used by Windshaft
var sql = querystring.stringify({sql: "SELECT * FROM test_table_private_1", api_key: 1234});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function() { done(); });
});
test("get'ing a tile with data from private table should fail when unauthenticated", function(done){
var sql = querystring.stringify({
sql: "SELECT * FROM test_table_private_1",
cache_buster:2 // this is to avoid getting the cached response
});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
}, function(res) {
// 403 Forbidden
assert.equal(res.statusCode, 403, res.statusCode + ': ' + res.body);
done();
});
});
test("get'ing a tile with data from private table should fail on unknown username", function(done){
var sql = querystring.stringify({
sql: "SELECT * FROM test_table_private_1",
cache_buster:2 // this is to avoid getting the cached response
});
assert.response(server, {
headers: {host: 'unknown_user'},
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
}, function(res) {
// FIXME: should be 403 Forbidden
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
assert.deepEqual(JSON.parse(res.body),
{error:"missing unknown_user's database_name in redis (try CARTODB/script/restore_redis)"});
assert.ok(!res.headers.hasOwnProperty('cache-control'),
"Unexpected Cache-Control: " + res.headers['cache-control']);
done();
});
});
test("get'ing a tile with data from private table should fail when unauthenticated (uses old redis key)",
function(done) {
var sql = querystring.stringify({
sql: "SELECT * FROM test_table_private_1",
cache_buster:3,
// 1235 is written in rails:users:localhost:map_key SET
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/39
map_key: 1235
});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/gadm4/6/31/24.png?' + sql,
method: 'GET'
},{
}, function(res) {
// 403 Forbidden
assert.equal(res.statusCode, 403, res.statusCode + ': ' + res.body);
// Failed in 1.6.0 of https://github.com/CartoDB/Windshaft-cartodb/issues/107
assert.ok(!res.headers.hasOwnProperty('cache-control'),
"Unexpected Cache-Control: " + res.headers['cache-control']);
done();
});
});
test("get'ing a tile with url specified 2.0.0 style should return an expected tile", function(done){
var style = querystring.stringify({style: test_style_black_200, style_version: '2.0.0'});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/15/16046/12354.png?cache_buster=4&' + style, // madrid
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
var ct = res.headers['content-type'];
assert.equal(ct, 'image/png');
assert.imageEqualsFile(res.body, './test/fixtures/test_table_15_16046_12354_styled_black.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
if (err) throw err;
done();
});
});
});
// See https://github.com/CartoDB/Windshaft-cartodb/issues/88
test("get'ing a tile from a user-specific database should return an expected tile", function(done){
var style = querystring.stringify({style: test_style_black_200, style_version: '2.0.0'});
@ -434,25 +148,6 @@ suite.skip('server old_api', function() {
);
});
test("get'ing a tile with url specified 2.1.0 style should return an expected tile", function(done){
var style = querystring.stringify({style: test_style_black_210, style_version: '2.1.0'});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/15/16046/12354.png?cache_buster=4&' + style, // madrid
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
var ct = res.headers['content-type'];
assert.equal(ct, 'image/png');
assert.imageEqualsFile(res.body, './test/fixtures/test_table_15_16046_12354_styled_black.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
if (err) throw err;
done();
});
});
});
test("get'ing a tile with url specified 2.1.0 style (lzma version)", function(done){
var qo = {
style: test_style_black_210,
@ -492,143 +187,6 @@ suite.skip('server old_api', function() {
);
});
// See http://github.com/Vizzuality/Windshaft-cartodb/issues/57
test("GET'ing a tile as anonymous with style set by POST", function(done){
step (
function postStyle1() {
var next = this;
assert.response(server, {
method: 'POST',
url: '/tiles/test_table/style',
headers: {host: 'localhost', 'Content-Type': 'application/x-www-form-urlencoded' },
data: querystring.stringify({style: 'Map { background-color:#fff; }', map_key: 1234})
},{}, function(res) {
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
next();
});
},
// Load the new cache with results from Style1 above
function getTileAnon1(err) {
if ( err ) throw err;
var next = this;
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/15/16046/12354.png',
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
var ct = res.headers['content-type'];
assert.equal(ct, 'image/png');
assert.imageEqualsFile(res.body, './test/fixtures/blank.png', IMAGE_EQUALS_ZERO_TOLERANCE_PER_MIL,
function(err/*, similarity*/) {
if (err) next(err);
else next();
});
});
},
// Get again with authentication
function getTileAuth1(err) {
if ( err ) throw err;
var next = this;
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/15/16046/12354.png?map_key=1234',
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
var ct = res.headers['content-type'];
assert.equal(ct, 'image/png');
assert.imageEqualsFile(res.body, './test/fixtures/blank.png', IMAGE_EQUALS_ZERO_TOLERANCE_PER_MIL,
function(err/*, similarity*/) {
if (err) next(err);
else next();
});
});
},
// Change the style
function postStyle2(err) {
if ( err ) throw err;
var next = this;
assert.response(server, {
method: 'POST',
url: '/tiles/test_table/style',
headers: {host: 'localhost', 'Content-Type': 'application/x-www-form-urlencoded' },
data: querystring.stringify({style: test_style_black_200, map_key: 1234})
},{}, function(res) {
try {
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
next();
}
catch (err) { next(err); }
});
},
// Verify the Style2 is applied. NOTE: pass the SAME cache_buster as before!
function getTileAnon2(err) {
if ( err ) throw err;
var next = this;
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/15/16046/12354.png',
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
var ct = res.headers['content-type'];
assert.equal(ct, 'image/png');
assert.imageEqualsFile(res.body, './test/fixtures/test_table_15_16046_12354_styled_black.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
// NOTE: we expect them to be EQUAL here
if (err) { next(err); return; }
next();
});
});
},
// Delete the style
function delStyle(err) {
if ( err ) throw err;
var next = this;
assert.response(server, {
method: 'DELETE',
url: '/tiles/test_table/style?map_key=1234',
headers: {host: 'localhost'}
},{}, function(res) {
try {
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
next();
}
catch (err) { next(err); }
});
},
// Verify the default style is applied.
function getTileAnon3(err) {
if ( err ) throw err;
var next = this;
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/15/16046/12354.png?cache_buster=2314',
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
var ct = res.headers['content-type'];
assert.equal(ct, 'image/png');
assert.imageEqualsFile(res.body, './test/fixtures/test_table_15_16046_12354_styled_black.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
// NOTE: we expect them to be different here
if (err) next();
else next(new Error('Last posted style still in effect after delete'));
}
);
});
},
function finish(err) {
done(err);
}
);
});
test("uses sqlapi to figure source data of query", function(done){
var qo = {
sql: "SELECT g.cartodb_id, g.codineprov, t.the_geom_webmercator" +