6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_4164_test.py

78 lines
2.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_4164
# title: Owner name is missing for generators/exceptions restored from a backup
# decription:
# tracker_id: CORE-4164
# min_versions: ['3.0']
# versions: 3.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0
# resources: None
substitutions_1 = [('=.*', '')]
init_script_1 = """
-- Scenario for this test:
-- create sequence g;
-- create exception e 'blablabla';
-- commit;
-- grant usage on sequence g to tmp$4164;
-- grant usage on exception e to tmp$4164;
-- grant usage on sequence g to mgr$4164 with grant option;
-- grant usage on exception e to mgr$4164 with grant option;
-- commit;
-- ==> and then do backup.
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
db_1 = db_factory(from_backup='core4164.fbk', init=init_script_1)
test_script_1 = """
set width usr 10;
set width grantor 10;
set width priv 4;
set width with_grant 6;
set width obj_name 10;
set width fld_name 15;
select
p.rdb$user usr
,p.rdb$grantor grantor
,p.rdb$privilege priv
-- ::: NB ::: Field rdb$grant_option will contain NULLs after restoring,
-- but <null> and 0 are considered by engine as the same in RDB$ tables.
-- Decided to apply `coalesce` after consulting with Dmitry, letter 27.03.2015 19:26
,coalesce(p.rdb$grant_option, 0) with_grant
,p.rdb$relation_name obj_name
,p.rdb$user_type usr_type
,p.rdb$object_type obj_type
,p.rdb$field_name fld_name
from rdb$user_privileges p
where upper(trim(p.rdb$relation_name)) in ( upper('g'), upper('e') )
;
2021-12-22 20:23:11 +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 = """
USR GRANTOR PRIV WITH_GRANT OBJ_NAME USR_TYPE OBJ_TYPE FLD_NAME
========== ========== ==== ============ ========== ======== ======== ===============
SYSDBA SYSDBA G 1 G 8 14 <null>
SYSDBA SYSDBA G 1 E 8 7 <null>
TMP$4164 SYSDBA G 0 G 8 14 <null>
TMP$4164 SYSDBA G 0 E 8 7 <null>
MGR$4164 SYSDBA G 1 G 8 14 <null>
MGR$4164 SYSDBA G 1 E 8 7 <null>
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2021-04-28 12:42:11 +02:00
def test_1(act_1: Action):
2021-04-26 20:07:00 +02:00
act_1.expected_stdout = expected_stdout_1
act_1.execute()
2021-12-22 20:23:11 +01:00
assert act_1.clean_stdout == act_1.clean_expected_stdout
2021-04-26 20:07:00 +02:00