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

99 lines
2.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5219
ISSUE: 5219
TITLE: It is not possible to save the connection information in the ON CONNECT trigger,
if the connection is created by the gbak
2022-01-24 20:27:02 +01:00
DESCRIPTION:
JIRA: CORE-4928
FBTEST: bugs.core_4928
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-11-26 19:20:43 +01:00
from pathlib import Path
2022-01-24 20:27:02 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table att_log (
att_id int,
att_name varchar(255),
att_user varchar(255),
att_addr varchar(255),
att_prot varchar(255),
att_auth varchar(255),
att_proc varchar(255),
2021-04-26 20:07:00 +02:00
att_dts timestamp default 'now'
);
2021-11-26 19:20:43 +01:00
2021-04-26 20:07:00 +02:00
commit;
2021-11-26 19:20:43 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
create or alter trigger trg_connect active on connect as
begin
in autonomous transaction do
insert into att_log(att_id, att_name, att_user, att_addr, att_prot, att_auth, att_proc)
2021-04-26 20:07:00 +02:00
select
mon$attachment_id
,mon$attachment_name
,mon$user
,mon$remote_address
,mon$remote_protocol
,mon$auth_method
,mon$remote_process
2021-04-26 20:07:00 +02:00
from mon$attachments
where
mon$remote_protocol starting with upper('TCP')
and mon$user = upper('SYSDBA')
and lower(mon$remote_process) similar to '%[\\/]gbak(.exe)?'
2021-04-26 20:07:00 +02:00
;
end
^
set term ;^
2021-11-26 19:20:43 +01:00
commit;
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory(init=init_script)
2021-11-26 19:20:43 +01:00
2022-01-24 20:27:02 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
IS_ATT_ID_OK 1
IS_ATT_NAME_OK 1
IS_ATT_ADDR_OK 1
IS_ATT_AUTH_OK 1
IS_ATT_DTS_OK 1
IS_ATT_PROC_OK 1
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
fbk_file = temp_file('tmp_core_4928.fbk')
2021-04-26 20:07:00 +02:00
2021-11-26 19:20:43 +01:00
@pytest.mark.version('>=3.0')
2022-01-24 20:27:02 +01:00
def test_1(act: Action, fbk_file: Path):
act.gbak(switches=['-b', act.db.dsn, str(fbk_file)])
act.reset()
2021-11-26 19:20:43 +01:00
# This was in original test, but it makes no sense as it overwites att_log content
# from backup that does not contain any data on v4.0.0.2496
# It's IMHO not important to test the issue anyway
2022-01-24 20:27:02 +01:00
#act.gbak(switches=['-rep', str(fbk_file), act.db.dsn])
#act.reset()
2021-11-26 19:20:43 +01:00
# Check
2022-01-24 20:27:02 +01:00
act.expected_stdout = expected_stdout
act.script = """
2021-11-26 19:20:43 +01:00
set list on;
select
--/*
iif( att_id > 0, 1, 0) is_att_id_ok
,iif(att_name containing 'test.fdb', 1, 0) is_att_name_ok
,iif( att_addr is not null, 1, 0) is_att_addr_ok
,iif( att_auth is not null, 1, 0) is_att_auth_ok
,iif( att_dts is not null, 1, 0) is_att_dts_ok
,iif( att_proc similar to '%[\\/]gbak(.exe)?', 1, 0) is_att_proc_ok
-- */
-- a.*
from rdb$database
left join att_log a on a.att_id <> current_connection;
2022-01-24 20:27:02 +01:00
"""
act.execute()
assert act.clean_stdout == act.clean_expected_stdout