From 9a3eb3e0fdf70f263c9e8f9b4134080d979224a9 Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Wed, 11 Apr 2018 12:26:09 +0200 Subject: [PATCH 01/16] add named maps Listing auth tests --- test/acceptance/auth/authorization.js | 72 ++++++++++++++++++++------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization.js index 02668251..3de51b85 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization.js @@ -353,36 +353,72 @@ describe('authorization', function() { testClient.drain(done); }); }); + describe('Listing named maps', function() { - it('should fail while listing named maps with a regular apikey token', function (done) { - const apikeyToken = 'regular1'; + it('should fail while listing named maps with a regular apikey token', function (done) { + const apikeyToken = 'regular1'; - const testClient = new TestClient({}, apikeyToken); + const testClient = new TestClient({}, apikeyToken); - testClient.getNamedMapList({ response: {status: 403 }}, function (err, res, body) { - assert.ifError(err); + testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) { + assert.ifError(err); - assert.equal(res.statusCode, 403); + assert.equal(res.statusCode, 403); - assert.equal(body.errors.length, 1); - assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); + assert.equal(body.errors.length, 1); + assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); - testClient.drain(done); + testClient.drain(done); + }); }); - }); - it('should list named maps with master apikey token', function (done) { - const apikeyToken = 1234; + it('should fail while listing named maps with the default apikey token', function (done) { + const apikeyToken = 'default_public'; - const testClient = new TestClient({}, apikeyToken); + const testClient = new TestClient({}, apikeyToken); - testClient.getNamedMapList({}, function (err, res, body) { - assert.ifError(err); + testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) { + assert.ifError(err); - assert.equal(res.statusCode, 200); - assert.ok(Array.isArray(body.template_ids)); + assert.equal(res.statusCode, 403); - testClient.drain(done); + assert.equal(body.errors.length, 1); + assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); + + testClient.drain(done); + }); + }); + + it('should fail while listing named maps with non-existent apikey token', function (done) { + const apikeyToken = 'wadus-wadus'; + + const testClient = new TestClient({}, apikeyToken); + + testClient.getNamedMapList({ response: { status: 401 } }, function (err, res, body) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(body.errors.length, 1); + assert.ok(body.errors[0].match(/Unauthorized/), body.errors[0]); + + testClient.drain(done); + }); + }); + + it('should list named maps with master apikey token', function (done) { + const apikeyToken = 1234; + + const testClient = new TestClient({}, apikeyToken); + + testClient.getNamedMapList({}, function (err, res, body) { + assert.ifError(err); + + assert.equal(res.statusCode, 200); + assert.ok(Array.isArray(body.template_ids)); + + testClient.drain(done); + }); }); }); From 9a7a8a324395c8b6fa188485d9762ee30e285b9e Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Thu, 12 Apr 2018 12:43:41 +0200 Subject: [PATCH 02/16] add named maps Create auth tests --- test/acceptance/auth/authorization.js | 72 +++++++++++++++++++++++---- test/support/test-client.js | 31 ++++++++++++ 2 files changed, 94 insertions(+), 9 deletions(-) diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization.js index 3de51b85..813f4e13 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization.js @@ -422,9 +422,7 @@ describe('authorization', function() { }); }); - it.skip('should create and get a named map tile using a regular apikey token', function (done) { - const apikeyToken = 'regular1'; - + describe.only('Create Named Map', function () { const template = { version: '0.0.1', name: 'auth-api-template', @@ -447,16 +445,72 @@ describe('authorization', function() { } }; - const testClient = new TestClient(template, apikeyToken); + it('should create and get a named map tile using the master apikey token', function (done) { + const apikeyToken = 1234; - testClient.getTile(0, 0, 0, function (err, res, tile) { - assert.ifError(err); + const testClient = new TestClient(template, apikeyToken); - assert.equal(res.statusCode, 200); - assert.ok(tile instanceof mapnik.Image); + testClient.getTile(0, 0, 0, function (err, res, tile) { + assert.ifError(err); - testClient.drain(done); + assert.equal(res.statusCode, 200); + assert.ok(tile instanceof mapnik.Image); + + testClient.drain(done); + }); }); + + it('should fail creating a named map using a regular apikey token', function (done) { + const apikeyToken = 'regular1'; + + const testClient = new TestClient(template, apikeyToken); + + testClient.createTemplate({ response: { status: 403 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClient.drain(done); + }); + }); + + it('should fail creating a named map using the default apikey token', function (done) { + const apikeyToken = 'default_public'; + + const testClient = new TestClient(template, apikeyToken); + + testClient.createTemplate({ response: { status: 403 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClient.drain(done); + }); + }); + + it('should fail creating a named map using a non-existent apikey token', function (done) { + const apikeyToken = 'wadus-wadus'; + + const testClient = new TestClient(template, apikeyToken); + + testClient.createTemplate({ response: { status: 401 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClient.drain(done); + }); + }); + }); it.skip('should fail creating a named map using a regular apikey token and a private table', function (done) { diff --git a/test/support/test-client.js b/test/support/test-client.js index 7b068901..b89009ba 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1367,3 +1367,34 @@ TestClient.prototype.getNamedTile = function (name, z, x, y, format, options, c }); }); }; + +TestClient.prototype.createTemplate = function (params, callback) { + if (!this.apiKey) { + return callback(new Error('apiKey param is mandatory to create a new template')); + } + + const createTemplateRequest = { + url: `/api/v1/map/named?${qs.stringify({ api_key: this.apiKey })}`, + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(this.template) + }; + + let createTemplateResponse = { + status: 200, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }; + + if (params.response) { + createTemplateResponse = Object.assign(createTemplateResponse, params.response); + } + + assert.response(this.server, createTemplateRequest, createTemplateResponse, (res, err) => { + return callback(err, res, JSON.parse(res.body)); + }); +}; From fbcf312071cd93eea4c554ce18685b1548b30a66 Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Thu, 12 Apr 2018 14:46:08 +0200 Subject: [PATCH 03/16] add named maps Delete auth tests --- test/acceptance/auth/authorization.js | 125 +++++++++++++++++++++++++- test/support/test-client.js | 50 ++++++++++- 2 files changed, 173 insertions(+), 2 deletions(-) diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization.js index 813f4e13..4e408c02 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization.js @@ -353,6 +353,7 @@ describe('authorization', function() { testClient.drain(done); }); }); + describe('Listing named maps', function() { it('should fail while listing named maps with a regular apikey token', function (done) { @@ -422,7 +423,7 @@ describe('authorization', function() { }); }); - describe.only('Create Named Map', function () { + describe('Create Named Map', function () { const template = { version: '0.0.1', name: 'auth-api-template', @@ -513,6 +514,128 @@ describe('authorization', function() { }); + describe('Delete Named Map', function () { + const templateBase = { + version: '0.0.1', + name: 'auth-api-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 + } + }, + layergroup: { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table_localhost_regular1', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0', + } + }] + } + }; + + it('should delete a named map using the master apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 1234; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-master'}); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({ }, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate({ templateId: template.template_id , response: { status: 204 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 204); + + testClientDelete.drain(done); + }); + }); + }); + + it('should fail deleting a named map using a regular apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 'regular1'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-regular' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate({ templateId: template.template_id, response: { status: 403 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + }); + }); + }); + + it('should fail deleting a named map using the default apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 'default_public'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-default' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate({ templateId: template.template_id, response: { status: 403 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + }); + }); + }); + + it('should fail creating a named map using a non-existent apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 'wadus'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-wadus' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate({ templateId: template.template_id, response: { status: 401 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClientDelete.drain(done); + }); + }); + }); + + }); + it.skip('should fail creating a named map using a regular apikey token and a private table', function (done) { const apikeyToken = 'regular1'; diff --git a/test/support/test-client.js b/test/support/test-client.js index b89009ba..04341e1b 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1395,6 +1395,54 @@ TestClient.prototype.createTemplate = function (params, callback) { } assert.response(this.server, createTemplateRequest, createTemplateResponse, (res, err) => { - return callback(err, res, JSON.parse(res.body)); + let body; + switch (res.headers['content-type']) { + case 'application/json; charset=utf-8': + body = JSON.parse(res.body); + break; + default: + body = res.body; + break; + } + + return callback(err, res, body); + }); +}; + + +TestClient.prototype.deleteTemplate = function (params, callback) { + if (!this.apiKey) { + return callback(new Error('apiKey param is mandatory to create a new template')); + } + + const deleteTemplateRequest = { + url: `/api/v1/map/named/${params.templateId}?${qs.stringify({ api_key: this.apiKey })}`, + method: 'DELETE', + headers: { + host: 'localhost', + } + }; + + let deleteTemplateResponse = { + status: 204, + headers: {} + }; + + if (params.response) { + deleteTemplateResponse = Object.assign(deleteTemplateResponse, params.response); + } + + assert.response(this.server, deleteTemplateRequest, deleteTemplateResponse, (res, err) => { + let body; + switch (res.headers['content-type']) { + case 'application/json; charset=utf-8': + body = JSON.parse(res.body); + break; + default: + body = res.body; + break; + } + + return callback(err, res, body); }); }; From f5bdb8b15bdd3f0e471dd4456111716ed6506548 Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Thu, 12 Apr 2018 16:03:02 +0200 Subject: [PATCH 04/16] add named maps Update auth tests --- test/acceptance/auth/authorization.js | 240 ++++++++++++++++++++++---- test/support/test-client.js | 42 ++++- 2 files changed, 247 insertions(+), 35 deletions(-) diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization.js index 4e408c02..aebe9fb8 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization.js @@ -511,7 +511,6 @@ describe('authorization', function() { testClient.drain(done); }); }); - }); describe('Delete Named Map', function () { @@ -541,21 +540,27 @@ describe('authorization', function() { const apikeyTokenCreate = 1234; const apikeyTokenDelete = 1234; - const template = Object.assign({}, templateBase, { name: templateBase.name + '-master'}); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-master'}); const testClientCreate = new TestClient(template, apikeyTokenCreate); - testClientCreate.createTemplate({ }, function (err, res, template) { + testClientCreate.createTemplate({}, function (err, res, template) { assert.ifError(err); const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate({ templateId: template.template_id , response: { status: 204 } }, function (err, res, response) { - assert.ifError(err); + testClientDelete.deleteTemplate( + { + templateId: template.template_id , + response: { status: 204 } + }, + function (err, res) { + assert.ifError(err); - assert.equal(res.statusCode, 204); + assert.equal(res.statusCode, 204); - testClientDelete.drain(done); - }); + testClientDelete.drain(done); + } + ); }); }); @@ -563,24 +568,30 @@ describe('authorization', function() { const apikeyTokenCreate = 1234; const apikeyTokenDelete = 'regular1'; - const template = Object.assign({}, templateBase, { name: templateBase.name + '-regular' }); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-regular' }); const testClientCreate = new TestClient(template, apikeyTokenCreate); testClientCreate.createTemplate({}, function (err, res, template) { assert.ifError(err); - const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate({ templateId: template.template_id, response: { status: 403 } }, function (err, res, response) { - assert.ifError(err); + const testClientDelete = new TestClient({}, apikeyTokenDelete); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); - assert.equal(res.statusCode, 403); + assert.equal(res.statusCode, 403); - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - testClientDelete.drain(done); - }); + testClientDelete.drain(done); + } + ); }); }); @@ -588,7 +599,7 @@ describe('authorization', function() { const apikeyTokenCreate = 1234; const apikeyTokenDelete = 'default_public'; - const template = Object.assign({}, templateBase, { name: templateBase.name + '-default' }); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-default' }); const testClientCreate = new TestClient(template, apikeyTokenCreate); @@ -596,24 +607,30 @@ describe('authorization', function() { assert.ifError(err); const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate({ templateId: template.template_id, response: { status: 403 } }, function (err, res, response) { - assert.ifError(err); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); - assert.equal(res.statusCode, 403); + assert.equal(res.statusCode, 403); - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - testClientDelete.drain(done); - }); + testClientDelete.drain(done); + } + ); }); }); - it('should fail creating a named map using a non-existent apikey token', function (done) { + it('should fail deleting a named map using a non-existent apikey token', function (done) { const apikeyTokenCreate = 1234; const apikeyTokenDelete = 'wadus'; - const template = Object.assign({}, templateBase, { name: templateBase.name + '-wadus' }); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-wadus' }); const testClientCreate = new TestClient(template, apikeyTokenCreate); @@ -621,16 +638,171 @@ describe('authorization', function() { assert.ifError(err); const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate({ templateId: template.template_id, response: { status: 401 } }, function (err, res, response) { - assert.ifError(err); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 401 } + }, + function (err, res, response) { + assert.ifError(err); - assert.equal(res.statusCode, 401); + assert.equal(res.statusCode, 401); - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); - testClientDelete.drain(done); - }); + testClientDelete.drain(done); + } + ); + }); + }); + }); + + describe.only('Update Named Map', function () { + const templateBase = { + version: '0.0.1', + name: 'auth-api-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 + } + }, + layergroup: { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table_localhost_regular1', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0', + } + }] + } + }; + + it('should update a named map using the master apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 1234; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-master' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 200 } + }, + function (err, res) { + assert.ifError(err); + + assert.equal(res.statusCode, 200); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail updating a named map using a regular apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 'regular1'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-regular' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail updating a named map using the default apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 'default_public'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-default' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail updating a named map using a non-existent apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 'wadus'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-wadus' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 401 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClientDelete.drain(done); + } + ); }); }); diff --git a/test/support/test-client.js b/test/support/test-client.js index 04341e1b..3e35b740 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1409,7 +1409,6 @@ TestClient.prototype.createTemplate = function (params, callback) { }); }; - TestClient.prototype.deleteTemplate = function (params, callback) { if (!this.apiKey) { return callback(new Error('apiKey param is mandatory to create a new template')); @@ -1446,3 +1445,44 @@ TestClient.prototype.deleteTemplate = function (params, callback) { return callback(err, res, body); }); }; + +TestClient.prototype.updateTemplate = function (params, callback) { + if (!this.apiKey) { + return callback(new Error('apiKey param is mandatory to create a new template')); + } + + const updateTemplateRequest = { + url: `/api/v1/map/named/${params.templateId}?${qs.stringify({ api_key: this.apiKey })}`, + method: 'PUT', + headers: { + host: 'localhost', + 'Content-Type': 'application/json; charset=utf-8' + }, + data: JSON.stringify(params.templateData) + }; + + let updateTemplateResponse = { + status: 200, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }; + + if (params.response) { + updateTemplateResponse = Object.assign(updateTemplateResponse, params.response); + } + + assert.response(this.server, updateTemplateRequest, updateTemplateResponse, (res, err) => { + let body; + switch (res.headers['content-type']) { + case 'application/json; charset=utf-8': + body = JSON.parse(res.body); + break; + default: + body = res.body; + break; + } + + return callback(err, res, body); + }); +}; \ No newline at end of file From 31e3b9953fe82652273044ca8936554fd1ba48ed Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Thu, 12 Apr 2018 16:22:56 +0200 Subject: [PATCH 05/16] add named maps GET auth tests --- test/acceptance/auth/authorization.js | 1010 ++++++++++++++----------- test/support/test-client.js | 40 + 2 files changed, 599 insertions(+), 451 deletions(-) diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization.js index aebe9fb8..37407531 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization.js @@ -353,496 +353,604 @@ describe('authorization', function() { testClient.drain(done); }); }); + describe.only('Named maps', function () { + describe('LIST Named maps', function () { - describe('Listing named maps', function() { + it('should fail while listing named maps with a regular apikey token', function (done) { + const apikeyToken = 'regular1'; - it('should fail while listing named maps with a regular apikey token', function (done) { - const apikeyToken = 'regular1'; + const testClient = new TestClient({}, apikeyToken); - const testClient = new TestClient({}, apikeyToken); + testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) { + assert.ifError(err); - testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) { - assert.ifError(err); + assert.equal(res.statusCode, 403); - assert.equal(res.statusCode, 403); + assert.equal(body.errors.length, 1); + assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); - assert.equal(body.errors.length, 1); - assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); + testClient.drain(done); + }); + }); - testClient.drain(done); + it('should fail while listing named maps with the default apikey token', function (done) { + const apikeyToken = 'default_public'; + + const testClient = new TestClient({}, apikeyToken); + + testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(body.errors.length, 1); + assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); + + testClient.drain(done); + }); + }); + + it('should fail while listing named maps with non-existent apikey token', function (done) { + const apikeyToken = 'wadus-wadus'; + + const testClient = new TestClient({}, apikeyToken); + + testClient.getNamedMapList({ response: { status: 401 } }, function (err, res, body) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(body.errors.length, 1); + assert.ok(body.errors[0].match(/Unauthorized/), body.errors[0]); + + testClient.drain(done); + }); + }); + + it('should list named maps with master apikey token', function (done) { + const apikeyToken = 1234; + + const testClient = new TestClient({}, apikeyToken); + + testClient.getNamedMapList({}, function (err, res, body) { + assert.ifError(err); + + assert.equal(res.statusCode, 200); + assert.ok(Array.isArray(body.template_ids)); + + testClient.drain(done); + }); }); }); - it('should fail while listing named maps with the default apikey token', function (done) { - const apikeyToken = 'default_public'; - - const testClient = new TestClient({}, apikeyToken); - - testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(body.errors.length, 1); - assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]); - - testClient.drain(done); - }); - }); - - it('should fail while listing named maps with non-existent apikey token', function (done) { - const apikeyToken = 'wadus-wadus'; - - const testClient = new TestClient({}, apikeyToken); - - testClient.getNamedMapList({ response: { status: 401 } }, function (err, res, body) { - assert.ifError(err); - - assert.equal(res.statusCode, 401); - - assert.equal(body.errors.length, 1); - assert.ok(body.errors[0].match(/Unauthorized/), body.errors[0]); - - testClient.drain(done); - }); - }); - - it('should list named maps with master apikey token', function (done) { - const apikeyToken = 1234; - - const testClient = new TestClient({}, apikeyToken); - - testClient.getNamedMapList({}, function (err, res, body) { - assert.ifError(err); - - assert.equal(res.statusCode, 200); - assert.ok(Array.isArray(body.template_ids)); - - testClient.drain(done); - }); - }); - }); - - describe('Create Named Map', function () { - const template = { - version: '0.0.1', - name: 'auth-api-template', - placeholders: { - buffersize: { - type: 'number', - default: 0 + describe('CREATE Named Map', function () { + const template = { + version: '0.0.1', + name: 'auth-api-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 + } + }, + layergroup: { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table_localhost_regular1', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0', + } + }] } - }, - layergroup: { - version: '1.7.0', - layers: [{ - type: 'cartodb', - options: { - sql: 'select * from test_table_localhost_regular1', - cartocss: TestClient.CARTOCSS.POINTS, - cartocss_version: '2.3.0', + }; + + it('should create and get a named map tile using the master apikey token', function (done) { + const apikeyToken = 1234; + + const testClient = new TestClient(template, apikeyToken); + + testClient.getTile(0, 0, 0, function (err, res, tile) { + assert.ifError(err); + + assert.equal(res.statusCode, 200); + assert.ok(tile instanceof mapnik.Image); + + testClient.drain(done); + }); + }); + + it('should fail creating a named map using a regular apikey token', function (done) { + const apikeyToken = 'regular1'; + + const testClient = new TestClient(template, apikeyToken); + + testClient.createTemplate({ response: { status: 403 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClient.drain(done); + }); + }); + + it('should fail creating a named map using the default apikey token', function (done) { + const apikeyToken = 'default_public'; + + const testClient = new TestClient(template, apikeyToken); + + testClient.createTemplate({ response: { status: 403 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClient.drain(done); + }); + }); + + it('should fail creating a named map using a non-existent apikey token', function (done) { + const apikeyToken = 'wadus-wadus'; + + const testClient = new TestClient(template, apikeyToken); + + testClient.createTemplate({ response: { status: 401 } }, function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClient.drain(done); + }); + }); + }); + + describe('DELETE Named Map', function () { + const templateBase = { + version: '0.0.1', + name: 'auth-api-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 } - }] - } - }; - - it('should create and get a named map tile using the master apikey token', function (done) { - const apikeyToken = 1234; - - const testClient = new TestClient(template, apikeyToken); - - testClient.getTile(0, 0, 0, function (err, res, tile) { - assert.ifError(err); - - assert.equal(res.statusCode, 200); - assert.ok(tile instanceof mapnik.Image); - - testClient.drain(done); - }); - }); - - it('should fail creating a named map using a regular apikey token', function (done) { - const apikeyToken = 'regular1'; - - const testClient = new TestClient(template, apikeyToken); - - testClient.createTemplate({ response: { status: 403 } }, function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - - testClient.drain(done); - }); - }); - - it('should fail creating a named map using the default apikey token', function (done) { - const apikeyToken = 'default_public'; - - const testClient = new TestClient(template, apikeyToken); - - testClient.createTemplate({ response: { status: 403 } }, function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - - testClient.drain(done); - }); - }); - - it('should fail creating a named map using a non-existent apikey token', function (done) { - const apikeyToken = 'wadus-wadus'; - - const testClient = new TestClient(template, apikeyToken); - - testClient.createTemplate({ response: { status: 401 } }, function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 401); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); - - testClient.drain(done); - }); - }); - }); - - describe('Delete Named Map', function () { - const templateBase = { - version: '0.0.1', - name: 'auth-api-template', - placeholders: { - buffersize: { - type: 'number', - default: 0 + }, + layergroup: { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table_localhost_regular1', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0', + } + }] } - }, - layergroup: { - version: '1.7.0', - layers: [{ - type: 'cartodb', - options: { - sql: 'select * from test_table_localhost_regular1', - cartocss: TestClient.CARTOCSS.POINTS, - cartocss_version: '2.3.0', - } - }] - } - }; + }; - it('should delete a named map using the master apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenDelete = 1234; + it('should delete a named map using the master apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 1234; - const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-master'}); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-master' }); - const testClientCreate = new TestClient(template, apikeyTokenCreate); + const testClientCreate = new TestClient(template, apikeyTokenCreate); - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); - const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate( - { - templateId: template.template_id , - response: { status: 204 } - }, - function (err, res) { - assert.ifError(err); + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 204 } + }, + function (err, res) { + assert.ifError(err); - assert.equal(res.statusCode, 204); + assert.equal(res.statusCode, 204); - testClientDelete.drain(done); - } - ); + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail deleting a named map using a regular apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 'regular1'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-regular' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenDelete); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail deleting a named map using the default apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 'default_public'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-default' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail deleting a named map using a non-existent apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenDelete = 'wadus'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-wadus' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient(template, apikeyTokenDelete); + testClientDelete.deleteTemplate( + { + templateId: template.template_id, + response: { status: 401 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); }); }); - it('should fail deleting a named map using a regular apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenDelete = 'regular1'; - - const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-regular' }); - - const testClientCreate = new TestClient(template, apikeyTokenCreate); - - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); - - const testClientDelete = new TestClient({}, apikeyTokenDelete); - testClientDelete.deleteTemplate( - { - templateId: template.template_id, - response: { status: 403 } - }, - function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - - testClientDelete.drain(done); + describe('GET Named Map', function () { + const templateBase = { + version: '0.0.1', + name: 'auth-api-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 } - ); - }); - }); - - it('should fail deleting a named map using the default apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenDelete = 'default_public'; - - const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-default' }); - - const testClientCreate = new TestClient(template, apikeyTokenCreate); - - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); - - const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate( - { - templateId: template.template_id, - response: { status: 403 } - }, - function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - - testClientDelete.drain(done); - } - ); - }); - }); - - it('should fail deleting a named map using a non-existent apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenDelete = 'wadus'; - - const template = Object.assign({}, templateBase, { name: templateBase.name + '-delete-wadus' }); - - const testClientCreate = new TestClient(template, apikeyTokenCreate); - - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); - - const testClientDelete = new TestClient(template, apikeyTokenDelete); - testClientDelete.deleteTemplate( - { - templateId: template.template_id, - response: { status: 401 } - }, - function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 401); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); - - testClientDelete.drain(done); - } - ); - }); - }); - }); - - describe.only('Update Named Map', function () { - const templateBase = { - version: '0.0.1', - name: 'auth-api-template', - placeholders: { - buffersize: { - type: 'number', - default: 0 + }, + layergroup: { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table_localhost_regular1', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0', + } + }] } - }, - layergroup: { - version: '1.7.0', - layers: [{ - type: 'cartodb', - options: { - sql: 'select * from test_table_localhost_regular1', - cartocss: TestClient.CARTOCSS.POINTS, - cartocss_version: '2.3.0', - } - }] - } - }; + }; - it('should update a named map using the master apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenUpdate = 1234; + it('should get a named map using the master apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenGet = 1234; - const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-master' }); - const templateUpdate = Object.assign({}, template, { zoom: 3 }); - const testClientCreate = new TestClient(template, apikeyTokenCreate); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-get-master' }); - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); + const testClientCreate = new TestClient(template, apikeyTokenCreate); - const testClientDelete = new TestClient({}, apikeyTokenUpdate); - testClientDelete.updateTemplate( - { - templateId: template.template_id, - templateData: templateUpdate, - response: { status: 200 } - }, - function (err, res) { - assert.ifError(err); + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); - assert.equal(res.statusCode, 200); + const testClientDelete = new TestClient({}, apikeyTokenGet); + testClientDelete.getTemplate( + { + templateId: template.template_id, + response: { status: 200 } + }, + function (err, res) { + assert.ifError(err); - testClientDelete.drain(done); - } - ); + assert.equal(res.statusCode, 200); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail getting a named map using a regular apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenGet = 'regular1'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-get-regular' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientGet = new TestClient({}, apikeyTokenGet); + testClientGet.getTemplate( + { + templateId: template.template_id, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientGet.drain(done); + } + ); + }); + }); + + it('should fail getting a named map using the default apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenGet = 'default_public'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-get-default' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientGet = new TestClient(template, apikeyTokenGet); + testClientGet.getTemplate( + { + templateId: template.template_id, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientGet.drain(done); + } + ); + }); + }); + + it('should fail getting a named map using a non-existent apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenGet = 'wadus'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-get-wadus' }); + + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientGet = new TestClient(template, apikeyTokenGet); + testClientGet.getTemplate( + { + templateId: template.template_id, + response: { status: 401 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClientGet.drain(done); + } + ); + }); }); }); - it('should fail updating a named map using a regular apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenUpdate = 'regular1'; - - const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-regular' }); - const templateUpdate = Object.assign({}, template, { zoom: 3 }); - const testClientCreate = new TestClient(template, apikeyTokenCreate); - - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); - - const testClientDelete = new TestClient({}, apikeyTokenUpdate); - testClientDelete.updateTemplate( - { - templateId: template.template_id, - templateData: templateUpdate, - response: { status: 403 } - }, - function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - - testClientDelete.drain(done); + describe('UPDATE Named Map', function () { + const templateBase = { + version: '0.0.1', + name: 'auth-api-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 } - ); - }); - }); - - it('should fail updating a named map using the default apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenUpdate = 'default_public'; - - const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-default' }); - const templateUpdate = Object.assign({}, template, { zoom: 3 }); - const testClientCreate = new TestClient(template, apikeyTokenCreate); - - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); - - const testClientDelete = new TestClient({}, apikeyTokenUpdate); - testClientDelete.updateTemplate( - { - templateId: template.template_id, - templateData: templateUpdate, - response: { status: 403 } - }, - function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 403); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); - - testClientDelete.drain(done); - } - ); - }); - }); - - it('should fail updating a named map using a non-existent apikey token', function (done) { - const apikeyTokenCreate = 1234; - const apikeyTokenUpdate = 'wadus'; - - const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-wadus' }); - const templateUpdate = Object.assign({}, template, { zoom: 3 }); - const testClientCreate = new TestClient(template, apikeyTokenCreate); - - testClientCreate.createTemplate({}, function (err, res, template) { - assert.ifError(err); - - const testClientDelete = new TestClient({}, apikeyTokenUpdate); - testClientDelete.updateTemplate( - { - templateId: template.template_id, - templateData: templateUpdate, - response: { status: 401 } - }, - function (err, res, response) { - assert.ifError(err); - - assert.equal(res.statusCode, 401); - - assert.equal(response.errors.length, 1); - assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); - - testClientDelete.drain(done); - } - ); - }); - }); - - }); - - it.skip('should fail creating a named map using a regular apikey token and a private table', function (done) { - const apikeyToken = 'regular1'; - - const template = { - version: '0.0.1', - name: 'auth-api-template-private', - placeholders: { - buffersize: { - type: 'number', - default: 0 + }, + layergroup: { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table_localhost_regular1', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0', + } + }] } - }, - layergroup: { - version: '1.7.0', - layers: [{ - type: 'cartodb', - options: { - sql: 'select * from populated_places_simple_reduced_private', - cartocss: TestClient.CARTOCSS.POINTS, - cartocss_version: '2.3.0', - } - }] - } - }; + }; - const testClient = new TestClient(template, apikeyToken); + it('should update a named map using the master apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 1234; - testClient.getTile(0, 0, 0, { response: PERMISSION_DENIED_RESPONSE }, function (err, res, body) { - assert.ifError(err); + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-master' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); - assert.ok(body.hasOwnProperty('errors')); - assert.equal(body.errors.length, 1); - assert.ok(body.errors[0].match(/permission denied/), body.errors[0]); + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); - testClient.drain(done); - }); + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 200 } + }, + function (err, res) { + assert.ifError(err); + + assert.equal(res.statusCode, 200); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail updating a named map using a regular apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 'regular1'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-regular' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail updating a named map using the default apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 'default_public'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-default' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 403 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 403); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Forbidden/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + it('should fail updating a named map using a non-existent apikey token', function (done) { + const apikeyTokenCreate = 1234; + const apikeyTokenUpdate = 'wadus'; + + const template = Object.assign({}, templateBase, { name: templateBase.name + '-update-wadus' }); + const templateUpdate = Object.assign({}, template, { zoom: 3 }); + const testClientCreate = new TestClient(template, apikeyTokenCreate); + + testClientCreate.createTemplate({}, function (err, res, template) { + assert.ifError(err); + + const testClientDelete = new TestClient({}, apikeyTokenUpdate); + testClientDelete.updateTemplate( + { + templateId: template.template_id, + templateData: templateUpdate, + response: { status: 401 } + }, + function (err, res, response) { + assert.ifError(err); + + assert.equal(res.statusCode, 401); + + assert.equal(response.errors.length, 1); + assert.ok(response.errors[0].match(/Unauthorized/), response.errors[0]); + + testClientDelete.drain(done); + } + ); + }); + }); + + }); }); }); diff --git a/test/support/test-client.js b/test/support/test-client.js index 3e35b740..f7911cc1 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1483,6 +1483,46 @@ TestClient.prototype.updateTemplate = function (params, callback) { break; } + return callback(err, res, body); + }); +}; + + +TestClient.prototype.getTemplate = function (params, callback) { + if (!this.apiKey) { + return callback(new Error('apiKey param is mandatory to create a new template')); + } + + const getTemplateRequest = { + url: `/api/v1/map/named/${params.templateId}?${qs.stringify({ api_key: this.apiKey })}`, + method: 'GET', + headers: { + host: 'localhost' + } + }; + + let getTemplateResponse = { + status: 200, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }; + + if (params.response) { + getTemplateResponse = Object.assign(getTemplateResponse, params.response); + } + + assert.response(this.server, getTemplateRequest, getTemplateResponse, (res, err) => { + let body; + switch (res.headers['content-type']) { + case 'application/json; charset=utf-8': + body = JSON.parse(res.body); + break; + default: + body = res.body; + break; + } + return callback(err, res, body); }); }; \ No newline at end of file From 6437e2ec67f4d773b7425e7d72ecb6a600be6c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 12 Apr 2018 16:32:44 +0200 Subject: [PATCH 06/16] Add test to check regression when cache buster during instantiation is not updated --- test/acceptance/regressions.js | 53 ++++++++++++++++++++++++++++++++++ test/support/test-client.js | 13 +++++++++ 2 files changed, 66 insertions(+) diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions.js index 421df02f..88b109a3 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions.js @@ -2,6 +2,7 @@ require('../support/test_helper'); var assert = require('../support/assert'); var TestClient = require('../support/test-client'); +const LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); describe('regressions', function() { @@ -37,4 +38,56 @@ describe('regressions', function() { testClient.drain(done); }); }); + + describe('map instantiation', function () { + const mapConfig = { + version: '1.7.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'select * from test_table', + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0' + } + }] + }; + + it('should have distint timestamps when the source was updated', function (done) { + const testClient = new TestClient(mapConfig); + + testClient.getLayergroup({}, (err, layergroup) => { + if (err) { + return done(err); + } + + const { cacheBuster: cacheBusterA } = LayergroupToken.parse(layergroup.layergroupid); + + const conn = testClient.getDBConnection(); + + const sql = `select CDB_TableMetadataTouch('test_table'::regclass)`; + + conn.query(sql, (err) => { + if (err) { + return done(err); + } + + testClient.getLayergroup({}, (err, layergroup) => { + if (err) { + return done(err); + } + + const { cacheBuster: cacheBusterB } = LayergroupToken.parse(layergroup.layergroupid); + + const timestampA = parseInt(cacheBusterA, 10); + const timestampB = parseInt(cacheBusterB, 10); + + assert.notEqual(timestampA, timestampB); + assert.ok(timestampA < timestampB, `timestampA: ${timestampA} > timestampB:${timestampB}`); + + testClient.drain(done); + }); + }); + }); + }); + }); }); diff --git a/test/support/test-client.js b/test/support/test-client.js index 7b068901..4c71ed6d 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1183,6 +1183,19 @@ TestClient.prototype.setUserRenderTimeoutLimit = function (user, userTimeoutLimi helper.configureMetadata('hmset', params, callback); }; +TestClient.prototype.getDBConnection = function () { + const dbname = _.template(global.environment.postgres_auth_user, { user_id: 1 }) + '_db'; + + const psql = new PSQL({ + user: 'postgres', + dbname: dbname, + host: global.environment.postgres.host, + port: global.environment.postgres.port + }); + + return psql; +}; + TestClient.prototype.setUserDatabaseTimeoutLimit = function (timeoutLimit, callback) { const dbname = _.template(global.environment.postgres_auth_user, { user_id: 1 }) + '_db'; const dbuser = _.template(global.environment.postgres_auth_user, { user_id: 1 }); From d1ba4a1759d06397dbd7fe87972e46fa1e3a351b Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Thu, 12 Apr 2018 17:41:07 +0200 Subject: [PATCH 07/16] remove unnecessary test --- test/acceptance/auth/authorization.js | 28 ++------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization.js index 37407531..2974d36d 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization.js @@ -37,31 +37,6 @@ describe('authorization', function() { }); }); - it.skip('should create and get a named map tile using a regular apikey token', function (done) { - const apikeyToken = 'regular1'; - const mapConfig = { - version: '1.7.0', - layers: [ - { - options: { - sql: 'select * FROM test_table_localhost_regular1', - cartocss: TestClient.CARTOCSS.POINTS, - cartocss_version: '2.3.0' - } - } - ] - }; - const testClient = new TestClient(mapConfig, apikeyToken); - - testClient.getTile(0, 0, 0, function (err, res, tile) { - assert.ifError(err); - - assert.equal(res.statusCode, 200); - assert.ok(tile instanceof mapnik.Image); - - testClient.drain(done); - }); - }); it('should fail getting a named map tile with default apikey token', function (done) { const apikeyTokenCreate = 'regular1'; @@ -353,7 +328,8 @@ describe('authorization', function() { testClient.drain(done); }); }); - describe.only('Named maps', function () { + + describe('Named maps', function () { describe('LIST Named maps', function () { it('should fail while listing named maps with a regular apikey token', function (done) { From 940cafacac487058b0e3b87658eec31662ee8dbf Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Thu, 12 Apr 2018 17:51:33 +0200 Subject: [PATCH 08/16] add newline add EOF --- test/support/test-client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/support/test-client.js b/test/support/test-client.js index f7911cc1..4bf2d91a 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1525,4 +1525,4 @@ TestClient.prototype.getTemplate = function (params, callback) { return callback(err, res, body); }); -}; \ No newline at end of file +}; From 53a40de2e7ab176900ada4c3d5181edb80b6b981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 12 Apr 2018 18:24:00 +0200 Subject: [PATCH 09/16] Use another table --- test/acceptance/regressions.js | 9 ++++----- test/support/sql/windshaft.test.sql | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions.js index 88b109a3..a0eca119 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions.js @@ -1,5 +1,3 @@ -require('../support/test_helper'); - var assert = require('../support/assert'); var TestClient = require('../support/test-client'); const LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); @@ -40,12 +38,13 @@ describe('regressions', function() { }); describe('map instantiation', function () { + const apikeyToken = 'regular1'; const mapConfig = { version: '1.7.0', layers: [{ type: 'cartodb', options: { - sql: 'select * from test_table', + sql: 'select * from test_table_localhost_regular1', cartocss: TestClient.CARTOCSS.POINTS, cartocss_version: '2.3.0' } @@ -53,7 +52,7 @@ describe('regressions', function() { }; it('should have distint timestamps when the source was updated', function (done) { - const testClient = new TestClient(mapConfig); + const testClient = new TestClient(mapConfig, apikeyToken); testClient.getLayergroup({}, (err, layergroup) => { if (err) { @@ -64,7 +63,7 @@ describe('regressions', function() { const conn = testClient.getDBConnection(); - const sql = `select CDB_TableMetadataTouch('test_table'::regclass)`; + const sql = `select CDB_TableMetadataTouch('test_table_localhost_regular1'::regclass)`; conn.query(sql, (err) => { if (err) { diff --git a/test/support/sql/windshaft.test.sql b/test/support/sql/windshaft.test.sql index d69e5691..51a6de8a 100644 --- a/test/support/sql/windshaft.test.sql +++ b/test/support/sql/windshaft.test.sql @@ -465,6 +465,8 @@ CREATE INDEX test_table_localhost_regular1_the_geom_webmercator_idx ON test_tabl GRANT ALL ON TABLE test_table_localhost_regular1 TO :TESTUSER; GRANT ALL ON TABLE test_table_localhost_regular1 TO test_windshaft_regular1; +INSERT INTO CDB_TableMetadata (tabname, updated_at) VALUES ('test_table_localhost_regular1'::regclass, '2009-02-13T23:31:30.123Z'); + -- analysis tables ----------------------------------------------- ALTER TABLE cdb_analysis_catalog OWNER TO :TESTUSER; From 1df7df21d5d1913fc7961b0e537b9ca42941ba71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 12 Apr 2018 18:31:22 +0200 Subject: [PATCH 10/16] Revert removed line --- test/acceptance/regressions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions.js index a0eca119..b8692d24 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions.js @@ -1,3 +1,4 @@ +require('../support/test_helper'); var assert = require('../support/assert'); var TestClient = require('../support/test-client'); const LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); From d8a5dc586defde3e0aea7980efbfafd4f66faada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 12 Apr 2018 19:58:33 +0200 Subject: [PATCH 11/16] Add test to check dataview filters when instantiating a named map --- test/acceptance/regressions.js | 74 ++++++++++++++++++++++++++++++++++ test/support/test-client.js | 64 +++++++++++++++++++++++++++-- 2 files changed, 135 insertions(+), 3 deletions(-) diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions.js index 421df02f..8ac3b4dc 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions.js @@ -37,4 +37,78 @@ describe('regressions', function() { testClient.drain(done); }); }); + + it('should create and instantiate a named map with filters', function (done) { + const apikeyToken = '1234'; + + const template = { + version: '0.0.1', + name: 'regression-dataview-filter-template', + placeholders: { + buffersize: { + type: 'number', + default: 0 + } + }, + layergroup: { + version: '1.6.0', + layers: [ + { + type: 'cartodb', + options: { + source: { + id: 'a1' + }, + cartocss: TestClient.CARTOCSS.POINTS, + cartocss_version: '2.3.0' + } + } + ], + dataviews: { + country_places_count: { + source: { + id: 'a1' + }, + type: 'aggregation', + options: { + column: 'adm0_a3', + aggregation: 'count' + } + } + }, + analyses: [ + { + id: 'a1', + type: 'source', + params: { + query: 'select * from populated_places_simple_reduced' + } + } + ] + } + }; + + const testClient = new TestClient(template, apikeyToken); + + const params = { + own_filter: 1, + filters: { + dataviews: { + country_places_count: { + accept: ['CAN'] + } + } + } + }; + + testClient.getDataview('country_places_count', params, (err, dataview) => { + assert.ifError(err); + + assert.equal(dataview.type, 'aggregation'); + assert.equal(dataview.categories.length, 1); + assert.deepEqual(dataview.categories[0], { value: 256, category: 'CAN', agg: false }); + + testClient.drain(done); + }); + }); }); diff --git a/test/support/test-client.js b/test/support/test-client.js index 7b068901..487dbe99 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -358,6 +358,8 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) { } var url = '/api/v1/map'; + var urlNamed = url + '/named'; + if (Object.keys(extraParams).length > 0) { url += '?' + qs.stringify(extraParams); } @@ -370,17 +372,73 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) { }; step( - function createLayergroup() { + function createTemplate () { var next = this; + + if (!self.template) { + return next(); + } + + if (!self.apiKey) { + return next(new Error('apiKey param is mandatory to create a new template')); + } + + params.placeholders = params.placeholders || {}; + assert.response(self.server, { - url: url, + url: urlNamed + '?' + qs.stringify({ api_key: self.apiKey }), method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, - data: JSON.stringify(self.mapConfig) + data: JSON.stringify(self.template) + }, + { + status: 200, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }, + function (res, err) { + if (err) { + return next(err); + } + return next(null, JSON.parse(res.body).template_id); + } + ); + }, + function createLayergroup(err, templateId) { + assert.ifError(err); + + var next = this; + + var data = templateId ? params.placeholders : self.mapConfig; + + const queryParams = {}; + + if (self.apiKey) { + queryParams.api_key = self.apiKey; + } + + if (params.filters !== undefined) { + queryParams.filters = JSON.stringify(params.filters); + } + + var path = templateId ? + urlNamed + '/' + templateId + '?' + qs.stringify(queryParams) : + url; + + assert.response(self.server, + { + url: path, + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(data) }, { status: 200, From c2c39938879a8d6678e2c19698c1d5e0e277982b Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Mon, 16 Apr 2018 10:21:54 +0200 Subject: [PATCH 12/16] Upgrade windshaft to 4.7.0 --- package.json | 4 ++-- yarn.lock | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 8b222d24..ec186b2c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "6.0.1", + "version": "6.1.0", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" @@ -48,7 +48,7 @@ "step-profiler": "~0.3.0", "turbo-carto": "0.20.2", "underscore": "~1.6.0", - "windshaft": "4.6.0", + "windshaft": "4.7.0", "yargs": "~5.0.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 405e89b6..397eba60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,20 +2,20 @@ # yarn lockfile v1 -"@carto/mapnik@3.6.2-carto.4": - version "3.6.2-carto.4" - resolved "https://registry.yarnpkg.com/@carto/mapnik/-/mapnik-3.6.2-carto.4.tgz#54042a5dbea293c54e1bd286b32277694c5dc2d2" +"@carto/mapnik@3.6.2-carto.7": + version "3.6.2-carto.7" + resolved "https://registry.yarnpkg.com/@carto/mapnik/-/mapnik-3.6.2-carto.7.tgz#ef057b0a379fec03bce92362a46f8d1729c950d9" dependencies: mapnik-vector-tile "1.5.0" nan "~2.7.0" node-pre-gyp "~0.6.30" protozero "1.5.1" -"@carto/tilelive-bridge@cartodb/tilelive-bridge#2.5.1-cdb4": - version "2.5.1-cdb4" - resolved "https://codeload.github.com/cartodb/tilelive-bridge/tar.gz/3eb554e5109199f50f457cec72ee288cffa5d6b3" +"@carto/tilelive-bridge@cartodb/tilelive-bridge#2.5.1-cdb6": + version "2.5.1-cdb6" + resolved "https://codeload.github.com/cartodb/tilelive-bridge/tar.gz/1d71bc845f257d635f54047f1d2be858341cd552" dependencies: - "@carto/mapnik" "3.6.2-carto.4" + "@carto/mapnik" "3.6.2-carto.7" "@mapbox/sphericalmercator" "~1.0.1" mapnik-pool "~0.1.3" @@ -23,11 +23,11 @@ version "1.0.5" resolved "https://registry.yarnpkg.com/@mapbox/sphericalmercator/-/sphericalmercator-1.0.5.tgz#70237b9774095ed1cfdbcea7a8fd1fc82b2691f2" -abaculus@cartodb/abaculus#2.0.3-cdb5: - version "2.0.3-cdb5" - resolved "https://codeload.github.com/cartodb/abaculus/tar.gz/b899cbea04b3e6093aa3ef32331920acd5f839a1" +abaculus@cartodb/abaculus#2.0.3-cdb7: + version "2.0.3-cdb7" + resolved "https://codeload.github.com/cartodb/abaculus/tar.gz/fcdefbf39956c1c86ce3d39547b903857796657f" dependencies: - "@carto/mapnik" "3.6.2-carto.4" + "@carto/mapnik" "3.6.2-carto.7" d3-queue "^2.0.2" sphericalmercator "1.0.x" @@ -861,9 +861,9 @@ graceful-fs@^4.1.2: version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" -grainstore@1.8.2: - version "1.8.2" - resolved "https://registry.yarnpkg.com/grainstore/-/grainstore-1.8.2.tgz#79dd7a91a098bf8b0ea3189961775c8cc7474319" +grainstore@1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/grainstore/-/grainstore-1.9.0.tgz#4f7604bb83538dbfe5d7dbe63be3a7fa345a14f8" dependencies: carto "0.16.3" debug "~3.1.0" @@ -2239,11 +2239,11 @@ through@2: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" -tilelive-mapnik@cartodb/tilelive-mapnik#0.6.18-cdb8: - version "0.6.18-cdb8" - resolved "https://codeload.github.com/cartodb/tilelive-mapnik/tar.gz/9cb4546c8fdd34ced0a41dbf70e143475b4e2067" +tilelive-mapnik@cartodb/tilelive-mapnik#0.6.18-cdb11: + version "0.6.18-cdb11" + resolved "https://codeload.github.com/cartodb/tilelive-mapnik/tar.gz/90b7a2d4a7032b72c15b0d3ea1a6ec8258a4a250" dependencies: - "@carto/mapnik" "3.6.2-carto.4" + "@carto/mapnik" "3.6.2-carto.7" generic-pool "~2.4.0" mime "~1.6.0" sphericalmercator "~1.0.4" @@ -2400,19 +2400,19 @@ window-size@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075" -windshaft@4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/windshaft/-/windshaft-4.6.0.tgz#d9394aff73c0aa761207ad2b0f12d1c23ac41244" +windshaft@4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/windshaft/-/windshaft-4.7.0.tgz#6fdee3c8c9b28b15835981d1ef565a52884e951c" dependencies: - "@carto/mapnik" "3.6.2-carto.4" - "@carto/tilelive-bridge" cartodb/tilelive-bridge#2.5.1-cdb4 - abaculus cartodb/abaculus#2.0.3-cdb5 + "@carto/mapnik" "3.6.2-carto.7" + "@carto/tilelive-bridge" cartodb/tilelive-bridge#2.5.1-cdb6 + abaculus cartodb/abaculus#2.0.3-cdb7 canvas cartodb/node-canvas#1.6.2-cdb2 carto cartodb/carto#0.15.1-cdb3 cartodb-psql "^0.10.1" debug "^3.1.0" dot "~1.0.2" - grainstore "1.8.2" + grainstore "1.9.0" queue-async "~1.0.7" redis-mpool "^0.5.0" request "2.85.0" @@ -2420,7 +2420,7 @@ windshaft@4.6.0: sphericalmercator "1.0.4" step "~0.0.6" tilelive "5.12.2" - tilelive-mapnik cartodb/tilelive-mapnik#0.6.18-cdb8 + tilelive-mapnik cartodb/tilelive-mapnik#0.6.18-cdb11 torque.js "~2.11.0" underscore "~1.6.0" From b11a766c28c0282cb886ec324f265ead9d7b84e9 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Tue, 3 Apr 2018 10:16:46 +0200 Subject: [PATCH 13/16] Add config for markers_symbolizer_caches examples --- config/environments/development.js.example | 7 ++++++- config/environments/production.js.example | 6 +++++- config/environments/staging.js.example | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 12de0912..842f55d2 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -210,7 +210,12 @@ var config = { 'cache-features': true, // Require metrics to the renderer - metrics: false + metrics: false, + + // Options for markers attributes, ellipses and images caches + markers_symbolizer_caches: { + disabled: false + } }, http: { timeout: 2000, // the timeout in ms for a http tile request diff --git a/config/environments/production.js.example b/config/environments/production.js.example index beb9f15c..771ed2b5 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -205,8 +205,12 @@ var config = { 'cache-features': true, // Require metrics to the renderer - metrics: false + metrics: false, + // Options for markers attributes, ellipses and images caches + markers_symbolizer_caches: { + disabled: false + } }, http: { timeout: 2000, // the timeout in ms for a http tile request diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 40d3bb8b..dd2d892c 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -205,8 +205,12 @@ var config = { 'cache-features': true, // Require metrics to the renderer - metrics: false + metrics: false, + // Options for markers attributes, ellipses and images caches + markers_symbolizer_caches: { + disabled: false + } }, http: { timeout: 2000, // the timeout in ms for a http tile request From 64fa18220fd0cfa1a64508a0b3dd9a6272db924a Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Tue, 3 Apr 2018 10:19:52 +0200 Subject: [PATCH 14/16] Update NEWS.md --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 20b8f06a..92e3e67f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ Released 2018-mm-dd New features: - Aggreation filters +- Upgrades Windshaft to 4.7.0, which includes @carto/mapnik v3.6.2-carto.7 with improvements to metrics and markers caching. It also adds an option to disable the markers symbolizer caches in mapnik. Bug Fixes: - Non-default aggregation selected the wrong columns (e.g. for vector tiles) From b760aa8c633ebda6efc121a0a010d3ea475d0ce2 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Mon, 16 Apr 2018 11:51:04 +0200 Subject: [PATCH 15/16] Release v6.1.0 --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 92e3e67f..41a41986 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ # Changelog ## 6.1.0 -Released 2018-mm-dd +Released 2018-04-16 New features: - Aggreation filters From 09fdf5b9905752d9604480c9ca6d9cf604c391d5 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Mon, 16 Apr 2018 11:53:06 +0200 Subject: [PATCH 16/16] Stub next version --- NEWS.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 41a41986..a359def5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,14 @@ # Changelog +## 6.1.1 +Released 2018-mm-dd + +New features: + + +Bug Fixes: + + ## 6.1.0 Released 2018-04-16 diff --git a/package.json b/package.json index ec186b2c..7bd0d1b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "6.1.0", + "version": "6.1.1", "description": "A map tile server for CartoDB", "keywords": [ "cartodb"