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

108 lines
3.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_1148
# title: Every user can view server log using services API
2021-11-10 19:02:05 +01:00
# decription:
2021-04-26 20:07:00 +02:00
# Instead of usage 'resource:test_user' (as it was before) we create every time this test run user TMP$C1148
# and make test connect to database as this user in order to check ability to connect and get engine version.
# Then we parse engine version (is it 2.5 or 3.0 ?) and construct command to obtain Firebird log using FBSVCMGR
# (switches differ for 2.5 and 3.0! For 2.5 it must be: "action_get_ib_log", for 3.0: "action_get_fb_log").
# After that we try to extract firebird log using fbsvcmgr and this command is EXPECTED return error, so we log
# this message to separate file (and STDOUT is redirected to /dev/null).
# Finally, we check content of 1st and 2nd files and remove temply created user.
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# tracker_id: CORE-1148
# min_versions: ['2.5.0']
# versions: 2.5
# qmid: bugs.core_1148
import pytest
2021-11-11 18:01:08 +01:00
from firebird.qa import db_factory, python_act, Action, user_factory, User
2021-11-10 19:02:05 +01:00
from firebird.driver import DatabaseError
2021-04-26 20:07:00 +02:00
# version: 2.5
# resources: None
2021-11-10 19:02:05 +01:00
substitutions_1 = [('ENGINE_VERSION .*', 'ENGINE_VERSION'),
('STDERR: UNABLE TO PERFORM OPERATION.*', 'STDERR: UNABLE TO PERFORM OPERATION'),
('STDERR: -YOU MUST HAVE SYSDBA RIGHTS AT THIS SERVER*', '')]
2021-04-26 20:07:00 +02:00
init_script_1 = """"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
2021-11-10 19:02:05 +01:00
#
#
2021-04-26 20:07:00 +02:00
# # Refactored 05-JAN-2016: removed dependency on recource 'test_user' because this lead to:
# # UNTESTED: bugs.core_2729
# # Add new user
# # Unexpected stderr stream received from GSEC.
# # (i.e. test remained in state "Untested" because of internal error in gsec while creating user 'test' from resource).
# # Checked on WI-V2.5.5.26952 (SC), WI-V3.0.0.32266 (SS/SC/CS).
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# import os
# import subprocess
# import time
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# # Obtain engine version:
# engine = str(db_conn.engine_version)
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# db_conn.execute_immediate("create user tmp$c1148 password 'QweRtyUi'")
# db_conn.commit()
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# if engine.startswith('2.5'):
# get_firebird_log_key='action_get_ib_log'
# else:
# get_firebird_log_key='action_get_fb_log'
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# fn_nul = open(os.devnull, 'w')
# fn_err=open( os.path.join(context['temp_directory'],'tmp_1148_get_fb_log.err'), 'w')
# subprocess.call([ context['fbsvcmgr_path'],
# "localhost:service_mgr",
2021-11-10 19:02:05 +01:00
# "user","TMP$C1148","password","QweRtyUi",
2021-04-26 20:07:00 +02:00
# get_firebird_log_key
# ],
# stdout=fn_nul,
# stderr=fn_err
# )
# fn_nul.close()
# fn_err.close()
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# # CLEANUP: drop user that was temp-ly created for this test:
# ##########
# db_conn.execute_immediate('drop user tmp$c1148')
# db_conn.commit()
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# # Ouput error log: it should contain text about unable to perform operation.
# # NB: text in FB 4.0 was splitted, phrase "You must have SYSDBA rights..." is
# # printed on separate line. Checking for matching to this phrase can be skipped
# # (see 'substitutions' section below):
# with open( fn_err.name,'r') as f:
# for line in f:
# print("STDERR: "+line.upper())
2021-11-10 19:02:05 +01:00
#
# # Do not remove this pause: on Windows closing of handles can take some (small) time.
2021-04-26 20:07:00 +02:00
# # Otherwise Windows(32) access error can raise here.
# time.sleep(1)
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# if os.path.isfile(fn_err.name):
# os.remove(fn_err.name)
2021-11-10 19:02:05 +01:00
#
#
2021-04-26 20:07:00 +02:00
#---
2021-11-10 19:02:05 +01:00
act_1 = python_act('db_1', substitutions=substitutions_1)
2021-11-11 18:01:08 +01:00
user_1 = user_factory(name='TMP$C1148', password='QweRtyUi')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=2.5')
2021-11-10 19:02:05 +01:00
def test_1(act_1: Action, user_1: User):
with act_1.connect_server(user=user_1.name, password=user_1.password) as srv:
with pytest.raises(DatabaseError, match='Unable to perform operation\n-You must have SYSDBA rights at this server'):
srv.info.get_log()
2021-04-26 20:07:00 +02:00