Windshaft-cartodb/test/acceptance/ported/regressions-test.js

39 lines
1.4 KiB
JavaScript
Raw Normal View History

'use strict';
var testHelper = require('../../support/test-helper');
2015-07-08 05:46:58 +08:00
var assert = require('../../support/assert');
var testClient = require('./support/test-client');
2015-07-08 05:46:58 +08:00
2019-10-22 01:07:24 +08:00
describe('regressions', function () {
after(function () {
2015-09-26 01:56:28 +08:00
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
2015-07-08 05:46:58 +08:00
});
// Test that you cannot write to the database from a tile request
//
// See http://github.com/CartoDB/Windshaft/issues/130
// [x] Needs a fix on the mapnik side: https://github.com/mapnik/mapnik/pull/2143
//
2019-10-22 01:07:24 +08:00
it('#130 database access is read-only', function (done) {
2015-07-08 05:46:58 +08:00
var writeSqlMapConfig = testClient.singleLayerMapConfig(
'select st_point(0,0) as the_geom, * from test_table_inserter(st_setsrid(st_point(0,0),4326),\'write\')'
);
var expectedResponse = {
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
2019-10-22 01:07:24 +08:00
testClient.getTile(writeSqlMapConfig, 0, 0, 0, expectedResponse, function (err, res) {
2015-07-08 05:46:58 +08:00
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.errors);
assert.strictEqual(parsedBody.errors.length, 1);
2015-07-08 05:46:58 +08:00
assert.ok(parsedBody.errors[0].match(/read-only transaction/), 'read-only error message expected');
done();
});
});
});