Changeset: 227749c1b794 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=227749c1b794
Modified Files:
sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.SQL.py
Branch: mtest
Log Message:
Extended the test to verify that then re-granted, a logged-in user can
immediately use the rights.
Removed old python code
diffs (86 lines):
diff --git a/sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.SQL.py
b/sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.SQL.py
--- a/sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.SQL.py
+++ b/sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.SQL.py
@@ -30,71 +30,17 @@ with SQLTestCase() as tc1:
# Revoke the right to select from the new user.
tc1.execute('REVOKE SELECT ON new_schema_as_well.test FROM
new_user').assertSucceeded()
- # The new user should not be able to select anymore.
- tc2.execute('UPDATE test SET x = -66 WHERE y = 66').assertFailed()
+ # The new user should not be able to select anymore while still logged
in
+ tc2.execute('SELECT * FROM test').assertFailed(err_code="42000",
err_message="SELECT: access denied for new_user to table
'new_schema_as_well.test'")
+ tc2.execute('UPDATE test SET x = -66 WHERE y =
66').assertFailed(err_code="42000", err_message="UPDATE: insufficient
privileges for user 'new_user' to update table 'test'")
tc2.execute('INSERT INTO test VALUES (66, 66)').assertSucceeded()
- tc2.execute('DELETE FROM test WHERE y = -66').assertFailed()
- tc2.execute('SELECT * FROM test').assertFailed()
-
-# import sys, time, pymonetdb, os
-
-# def connect(username, password):
-# return pymonetdb.connect(database = os.getenv('TSTDB'),
-# hostname = 'localhost',
-# port = int(os.getenv('MAPIPORT')),
-# username = username,
-# password = password,
-# autocommit = True)
-
-# def query(conn, sql):
-# print(sql)
-# cur = conn.cursor()
-# try:
-# cur.execute(sql)
-# except pymonetdb.OperationalError as e:
-# print("!", e)
-# return
-# r = cur.fetchall()
-# cur.close()
-# print(r)
+ tc2.execute('DELETE FROM test WHERE y =
-66').assertFailed(err_code="42000", err_message="DELETE FROM: insufficient
privileges for user 'new_user' to delete from table 'test'")
-# def run(conn, sql):
-# print(sql)
-# try:
-# r = conn.execute(sql)
-# except pymonetdb.OperationalError as e:
-# print("!", e)
-# return
-# print('# OK')
-
-
-# c1 = connect('monetdb', 'monetdb')
-# # Create a new schema with a new table.
-# run(c1, 'CREATE SCHEMA new_schema_as_well')
-# run(c1, 'SET SCHEMA new_schema_as_well')
-# run(c1, 'CREATE TABLE test (x int, y int)')
-# run(c1, 'INSERT INTO test VALUES (-1, -1)')
+ # Re-grant the right to select to the new user.
+ tc1.execute('GRANT SELECT ON new_schema_as_well.test TO
new_user').assertSucceeded()
-# # Create a new user and grant the right to select.
-# run(c1, 'CREATE USER new_user WITH PASSWORD \'new_quite_long_password\' NAME
\'newUser\' SCHEMA new_schema_as_well')
-# run(c1, 'GRANT SELECT ON new_schema_as_well.test TO new_user')
-# run(c1, 'GRANT UPDATE ON new_schema_as_well.test TO new_user')
-# run(c1, 'GRANT INSERT ON new_schema_as_well.test TO new_user')
-# run(c1, 'GRANT DELETE ON new_schema_as_well.test TO new_user')
-
-# # Login the new user, and select.
-# c2 = connect('new_user', 'new_quite_long_password')
-# query(c2, 'SELECT * FROM test')
-# run(c2, 'UPDATE test SET x = -3 WHERE y = -1')
-# run(c2, 'INSERT INTO test VALUES (0, 0)')
-# run(c2, 'DELETE FROM test WHERE y = -2')
-
-# # Revoke the right to select from the new user.
-# run(c1, 'REVOKE SELECT ON new_schema_as_well.test FROM new_user')
-
-# # The new user should not be able to select anymore.
-# run(c2, 'UPDATE test SET x = -66 WHERE y = 66')
-# run(c2, 'INSERT INTO test VALUES (66, 66)')
-# run(c2, 'DELETE FROM test WHERE y = -66')
-# query(c2, 'SELECT * FROM test')
-
+ # The new user should be able to select again while still logged in
+ tc2.execute('SELECT * FROM test').assertSucceeded()
+ tc2.execute('UPDATE test SET x = -66 WHERE y = 66').assertSucceeded()
+ tc2.execute('INSERT INTO test VALUES (66, 66)').assertSucceeded()
+ tc2.execute('DELETE FROM test WHERE y = -66').assertSucceeded()
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list