Merge pull request #323 from CartoDB/321-grant-sequence
grant usage on cartodb_id sequence when sharing read write
This commit is contained in:
commit
0a58c05049
@ -111,6 +111,7 @@ AS $$
|
||||
BEGIN
|
||||
EXECUTE 'GRANT USAGE ON SCHEMA "' || from_schema || '" TO "' || to_role_name || '"';
|
||||
EXECUTE 'GRANT SELECT, INSERT, UPDATE, DELETE ON "' || from_schema || '"."' || table_name || '" TO "' || to_role_name || '"';
|
||||
EXECUTE 'GRANT USAGE, SELECT ON SEQUENCE ' || pg_catalog.pg_get_serial_sequence(Format('%I.%I', from_schema, table_name), 'cartodb_id') || ' TO "' || to_role_name || '"';
|
||||
END
|
||||
$$ LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE;
|
||||
|
||||
|
@ -315,6 +315,8 @@ function test_member_1_cannot_grant_read_write_permission_to_other_schema_than_i
|
||||
}
|
||||
|
||||
function test_member_2_can_write_to_member_1_table_after_write_permission_is_added() {
|
||||
sql cdb_testmember_1 "ALTER TABLE cdb_testmember_1.foo ADD cartodb_id SERIAL NOT NULL UNIQUE;"
|
||||
|
||||
sql cdb_testmember_1 "SELECT * FROM cartodb.CDB_Organization_Add_Table_Read_Write_Permission('cdb_testmember_1', 'foo', 'cdb_testmember_2')"
|
||||
sql cdb_testmember_2 'INSERT INTO cdb_testmember_1.foo VALUES (5), (6), (7), (8), (9);'
|
||||
sql cdb_testmember_1 'SELECT count(*) FROM cdb_testmember_1.foo;' should 10
|
||||
@ -322,6 +324,8 @@ function test_member_2_can_write_to_member_1_table_after_write_permission_is_add
|
||||
sql cdb_testmember_2 'DELETE FROM cdb_testmember_1.foo where a = 9;'
|
||||
sql cdb_testmember_1 'SELECT count(*) FROM cdb_testmember_1.foo;' should 9
|
||||
sql cdb_testmember_2 'SELECT count(*) FROM cdb_testmember_1.foo;' should 9
|
||||
|
||||
sql cdb_testmember_1 "ALTER TABLE cdb_testmember_1.foo DROP cartodb_id;"
|
||||
}
|
||||
|
||||
function test_member_1_removes_access_and_member_2_can_no_longer_query_the_table() {
|
||||
@ -332,10 +336,14 @@ function test_member_1_removes_access_and_member_2_can_no_longer_query_the_table
|
||||
}
|
||||
|
||||
function test_member_1_removes_access_and_member_2_can_no_longer_write_to_the_table() {
|
||||
sql cdb_testmember_1 "ALTER TABLE cdb_testmember_1.foo ADD cartodb_id SERIAL NOT NULL UNIQUE;"
|
||||
|
||||
sql cdb_testmember_1 "SELECT * FROM cartodb.CDB_Organization_Add_Table_Read_Write_Permission('cdb_testmember_1', 'foo', 'cdb_testmember_2')"
|
||||
sql cdb_testmember_2 'INSERT INTO cdb_testmember_1.foo VALUES (5), (6), (7), (8), (9);'
|
||||
sql cdb_testmember_1 "SELECT * FROM cartodb.CDB_Organization_Remove_Access_Permission('cdb_testmember_1', 'foo', 'cdb_testmember_2')"
|
||||
sql cdb_testmember_2 'INSERT INTO cdb_testmember_1.foo VALUES (5), (6), (7), (8), (9);' fails
|
||||
|
||||
sql cdb_testmember_1 "ALTER TABLE cdb_testmember_1.foo DROP cartodb_id;"
|
||||
}
|
||||
|
||||
function test_giving_permissions_to_two_tables_and_removing_from_first_table_should_not_remove_from_second() {
|
||||
@ -418,7 +426,7 @@ function test_cdb_usertables_should_work_with_orgusers() {
|
||||
sql cdb_testmember_1 "CREATE TABLE test_perms_pub (a int)"
|
||||
sql cdb_testmember_1 "INSERT INTO test_perms_pub (a) values (1);"
|
||||
sql cdb_testmember_1 "GRANT SELECT ON TABLE test_perms_pub TO publicuser"
|
||||
|
||||
|
||||
sql cdb_testmember_1 "CREATE TABLE test_perms_priv (a int)"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user