Group name validation delegated to role creation
This commit is contained in:
parent
db89bf1a94
commit
e11f4ef169
@ -116,10 +116,6 @@ DECLARE
|
|||||||
prefix TEXT;
|
prefix TEXT;
|
||||||
max_length constant INTEGER := 63;
|
max_length constant INTEGER := 63;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF group_name !~ '^[a-zA-Z_][a-zA-Z0-9_]*$'
|
|
||||||
THEN
|
|
||||||
RAISE EXCEPTION 'Group name (%) must be a valid identifier. See http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS', group_name;
|
|
||||||
END IF;
|
|
||||||
prefix = format('%s_g_', cartodb._CDB_Group_ShortDatabaseName());
|
prefix = format('%s_g_', cartodb._CDB_Group_ShortDatabaseName());
|
||||||
group_role := format('%s%s', prefix, group_name);
|
group_role := format('%s%s', prefix, group_name);
|
||||||
IF LENGTH(group_role) > max_length
|
IF LENGTH(group_role) > max_length
|
||||||
|
@ -523,16 +523,6 @@ function test_valid_group_names() {
|
|||||||
sql postgres "select cartodb._CDB_Group_GroupRole('_group_1$_a');"
|
sql postgres "select cartodb._CDB_Group_GroupRole('_group_1$_a');"
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_not_valid_group_names() {
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole('1$_a');" fails
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole(' group_1$_a');" fails
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole('group_1$_a ');" fails
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole(' group_1$_a ');" fails
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole('group _1$_a');" fails
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole('groupña');" fails
|
|
||||||
sql postgres "select cartodb._CDB_Group_GroupRole('a123456789012345678901234567890123456789012345678901234567890');" fails
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_administrator_name_generation() {
|
function test_administrator_name_generation() {
|
||||||
sql postgres "select cartodb._CDB_Organization_Admin_Role_Name();"
|
sql postgres "select cartodb._CDB_Organization_Admin_Role_Name();"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user