#coding:utf-8 # # id: functional.services.user_management # title: Check ability to make connect to FB services and add/drop user. # decription: # We check here: # 1) FB services features which add and remove user; # 2) Python fdb driver functions (from class Connection): add_user(), get_users() and remove_user() # # NB. # User with name 'tmp$test$user$' must NOT present in security_db. # Correctness of adding user is verified by establishing TCP-based attachment to test DB using its login/password. # # See doc: # https://firebirdsql.org/file/documentation/drivers_documentation/python/fdb/reference.html#fdb.services.Connection.add_user # https://firebirdsql.org/file/documentation/drivers_documentation/python/fdb/usage-guide.html#user-maintanance # # Checked on: # FB25Cs, build 2.5.8.27067: OK, 1.015s. # FB25SC, build 2.5.8.27070: OK, 0.813s. # fb30Cs, build 3.0.3.32805: OK, 2.297s. # FB30SS, build 3.0.3.32813: OK, 2.109s. # FB40CS, build 4.0.0.748: OK, 2.859s. # FB40SS, build 4.0.0.767: OK, 2.000s. # # tracker_id: # min_versions: ['2.5.8'] # versions: 2.5.8 # qmid: import pytest from firebird.qa import db_factory, python_act, Action # version: 2.5.8 # resources: None substitutions_1 = [] init_script_1 = """""" db_1 = db_factory(sql_dialect=3, init=init_script_1) # test_script_1 #--- # # import os # import subprocess # from fdb import services # # TEST_USER_NAME='tmp$test$user$'.upper() # db_conn.close() # # svc_con = services.connect( host='localhost', user = user_name, password = user_password ) # # u01 = services.User(TEST_USER_NAME) # u01.password = 'QweRty' # u01.first_name = 'Foo' # u01.last_name = 'Bar' # # # print('Adding user.') # svc_con.add_user(u01) # print('Done.') # # usr_list = svc_con.get_users() # print('Search in users list.') # for u in usr_list: # if u.name == TEST_USER_NAME: # print('Found user:', u.name) # # sql=''' # select # mon$user as user_connected # ,iif( upper(mon$remote_protocol) starting with upper('TCP'), 'TCP', coalesce(mon$remote_protocol, '') ) as protocol_info # from mon$attachments # where mon$attachment_id = current_connection # ''' # # try: # print('Trying to establish connection.') # usr_con = fdb.connect( dsn = dsn, user=TEST_USER_NAME, password='QweRty') # cur2 = usr_con.cursor() # cur2.execute( sql ) # for r in cur2: # for i in range(0,len(r)): # print( ''.join( ( r[i] ) ) ) # print('Done.') # finally: # usr_con.close() # # # print('Removing user.') # svc_con.remove_user(u01) # print('Done.') #--- act_1 = python_act('db_1', substitutions=substitutions_1) expected_stdout_1 = """ Adding user. Done. Search in users list. Found user: TMP$TEST$USER$ Trying to establish connection. TMP$TEST$USER$ TCP Done. Removing user. Done. """ @pytest.mark.version('>=2.5.8') @pytest.mark.xfail def test_1(act_1: Action): pytest.fail("Test not IMPLEMENTED")