2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-23 20:41:55 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-4543
|
|
|
|
ISSUE: 4543
|
|
|
|
TITLE: Add database owner to mon$database
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-4218
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_4218
|
2022-01-23 20:41:55 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-11-18 20:15:37 +01:00
|
|
|
from pathlib import Path
|
2022-01-23 20:41:55 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2024-05-09 23:44:18 +02:00
|
|
|
tmp_user: User = user_factory('db', name='TMP_U4218', password='123')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2024-05-09 23:44:18 +02:00
|
|
|
act = python_act('db', substitutions = [('[ \t]+', ' ')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
test_db = temp_file('owner-db.fdb')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-11-18 20:15:37 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
2024-05-09 23:44:18 +02:00
|
|
|
def test_1(act: Action, tmp_user: User, test_db: Path):
|
2022-01-23 20:41:55 +01:00
|
|
|
with act.db.connect() as con:
|
2021-11-18 20:15:37 +01:00
|
|
|
c = con.cursor()
|
|
|
|
c.execute('grant create database to user TMP_U4218')
|
|
|
|
con.commit()
|
2024-05-09 23:44:18 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
test_script = f"""
|
2024-05-09 23:44:18 +02:00
|
|
|
create database 'localhost:{test_db}' user {tmp_user.name} password '{tmp_user.password}';
|
|
|
|
set list on;
|
|
|
|
select current_user as who_am_i, mon$owner as who_is_owner from mon$database;
|
|
|
|
commit;
|
|
|
|
connect 'localhost:{test_db}';
|
|
|
|
select current_user as who_am_i, mon$owner as who_is_owner from mon$database;
|
|
|
|
commit;
|
|
|
|
drop database;
|
|
|
|
quit;
|
2022-01-23 20:41:55 +01:00
|
|
|
"""
|
2024-05-09 23:44:18 +02:00
|
|
|
expected_stdout = f"""
|
|
|
|
WHO_AM_I {tmp_user.name.upper()}
|
|
|
|
WHO_IS_OWNER {tmp_user.name.upper()}
|
|
|
|
WHO_AM_I SYSDBA
|
|
|
|
WHO_IS_OWNER {tmp_user.name.upper()}
|
|
|
|
"""
|
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
act.expected_stdout = expected_stdout
|
2024-05-09 23:44:18 +02:00
|
|
|
act.isql(switches=['-q'], input=test_script, connect_db=False, combine_output = True)
|
2022-01-23 20:41:55 +01:00
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|