6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_4836_test.py

64 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5132
ISSUE: 5132
TITLE: Grant update(c) on t to U01 with grant option: user U01 will not be able to `revoke update(c) on t from <user | role>` if this `U01` do some DML before revoke
2022-01-24 20:27:02 +01:00
DESCRIPTION:
JIRA: CORE-4836
FBTEST: bugs.core_4836
NOTES:
[12.12.2023] pzotov
Added 'SQLSTATE' in substitutions: runtime error must not be filtered out by '?!(...)' pattern
("negative lookahead assertion", see https://docs.python.org/3/library/re.html#regular-expression-syntax).
Added 'combine_output = True' in order to see SQLSTATE if any error occurs.
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
tmp_user = user_factory('db', name='tmp$c4836', password='123', admin=True)
tmp_role = role_factory('db', name='tmp$r4836')
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
recreate table test(id int, text varchar(30));
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
grant select on test to public;
grant update(text) on test to tmp$c4836 with grant option;
commit;
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
connect '$(DSN)' user tmp$c4836 password '123';
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
grant update (text) on test to tmp$r4836;
commit;
show grants;
commit;
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
select * from test; -- this DML prevented to do subsequent `revoke update(text) on test from role` on build 3.0.0.31873
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
commit;
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
revoke update(text) on test from role tmp$r4836;
commit;
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
show grants;
commit;
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
act = isql_act('db', test_script, substitutions=[('^((?!SQLSTATE|C4836|R4836).)*$', '')])
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
GRANT UPDATE (TEXT) ON TEST TO USER TMP$C4836 WITH GRANT OPTION
GRANT UPDATE (TEXT) ON TEST TO ROLE TMP$R4836 GRANTED BY TMP$C4836
GRANT UPDATE (TEXT) ON TEST TO USER TMP$C4836 WITH GRANT OPTION
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-24 20:27:02 +01:00
def test_1(act: Action, tmp_user: User, tmp_role: Role):
act.expected_stdout = expected_stdout
act.execute(combine_output = True)
2022-01-24 20:27:02 +01:00
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00