6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_4469_test.py

66 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4789
ISSUE: 4789
TITLE: Add field in SEC$USERS reflecting whether a user has RDB$ADMIN role in security database
DESCRIPTION:
JIRA: CORE-4469
FBTEST: bugs.core_4469
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
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
user_boss1 = user_factory('db', name='boss1', do_not_create=True)
user_boss2 = user_factory('db', name='boss2', do_not_create=True)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
2021-10-21 19:29:23 +02:00
2021-04-26 20:07:00 +02:00
create user boss1 password '123' grant admin role;
commit;
2021-10-21 19:29:23 +02:00
select SEC$ADMIN is_admin_boss1 from sec$users where sec$user_name = upper('boss1');
2021-04-26 20:07:00 +02:00
create user boss2 password '456';
commit;
2021-10-21 19:29:23 +02:00
select SEC$ADMIN is_admin_boss2a from sec$users where sec$user_name = upper('boss2');
2021-04-26 20:07:00 +02:00
alter user boss2 grant admin role;
commit;
2021-10-21 19:29:23 +02:00
select SEC$ADMIN is_admin_boss2b from sec$users where sec$user_name = upper('boss2');
2021-04-26 20:07:00 +02:00
alter user boss2 revoke admin role;
commit;
2021-10-21 19:29:23 +02:00
select SEC$ADMIN is_admin_boss2c from sec$users where sec$user_name = upper('boss2');
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script, substitutions=[('Statement failed, SQLSTATE = HY000', ''),
('record not found for user:.*', '')])
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
IS_ADMIN_BOSS1 <true>
IS_ADMIN_BOSS2A <false>
IS_ADMIN_BOSS2B <true>
IS_ADMIN_BOSS2C <false>
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stderr = """
2021-10-21 19:29:23 +02:00
Statement failed, SQLSTATE = HY000
record not found for user: BOSS1
Statement failed, SQLSTATE = HY000
record not found for user: BOSS2
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action, user_boss1: User, user_boss2: User):
act.expected_stdout = expected_stdout
act.expected_stderr = expected_stderr
act.execute()
assert (act.clean_stderr == act.clean_expected_stderr and
act.clean_stdout == act.clean_expected_stdout)
2021-04-26 20:07:00 +02:00