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

81 lines
2.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-27 20:08:36 +01:00
"""
ID: issue-6507
ISSUE: 6507
TITLE: mapping rules destroyed by backup / restore
DESCRIPTION:
JIRA: CORE-6265
FBTEST: bugs.core_6265
2022-01-27 20:08:36 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-14 20:56:34 +01:00
from io import BytesIO
from pathlib import Path
2022-01-27 20:08:36 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
boss_role = role_factory('db', name='boss')
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RDB$MAP_NAME MAP_BOSS
RDB$MAP_USING P
RDB$MAP_PLUGIN WIN_SSPI
RDB$MAP_DB <null>
RDB$MAP_FROM_TYPE USER
RDB$MAP_FROM BILL
RDB$MAP_TO_TYPE 1
RDB$MAP_TO BOSS
Records affected: 1
2021-12-14 20:56:34 +01:00
"""
2021-04-26 20:07:00 +02:00
2021-12-14 20:56:34 +01:00
init_ddl = """
--create role boss;
create mapping map_boss using plugin win_sspi from user Bill to role boss;
commit;
create view v_map as
select
rdb$map_name,
rdb$map_using,
rdb$map_plugin,
rdb$map_db,
rdb$map_from_type,
rdb$map_from,
rdb$map_to_type,
rdb$map_to
from rdb$auth_mapping;
commit;
set list on;
set count on;
select * from v_map;
"""
restored_db_1 = temp_file('tmp_6265_1.fdb')
restored_db_2 = temp_file('tmp_6265_2.fdb')
2021-04-26 20:07:00 +02:00
2021-12-14 20:56:34 +01:00
@pytest.mark.version('>=3.0.6')
2022-01-27 20:08:36 +01:00
def test_1(act: Action, boss_role: Role, restored_db_1: Path, restored_db_2: Path):
act.isql(switches=['-q'], input=init_ddl)
2021-12-14 20:56:34 +01:00
#
backup = BytesIO()
2022-01-27 20:08:36 +01:00
with act.connect_server() as srv:
2021-12-14 20:56:34 +01:00
# BACKUP-RESTORE #1:
2022-01-27 20:08:36 +01:00
srv.database.local_backup(database=act.db.db_path, backup_stream=backup)
2021-12-14 20:56:34 +01:00
backup.seek(0)
srv.database.local_restore(database=restored_db_1, backup_stream=backup)
# BACKUP-RESTORE #2:
backup.seek(0)
backup.truncate()
srv.database.local_backup(database=restored_db_1, backup_stream=backup)
backup.seek(0)
srv.database.local_restore(database=restored_db_2, backup_stream=backup)
# Check
2022-01-27 20:08:36 +01:00
act.reset()
act.expected_stdout = expected_stdout
act.isql(switches=[act.get_dsn(restored_db_2)], connect_db=False,
input='set list on; set count on; select * from v_map;')
assert act.clean_stdout == act.clean_expected_stdout