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
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
test_user: User = user_factory('db', name='TMP_U4218', password='123')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
act = python_act('db', substitutions=[('Commit current transaction \\(y/n\\)\\?', '')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
WHO_AM_I TMP_U4218
|
|
|
|
WHO_IS_OWNER TMP_U4218
|
|
|
|
WHO_AM_I SYSDBA
|
|
|
|
WHO_IS_OWNER TMP_U4218
|
2021-11-18 20:15:37 +01:00
|
|
|
"""
|
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')
|
2022-01-23 20:41:55 +01:00
|
|
|
def test_1(act: Action, test_user: User, test_db: Path):
|
|
|
|
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()
|
2022-01-23 20:41:55 +01:00
|
|
|
test_script = f"""
|
|
|
|
create database 'localhost:{test_db}' user 'TMP_U4218' password '123';
|
2021-11-18 20:15:37 +01:00
|
|
|
set list on;
|
2022-01-16 10:03:34 +01:00
|
|
|
set list on; -- Needed on Windows to really set list ON.
|
2021-11-18 20:15:37 +01:00
|
|
|
select current_user as who_am_i, mon$owner as who_is_owner from mon$database;
|
|
|
|
commit;
|
2022-01-23 20:41:55 +01:00
|
|
|
connect 'localhost:{test_db}';
|
2021-11-18 20:15:37 +01:00
|
|
|
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
|
|
|
"""
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.isql(switches=['-q'], input=test_script)
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|