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

223 lines
7.4 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5286
ISSUE: 5286
TITLE: Both client and server could not close connection after failed authentification
DESCRIPTION:
Reproduced on 3.0.0.32136 RC1 with firebird.conf:
AuthServer = Legacy_Auth,Srp
AuthClient = Srp,Legacy_Auth
::: NB-1 :::
In order to get this environment for client test temp-ly CHANGES firebird.conf
Test will restore original firebird.conf in the end.
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
::: NB-2 :::
We have to prepare auxiliary Python script to be executed in SEPARATE (NEW!) execution context,
otherwise firebird.log is filled with messages "errno = 10054" only after this test completely finished.
See variable 'f_python_separate_exec_context' - it points to this temp .py file.
This aux Python script is called like this:
os.system( f_python_separate_exec_context )
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
It contains three attempts to make connection with invalid passwords.
Exceptions ('Your user/password not defined...') are suppressed, we need only make these attempts to check
that no new records withh be added to firebird.log (as it is confirmed to be in 3.0.0.32136 RC1).
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
File firebird.log is compared BEFORE and AFTER os.system( f_python_separate_exec_context ).
No new messages related to 10054 error should occur during this test in firebird.log.
JIRA: CORE-4998
FBTEST: bugs.core_4998
2022-01-24 20:27:02 +01:00
"""
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
act = python_act('db')
@pytest.mark.skip('FIXME: firebird.conf')
@pytest.mark.version('>=3.0')
def test_1(act: Action):
2022-01-25 22:55:48 +01:00
pytest.fail("Not IMPLEMENTED")
2021-04-26 20:07:00 +02:00
# test_script_1
#---
# import os
# import sys
# import subprocess
# import difflib
# import datetime
# import time
# import re
# import shutil
# from fdb import services
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# THIS_DSN = dsn
# DBAUSR = user_name
# db_conn.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# svc = services.connect(host='localhost')
# fb_home=svc.get_home_directory()
# svc.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# def flush_and_close(file_handle):
# # https://docs.python.org/2/library/os.html#os.fsync
2021-11-26 19:20:43 +01:00
# # If you're starting with a Python file object f,
# # first do f.flush(), and
2021-04-26 20:07:00 +02:00
# # then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk.
# global os
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# file_handle.flush()
# if file_handle.mode not in ('r', 'rb'):
# # otherwise: "OSError: [Errno 9] Bad file descriptor"!
# os.fsync(file_handle.fileno())
# file_handle.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
# if type(f_names_list[i]) == file:
# del_name = f_names_list[i].name
# elif type(f_names_list[i]) == str:
# del_name = f_names_list[i]
# else:
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# del_name = None
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# def svc_get_fb_log( f_fb_log ):
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# global subprocess
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# subprocess.call( [ context['fbsvcmgr_path'],
# "localhost:service_mgr",
# "action_get_fb_log"
# ],
# stdout=f_fb_log, stderr=subprocess.STDOUT
# )
# return
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# ###########################################################################################
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# fbconf = os.path.join( fb_home, 'firebird.conf')
# fbcbak = os.path.join( fb_home, 'firebird_'+dts+'.bak')
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# shutil.copy2( fbconf, fbcbak )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f_fbconf = open(fbconf,'r')
# fbconf_content=f_fbconf.readlines()
# f_fbconf.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# for i,s in enumerate( fbconf_content ):
# if s.lower().lstrip().startswith( 'wirecrypt'.lower() ):
# fbconf_content[i] = '# <temply commented> ' + s
# if s.lower().lstrip().startswith( 'AuthClient'.lower() ):
# fbconf_content[i] = '# <temply commented> ' + s
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# fbconf_content.append('\\n# Temporarily added by fbtest, CORE-4998. Should be removed auto:')
# fbconf_content.append("\\n#" + '='*30 )
# fbconf_content.append('\\nAuthClient = Srp,Legacy_Auth')
# fbconf_content.append("\\n#" + '='*30 )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f_fbconf=open(fbconf,'w')
# f_fbconf.writelines( fbconf_content )
# flush_and_close( f_fbconf )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# ###########################################################################################
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f_fblog_before=open( os.path.join(context['temp_directory'],'tmp_4998_fblog_before.txt'), 'w')
# svc_get_fb_log( f_fblog_before )
# flush_and_close( f_fblog_before )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# other_exec_context_python_text = '''import fdb
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# for i in range(0,3):
# con1 = None
# try:
# con1 = fdb.connect( dsn = '%(THIS_DSN)s', user = '%(DBAUSR)s', password = 'inv@l1d' + str(i) )
# except Exception, e:
# pass
# finally:
# if con1:
# con1.close()
# exit(0)
# ''' % locals()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f_python_separate_exec_context = os.path.join(context['temp_directory'], 'tmp_core_4998_try_connect_with_invalid_passwords.py')
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f = open( f_python_separate_exec_context, 'w')
# f.write( other_exec_context_python_text )
# flush_and_close( f )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# ########################################################################################################
# ### l a u n c h P y t h o n i n a n o t h e r e x e c u t i o n c o n t e x t ###
# ########################################################################################################
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# # 17.06.2018. We have to add full path and name of interpretep (e.g. 'C:\\Python27\\python.exe')
# # because it can appear that OS will not be able to recognize how to handle .py files!
2021-11-26 19:20:43 +01:00
# # sys.executable - returns full path to Python exe,
#
2021-04-26 20:07:00 +02:00
# os.system( sys.executable + ' ' + f_python_separate_exec_context )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# time.sleep(1)
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f_fblog_after=open( os.path.join(context['temp_directory'],'tmp_4998_fblog_after.txt'), 'w')
# svc_get_fb_log( f_fblog_after )
# flush_and_close( f_fblog_after )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# # RESTORE original config:
# ##########################
# shutil.move( fbcbak, fbconf)
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# # Compare firebird.log versions BEFORE and AFTER this test:
# ######################
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# oldfb=open(f_fblog_before.name, 'r')
# newfb=open(f_fblog_after.name, 'r')
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# difftext = ''.join(difflib.unified_diff(
2021-11-26 19:20:43 +01:00
# oldfb.readlines(),
2021-04-26 20:07:00 +02:00
# newfb.readlines()
# ))
# oldfb.close()
# newfb.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# f_diff_txt=open( os.path.join(context['temp_directory'],'tmp_4998_diff.txt'), 'w')
# f_diff_txt.write(difftext)
# flush_and_close( f_diff_txt )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# # INET/inet_error: read errno = 10054
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# allowed_patterns = (
# re.compile('\\.*inet_error\\:{0,1}\\s{0,}read\\s+errno\\s{0,}\\={0,}\\s{0,}10054\\.*', re.IGNORECASE),
# )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_diff_txt.name,'r') as f:
# for line in f:
# if line.startswith('+'):
# match2some = filter( None, [ p.search(line) for p in allowed_patterns ] )
# if match2some:
# print( 'UNEXPECTED TEXT IN FIREBIRD.LOG: ' + (' '.join(line.split()).upper()) )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# #####################################################################
# # Cleanup:
# time.sleep(1)
# cleanup( (f_diff_txt,f_fblog_before,f_fblog_after, f_python_separate_exec_context) )
2021-11-26 19:20:43 +01:00
#
#
2021-04-26 20:07:00 +02:00
#---