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

57 lines
1.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-20 17:32:14 +01:00
"""
ID: issue-2067
ISSUE: 2067
TITLE: Non-privileged monitoring reports wrong attachment data
DESCRIPTION:
When non-SYSDBA user selects from MON$ATTACHMENTS and other attachments are active at this point,
the resulting rowset refers to a wrong attachment (the one with minimal ID) instead of the current attachment.
JIRA: CORE-1642
FBTEST: bugs.core_1642
2022-01-20 17:32:14 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
init_script = """
2021-11-11 18:01:08 +01:00
create or alter view v_my_attach as
2021-04-26 20:07:00 +02:00
select current_user as who_am_i, iif(current_connection - mon$attachment_id = 0, 'OK.', 'BAD') as my_attach_id
from mon$attachments;
commit;
grant select on v_my_attach to public;
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
db = db_factory(init=init_script)
2021-11-11 18:01:08 +01:00
2022-01-20 17:32:14 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
TMP$C1642_ALAN OK.
TMP$C1642_JOHN OK.
TMP$C1642_MICK OK.
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
user_1 = user_factory('db', name='tmp$c1642_alan', password='123')
user_2 = user_factory('db', name='tmp$c1642_john', password = '456')
user_3 = user_factory('db', name='tmp$c1642_mick', password = '789')
2021-11-11 18:01:08 +01:00
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=2.5')
2022-01-20 17:32:14 +01:00
def test_1(act: Action, user_1: User, user_2: User, user_3: User, capsys):
act.expected_stdout = expected_stdout
2021-11-11 18:01:08 +01:00
for user in [user_1, user_2, user_3]:
2022-01-20 17:32:14 +01:00
with act.db.connect(user=user.name, password=user.password) as con:
2021-11-11 18:01:08 +01:00
c = con.cursor()
c.execute('select who_am_i, my_attach_id from v_my_attach')
for row in c:
print(row[0], row[1])
2022-01-20 17:32:14 +01:00
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout
2021-11-11 18:01:08 +01:00
2021-04-26 20:07:00 +02:00