|
| 1 | +# ----------------------------------------------------------------------------- |
| 2 | +# Copyright (c) 2026, Oracle and/or its affiliates. |
| 3 | +# |
| 4 | +# Licensed under the Universal Permissive License v 1.0 as shown at |
| 5 | +# http://oss.oracle.com/licenses/upl. |
| 6 | +# ----------------------------------------------------------------------------- |
| 7 | + |
| 8 | +import os |
| 9 | + |
| 10 | +import pytest |
| 11 | + |
| 12 | + |
| 13 | +def get_credential_env_value(name, default_value=None): |
| 14 | + return os.environ.get(f"PYSAI_TEST_{name}", default_value) |
| 15 | + |
| 16 | + |
| 17 | +@pytest.fixture(scope="session") |
| 18 | +def oci_credential(): |
| 19 | + """ |
| 20 | + Override the root autouse OCI credential fixture for credential-only tests. |
| 21 | + These suites should not require OCI environment variables unless a test |
| 22 | + explicitly opts into them. |
| 23 | + """ |
| 24 | + return None |
| 25 | + |
| 26 | + |
| 27 | +@pytest.fixture(scope="session") |
| 28 | +def credential_test_params(test_env): |
| 29 | + return { |
| 30 | + "user": test_env.test_user, |
| 31 | + "password": test_env.test_user_password, |
| 32 | + "dsn": test_env.connect_string, |
| 33 | + "user_ocid": get_credential_env_value( |
| 34 | + "OCI_USER_OCID", default_value="user ocid" |
| 35 | + ), |
| 36 | + "tenancy_ocid": get_credential_env_value( |
| 37 | + "OCI_TENANCY_OCID", default_value="tenancy ocid" |
| 38 | + ), |
| 39 | + "private_key": get_credential_env_value( |
| 40 | + "OCI_PRIVATE_KEY", default_value="private key" |
| 41 | + ), |
| 42 | + "fingerprint": get_credential_env_value( |
| 43 | + "OCI_FINGERPRINT", default_value="fingerprint" |
| 44 | + ), |
| 45 | + "cred_username": get_credential_env_value( |
| 46 | + "CRED_USERNAME", default_value="OCI credential username" |
| 47 | + ), |
| 48 | + "cred_password": get_credential_env_value( |
| 49 | + "CRED_PASSWORD", default_value="OCI credential password" |
| 50 | + ), |
| 51 | + } |
0 commit comments