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_4980_test.py

125 lines
3.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_4980
# title: Operator REVOKE can modify rights granted to system tables at DB creation time
2021-12-19 22:25:36 +01:00
# decription:
2021-04-26 20:07:00 +02:00
# We create here NON-privileged user and revoke any right from him. Also create trivial table TEST.
# Then try to connect with as user and query non-system table TEST and system tables.
# Query to table TEST should be denied, but queries to RDB-tables should run OK and display their data.
2021-12-19 22:25:36 +01:00
#
2021-04-26 20:07:00 +02:00
# tracker_id: CORE-4980
# min_versions: ['3.0']
# versions: 3.0, 4.0
# qmid: None
import pytest
2021-12-19 22:25:36 +01:00
from firebird.qa import db_factory, isql_act, Action, user_factory, User
2021-04-26 20:07:00 +02:00
# version: 3.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
test_script_1 = """
set wng off;
recreate table test(id int);
commit;
insert into test values(1);
commit;
connect '$(DSN)' user tmp_c4980 password '123';
-- All subsequent statements (being issued by TMP_C4980) failed on 3.0.0.32134 and runs OK on build 32136:
set list on;
select current_user as who_am_i from rdb$database;
select current_user as who_am_i, r.rdb$character_set_name from rdb$database r;
select current_user as who_am_i, r.rdb$relation_name from rdb$relations r order by rdb$relation_id rows 1;
select current_user as who_am_i, t.id from test t; -- this should ALWAYS fail because this is non-system table.
commit;
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
WHO_AM_I TMP_C4980
WHO_AM_I TMP_C4980
RDB$CHARACTER_SET_NAME NONE
WHO_AM_I TMP_C4980
RDB$RELATION_NAME RDB$PAGES
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
expected_stderr_1 = """
Statement failed, SQLSTATE = 28000
no permission for SELECT access to TABLE TEST
2021-12-19 22:25:36 +01:00
"""
user_1 = user_factory('db_1', name='tmp_c4980', password='123')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0,<4.0')
2021-12-19 22:25:36 +01:00
def test_1(act_1: Action, user_1: User):
2021-04-26 20:07:00 +02:00
act_1.expected_stdout = expected_stdout_1
act_1.expected_stderr = expected_stderr_1
act_1.execute()
2021-12-22 20:23:11 +01:00
assert act_1.clean_stderr == act_1.clean_expected_stderr
assert act_1.clean_stdout == act_1.clean_expected_stdout
2021-04-26 20:07:00 +02:00
# version: 4.0
# resources: None
substitutions_2 = []
init_script_2 = """"""
db_2 = db_factory(sql_dialect=3, init=init_script_2)
test_script_2 = """
set wng off;
recreate table test(id int);
commit;
insert into test values(1);
commit;
connect '$(DSN)' user tmp_c4980 password '123';
set list on;
select current_user as who_am_i from rdb$database;
select current_user as who_am_i, r.rdb$character_set_name from rdb$database r;
select current_user as who_am_i, r.rdb$relation_name from rdb$relations r order by rdb$relation_id rows 1;
select current_user as who_am_i, t.id from test t; -- this should ALWAYS fail because this is non-system table.
commit;
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
act_2 = isql_act('db_2', test_script_2, substitutions=substitutions_2)
expected_stdout_2 = """
WHO_AM_I TMP_C4980
WHO_AM_I TMP_C4980
RDB$CHARACTER_SET_NAME NONE
WHO_AM_I TMP_C4980
RDB$RELATION_NAME RDB$PAGES
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
expected_stderr_2 = """
Statement failed, SQLSTATE = 28000
no permission for SELECT access to TABLE TEST
-Effective user is TMP_C4980
2021-12-19 22:25:36 +01:00
"""
user_2 = user_factory('db_2', name='tmp_c4980', password='123')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2021-12-19 22:25:36 +01:00
def test_2(act_2: Action, user_2: User):
2021-04-26 20:07:00 +02:00
act_2.expected_stdout = expected_stdout_2
act_2.expected_stderr = expected_stderr_2
act_2.execute()
2021-12-22 20:23:11 +01:00
assert act_2.clean_stderr == act_2.clean_expected_stderr
assert act_2.clean_stdout == act_2.clean_expected_stdout
2021-04-26 20:07:00 +02:00