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

69 lines
2.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID: issue-6053
ISSUE: 6053
TITLE: User with DROP DATABASE privilege can't drop database
DESCRIPTION:
JIRA: CORE-5790
"""
2021-04-26 20:07:00 +02:00
import pytest
from pathlib import Path
2022-01-26 21:10:46 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RDB$USER TMP$C5790
RDB$GRANTOR SYSDBA
RDB$PRIVILEGE O
RDB$GRANT_OPTION 0
RDB$RELATION_NAME SQL$DATABASE
RDB$FIELD_NAME <null>
RDB$USER_TYPE 8
2021-12-31 12:06:51 +01:00
rdb_object_type_is_expected ? YES
2021-04-26 20:07:00 +02:00
Records affected: 1
Records affected: 0
"""
2022-01-26 21:10:46 +01:00
test_user = user_factory('db', name='tmp$c5790', password='123')
fdb_file = temp_file('tmp_5790.fdb')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.4')
2022-01-26 21:10:46 +01:00
def test_1(act: Action, test_user: User, fdb_file: Path):
act.expected_stdout = expected_stdout
test_script = f"""
create database 'localhost:{fdb_file}';
alter database set linger to 0;
commit;
grant drop database to {test_user.name};
commit;
connect 'localhost:{fdb_file}' user {test_user.name} password '{test_user.password}';
set list on;
set count on;
select
r.rdb$user -- {test_user.name}
,r.rdb$grantor -- sysdba
,r.rdb$privilege -- o
,r.rdb$grant_option -- 0
,r.rdb$relation_name -- sql$database
,r.rdb$field_name -- <null>
,r.rdb$user_type -- 8
2021-12-31 12:06:51 +01:00
,iif( r.rdb$object_type = decode( left(rdb$get_context('SYSTEM', 'ENGINE_VERSION'),1), '3',20, '4',21, '5', 21), 'YES', 'NO: ' || r.rdb$object_type) "rdb_object_type_is_expected ?"
from rdb$user_privileges r
where r.rdb$user=upper('{test_user.name}');
2021-04-26 20:07:00 +02:00
-- this should NOT show any attachments: "Records affected: 0" must be shown here.
select * from mon$attachments where mon$attachment_id != current_connection;
commit;
2021-04-26 20:07:00 +02:00
drop database;
rollback;
2022-01-26 21:10:46 +01:00
"""
act.isql(switches=['-q'], input=test_script)
assert act.clean_stdout == act.clean_expected_stdout
assert not fdb_file.exists()