Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,49 @@ jobs:
pip install pytest anyio
pip install -e .

- name: Debug vector index secret wiring
run: |
python - <<'PY'
import hashlib
import os
from urllib.parse import urlparse

def log_env(name):
value = os.environ.get(name)
if value is None:
print(f"{name}: missing")
return
digest = hashlib.sha256(value.encode()).hexdigest()[:12]
print(
f"{name}: set len={len(value)} stripped={value == value.strip()} "
f"sha256_12={digest}"
)

for env_name in (
"PYSAI_TEST_USER",
"PYTEST_TEST_OBJSTORE_EMBEDDING_LOC",
"PYTEST_TEST_OBJSTORE_USERNAME",
"PYTEST_TEST_OBJSTORE_PASSWORD",
):
log_env(env_name)

location = os.environ.get("PYTEST_TEST_OBJSTORE_EMBEDDING_LOC")
if location:
print(
"PYTEST_TEST_OBJSTORE_EMBEDDING_LOC "
f"host={urlparse(location.strip()).hostname}"
)

user = os.environ.get("PYSAI_TEST_USER")
if user:
print(f"PYSAI_TEST_USER uppercase={user == user.upper()}")
PY
env:
PYSAI_TEST_USER: ${{ secrets.PYSAI_TEST_USER }}_${{env.PYTHON_VERSION_WITHOUT_DOT}}
PYTEST_TEST_OBJSTORE_EMBEDDING_LOC: ${{ secrets.PYTEST_TEST_OBJSTORE_EMBEDDING_LOC }}
PYTEST_TEST_OBJSTORE_USERNAME: ${{ secrets.PYTEST_TEST_OBJSTORE_USERNAME }}
PYTEST_TEST_OBJSTORE_PASSWORD: ${{ secrets.PYTEST_TEST_OBJSTORE_PASSWORD }}

- name: Run select_ai tests
run: |
python_version=${{matrix.python-version}}
Expand All @@ -58,3 +101,6 @@ jobs:
PYSAI_TEST_EMAIL_SENDER: ${{secrets.PYSAI_TEST_EMAIL_SENDER}}
PYSAI_TEST_EMAIL_SMTPHOST: ${{secrets.PYSAI_TEST_EMAIL_SMTPHOST}}
PYSAI_TEST_OPENAI_API_KEY: ${{secrets.PYSAI_TEST_OPENAI_API_KEY}}
PYTEST_TEST_OBJSTORE_EMBEDDING_LOC: ${{ secrets.PYTEST_TEST_OBJSTORE_EMBEDDING_LOC }}
PYTEST_TEST_OBJSTORE_USERNAME: ${{ secrets.PYTEST_TEST_OBJSTORE_USERNAME }}
PYTEST_TEST_OBJSTORE_PASSWORD: ${{ secrets.PYTEST_TEST_OBJSTORE_PASSWORD }}
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import os
import uuid
from urllib.parse import urlparse

import oracledb
import pytest
Expand Down Expand Up @@ -90,6 +91,15 @@ def _grant_http_access(cur, username: str, provider_endpoint: str):
)


def _grant_vector_index_http_access(cur, username: str):
location = os.environ.get("PYTEST_TEST_OBJSTORE_EMBEDDING_LOC")
if not location:
return
host = urlparse(location.strip()).hostname
if host:
_grant_http_access(cur, username=username, provider_endpoint=host)


def _append_host_ace(cur, host: str, privileges, username: str):
privilege_list = ",".join([f"'{p}'" for p in privileges])
cur.execute(
Expand Down Expand Up @@ -193,6 +203,10 @@ def setup_test_user(test_env):
username=test_env.test_user,
provider_endpoint=select_ai.OpenAIProvider.provider_endpoint,
)
_grant_vector_index_http_access(
cur,
username=test_env.test_user,
)
conn.commit()
finally:
cur.close()
Expand Down
51 changes: 51 additions & 0 deletions tests/credential/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

import os

import pytest


def get_credential_env_value(name, default_value=None):
return os.environ.get(f"PYSAI_TEST_{name}", default_value)


@pytest.fixture(scope="session")
def oci_credential():
"""
Override the root autouse OCI credential fixture for credential-only tests.
These suites should not require OCI environment variables unless a test
explicitly opts into them.
"""
return None


@pytest.fixture(scope="session")
def credential_test_params(test_env):
return {
"user": test_env.test_user,
"password": test_env.test_user_password,
"dsn": test_env.connect_string,
"user_ocid": get_credential_env_value(
"OCI_USER_OCID", default_value="user ocid"
),
"tenancy_ocid": get_credential_env_value(
"OCI_TENANCY_OCID", default_value="tenancy ocid"
),
"private_key": get_credential_env_value(
"OCI_PRIVATE_KEY", default_value="private key"
),
"fingerprint": get_credential_env_value(
"OCI_FINGERPRINT", default_value="fingerprint"
),
"cred_username": get_credential_env_value(
"CRED_USERNAME", default_value="OCI credential username"
),
"cred_password": get_credential_env_value(
"CRED_PASSWORD", default_value="OCI credential password"
),
}
Loading
Loading