|
3 | 3 | from tests.model_explainability.evalhub.constants import ( |
4 | 4 | EVALHUB_HEALTH_PATH, |
5 | 5 | EVALHUB_HEALTH_STATUS_HEALTHY, |
| 6 | + EVALHUB_PROVIDERS_PATH, |
6 | 7 | ) |
7 | 8 | from utilities.guardrails import get_auth_headers |
8 | 9 | from utilities.opendatahub_logger import get_logger |
9 | 10 |
|
10 | 11 | LOGGER = get_logger(name=__name__) |
11 | 12 |
|
| 13 | +TENANT_HEADER: str = "X-Tenant" |
| 14 | + |
| 15 | + |
| 16 | +def _build_headers(token: str, tenant: str | None = None) -> dict[str, str]: |
| 17 | + """Build request headers with auth and optional tenant. |
| 18 | +
|
| 19 | + Args: |
| 20 | + token: Bearer token for authentication. |
| 21 | + tenant: Namespace for the X-Tenant header. Omitted if None. |
| 22 | +
|
| 23 | + Returns: |
| 24 | + Headers dict. |
| 25 | + """ |
| 26 | + headers = get_auth_headers(token=token) |
| 27 | + if tenant is not None: |
| 28 | + headers[TENANT_HEADER] = tenant |
| 29 | + return headers |
| 30 | + |
12 | 31 |
|
13 | 32 | def validate_evalhub_health( |
14 | 33 | host: str, |
@@ -45,3 +64,26 @@ def validate_evalhub_health( |
45 | 64 | f"Expected status '{EVALHUB_HEALTH_STATUS_HEALTHY}', got '{data['status']}'" |
46 | 65 | ) |
47 | 66 | assert "timestamp" in data, "Health response missing 'timestamp' field" |
| 67 | + |
| 68 | + |
| 69 | +def validate_evalhub_providers( |
| 70 | + host: str, |
| 71 | + token: str, |
| 72 | + ca_bundle_file: str, |
| 73 | + tenant: str | None = None, |
| 74 | +) -> dict: |
| 75 | + """Smoke test for the EvalHub providers endpoint.""" |
| 76 | + url = f"https://{host}{EVALHUB_PROVIDERS_PATH}" |
| 77 | + |
| 78 | + response = requests.get( |
| 79 | + url=url, |
| 80 | + headers=_build_headers(token=token, tenant=tenant), |
| 81 | + verify=ca_bundle_file, |
| 82 | + timeout=10, |
| 83 | + ) |
| 84 | + response.raise_for_status() |
| 85 | + |
| 86 | + data = response.json() |
| 87 | + assert data.get("items"), f"Smoke test failed: Providers list is empty for tenant {tenant}" |
| 88 | + |
| 89 | + return data |
0 commit comments