|
| 1 | +#------------------------------------------------------------------------------ |
| 2 | +# Copyright (c) 2022, Oracle and/or its affiliates. |
| 3 | +# |
| 4 | +# This software is dual-licensed to you under the Universal Permissive License |
| 5 | +# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License |
| 6 | +# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose |
| 7 | +# either license. |
| 8 | +# |
| 9 | +# If you elect to accept the software under the Apache License, Version 2.0, |
| 10 | +# the following applies: |
| 11 | +# |
| 12 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 | +# you may not use this file except in compliance with the License. |
| 14 | +# You may obtain a copy of the License at |
| 15 | +# |
| 16 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +# |
| 18 | +# Unless required by applicable law or agreed to in writing, software |
| 19 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | +# See the License for the specific language governing permissions and |
| 22 | +# limitations under the License. |
| 23 | +#------------------------------------------------------------------------------ |
| 24 | + |
| 25 | +""" |
| 26 | +5000 - Module for testing external authentication |
| 27 | +""" |
| 28 | + |
| 29 | +import unittest |
| 30 | + |
| 31 | +import oracledb |
| 32 | +import test_env |
| 33 | + |
| 34 | +@unittest.skipIf(test_env.get_is_thin(), |
| 35 | + "thin mode doesn't support external authentication yet") |
| 36 | +class TestCase(test_env.BaseTestCase): |
| 37 | + require_connection = False |
| 38 | + |
| 39 | + def test_5000_pool_with_user_and_password_and_externalauth_enabled(self): |
| 40 | + """ |
| 41 | + 5000 - test error on creating a pool with user and password specified |
| 42 | + and externalauth enabled |
| 43 | + """ |
| 44 | + self.assertRaisesRegex(oracledb.DatabaseError, "^DPI-1032:", |
| 45 | + test_env.get_pool, min=1, max=2, increment=1, |
| 46 | + getmode=oracledb.POOL_GETMODE_WAIT, |
| 47 | + externalauth=True, homogeneous=False) |
| 48 | + |
| 49 | + def test_5001_pool_with_no_password_and_externalauth_enabled(self): |
| 50 | + """ |
| 51 | + 5001 - test error on creating a pool without password and with user |
| 52 | + specified and externalauth enabled |
| 53 | + """ |
| 54 | + self.assertRaisesRegex(oracledb.DatabaseError, "^DPI-1032:", |
| 55 | + oracledb.create_pool, |
| 56 | + user=test_env.get_main_user(), |
| 57 | + min=1, max=2, increment=1, |
| 58 | + getmode=oracledb.POOL_GETMODE_WAIT, |
| 59 | + externalauth=True, homogeneous=False) |
| 60 | + |
| 61 | + def test_5002_pool_with_no_user_and_externalauth_enabled(self): |
| 62 | + """ |
| 63 | + 5002 - test error on creating a pool without user and with password |
| 64 | + specified and externalauth enabled |
| 65 | + """ |
| 66 | + self.assertRaisesRegex(oracledb.DatabaseError, "^DPI-1032:", |
| 67 | + oracledb.create_pool, |
| 68 | + password=test_env.get_main_password(), |
| 69 | + min=1, max=2, increment=1, |
| 70 | + getmode=oracledb.POOL_GETMODE_WAIT, |
| 71 | + externalauth=True, homogeneous=False) |
| 72 | + |
| 73 | +if __name__ == "__main__": |
| 74 | + test_env.run_test_cases() |
0 commit comments