Changeset: 54fe6f27774c for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=54fe6f27774c Added Files: sql/test/Users/Tests/util.py Modified Files: sql/test/Users/Tests/changePasswordUser.SQL.py sql/test/Users/Tests/changeSchemaUser.SQL.py sql/test/Users/Tests/dropManyUsers.Bug-3764.SQL.py sql/test/Users/Tests/grantMonetdbToRegularUser.Bug-3771.SQL.py sql/test/Users/Tests/grantMonetdbToSchemaOwner.Bug-3771.SQL.py sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.SQL.py sql/test/Users/Tests/grantRole.Bug-3772.SQL.py sql/test/Users/Tests/renameUser.SQL.py sql/test/Users/Tests/role.SQL.py Branch: default Log Message:
Refactoring. diffs (truncated from 534 to 300 lines): diff --git a/sql/test/Users/Tests/changePasswordUser.SQL.py b/sql/test/Users/Tests/changePasswordUser.SQL.py --- a/sql/test/Users/Tests/changePasswordUser.SQL.py +++ b/sql/test/Users/Tests/changePasswordUser.SQL.py @@ -1,50 +1,34 @@ ### # Assess that the admin can change the password of a user. -# Assess that a user can change its one password. +# Assess that a user can change its own password. ### -import os, sys -try: - from MonetDBtesting import process -except ImportError: - import process +from util import sql_test_client -def client(user, passwd, input=None): - clt = process.client(lang='sql', user=user, passwd=passwd, - stdin = process.PIPE, - stdout = process.PIPE, - stderr = process.PIPE, - port = int(os.getenv('MAPIPORT'))) - out, err = clt.communicate(input) - sys.stdout.write(out) - sys.stderr.write(err) - -sql_client = os.getenv('SQL_CLIENT') - -client('monetdb', 'monetdb', input = """\ +sql_test_client('monetdb', 'monetdb', input = """\ ALTER USER april WITH UNENCRYPTED PASSWORD 'april2'; """) # try to log in with old password -client('april', 'april', input = """\ +sql_test_client('april', 'april', input = """\ select 'password april'; """) # try to log in with new password -client('april', 'april2', input = """\ +sql_test_client('april', 'april2', input = """\ select 'password april2'; ALTER USER SET UNENCRYPTED PASSWORD 'april5' USING OLD PASSWORD 'april3'; ALTER USER SET UNENCRYPTED PASSWORD 'april' USING OLD PASSWORD 'april2'; """) # try to log in with old password -client('april', 'april2', input = """\ +sql_test_client('april', 'april2', input = """\ select 'password april2 (wrong!!!)'; """) # try to log in with the new password -client('april', 'april', input = """\ +sql_test_client('april', 'april', input = """\ select 'password change successfully'; """) diff --git a/sql/test/Users/Tests/changeSchemaUser.SQL.py b/sql/test/Users/Tests/changeSchemaUser.SQL.py --- a/sql/test/Users/Tests/changeSchemaUser.SQL.py +++ b/sql/test/Users/Tests/changeSchemaUser.SQL.py @@ -1,42 +1,26 @@ ### -# Assess that the schema of a user can be changed. -# Assess that there is an error message if it tries to set an unexisting schema. -# Assess that there is an error message if it tries to set a schema for an unexisting user. -# Assess that a user that owns a schema cannot be dropped. +# Change the default schema of a user (possible). +# Change the default schema of a user to an unexisting schema (not possible). +# Change the default schema for an unexisting user (not possible). +# Drop a user that owns a schema (not possible). ### -import os, sys -try: - from MonetDBtesting import process -except ImportError: - import process +from util import sql_test_client -def client(user, passwd, input=None): - clt = process.client(lang='sql', user=user, passwd=passwd, - stdin = process.PIPE, - stdout = process.PIPE, - stderr = process.PIPE, - port = int(os.getenv('MAPIPORT'))) - out, err = clt.communicate(input) - sys.stdout.write(out) - sys.stderr.write(err) - -sql_client = os.getenv('SQL_CLIENT') - -client('monetdb', 'monetdb', input = """\ +sql_test_client('monetdb', 'monetdb', input = """\ ALTER USER "april" SET SCHEMA library; ALTER USER "april2" SET SCHEMA library; --no such user ALTER USER "april" SET SCHEMA library2; --no such schema """) # This is the new april, so these operations should fail. -client('april', 'april', input = """\ +sql_test_client('april', 'april', input = """\ SELECT * from bank.accounts; --no such table. SELECT * from library.orders; --not enough privileges. """) -client('monetdb', 'monetdb', input = """\ +sql_test_client('monetdb', 'monetdb', input = """\ ALTER USER "april" SET SCHEMA bank; CREATE SCHEMA forAlice AUTHORIZATION april; DROP user april; diff --git a/sql/test/Users/Tests/dropManyUsers.Bug-3764.SQL.py b/sql/test/Users/Tests/dropManyUsers.Bug-3764.SQL.py --- a/sql/test/Users/Tests/dropManyUsers.Bug-3764.SQL.py +++ b/sql/test/Users/Tests/dropManyUsers.Bug-3764.SQL.py @@ -3,26 +3,9 @@ # Drop four users. ### -import os, sys -try: - from MonetDBtesting import process -except ImportError: - import process +from util import sql_test_client -def client(user, passwd, input=None): - clt = process.client(lang='sql', user=user, passwd=passwd, - stdin = process.PIPE, - stdout = process.PIPE, - stderr = process.PIPE, - port = int(os.getenv('MAPIPORT'))) - out, err = clt.communicate(input) - sys.stdout.write(out) - sys.stderr.write(err) - -sql_client = os.getenv('SQL_CLIENT') - - -client('monetdb', 'monetdb', input = """\ +sql_test_client('monetdb', 'monetdb', input = """\ CREATE SCHEMA newSchema; select * from "sys"."users"; diff --git a/sql/test/Users/Tests/grantMonetdbToRegularUser.Bug-3771.SQL.py b/sql/test/Users/Tests/grantMonetdbToRegularUser.Bug-3771.SQL.py --- a/sql/test/Users/Tests/grantMonetdbToRegularUser.Bug-3771.SQL.py +++ b/sql/test/Users/Tests/grantMonetdbToRegularUser.Bug-3771.SQL.py @@ -4,26 +4,9 @@ ### -import os, sys -try: - from MonetDBtesting import process -except ImportError: - import process +from util import sql_test_client -def client(user, passwd, input=None): - clt = process.client(lang='sql', user=user, passwd=passwd, - stdin = process.PIPE, - stdout = process.PIPE, - stderr = process.PIPE, - port = int(os.getenv('MAPIPORT'))) - out, err = clt.communicate(input) - sys.stdout.write(out) - sys.stderr.write(err) - -sql_client = os.getenv('SQL_CLIENT') - - -client('monetdb', 'monetdb', input = """\ +sql_test_client('monetdb', 'monetdb', input = """\ CREATE USER user_with_many_rights with password 'ThisIsAS3m1S3cur3P4ssw0rd' name 'user gets monetdb rights' schema sys; CREATE SCHEMA a_brand_new_schema_with_a_longer_name_than_usual; @@ -35,7 +18,7 @@ GRANT monetdb to user_with_many_rights; """) -client('user_with_many_rights', 'ThisIsAS3m1S3cur3P4ssw0rd', input = """\ +sql_test_client('user_with_many_rights', 'ThisIsAS3m1S3cur3P4ssw0rd', input = """\ -- Check delete. set schema a_brand_new_schema_with_a_longer_name_than_usual; set role monetdb; diff --git a/sql/test/Users/Tests/grantMonetdbToSchemaOwner.Bug-3771.SQL.py b/sql/test/Users/Tests/grantMonetdbToSchemaOwner.Bug-3771.SQL.py --- a/sql/test/Users/Tests/grantMonetdbToSchemaOwner.Bug-3771.SQL.py +++ b/sql/test/Users/Tests/grantMonetdbToSchemaOwner.Bug-3771.SQL.py @@ -1,43 +1,26 @@ ### -# Let a user inherit the rights of monetdb. +# Let a scheam owner inherit the rights of monetdb. # Check that by assuming the monetdb role the user has complete privileges (e.g. select, create, drop). ### -import os, sys -try: - from MonetDBtesting import process -except ImportError: - import process +from util import sql_test_client -def client(user, passwd, input=None): - clt = process.client(lang='sql', user=user, passwd=passwd, - stdin = process.PIPE, - stdout = process.PIPE, - stderr = process.PIPE, - port = int(os.getenv('MAPIPORT'))) - out, err = clt.communicate(input) - sys.stdout.write(out) - sys.stderr.write(err) +sql_test_client('monetdb', 'monetdb', input = """\ +CREATE USER owner with password 'ThisIsAS3m1S3cur3P4ssw0rd' name 'user gets monetdb rights' schema sys; -sql_client = os.getenv('SQL_CLIENT') +CREATE SCHEMA schemaForOwner AUTHORIZATION owner; - -client('monetdb', 'monetdb', input = """\ -CREATE USER user_with_many_rights with password 'ThisIsAS3m1S3cur3P4ssw0rd' name 'user gets monetdb rights' schema sys; - -CREATE SCHEMA a_brand_new_schema_with_a_longer_name_than_usual AUTHORIZATION user_with_many_rights; - -CREATE table a_brand_new_schema_with_a_longer_name_than_usual.testTable(v1 int, v2 int); +CREATE table schemaForOwner.testTable(v1 int, v2 int); -- Grant delete rights. -GRANT monetdb to user_with_many_rights; +GRANT monetdb to owner; """) -client('user_with_many_rights', 'ThisIsAS3m1S3cur3P4ssw0rd', input = """\ +sql_test_client('owner', 'ThisIsAS3m1S3cur3P4ssw0rd', input = """\ -- Check delete. -set schema a_brand_new_schema_with_a_longer_name_than_usual; +set schema schemaForOwner; set role monetdb; DROP TABLE testTable; diff --git a/sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.SQL.py b/sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.SQL.py --- a/sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.SQL.py +++ b/sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.SQL.py @@ -2,29 +2,12 @@ # Give a privilege to a USER, then remove it and give it again (possible). # Assess that by granting one privilege, he only gets that one privilege. # Assess that the privilege was indeed removed. -# Assess that it is possible to regrant the same privilege. +# Assess that it is possible to regrant the revoked privilege. ### -import os, sys -try: - from MonetDBtesting import process -except ImportError: - import process +from util import sql_test_client -def client(user, passwd, input=None): - clt = process.client(lang='sql', user=user, passwd=passwd, - stdin = process.PIPE, - stdout = process.PIPE, - stderr = process.PIPE, - port = int(os.getenv('MAPIPORT'))) - out, err = clt.communicate(input) - sys.stdout.write(out) - sys.stderr.write(err) - -sql_client = os.getenv('SQL_CLIENT') - - -client('monetdb', 'monetdb', input = """\ +sql_test_client('monetdb', 'monetdb', input = """\ CREATE SCHEMA schemaTest; CREATE USER user_delete with password 'delete' name 'user can only delete' schema schemaTest; @@ -46,7 +29,7 @@ GRANT SELECT on table schemaTest.testTab """) -client('user_delete', 'delete', input = """\ +sql_test_client('user_delete', 'delete', input = """\ -- Check delete. DELETE FROM testTable where v1 = 2; @@ -56,7 +39,7 @@ UPDATE testTable set v1 = 2 where v2 = 7 INSERT into testTable values (3, 3); """) -client('user_update', 'update', input = """\ +sql_test_client('user_update', 'update', input = """\ -- Check insert. UPDATE testTable set v1 = 2 where v2 = 7; @@ -66,7 +49,7 @@ INSERT into testTable values (3, 3); DELETE FROM testTable where v1 = 2; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list