Added MSQL test cases for Roles.

This commit is contained in:
Murtuza Zabuawala 2019-09-16 11:41:48 +05:30 committed by Akshay Joshi
parent 6e7759f1d5
commit d923dcf98b
19 changed files with 141 additions and 22 deletions

View File

@ -506,8 +506,7 @@ rolmembership:{
"The current user does not have permission to create "
"the role."
)
elif action == 'msql' and 'rid' in kwargs and \
kwargs['rid'] != -1:
elif action == 'msql' and 'rid' in kwargs:
fetch_name = True
if check_permission:
@ -863,8 +862,8 @@ rolmembership:{
@check_precondition(action='msql')
@validate_request
def msql(self, gid, sid, rid=-1):
if rid == -1:
def msql(self, gid, sid, rid=None):
if rid is None:
return make_json_response(
data=render_template(
self.sql_path + 'create.sql',

View File

@ -0,0 +1 @@
COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description';

View File

@ -0,0 +1,2 @@
ALTER ROLE "Role1_$%{}[]()&*^!@""'`\/#"
RENAME TO "Role2_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,11 @@
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#"
NOSUPERUSER
NOCREATEDB
NOREPLICATION
CONNECTION LIMIT 100
VALID UNTIL '2050-01-01T00:00:00+05:30'
PASSWORD 'xxxxxx';
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres
SET application_name TO 'pg4';

View File

@ -0,0 +1 @@
COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description';

View File

@ -0,0 +1,2 @@
ALTER ROLE "Role1_$%{}[]()&*^!@""'`\/#"
RENAME TO "Role2_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,11 @@
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#"
SUPERUSER
CREATEDB
NOREPLICATION
CONNECTION LIMIT 100
VALID UNTIL '2050-01-01T00:00:00+05:30'
PASSWORD 'xxxxxx';
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres
SET application_name TO 'pg4';

View File

@ -0,0 +1,9 @@
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
LOGIN
SUPERUSER
CREATEDB
CREATEROLE
INHERIT
REPLICATION
CONNECTION LIMIT -1
PASSWORD 'xxxxxx';

View File

@ -0,0 +1,9 @@
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
NOLOGIN
NOSUPERUSER
NOCREATEDB
NOCREATEROLE
INHERIT
NOREPLICATION
CONNECTION LIMIT -1
PASSWORD 'xxxxxx';

View File

@ -5,6 +5,7 @@
"name": "Create Role",
"endpoint": "NODE-role.obj",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql",
"data": {
"rolname": "Role1_$%{}[]()&*^!@\"'`\\/#",
"rolcanlogin": false,
@ -17,37 +18,42 @@
"rolcatupdate": false,
"rolreplication": false,
"rolmembership": [],
"rolvaliduntil": null,
"seclabels": [],
"variables": []
},
"expected_sql_file": "create_role.sql"
"expected_sql_file": "create_role.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Role description",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"description": "This is detailed description"
},
"expected_sql_file": "alter_role_description.sql"
"expected_sql_file": "alter_role_description.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Role name",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolname": "Role2_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_role_name.sql"
"expected_sql_file": "alter_role_name.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Role options",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolsuper": true,
"rolcreatedb": true,
@ -57,7 +63,8 @@
"rolvaliduntil": "2050-01-01 00:00:00 +05:30",
"variables": { "added": [{"name":"application_name","value":"pg4","database":"postgres"}] }
},
"expected_sql_file": "alter_role_options.sql"
"expected_sql_file": "alter_role_options.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "delete",
@ -70,6 +77,7 @@
"name": "Create Login Role",
"endpoint": "NODE-role.obj",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql",
"data": {
"rolname": "Role1_$%{}[]()&*^!@\"'`\\/#",
"rolcanlogin": true,
@ -82,37 +90,42 @@
"rolcatupdate": true,
"rolreplication": true,
"rolmembership": [],
"rolvaliduntil": null,
"seclabels": [],
"variables": []
},
"expected_sql_file": "create_login_role.sql"
"expected_sql_file": "create_login_role.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Login Role description",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"description": "This is detailed description"
},
"expected_sql_file": "alter_login_role_description.sql"
"expected_sql_file": "alter_login_role_description.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Login Role name",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolname": "Role2_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_login_role_name.sql"
"expected_sql_file": "alter_login_role_name.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Login Role options",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolsuper": false,
"rolcreatedb": false,
@ -122,7 +135,8 @@
"rolvaliduntil": "2050-01-01 00:00:00 +05:30",
"variables": { "added": [{"name":"application_name","value":"pg4","database":"postgres"}] }
},
"expected_sql_file": "alter_login_role_options.sql"
"expected_sql_file": "alter_login_role_options.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "delete",

