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

144 lines
4.3 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5859
ISSUE: 5859
TITLE: System function RDB$ROLE_IN_USE cannot take long role names
DESCRIPTION:
Test creates several roles and grants them to user.
Role #1 is common ascii string without spaces.
Role #2 is ascii string with spaces, all character are written in UPPERCASE.
Role #3 is ascii string with spaces, all character are written in lowercase.
After make connection to database using role #3 we have to check that this role
indeed was applied to connection and that rdb$role_in_use *does* return this role name also.
See also: github.com/FirebirdSQL/firebird/commit/61b4bf0d276884a0ba0f2edef3b41fa2c58c87ee
Comments there:
- roleStr.upper();
+ //roleStr.upper(); // sorry - but this breaks role names containing lower case letters
::: NB CAUTION ::: TEMPLY DEFERRED :::
We also have to check cases when role contains NON-ASCII characters but currently this is impossible.
Exception like:
===
Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 63, actual 79
===
- is raised when non-ascii role contains only ~40 *characters* and connection charset = UTF8.
Sent letter to Alex, 23.06.2018 09:21, waiting for reply.
JIRA: CORE-5593
FBTEST: bugs.core_5593
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set names utf8;
set wng off;
set list on;
set bail on;
create or alter user tmp$c5593 password '123' revoke admin role;
commit;
--revoke all on all from tmp$c5593; --> led to crash on 4.0.0.1036
--commit;
create or alter view v_role_info as
2022-01-25 22:55:48 +01:00
select
2021-04-26 20:07:00 +02:00
current_user as who_am_i,
current_role as my_current_role,
2022-01-25 22:55:48 +01:00
rdb$role_name as r_name,
rdb$owner_name r_owner,
2021-04-26 20:07:00 +02:00
rdb$role_in_use(rdb$role_name) r_in_use
from rdb$roles
where coalesce(rdb$system_flag,0) = 0
;
commit;
create role chief;
create role "CHIEF OF TRANSPORT AND LOGISTICS DEPARTMENT";
create role "chief of financial and accounting department";
commit;
grant chief to user tmp$c5593;
grant "CHIEF OF TRANSPORT AND LOGISTICS DEPARTMENT" to user tmp$c5593;
grant "chief of financial and accounting department" to user tmp$c5593;
commit;
--show grants;
grant select on v_role_info to user tmp$c5593;
commit;
2022-01-25 22:55:48 +01:00
--set echo on;
2021-04-26 20:07:00 +02:00
connect '$(DSN)'
2022-01-25 22:55:48 +01:00
user tmp$c5593
2021-04-26 20:07:00 +02:00
password '123'
role chief
;
select * from v_role_info where my_current_role = r_name;
commit;
connect '$(DSN)'
2022-01-25 22:55:48 +01:00
user tmp$c5593
2021-04-26 20:07:00 +02:00
password '123'
role "CHIEF OF TRANSPORT AND LOGISTICS DEPARTMENT"
;
select * from v_role_info where my_current_role = r_name;
commit;
2022-01-25 22:55:48 +01:00
2021-04-26 20:07:00 +02:00
connect '$(DSN)'
2022-01-25 22:55:48 +01:00
user tmp$c5593
2021-04-26 20:07:00 +02:00
password '123'
role "chief of financial and accounting department"
;
-- ###########################################
2022-01-25 22:55:48 +01:00
-- Before fix this statement returned FALSE as
2021-04-26 20:07:00 +02:00
-- result of rdb$role_in_use(rdb$role_name)
-- ###########################################
select * from v_role_info where my_current_role = r_name;
commit;
-- cleanup
connect '$(DSN)' user sysdba password 'masterkey';
drop user tmp$c5593;
commit;
2022-01-25 22:55:48 +01:00
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
WHO_AM_I TMP$C5593
MY_CURRENT_ROLE CHIEF
R_NAME CHIEF
R_OWNER SYSDBA
R_IN_USE <true>
WHO_AM_I TMP$C5593
MY_CURRENT_ROLE CHIEF OF TRANSPORT AND LOGISTICS DEPARTMENT
R_NAME CHIEF OF TRANSPORT AND LOGISTICS DEPARTMENT
R_OWNER SYSDBA
R_IN_USE <true>
WHO_AM_I TMP$C5593
MY_CURRENT_ROLE chief of financial and accounting department
R_NAME chief of financial and accounting department
R_OWNER SYSDBA
R_IN_USE <true>
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-25 22:55:48 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00