2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../support/test-helper');
|
2015-03-30 21:07:49 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
var assert = require('../support/assert');
|
2011-09-05 07:00:41 +08:00
|
|
|
var querystring = require('querystring');
|
2019-10-22 01:07:24 +08:00
|
|
|
var step = require('step');
|
2012-11-14 17:40:48 +08:00
|
|
|
|
2019-10-07 15:40:50 +08:00
|
|
|
var CartodbWindshaft = require('../../lib/server');
|
2019-10-07 16:10:51 +08:00
|
|
|
var serverOptions = require('../../lib/server-options');
|
2011-09-05 07:00:41 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('server', function () {
|
2018-04-16 22:16:23 +08:00
|
|
|
var server;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
server = new CartodbWindshaft(serverOptions);
|
|
|
|
server.setMaxListeners(0);
|
|
|
|
});
|
2012-07-12 19:31:39 +08:00
|
|
|
|
2012-08-14 21:13:23 +08:00
|
|
|
// TODO: I guess this should be a 404 instead...
|
2019-10-22 01:07:24 +08:00
|
|
|
it('get call to server returns 200', function (done) {
|
|
|
|
step(
|
|
|
|
function doGet () {
|
|
|
|
var next = this;
|
|
|
|
assert.response(server, {
|
|
|
|
url: '/',
|
|
|
|
method: 'GET'
|
|
|
|
}, {}, function (res, err) { next(err, res); });
|
|
|
|
},
|
|
|
|
function doCheck (err, res) {
|
|
|
|
assert.ifError(err);
|
|
|
|
assert.ok(res.statusCode, 200);
|
|
|
|
var cc = res.headers['x-cache-channel'];
|
|
|
|
assert.ok(!cc);
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
function finish (err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
);
|
2012-07-09 22:49:31 +08:00
|
|
|
});
|
2012-08-14 21:06:04 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('get call to server returns 200', function (done) {
|
2012-10-08 23:26:12 +08:00
|
|
|
assert.response(server, {
|
|
|
|
url: '/version',
|
|
|
|
method: 'GET'
|
2019-10-22 01:07:24 +08:00
|
|
|
}, {
|
|
|
|
status: 200
|
|
|
|
}, function (res) {
|
|
|
|
var parsed = JSON.parse(res.body);
|
2019-10-22 05:33:27 +08:00
|
|
|
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'windshaft_cartodb'), "No 'windshaft_cartodb' version in " + parsed);
|
|
|
|
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'windshaft'), "No 'windshaft' version in " + parsed);
|
|
|
|
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'grainstore'), "No 'grainstore' version in " + parsed);
|
|
|
|
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'node_mapnik'), "No 'node_mapnik' version in " + parsed);
|
|
|
|
assert.ok(Object.prototype.hasOwnProperty.call(parsed, 'mapnik'), "No 'mapnik' version in " + parsed);
|
2019-10-22 01:07:24 +08:00
|
|
|
done();
|
2012-10-08 23:26:12 +08:00
|
|
|
});
|
|
|
|
});
|
2015-03-24 02:28:34 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('server old_api', function () {
|
2018-04-16 22:16:23 +08:00
|
|
|
var server;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
server = new CartodbWindshaft(serverOptions);
|
|
|
|
server.setMaxListeners(0);
|
|
|
|
});
|
2013-03-13 17:36:28 +08:00
|
|
|
|
2014-01-29 17:40:35 +08:00
|
|
|
// See https://github.com/CartoDB/Windshaft-cartodb/issues/115
|
2019-10-22 01:07:24 +08:00
|
|
|
it.skip("get'ing tile with not-strictly-valid style", function (done) {
|
|
|
|
var style = querystring.stringify({ style: '#test_table{line-color:black}}', style_version: '2.0.0' });
|
2014-01-29 17:40:35 +08:00
|
|
|
assert.response(server, {
|
2019-10-22 01:07:24 +08:00
|
|
|
headers: { host: 'localhost' },
|
2014-01-29 17:40:35 +08:00
|
|
|
url: '/tiles/test_table/0/0/0.png?' + style, // madrid
|
|
|
|
method: 'GET',
|
|
|
|
encoding: 'binary'
|
2019-10-22 01:07:24 +08:00
|
|
|
}, {}, function (res) {
|
2019-10-22 01:41:03 +08:00
|
|
|
assert.strictEqual(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
2019-10-22 01:07:24 +08:00
|
|
|
done();
|
2014-01-29 17:40:35 +08:00
|
|
|
});
|
|
|
|
});
|
2012-07-09 22:49:31 +08:00
|
|
|
});
|