6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_1076_test.py

201 lines
6.4 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_1076
# title: gsec truncate First.Middle.Last Name fields to 17 chars instead of 32 chars available in field definition
2021-11-10 19:02:05 +01:00
# decription:
2021-04-26 20:07:00 +02:00
# FB2.0 correctly saves First, Middle & Last Name fields in the security database to the available length of 32 characters.
# FB1.5.3 and still now FB1.5.4RC1 truncates these field lengths to 17 chars.
# ---
# 11.01.2016: refactored for 3.0: use FBSVCMGR instead of GSEC. This was agreed with Alex, see his reply 11.01.2015 17:57.
2021-11-10 19:02:05 +01:00
#
#
2021-04-26 20:07:00 +02:00
# tracker_id: CORE-1076
# min_versions: []
# versions: 3.0
2021-11-10 19:02:05 +01:00
# qmid:
2021-04-26 20:07:00 +02:00
import pytest
2021-11-10 19:02:05 +01:00
from firebird.qa import db_factory, python_act, Action
2021-04-26 20:07:00 +02:00
# version: 3.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
# import os
# import time
# import subprocess
# from subprocess import Popen
# from fdb import services
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
2021-11-10 19:02:05 +01:00
#
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
2021-11-10 19:02:05 +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-10 19:02:05 +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-10 19:02:05 +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-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
2021-11-10 19:02:05 +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 os.path.isfile( f_names_list[i]):
# os.remove( f_names_list[i] )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# db_name=db_conn.database_name
# db_conn.close()
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# svc = services.connect(host='localhost')
# security_db_name = svc.get_security_database_path() # path+name of security DB
# svc.close()
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# check_login="Nebuchadnezzar2_King_of_Babylon"
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# f_svc_log=open( os.path.join(context['temp_directory'],'tmp_1076_fbsvc.log'), 'w')
# f_svc_err=open( os.path.join(context['temp_directory'],'tmp_1076_fbsvc.err'), 'w')
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# f_svc_log.write("Try to add user.")
# f_svc_log.write("\\n")
# f_svc_log.seek(0,2)
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# subprocess.call( [ context['fbsvcmgr_path']
# ,"localhost:service_mgr"
# ,"action_add_user"
# ,"dbname", security_db_name
# ,"sec_username", check_login
# ,"sec_password", "Nebu_King_of_Babylon"
# ]
# ,stdout=f_svc_log, stderr=f_svc_err
# )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# f_svc_log.seek(0,2)
# f_svc_log.write("\\n")
# f_svc_log.write("Try to modify user: change password and some attributes.")
# f_svc_log.write("\\n")
# f_svc_log.seek(0,2)
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# subprocess.call( [ context['fbsvcmgr_path']
# ,"localhost:service_mgr"
# ,"action_modify_user"
# ,"dbname", security_db_name
# ,"sec_username", check_login
# ,"sec_firstname", "Nebuchadnezzar3_King_of_Babylon"
# ,"sec_middlename", "Nebuchadnezzar4_King_of_Babylon"
# ,"sec_lastname", "Nebuchadnezzar5_King_of_Babylon"
# ]
# ,stdout=f_svc_log, stderr=f_svc_err
# )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# f_svc_log.seek(0,2)
# f_svc_log.write("\\n")
# f_svc_log.write("All done.")
# f_svc_log.write("\\n")
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# flush_and_close( f_svc_log )
# flush_and_close( f_svc_err )
2021-11-10 19:02:05 +01:00
#
# isql_txt=''' set list on;
# select sec$user_name, sec$first_name, sec$middle_name, sec$last_name from sec$users
2021-04-26 20:07:00 +02:00
# where upper(sec$user_name) = upper('%s');
# commit;
# drop user %s;
# ''' % (check_login, check_login)
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# f_sql_txt=open( os.path.join(context['temp_directory'],'tmp_1076_isql.sql'), 'w')
# f_sql_txt.write(isql_txt)
# flush_and_close( f_sql_txt )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_1076_isql.log'), 'w')
# f_sql_err=open( os.path.join(context['temp_directory'],'tmp_1076_isql.err'), 'w')
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# subprocess.call( [ context['isql_path'], dsn, "-i", f_sql_txt.name ]
# ,stdout=f_sql_log
# ,stderr=f_sql_err
# )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# flush_and_close( f_sql_log )
# flush_and_close( f_sql_err )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_svc_log.name,'r') as f:
# l = [l for l in f.readlines() if l.strip()]
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# for line in l:
# print("SVC STDOUT: "+line )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_svc_err.name,'r') as f:
# l = [l for l in f.readlines() if l.strip()]
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# for line in l:
# print("SVC STDERR: "+line )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_sql_log.name,'r') as f:
# l = [l for l in f.readlines() if l.strip()]
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# for line in l:
# print("SQL STDOUT: "+line )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# with open( f_sql_err.name,'r') as f:
# l = [l for l in f.readlines() if l.strip()]
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# for line in l:
# print("SQL STDERR: "+line )
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# #############################################
2021-11-10 19:02:05 +01:00
#
2021-04-26 20:07:00 +02:00
# # Cleanup.
# time.sleep(1)
# cleanup( [i.name for i in (f_svc_log, f_svc_err, f_sql_log, f_sql_err, f_sql_txt)] )
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-04-26 20:07:00 +02:00
expected_stdout_1 = """
2021-11-10 19:02:05 +01:00
SEC$USER_NAME NEBUCHADNEZZAR2_KING_OF_BABYLON
SEC$FIRST_NAME Nebuchadnezzar3_King_of_Babylon
SEC$MIDDLE_NAME Nebuchadnezzar4_King_of_Babylon
SEC$LAST_NAME Nebuchadnezzar5_King_of_Babylon
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2021-11-10 19:02:05 +01:00
def test_1(act_1: Action):
with act_1.connect_server() as srv:
check_login = "Nebuchadnezzar2_King_of_Babylon"
srv.user.add(user_name=check_login, password="Nebu_King_of_Babylon")
srv.user.update(user_name=check_login,
first_name="Nebuchadnezzar3_King_of_Babylon",
middle_name="Nebuchadnezzar4_King_of_Babylon",
last_name="Nebuchadnezzar5_King_of_Babylon")
#
act_1.script = f"""set list on;
select sec$user_name, sec$first_name, sec$middle_name, sec$last_name from sec$users
where upper(sec$user_name) = upper('{check_login}');
commit;
drop user {check_login};
"""
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout
2021-04-26 20:07:00 +02:00