add test should create a layergroup with a buffer analysis using a regular apikey token AND grant privileges to master and regular roles in bootstraping sql

This commit is contained in:
Eneko Lakasta 2018-02-08 18:54:14 +01:00
parent c7780e9f42
commit a8de436424
2 changed files with 48 additions and 0 deletions

View File

@ -207,4 +207,48 @@ describe('authorization', function() {
testClient.drain(done); testClient.drain(done);
}); });
}); });
it('should create a layergroup with a buffer analysis using a regular apikey token', function (done) {
const apikeyToken = 'regular1';
const mapConfig = {
version: '1.7.0',
layers: [
{
type: 'cartodb',
options: {
source: {
id: 'HEAD1'
},
cartocss: TestClient.CARTOCSS.POINTS,
cartocss_version: '2.3.0'
}
}
],
analyses: [
{
id: "HEAD1",
type: "buffer",
params: {
source: {
id: 'HEAD2',
type: 'source',
params: {
query: 'select * from test_table_localhost_regular1'
}
},
radius: 50000
}
}
]
};
const testClient = new TestClient(mapConfig, apikeyToken);
testClient.getLayergroup(function (err, layergroupResult) {
assert.ifError(err);
assert.ok(layergroupResult.layergroupid);
testClient.drain(done);
});
});
}); });

View File

@ -27,6 +27,8 @@ CREATE USER :TESTUSER WITH PASSWORD ':TESTPASS';
DROP USER IF EXISTS test_windshaft_regular1; DROP USER IF EXISTS test_windshaft_regular1;
CREATE USER test_windshaft_regular1 WITH PASSWORD 'regular1'; CREATE USER test_windshaft_regular1 WITH PASSWORD 'regular1';
GRANT test_windshaft_regular1 to :TESTUSER;
-- first table -- first table
CREATE TABLE test_table ( CREATE TABLE test_table (
updated_at timestamp without time zone DEFAULT now(), updated_at timestamp without time zone DEFAULT now(),
@ -193,6 +195,7 @@ INSERT INTO CDB_TableMetadata (tabname, updated_at) VALUES ('test_table_private_
-- GRANT SELECT ON CDB_TableMetadata TO :PUBLICUSER; -- GRANT SELECT ON CDB_TableMetadata TO :PUBLICUSER;
GRANT SELECT ON CDB_TableMetadata TO :TESTUSER; GRANT SELECT ON CDB_TableMetadata TO :TESTUSER;
GRANT SELECT ON CDB_TableMetadata TO test_windshaft_regular1; -- for analysis
-- long name table -- long name table
CREATE TABLE CREATE TABLE
@ -755,6 +758,7 @@ GRANT SELECT ON TABLE analysis_rent_listings TO :PUBLICUSER;
-- --
GRANT SELECT, UPDATE, INSERT, DELETE ON cdb_analysis_catalog TO :TESTUSER; GRANT SELECT, UPDATE, INSERT, DELETE ON cdb_analysis_catalog TO :TESTUSER;
GRANT SELECT, UPDATE, INSERT, DELETE ON cdb_analysis_catalog TO test_windshaft_regular1; -- for analysis
DROP EXTENSION IF EXISTS crankshaft; DROP EXTENSION IF EXISTS crankshaft;
CREATE SCHEMA IF NOT EXISTS cdb_crankshaft; CREATE SCHEMA IF NOT EXISTS cdb_crankshaft;