2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID : issue - 6346
ISSUE : 6346
TITLE : Connection does not see itself in the MON $ ATTACHMENTS when Domain / Username ( using SSPI ) is 31 bytes long
DESCRIPTION :
Could not reproduce bug on WI - V3 .0 .4 .33054 , discussed this with dimitr and alex .
Problem can appear randomly when some byte in memory contains value not equal to 0x0 .
It was decided to implement test that
* adds user with name of 31 octets ( 15 non - ascii , plus 1 ascii character : " К о ва ле вс кий_О ле г " ) ;
* launches ISQL utility as separate process with trying to connect do test DB using this non - ascii login ;
* count record in mon $ attachments table that belongs to current attachment . Result must be : 1.
: : : NB : : :
As of fdb 2.0 .1 and fbtest 1.0 .7 , there is NO ability to run macros runProgram ( ) with specifying non - ascii user name
in its parameters list : errror ' invalid user/password ' will raise in this case . The same error will be raised if we
try to launch isql directly in subprocess . call ( ) . For this reason it was decided to create temporary BATCH file ( . bat )
that contains necessary command to run isql . exe , i . e . we actually invoke new instance of cmd . exe .
The reason of why ' invalid user/password ' raises ( in other cases ) remains unclear for me .
JIRA : CORE - 6097
2022-02-02 15:46:19 +01:00
FBTEST : bugs . core_6097
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
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 ' )
expected_stdout = """
SEC $ USER_NAME К о ва ле вс кий_О ле г
OCTETS_IN_NAME 31
Records affected : 1
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
WHO_AM_I К о ва ле вс кий_О ле г
MON_PROTOCOL TCP
MON_AUTH_METHOD Srp
Records affected : 1
"""
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
@pytest.mark.skip ( ' FIXME: Not IMPLEMENTED ' )
@pytest.mark.version ( ' >=3.0.5 ' )
@pytest.mark.platform ( ' Windows ' )
def test_1 ( act : Action ) :
pytest . fail ( " Not IMPLEMENTED " )
2021-04-26 20:07:00 +02:00
# test_script_1
#---
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# import os
# import subprocess
# import time
# import fdb
# from fdb import services
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_conn.close()
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# sql_txt='''
# -- fb_home = %s
# set bail on;
# set count on;
# set list on;
# create or alter user "К о ва ле вс кий_О ле г " password '123' using plugin Srp;
# commit;
# set list on;
# select sec$user_name, octet_length(trim(sec$user_name)) as octets_in_name from sec$users where sec$user_name = 'К о ва ле вс кий_О ле г ';
# commit;
# ''' % (fb_home,)
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_init_sql=open( os.path.join(context['temp_directory'],'tmp_6097_prepare.sql'), 'w')
# f_init_sql.write( sql_txt )
# f_init_sql.close()
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_init_log=open( os.path.join(context['temp_directory'],'tmp_6097_prepare.log'), 'w')
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# subprocess.call([ fb_home+"isql", dsn, "-q", "-ch", "utf8", "-i", f_init_sql.name], stdout=f_init_log, stderr=subprocess.STDOUT)
# f_init_log.close()
2021-12-15 22:02:07 +01:00
#
# # does not work, raises 'invalid user/password':
2021-04-26 20:07:00 +02:00
# #runProgram( fb_home+'isql', [dsn, "-q", "-user", "К о ва ле вс кий_О ле г ", "-pas", "123" ], 'set list on; set count on; select * from mon$attachments where mon$attachment_id = current_connection;')
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_check_sql=open( os.path.join(context['temp_directory'],'tmp_6097_check.sql'), 'w')
# #f_check_sql.write( 'set list on; select count(*) as "Can_i_see_myself ?" from mon$attachments where mon$attachment_id = current_connection;' )
# f_check_sql.write( 'set count on; set list on; select mon$user as who_am_i, left(mon$remote_protocol,3) as mon_protocol, mon$auth_method as mon_auth_method from mon$attachments where mon$attachment_id = current_connection;' )
# f_check_sql.close()
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_bat_text='''
# @echo off
# chcp 65001 1>nul
# %s %s -user "К о ва ле вс кий_О ле г " -pas 123 -ch utf8 -q -i %s
# ''' % ( fb_home+'isql.exe', dsn, f_check_sql.name )
# #''' % ( fb_home+'isql.exe', 'localhost:employee', f_check_sql.name )
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_check_bat=open( os.path.join(context['temp_directory'],'tmp_6097_check.bat'), 'w')
# f_check_bat.write( f_bat_text )
# f_check_bat.close()
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_check_log=open( os.path.join(context['temp_directory'],'tmp_6097_check.log'), 'w')
# # does not work, raises 'invalid user/password': subprocess.call(["isql", dsn, "-q", "-user", "К о ва ле вс кий_О ле г ", "-pas", "123", "-ch", "utf8", "-i", f_check_sql.name], stdout=f_run_log, stderr=subprocess.STDOUT)
# subprocess.call([f_check_bat.name], stdout=f_check_log, stderr=subprocess.STDOUT)
# f_check_log.close()
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# # Let redirected output of isql be flushed on disk:
# time.sleep(1)
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_init_log.name,'r') as f:
# for line in f:
# print(line)
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_check_log.name,'r') as f:
# for line in f:
# print(line)
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# # Cleanup.
# ##########
2021-12-15 22:02:07 +01:00
#
2021-04-26 20:07:00 +02:00
# f_list = (f_init_sql, f_init_log, f_check_sql, f_check_bat, f_check_log)
# for i in range(len(f_list)):
# if os.path.isfile(f_list[i].name):
# os.remove(f_list[i].name)
2021-12-15 22:02:07 +01:00
#
#
2021-04-26 20:07:00 +02:00
#---