6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/bugs/core_4503_test.py

129 lines
4.8 KiB
Python

#coding:utf-8
#
# id: bugs.core_4503
# title: ISQL command SHOW USERS display only me
# decription:
# 29.07.2016: instead of issuing SHOW USERS which has unstable output (can be changed multiple times!)
# it was decided to replace it with SQL query which actually is done by this command.
# This query can be easily found in trace when we run SHOW USERS.
# Also, we limit output with only those users who is enumerated here thus one may do not warry about
# another user logins which could left in securitiN.fdb after some test failed.
#
# 29.03.2018: changed user names, replaced count of SYSDBA attachments with literal 1.
# Checked on:
# fb30Cs, build 3.0.4.32924: OK, 3.781s.
# FB30SS, build 3.0.4.32939: OK, 1.312s.
# FB40CS, build 4.0.0.918: OK, 4.547s.
# FB40SS, build 4.0.0.943: OK, 2.094s.
#
# tracker_id: CORE-4503
# min_versions: ['3.0']
# versions: 3.0
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0
# resources: None
substitutions_1 = []
init_script_1 = """
create or alter user TMP$C4503_BILL password '123';
create or alter user TMP$C4503_JOHN password '456';
create or alter user TMP$C4503_MICK password '789';
create or alter user TMP$C4503_BOSS password '000';
-- do NOT remove or change name 'test' - it is used in several old tests, see resources/test_user.fbr:
-- core_1083.fbt core_1845.fbt core_1148.fbt core_2729.fbt -- all of them can create user 'TEST' and do not remove it.
create or alter user test password 'test';
drop user test; -- immediatelly remove this name
commit;
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
# import os
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
# db_conn.close()
#
# con_0a = kdb.connect(dsn=dsn.encode())
# con_0b = kdb.connect(dsn=dsn.encode())
#
# con_1a = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_BILL',password='123')
# con_1b = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_BILL',password='123')
# con_1c = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_BILL',password='123')
# con_1d = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_BILL',password='123')
# con_1e = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_BILL',password='123')
#
# con_2a = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_JOHN',password='456')
# con_2b = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_JOHN',password='456')
# con_2c = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_JOHN',password='456')
# con_2d = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_JOHN',password='456')
#
# con_3a = kdb.connect(dsn=dsn.encode(),user='TMP$C4503_MICK',password='789')
# script = '''
# set list on;
# -- "SHOW USERS" command actually runs following query:
# select
# case
# when coalesce(mon$user, sec$user_name) = current_user
# then '#'
# when sec$user_name is distinct from null
# then ' '
# else '-'
# end is_current_user
# ,coalesce(m.mon$user, u.sec$user_name) user_name
# ,iif( m.mon$user = upper('SYSDBA'), 1, count(m.mon$user) ) keeps_attachments
# from mon$attachments m
# full join sec$users u on m.mon$user = u.sec$user_name
# where
# coalesce(mon$system_flag, 0) = 0
# and coalesce(m.mon$user, u.sec$user_name) in ( upper('TMP$C4503_BILL'), upper('TMP$C4503_BOSS'), upper('TMP$C4503_JOHN'), upper('TMP$C4503_MICK'), upper('SYSDBA') )
# group by mon$user, sec$user_name
# order by coalesce(mon$user, sec$user_name);
# commit;
#
# drop user TMP$C4503_BILL;
# drop user TMP$C4503_JOHN;
# drop user TMP$C4503_MICK;
# drop user TMP$C4503_BOSS;
# '''
# runProgram('isql',[dsn,'-q'],script)
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
IS_CURRENT_USER #
USER_NAME SYSDBA
KEEPS_ATTACHMENTS 1
IS_CURRENT_USER
USER_NAME TMP$C4503_BILL
KEEPS_ATTACHMENTS 5
IS_CURRENT_USER
USER_NAME TMP$C4503_BOSS
KEEPS_ATTACHMENTS 0
IS_CURRENT_USER
USER_NAME TMP$C4503_JOHN
KEEPS_ATTACHMENTS 4
IS_CURRENT_USER
USER_NAME TMP$C4503_MICK
KEEPS_ATTACHMENTS 1
"""
@pytest.mark.version('>=3.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")