def test_2407_heterogeneous(self): "2407 - test heterogeneous pool with user and password specified" pool = test_env.get_pool(min=2, max=8, increment=3, homogeneous=False, getmode=oracledb.SPOOL_ATTRVAL_WAIT) self.assertEqual(pool.homogeneous, 0) conn = pool.acquire() self.__verify_connection(pool.acquire(), test_env.get_main_user()) conn.close() conn = pool.acquire(test_env.get_main_user(), test_env.get_main_password()) self.__verify_connection(conn, test_env.get_main_user()) conn.close() conn = pool.acquire(test_env.get_proxy_user(), test_env.get_proxy_password()) self.__verify_connection(conn, test_env.get_proxy_user()) conn.close() user_str = "%s[%s]" % \ (test_env.get_main_user(), test_env.get_proxy_user()) conn = pool.acquire(user_str, test_env.get_main_password()) self.__verify_connection(conn, test_env.get_proxy_user(), test_env.get_main_user()) conn.close()
def test_2409_heterogeneous_wrong_password(self): "2409 - test heterogeneous pool with wrong password specified" pool = test_env.get_pool(min=2, max=8, increment=3, getmode=oracledb.SPOOL_ATTRVAL_WAIT, homogeneous=False) self.assertRaises(oracledb.DatabaseError, pool.acquire, test_env.get_proxy_user(), "this is the wrong password")
def test_2401_proxy_auth(self): "2401 - test that proxy authentication is possible" pool = test_env.get_pool(min=2, max=8, increment=3, getmode=oracledb.SPOOL_ATTRVAL_WAIT) self.assertEqual(pool.homogeneous, True, "homogeneous should be True by default") self.assertRaises(oracledb.DatabaseError, pool.acquire, user="******") pool = test_env.get_pool(min=2, max=8, increment=3, getmode=oracledb.SPOOL_ATTRVAL_WAIT, homogeneous=False) msg = "homogeneous should be False after setting it in the constructor" self.assertEqual(pool.homogeneous, False, msg) connection = pool.acquire(user=test_env.get_proxy_user()) cursor = connection.cursor() cursor.execute('select user from dual') result, = cursor.fetchone() self.assertEqual(result, test_env.get_proxy_user().upper())
def test_2408_heterogenous_without_user(self): "2408 - test heterogeneous pool without user and password specified" pool = test_env.get_pool(user="", password="", min=2, max=8, increment=3, getmode=oracledb.SPOOL_ATTRVAL_WAIT, homogeneous=False) self.__verify_connection(pool.acquire(test_env.get_main_user(), test_env.get_main_password()), test_env.get_main_user()) self.__verify_connection(pool.acquire(test_env.get_proxy_user(), test_env.get_proxy_password()), test_env.get_proxy_user()) user_str = "%s[%s]" % \ (test_env.get_main_user(), test_env.get_proxy_user()) self.__verify_connection(pool.acquire(user_str, test_env.get_main_password()), test_env.get_proxy_user(), test_env.get_main_user())
def test_1133_current_schema(self): "1133 - test current_schame is set properly" conn = test_env.get_connection() self.assertEqual(conn.current_schema, None) user = test_env.get_main_user().upper() proxy_user = test_env.get_proxy_user().upper() cursor = conn.cursor() cursor.execute(f'alter session set current_schema={proxy_user}') self.assertEqual(conn.current_schema, proxy_user) conn.current_schema = user self.assertEqual(conn.current_schema, user) cursor.execute(""" select sys_context('userenv', 'current_schema') from dual""") result, = cursor.fetchone() self.assertEqual(result, user)
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # SetupTest.py # # Creates users and populates their schemas with the tables and packages # necessary for the cx_Oracle test suite. #------------------------------------------------------------------------------ import cx_Oracle import test_env import DropTest # connect as administrative user (usually SYSTEM or ADMIN) conn = cx_Oracle.connect(test_env.get_admin_connect_string()) # drop existing users and editions, if applicable DropTest.drop_tests(conn) # create test schemas print("Creating test schemas...") test_env.run_sql_script(conn, "SetupTest", main_user=test_env.get_main_user(), main_password=test_env.get_main_password(), proxy_user=test_env.get_proxy_user(), proxy_password=test_env.get_proxy_password()) print("Done.")
def drop_tests(conn): print("Dropping test schemas...") test_env.run_sql_script(conn, "drop_test", main_user=test_env.get_main_user(), proxy_user=test_env.get_proxy_user())