View File

@ -0,0 +1 @@
COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description';

View File

@ -0,0 +1,2 @@
ALTER ROLE "Role1_$%{}[]()&*^!@""'`\/#"
RENAME TO "Role2_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,11 @@
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#"
NOSUPERUSER
NOCREATEDB
NOREPLICATION
CONNECTION LIMIT 100
VALID UNTIL '2050-01-01T00:00:00+05:30'
PASSWORD 'xxxxxx';
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres
SET application_name TO 'pg4';

View File

@ -0,0 +1 @@
COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description';

View File

@ -0,0 +1,2 @@
ALTER ROLE "Role1_$%{}[]()&*^!@""'`\/#"
RENAME TO "Role2_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,11 @@
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#"
SUPERUSER
CREATEDB
NOREPLICATION
CONNECTION LIMIT 100
VALID UNTIL '2050-01-01T00:00:00+05:30'
PASSWORD 'xxxxxx';
ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres
SET application_name TO 'pg4';

View File

@ -0,0 +1,9 @@
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
LOGIN
SUPERUSER
CREATEDB
CREATEROLE
INHERIT
REPLICATION
CONNECTION LIMIT -1
PASSWORD 'xxxxxx';

View File

@ -0,0 +1,9 @@
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
NOLOGIN
NOSUPERUSER
NOCREATEDB
NOCREATEROLE
INHERIT
NOREPLICATION
CONNECTION LIMIT -1
PASSWORD 'xxxxxx';

View File

@ -5,6 +5,7 @@
"name": "Create Role",
"endpoint": "NODE-role.obj",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql",
"data": {
"rolname": "Role1_$%{}[]()&*^!@\"'`\\/#",
"rolcanlogin": false,
@ -17,37 +18,42 @@
"rolcatupdate": false,
"rolreplication": false,
"rolmembership": [],
"rolvaliduntil": null,
"seclabels": [],
"variables": []
},
"expected_sql_file": "create_role.sql"
"expected_sql_file": "create_role.sql",
"expected_msql_file": "create_role.msql"
},
{
"type": "alter",
"name": "Alter Role description",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"description": "This is detailed description"
},
"expected_sql_file": "alter_role_description.sql"
"expected_sql_file": "alter_role_description.sql",
"expected_msql_file": "alter_role_description.msql"
},
{
"type": "alter",
"name": "Alter Role name",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolname": "Role2_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_role_name.sql"
"expected_sql_file": "alter_role_name.sql",
"expected_msql_file": "alter_role_name.msql"
},
{
"type": "alter",
"name": "Alter Role options",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolsuper": true,
"rolcreatedb": true,
@ -58,6 +64,7 @@
"variables": { "added": [{"name":"application_name","value":"pg4","database":"postgres"}] }
},
"expected_sql_file": "alter_role_options.sql",
"expected_msql_file": "alter_role_options.msql",
"convert_timestamp_columns": ["rolvaliduntil"]
},
{
@ -71,6 +78,7 @@
"name": "Create Login Role",
"endpoint": "NODE-role.obj",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql",
"data": {
"rolname": "Role1_$%{}[]()&*^!@\"'`\\/#",
"rolcanlogin": true,
@ -83,37 +91,42 @@
"rolcatupdate": true,
"rolreplication": true,
"rolmembership": [],
"rolvaliduntil": null,
"seclabels": [],
"variables": []
},
"expected_sql_file": "create_login_role.sql"
"expected_sql_file": "create_login_role.sql",
"expected_msql_file": "create_login_role.msql"
},
{
"type": "alter",
"name": "Alter Login Role description",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"description": "This is detailed description"
},
"expected_sql_file": "alter_login_role_description.sql"
"expected_sql_file": "alter_login_role_description.sql",
"expected_msql_file": "alter_login_role_description.msql"
},
{
"type": "alter",
"name": "Alter Login Role name",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolname": "Role2_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_login_role_name.sql"
"expected_sql_file": "alter_login_role_name.sql",
"expected_msql_file": "alter_login_role_name.msql"
},
{
"type": "alter",
"name": "Alter Login Role options",
"endpoint": "NODE-role.obj_id",
"sql_endpoint": "NODE-role.sql_id",
"msql_endpoint": "NODE-role.msql_id",
"data": {
"rolsuper": false,
"rolcreatedb": false,
@ -124,6 +137,7 @@
"variables": { "added": [{"name":"application_name","value":"pg4","database":"postgres"}] }
},
"expected_sql_file": "alter_login_role_options.sql",
"expected_msql_file": "alter_login_role_options.msql",
"convert_timestamp_columns": ["rolvaliduntil"]
},
{