mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\core_1292_test.py: Reimplemented because of fail if we change OptimizeForFirstRows = true config parameter. See notes.
This commit is contained in:
parent
a53cc7ffad
commit
01a2478ad2
@ -7,56 +7,51 @@ TITLE: Can't create table using long username and UTF8 as attachment chars
|
||||
DESCRIPTION:
|
||||
JIRA: CORE-1292
|
||||
FBTEST: bugs.core_1292
|
||||
NOTES:
|
||||
[23.08.2024] pzotov
|
||||
1. Removed LIST() from initial query because it displays tokens in unpredictable order.
|
||||
This can cause fail if we change OptimizeForFirstRows = true config parameter.
|
||||
2. Found oddities when try to use non-ascii user name and substitute it using f-notation:
|
||||
at least REVOKE and GRANT commands reflect this user name in the trace as encoded
|
||||
in cp1251 instead of utf8. This causes:
|
||||
335544321 : arithmetic exception, numeric overflow, or string truncation
|
||||
335544565 : Cannot transliterate character between character sets
|
||||
To be investigated further.
|
||||
"""
|
||||
|
||||
import locale
|
||||
import pytest
|
||||
from firebird.qa import *
|
||||
|
||||
db = db_factory(charset='UTF8')
|
||||
db = db_factory(charset = 'utf8')
|
||||
|
||||
test_script = """
|
||||
set wng off;
|
||||
act = python_act('db', substitutions = [ ('[ \t]+', ' '), ])
|
||||
tmp_user = user_factory('db', name='Nebuchadnezzar_The_Babylon_Lord', password='123', plugin = 'Srp')
|
||||
#tmp_user = user_factory('db', name='"НавохудоносорВластелинВавилона2"', password='123', plugin = 'Srp')
|
||||
|
||||
-- Drop old account if it remains from prevoius run:
|
||||
set term ^;
|
||||
execute block as
|
||||
begin
|
||||
begin
|
||||
execute statement 'drop user Nebuchadnezzar2_King_of_Babylon' with autonomous transaction;
|
||||
when any do begin end
|
||||
end
|
||||
end^
|
||||
set term ;^
|
||||
commit;
|
||||
@pytest.mark.version('>=3')
|
||||
def test_1(act: Action, tmp_user: User, capsys):
|
||||
|
||||
test_sql = f"""
|
||||
set bail on;
|
||||
set list on;
|
||||
set wng off;
|
||||
connect '{act.db.dsn}' user {act.db.user} password '{act.db.password}';
|
||||
revoke all on all from {tmp_user.name};
|
||||
grant create table to {tmp_user.name};
|
||||
commit;
|
||||
|
||||
create user Nebuchadnezzar2_King_of_Babylon password 'guinness'; -- revoke admin role;
|
||||
-- 1234567890123456789012345678901
|
||||
-- 1 2 3
|
||||
commit;
|
||||
revoke all on all from Nebuchadnezzar2_King_of_Babylon;
|
||||
set term ^;
|
||||
execute block as
|
||||
begin
|
||||
if ( rdb$get_context('SYSTEM', 'ENGINE_VERSION') not starting with '2.5' ) then
|
||||
begin
|
||||
execute statement 'grant create table to Nebuchadnezzar2_King_of_Babylon';
|
||||
end
|
||||
end
|
||||
^
|
||||
set term ;^
|
||||
commit;
|
||||
connect '{act.db.dsn}' user {tmp_user.name} password '{tmp_user.password}';
|
||||
|
||||
connect '$(DSN)' user 'Nebuchadnezzar2_King_of_Babylon' password 'guinness';
|
||||
select a.mon$user as who_am_i, c.rdb$character_set_name as my_connection_charset
|
||||
from mon$attachments a
|
||||
join rdb$character_sets c on a.mon$character_set_id = c.rdb$character_set_id
|
||||
where a.mon$attachment_id = current_connection;
|
||||
|
||||
create table test(n int);
|
||||
commit;
|
||||
create table test(n int);
|
||||
commit;
|
||||
|
||||
connect '$(DSN)' user 'SYSDBA' password 'masterkey';
|
||||
connect '{act.db.dsn}' user {act.db.user} password '{act.db.password}';
|
||||
|
||||
set list on;
|
||||
select usr_name, grantor, can_grant, tab_name,usr_type,obj_type, list(priv) priv_list
|
||||
from (
|
||||
select
|
||||
p.rdb$user usr_name
|
||||
,p.rdb$grantor grantor
|
||||
@ -66,31 +61,58 @@ test_script = """
|
||||
,p.rdb$object_type obj_type
|
||||
,trim(p.rdb$privilege) priv
|
||||
from rdb$user_privileges p
|
||||
where upper(trim(p.rdb$relation_name)) = upper('test')
|
||||
order by priv
|
||||
)
|
||||
group by usr_name, grantor, can_grant, tab_name,usr_type,obj_type;
|
||||
commit;
|
||||
where
|
||||
upper(trim(p.rdb$relation_name)) = upper('test')
|
||||
and p.rdb$user = _utf8 '{tmp_user.name}' collate unicode_ci
|
||||
order by priv;
|
||||
commit;
|
||||
"""
|
||||
|
||||
drop user Nebuchadnezzar2_King_of_Babylon;
|
||||
commit;
|
||||
"""
|
||||
expected_stdout = f"""
|
||||
WHO_AM_I {tmp_user.name.upper()}
|
||||
MY_CONNECTION_CHARSET UTF8
|
||||
|
||||
act = isql_act('db', test_script, substitutions=[('PRIV_LIST.*', '')])
|
||||
USR_NAME {tmp_user.name.upper()}
|
||||
GRANTOR {tmp_user.name.upper()}
|
||||
CAN_GRANT 1
|
||||
TAB_NAME TEST
|
||||
USR_TYPE 8
|
||||
OBJ_TYPE 0
|
||||
PRIV D
|
||||
|
||||
expected_stdout = """
|
||||
USR_NAME NEBUCHADNEZZAR2_KING_OF_BABYLON
|
||||
GRANTOR NEBUCHADNEZZAR2_KING_OF_BABYLON
|
||||
CAN_GRANT 1
|
||||
TAB_NAME TEST
|
||||
USR_TYPE 8
|
||||
OBJ_TYPE 0
|
||||
D,I,R,S,U
|
||||
"""
|
||||
USR_NAME {tmp_user.name.upper()}
|
||||
GRANTOR {tmp_user.name.upper()}
|
||||
CAN_GRANT 1
|
||||
TAB_NAME TEST
|
||||
USR_TYPE 8
|
||||
OBJ_TYPE 0
|
||||
PRIV I
|
||||
|
||||
USR_NAME {tmp_user.name.upper()}
|
||||
GRANTOR {tmp_user.name.upper()}
|
||||
CAN_GRANT 1
|
||||
TAB_NAME TEST
|
||||
USR_TYPE 8
|
||||
OBJ_TYPE 0
|
||||
PRIV R
|
||||
|
||||
USR_NAME {tmp_user.name.upper()}
|
||||
GRANTOR {tmp_user.name.upper()}
|
||||
CAN_GRANT 1
|
||||
TAB_NAME TEST
|
||||
USR_TYPE 8
|
||||
OBJ_TYPE 0
|
||||
PRIV S
|
||||
|
||||
USR_NAME {tmp_user.name.upper()}
|
||||
GRANTOR {tmp_user.name.upper()}
|
||||
CAN_GRANT 1
|
||||
TAB_NAME TEST
|
||||
USR_TYPE 8
|
||||
OBJ_TYPE 0
|
||||
PRIV U
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=3')
|
||||
def test_1(act: Action):
|
||||
act.expected_stdout = expected_stdout
|
||||
act.execute()
|
||||
act.isql(switches = ['-q'], input = test_sql, charset = 'utf8', connect_db=False, credentials = False, combine_output = True, io_enc = locale.getpreferredencoding())
|
||||
assert act.clean_stdout == act.clean_expected_stdout
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user