repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
onyx
backend/tests/external_dependency_unit/db/test_targeted_reindex_create.py
.py
"""External dependency unit tests for `create_targeted_reindex_job`. Validates that submitting a targeted reindex request: - writes the job row + target rows + per-cc-pair synthetic IndexAttempts - pre-allocates a celery task UUID - dedupes (cc_pair, document_id) pairs - enforces the MAX_TARGETS_PER_REQUEST cap - rais...
394
13,290
onyx
backend/tests/external_dependency_unit/db/test_port_metadata_defer_e2e.py
.py
"""End-to-end deferred-metadata-sync (permission) test for the reindex port. The existing sync-priority tests mock the document index and assert the producer's LOW/MEDIUM/HIGH *decision*. This test instead drives the real OpenSearch `OpenSearchIndexPair.update()` defer path against live indices, proving the correctnes...
646
24,402
onyx
backend/tests/external_dependency_unit/db/test_incognito_history_exclusion.py
.py
"""Guards that an incognito session stays out of every surface its owner sees. Covers the three that list a user's own sessions: history, search, and the chat list a project carries. Exercises the real WHERE clauses against Postgres, since a mocked session would happily return rows the SQL would have filtered. """ fr...
341
11,974
onyx
backend/tests/external_dependency_unit/db/test_userfile_port_scope.py
.py
"""External dependency unit tests for the user-file port scope (PR1 β€” schema + helpers). Covers the scope-polymorphic PortAttempt (exactly-one CHECK, the NULL-distinct user-branch active-unique index), the user-file enumeration/survival helpers the port scheduler will consume, and the secondary_reconcile_pending flag ...
420
15,404
onyx
backend/tests/external_dependency_unit/db/test_user_account_type.py
.py
""" Tests that account_type is correctly set when creating users through the internal DB functions: add_slack_user_if_not_exists and batch_add_ext_perm_user_if_not_exists. These functions are called by background workers (Slack bot, permission sync) and are not exposed via API endpoints, so they must be tested directl...
54
1,834
onyx
backend/tests/external_dependency_unit/db/test_agent_sharing_knowledge_guard.py
.py
"""Regression coverage for the editor knowledge-attach guard (ENG-4180): a non-owner editor may only ATTACH document sets they can access; pre-existing attachments survive updates, and a removed inaccessible set cannot be re-added by that editor.""" from uuid import uuid4 import pytest from sqlalchemy.orm import Sess...
129
4,771
onyx
backend/tests/external_dependency_unit/db/test_reindex_port.py
.py
"""External dependency unit tests for the reindexing-port DB layer. Scoped to behavior/invariants worth guarding (the column existence + defaults are covered by applying the migration, which this repo does not test programmatically): - the partial-unique "one active attempt per (cc_pair, FUTURE)" index β€” and that it...
2,336
90,484
onyx
backend/tests/external_dependency_unit/db/test_swap_credentials_hierarchy.py
.py
"""Test that swapping a cc_pair's credential_id cascades to the hierarchy_node_by_connector_credential_pair join table. Regression for ForeignKeyViolation on `hierarchy_node_by_connector_cre_connector_id_credential_id_fkey` when a connector with hierarchy nodes has its credential swapped (e.g. Confluence). """ from u...
121
4,202
onyx
backend/tests/external_dependency_unit/db/test_connector_state_snapshot_query.py
.py
from datetime import datetime, timezone from sqlalchemy.orm import Session from onyx.configs.constants import DEFAULT_CC_PAIR_ID, DocumentSource from onyx.db.connector_credential_pair import ( ConnectorStateSnapshot, get_connector_state_snapshots, ) from onyx.db.enums import AccessType, ConnectorCredentialPai...
63
2,161
onyx
backend/tests/external_dependency_unit/db/conftest.py
.py
"""Fixtures for testing DAL classes against a real PostgreSQL database. These fixtures build on the db_session and tenant_context fixtures from the parent conftest (tests/external_dependency_unit/conftest.py). Requires a running Postgres instance. Run with:: python -m dotenv -f .vscode/.env run -- pytest tests/e...
92
2,742
onyx
backend/tests/external_dependency_unit/opensearch/test_assistant_knowledge_filter.py
.py
"""Tests for OpenSearch assistant knowledge filter construction. These tests verify that when an assistant (persona) has knowledge attached, the search filter includes the appropriate scope filters with OR logic (not AND), ensuring documents are discoverable across knowledge types like attached documents, hierarchy no...
256
10,021
onyx
backend/tests/external_dependency_unit/opensearch/test_opensearch_client.py
.py
"""External dependency unit tests for OpenSearchIndexClient. These tests assume OpenSearch is running and test all implemented methods using real schemas, pipelines, and search queries from the codebase. """ import re import uuid from collections.abc import Generator from datetime import datetime, timedelta, timezone...
3,339
137,181
onyx
backend/tests/external_dependency_unit/opensearch/test_forced_document_set_filter.py
.py
"""Tests for the operator-forced document-set scope in OpenSearch query construction. The forced scope (from FORCED_DOCUMENT_SET_NAMES) must be applied as a STANDALONE top-level AND filter clause β€” distinct from the user/persona ``document_set`` scope, which lives inside the OR-based knowledge filter. This is what mak...
116
4,934
onyx
backend/tests/external_dependency_unit/cache/test_cache_backend_parity.py
.py
"""Parameterized tests that run the same CacheBackend operations against both Redis and PostgreSQL, asserting identical return values. Each test runs twice (once per backend) via the ``cache`` fixture defined in conftest.py. """ import time from uuid import uuid4 from onyx.cache.interface import TTL_KEY_NOT_FOUND, T...
99
2,892
onyx
backend/tests/external_dependency_unit/cache/test_encrypted_kv_store_accessor.py
.py
"""Guards encrypted KV row storage, updates, and missing-key errors.""" from collections.abc import Generator import pytest from sqlalchemy import delete from onyx.db.encrypted_kv_store import ( delete_encrypted_kv, load_encrypted_kv, upsert_encrypted_kv, ) from onyx.db.engine.sql_engine import get_sessi...
64
1,966
onyx
backend/tests/external_dependency_unit/cache/test_postgres_cache_backend.py
.py
"""Tests for PostgresCacheBackend against real PostgreSQL. Covers every method on the backend: KV CRUD, TTL behaviour, advisory locks (acquire / release / contention), list operations (rpush / blpop), and the periodic cleanup function. """ import time from uuid import uuid4 from sqlalchemy import select from onyx.c...
231
7,674
onyx
backend/tests/external_dependency_unit/cache/test_stream_buffer_backends.py
.py
"""Stream-buffer behavior on the real cache backends: the chunk write/read roundtrip, done-marking, and gap signaling must hold identically on Redis and the Postgres (lite) backend.""" from uuid import uuid4 from onyx.cache.interface import CacheBackend from onyx.chat.stream_buffer import StreamBufferWriter, _chunk_k...
50
1,626
onyx
backend/tests/external_dependency_unit/cache/conftest.py
.py
"""Fixtures for cache backend tests. Requires a running PostgreSQL instance (and Redis for parity tests). Run with:: python -m dotenv -f .vscode/.env run -- pytest tests/external_dependency_unit/cache/ """ from collections.abc import Generator import pytest from onyx.cache.interface import CacheBackend from on...
60
1,776
onyx
backend/tests/external_dependency_unit/cache/test_kv_store_cache_layer.py
.py
"""Tests for PgRedisKVStore's cache layer integration with CacheBackend. Verifies that the KV store correctly uses the CacheBackend for caching in front of PostgreSQL: cache hits, cache misses falling through to PG, cache population after PG reads, cache invalidation on delete, and graceful degradation when the cache ...
130
4,558
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_mcp_server_resolver.py
.py
"""External-dependency-unit tests for `MCPServerResolver` against a real DB. Pins the claim->resolve contract per MCP auth mode: craft-enabled servers are claimed by exact URL-prefix attribution, credentials come from the same `mcp_connection_config` rows chat writes, an expired OAuth token is refreshed through the to...
783
27,460
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_mcp_approval_pipeline.py
.py
"""External-dependency-unit tests for the shared approval pipeline carrying an MCP-server target. Companion `mcp_server_id` columns let one approval/policy code path serve both external apps and MCP servers. These pin the MCP half: an approval row attributes to a server, session-grant lookups isolate by target, the ex...
184
5,747
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_identity_docker_lookup.py
.py
"""External-dependency-unit tests for ``DockerEventsLookup``. Unit tests stub the docker SDK; This file spins up real labeled containers on the host docker daemon and exercises the cache from the initial-sync + events paths. Skipped automatically when the docker socket is absent so local contributors without docker ru...
280
9,424
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_identity_resolver.py
.py
"""External-dependency-unit tests for `IdentityResolver`. Unit tests stub `Session.scalar`; this file exercises the real ORM queries against Postgres so a schema-level regression (column rename, enum drift, ordering change) actually fails the test. """ import datetime as dt from collections.abc import Generator from ...
151
5,092
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_mcp_approval_evaluator.py
.py
"""External-dependency-unit tests for `McpRequestEvaluator` against a real DB. Pins proxy-authoritative per-tool approvals: a craft MCP `tools/call` becomes an `AllMatchedActions` targeting the server, carrying the tool's effective policy (admin override else default ASK); protocol plumbing is ungated (``None``); an u...
337
11,732
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_gate_claim_arbiter.py
.py
"""External-dependency-unit tests for GateAddon persistence and race behavior. Run against real Postgres rows so transaction visibility and conditional updates are tested rather than inferred from mocked session calls. """ from __future__ import annotations import datetime as dt from typing import Any from uuid impo...
320
11,161
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_onyx_pat_resolver.py
.py
"""External-dependency-unit test for `OnyxPatResolver` against a real DB. Pins the full claim->resolve contract the unit test mocks: `ensure_sandbox_pat` mints a PAT and persists it (encrypted) on the sandbox row, the resolver claims the configured Onyx API host, and reads the token back β€” through real `EncryptedStrin...
61
2,275
onyx
backend/tests/external_dependency_unit/sandbox_proxy/test_approval_cache.py
.py
"""External-dependency-unit tests for `approval_cache` against a real `CacheBackend` (Redis). Pins the RPUSH / BLPOP / TTL contract; mocks nothing.""" import threading import time from uuid import UUID, uuid4 import pytest from onyx.cache.factory import get_cache_backend from onyx.db.enums import ApprovalDecision, G...
186
5,994
onyx
backend/tests/external_dependency_unit/redis/test_lock_context.py
.py
"""External dependency tests for redis_shared_lock context manager. These tests require Redis to be running. """ import threading import time from collections.abc import Generator import pytest from onyx.redis.lock_context import RedisSharedLockAcquisitionError, redis_shared_lock from onyx.redis.redis_pool import g...
306
9,823
onyx
backend/tests/external_dependency_unit/redis/test_incognito_context.py
.py
"""Guards the incognito context store's Redis contract. Round trip, the compare-and-set that guards against concurrent turns, the sliding TTL, teardown, corruption degrading to an ended session, image stripping, and the storage caps, all against a real Redis. Each test runs under a unique tenant so runs cannot collide...
231
7,854
onyx
backend/tests/external_dependency_unit/redis/test_tenant_redis.py
.py
"""External dependency tests for ``TenantRedisClient``. These tests run against a real Redis and verify the prefixing contract on which multi-tenant isolation depends: * Writes through ``TenantRedisClient`` land under the tenant-prefixed key. * Reads through ``TenantRedisClient`` find data written under the same ...
465
16,666
onyx
backend/tests/integration/conftest.py
.py
import os import platform import shutil import subprocess from collections.abc import Callable, Generator from typing import Any from unittest.mock import patch import pytest # Integration tests rely on this mode to enable mock_llm_response paths. os.environ["INTEGRATION_TESTS_MODE"] = "true" # Backend directory (`/...
532
18,903
onyx
backend/tests/integration/mock_services/mcp_test_server/run_mcp_server_no_auth.py
.py
import os import sys from fastmcp import FastMCP mcp = FastMCP("My HTTP MCP") @mcp.tool def hello(name: str) -> str: """Say hi.""" return f"Hello, {name}!" def make_many_tools() -> None: def make_tool(i: int) -> None: @mcp.tool(name=f"tool_{i}", description=f"Get secret value {i}") def...
42
1,264
onyx
backend/tests/integration/mock_services/mcp_test_server/run_mcp_server_api_key.py
.py
import sys import uvicorn from fastapi import FastAPI from fastapi.responses import PlainTextResponse from fastmcp import FastMCP from fastmcp.server.auth import StaticTokenVerifier def make_many_tools(mcp: FastMCP) -> None: def make_tool(i: int) -> None: @mcp.tool(name=f"tool_{i}", description=f"Get sec...
60
1,649
onyx
backend/tests/integration/mock_services/mcp_test_server/run_mcp_server_per_user_key.py
.py
import argparse import sys from datetime import datetime, timezone from typing import Any, Awaitable, Callable, Dict, Optional import bcrypt import uvicorn from fastapi import FastAPI from fastapi.responses import PlainTextResponse from fastmcp import FastMCP from fastmcp.server.auth.auth import AccessToken, TokenVeri...
212
6,880
onyx
backend/tests/integration/mock_services/mcp_test_server/run_mock_oidc_idp.py
.py
# /// script # requires-python = ">=3.13" # dependencies = [ # "fastapi>=0.110", # "uvicorn>=0.29", # "pyjwt[crypto]>=2.8", # "cryptography>=42", # "python-multipart>=0.0.9", # ] # /// """Self-contained mock OIDC / OAuth2 authorization server for MCP e2e tests. Run it with no external setup:: uv run run...
406
14,996
onyx
backend/tests/integration/mock_services/mcp_test_server/run_mcp_server_oauth.py
.py
import os from collections.abc import Awaitable, Callable, Iterable from typing import Any from urllib.parse import urlsplit, urlunsplit import uvicorn from fastapi import FastAPI, Request from fastapi.responses import JSONResponse, PlainTextResponse, Response from fastmcp import FastMCP from fastmcp.server.auth.provi...
208
8,368
onyx
backend/tests/integration/mock_services/mcp_test_server/run_mcp_server_google_oauth.py
.py
""" MCP Test Server for Google OAuth Pass-Through Authentication This server validates Google OAuth access tokens that are passed through from Onyx. When users log into Onyx with Google OAuth, their access token is stored and can be passed to MCP servers that require authentication. This server validates those tokens...
249
8,605
onyx
backend/tests/integration/mock_services/mock_connector_server/main.py
.py
from fastapi import FastAPI, HTTPException from pydantic import BaseModel, Field # We would like to import these, but it makes building this so much harder/slower # from onyx.connectors.mock_connector.connector import SingleConnectorYield # from onyx.connectors.models import ConnectorCheckpoint app = FastAPI() # Gl...
75
2,261
onyx
backend/tests/integration/multitenant_tests/test_mobile_bearer_tenant_resolution.py
.py
"""Multi-tenant regression test for mobile bearer-token tenant resolution. A mobile client authenticates with the opaque session token in the ``Authorization: Bearer`` header (no cookie). In multi-tenant cloud the EE tenant middleware must resolve the tenant from that header β€” otherwise every authed route falls back t...
51
2,388
onyx
backend/tests/integration/multitenant_tests/test_get_schemas_needing_migration.py
.py
""" Integration tests for onyx.db.engine.tenant_utils.get_schemas_needing_migration. These tests require a live database and exercise the function directly, independent of the alembic migration runner script. Usage: pytest tests/integration/multitenant_tests/test_get_schemas_needing_migration.py -v """ from __fu...
175
5,332
onyx
backend/tests/integration/multitenant_tests/invitation/test_user_invitation.py
.py
from uuid import uuid4 from onyx.db.models import UserRole from tests.integration.common_utils.managers.user import UserManager from tests.integration.common_utils.test_models import DATestUser INVITED_BASIC_USER = "basic_user" INVITED_BASIC_USER_EMAIL = "basic_user@example.com" def test_admin_can_invite_users(rese...
116
4,708
onyx
backend/tests/integration/multitenant_tests/tenants/test_tenant_creation.py
.py
from http import HTTPStatus from uuid import uuid4 from onyx.configs.constants import DocumentSource from onyx.db.enums import AccessType from onyx.db.models import UserRole from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.inte...
147
5,316
onyx
backend/tests/integration/multitenant_tests/tenants/test_tenant_provisioning_rollback.py
.py
""" Integration tests for tenant provisioning rollback behavior. Tests the fix for the drop_schema bug where: 1. isidentifier() rejected valid UUID tenant IDs (with hyphens) 2. SQL syntax was broken (%(schema_name)s instead of proper identifier handling) This test verifies the full flow: provisioning failure β†’ rollba...
108
4,109
onyx
backend/tests/integration/multitenant_tests/syncing/test_search_permissions.py
.py
from typing import Any from uuid import uuid4 from onyx.db.models import UserRole from tests.integration.common_utils.managers.api_key import APIKeyManager from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_utils.managers.chat import ChatSessionManager from tests.in...
294
11,716
onyx
backend/tests/integration/multitenant_tests/discord_bot/test_discord_bot_multitenant.py
.py
"""Multi-tenant isolation tests for Discord bot. These tests ensure tenant isolation and prevent data leakage between tenants. Tests follow the multi-tenant integration test pattern using API client. """ from unittest.mock import patch from uuid import uuid4 import pytest from onyx.db.discord_bot import get_guild_c...
464
17,991
onyx
backend/tests/integration/tests/index_attempt/test_index_attempt_pagination.py
.py
import time from datetime import datetime from onyx.db.models import IndexingStatus from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_utils.managers.index_attempt import IndexAttemptManager from tests.integration.common_utils.managers.user import UserManager from t...
123
4,556
onyx
backend/tests/integration/tests/streaming_endpoints/test_user_usage_tracking.py
.py
"""End-to-end: a real streamed chat message must flow through the whole per-user usage seam β€” generation span -> tracing processor registration -> background drain thread -> user_usage rollup -> readable back through GET /user/usage, attributed to the calling user. Every other test for this feature mocks that seam (sq...
68
2,720
onyx
backend/tests/integration/tests/streaming_endpoints/test_resume_stream.py
.py
"""Resume-stream contract: an in-flight run's buffered stream can be replayed and tailed by a second client, get-chat-session exposes the resumable run while it is in flight, and completed or idle sessions 404 so clients fall back to the persisted message. The api_server runs in-process via TestClient here, which buff...
171
6,756
onyx
backend/tests/integration/tests/streaming_endpoints/test_chat_stream.py
.py
import time from onyx.configs.constants import MessageType from tests.integration.common_utils.managers.chat import ChatSessionManager from tests.integration.common_utils.managers.llm_provider import LLMProviderManager from tests.integration.common_utils.test_models import DATestUser from tests.integration.conftest im...
180
6,912
onyx
backend/tests/integration/tests/streaming_endpoints/test_gateway_usage_tracking.py
.py
import time from onyx.db.enums import Permission from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.managers.llm_provider import LLMProviderManager from tests.integration.common_utils.managers.pat import ...
132
4,821
onyx
backend/tests/integration/tests/streaming_endpoints/test_chat_file_attachment.py
.py
import mimetypes from typing import Any from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.managers.chat import ChatSessionManager from tests.integration.common_utils.managers.file import FileManager from...
176
6,854
onyx
backend/tests/integration/tests/document_set/test_syncing.py
.py
from uuid import uuid4 from onyx.server.documents.models import DocumentSource from tests.integration.common_utils.constants import NUM_DOCS from tests.integration.common_utils.managers.api_key import APIKeyManager from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_...
209
5,777
onyx
backend/tests/integration/tests/query_history/utils.py
.py
from concurrent.futures import ThreadPoolExecutor, as_completed from onyx.configs.constants import QAFeedbackType from tests.integration.common_utils.managers.api_key import APIKeyManager from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_utils.managers.chat import ...
130
4,673
onyx
backend/tests/integration/tests/query_history/test_usage_reports.py
.py
from datetime import datetime, timedelta, timezone from ee.onyx.db.usage_export import get_all_empty_chat_message_entries from onyx.db.engine.sql_engine import get_session_with_current_tenant from onyx.db.seeding.chat_history_seeding import seed_chat_history def test_usage_reports(reset: None) -> None: # noqa: ARG0...
47
1,709
onyx
backend/tests/integration/tests/query_history/test_query_history.py
.py
import csv import io import os from datetime import datetime, timedelta, timezone import pytest from onyx.configs.constants import QAFeedbackType, SessionType from tests.integration.common_utils.managers.api_key import APIKeyManager from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests....
160
5,923
onyx
backend/tests/integration/tests/query_history/test_query_history_pagination.py
.py
import os from datetime import datetime import pytest from onyx.configs.constants import QAFeedbackType from tests.integration.common_utils.managers.query_history import QueryHistoryManager from tests.integration.common_utils.test_models import DAQueryHistoryEntry, DATestUser from tests.integration.tests.query_histor...
119
4,418
onyx
backend/tests/integration/tests/llm_auto_update/test_auto_llm_update.py
.py
""" Integration tests for Auto LLM model update feature. These tests verify that LLM providers in Auto mode get their models automatically synced from the GitHub config via the celery background task. Environment variables for testing: - AUTO_LLM_UPDATE_INTERVAL_SECONDS: Set to a low value (e.g., 5) for faster tests ...
261
8,965
onyx
backend/tests/integration/tests/reporting/test_usage_export_api.py
.py
import csv import os import time from datetime import datetime, timedelta, timezone from io import BytesIO, StringIO from uuid import UUID, uuid4 from zipfile import ZipFile import pytest from ee.onyx.db.usage_export import UsageReportMetadata from onyx.configs.constants import DEFAULT_PERSONA_ID from onyx.db.seeding...
466
16,132
onyx
backend/tests/integration/tests/security/test_runtime_security_settings.py
.py
"""Integration test for runtime-configurable security settings. The integration api_server runs as a single uvicorn worker, so the PUT handler's local-cache invalidation takes effect on the very next request without any TTL wait. """ from collections.abc import Generator import pytest from tests.integration.common_...
149
4,641
onyx
backend/tests/integration/tests/personalization/test_personalization_flow.py
.py
from onyx.configs.constants import FASTAPI_USERS_AUTH_COOKIE_NAME from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.managers.user import UserManager from tests.integration.common_utils.test_models import ...
115
4,135
onyx
backend/tests/integration/tests/llm_workflows/test_nightly_provider_chat_workflow.py
.py
import json import os import time from uuid import uuid4 import pytest from pydantic import BaseModel, ConfigDict from onyx.configs import app_configs from onyx.configs.constants import DocumentSource from onyx.tools.constants import SEARCH_TOOL_ID from tests.integration.common_utils.constants import API_SERVER_URL f...
462
15,871
onyx
backend/tests/integration/tests/llm_workflows/test_mock_llm_tool_calls.py
.py
from onyx.configs import app_configs from onyx.configs.constants import DocumentSource from onyx.tools.constants import SEARCH_TOOL_ID from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_utils.managers.chat import ChatSessionManager from tests.integration.common_utils...
126
4,891
onyx
backend/tests/integration/tests/llm_workflows/test_tool_policy_enforcement.py
.py
from onyx.configs import app_configs from onyx.configs.constants import DocumentSource from onyx.tools.constants import SEARCH_TOOL_ID from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_utils.managers.chat import ChatSessionManager from tests.integration.common_utils...
182
6,774
onyx
backend/tests/integration/tests/connector/test_connector_deletion.py
.py
""" This file contains tests for the following: - Ensuring deletion of a connector also: - deletes the documents in vespa for that connector - updates the document sets and user groups to remove the connector - Ensure that deleting a connector that is part of an overlapping document set and/or user group works ...
408
13,243
onyx
backend/tests/integration/tests/connector/test_connector_creation.py
.py
import os from datetime import datetime, timezone from onyx.connectors.models import InputType from onyx.server.documents.models import DocumentSource from tests.integration.common_utils.managers.cc_pair import CCPairManager from tests.integration.common_utils.managers.user import UserManager from tests.integration.co...
133
4,701
onyx
backend/tests/integration/tests/connector/test_last_indexed_time.py
.py
""" Integration tests for the "Last Indexed" time displayed on both the per-connector detail page and the all-connectors listing page. Expected behavior: "Last Indexed" = time_started of the most recent successful index attempt for the cc pair, regardless of pagination. Edge cases: 1. First page of index attempts is ...
234
8,717
onyx
backend/tests/integration/tests/llm_provider/test_llm_provider.py
.py
import uuid from typing import Any import httpx import pytest from onyx.llm.constants import LlmProviderNames from onyx.llm.model_capabilities import ( get_max_input_tokens, litellm_thinks_model_supports_image_input, model_is_reasoning_model, ) from onyx.llm.model_name_parser import parse_litellm_model_na...
2,326
85,729
onyx
backend/tests/integration/tests/llm_provider/test_llm_provider_persona_access.py
.py
""" Integration tests for LLM Provider persona access authorization. """ import os import pytest from onyx.llm.constants import LlmProviderNames from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.manage...
248
8,499
onyx
backend/tests/integration/tests/llm_provider/test_llm_provider_access_control.py
.py
import os import pytest from sqlalchemy import select from sqlalchemy.orm import Session from onyx.db.engine.sql_engine import get_session_with_current_tenant from onyx.db.llm import ( can_user_access_llm_provider, fetch_user_group_ids, update_default_provider, upsert_llm_provider, ) from onyx.db.mode...
545
17,549
onyx
backend/tests/integration/tests/llm_provider/test_provider_listing_cache.py
.py
""" Integration tests for the LLM provider listing cache. The listing endpoints are memoized in Redis (see onyx/server/manage/llm/provider_cache.py) with a long TTL, so mutations that change the payload must invalidate explicitly for edits to show up promptly. """ from tests.integration.common_utils.constants import ...
64
2,400
onyx
backend/tests/integration/tests/tags/test_tags.py
.py
from onyx.configs.constants import DocumentSource from onyx.connectors.models import InputType from onyx.db.engine.sql_engine import get_session_with_current_tenant from onyx.db.models import Document from onyx.db.tag import get_structured_tags_for_document from tests.integration.common_utils.managers.api_key import AP...
221
7,916
onyx
backend/tests/integration/tests/scim/test_scim_users.py
.py
"""Integration tests for SCIM user provisioning endpoints. Covers the full user lifecycle as driven by an IdP (Okta / Azure AD): 1. Create a user via POST /Users 2. Retrieve a user via GET /Users/{id} 3. List, filter, and paginate users via GET /Users 4. Replace a user via PUT /Users/{id} 5. Patch a user (deactivate/r...
569
19,570
onyx
backend/tests/integration/tests/scim/test_scim_groups.py
.py
"""Integration tests for SCIM group provisioning endpoints. Covers the full group lifecycle as driven by an IdP (Okta / Azure AD): 1. Create a group via POST /Groups 2. Retrieve a group via GET /Groups/{id} 3. List, filter, and paginate groups via GET /Groups 4. Replace a group via PUT /Groups/{id} 5. Patch a group (a...
699
23,978
onyx
backend/tests/integration/tests/scim/test_scim_tokens.py
.py
"""Integration tests for SCIM token management. Covers the admin token API and SCIM bearer-token authentication: 1. Token lifecycle: create, retrieve metadata, use for SCIM requests 2. Token rotation: creating a new token revokes previous tokens 3. Revoked tokens are rejected by SCIM endpoints 4. Non-admin users canno...
165
6,027
onyx
backend/tests/integration/tests/users/test_default_group_assignment.py
.py
"""Integration tests for default group assignment on user registration. Verifies that: - The first registered user is assigned to the Admin default group - Subsequent registered users are assigned to the Basic default group - account_type is set to STANDARD for email/password registrations """ from onyx.auth.schemas ...
79
3,166
onyx
backend/tests/integration/tests/users/test_slack_user_deactivation.py
.py
"""Integration tests for Slack user deactivation and reactivation via admin endpoints. Verifies that: - Slack users can be deactivated by admins - Deactivated Slack users can be reactivated by admins - Reactivation is blocked when the seat limit is reached """ from datetime import datetime, timedelta, timezone impor...
119
3,917
onyx
backend/tests/integration/tests/users/test_user_pagination.py
.py
from onyx.auth.schemas import UserRole from onyx.server.models import FullUserSnapshot from tests.integration.common_utils.managers.user import UserManager from tests.integration.common_utils.test_models import DATestUser # Gets a page of users from the db that match the given parameters and then # compares that retu...
168
5,886
onyx
backend/tests/integration/tests/users/test_seat_limit.py
.py
"""Integration tests for seat limit enforcement on user creation paths. Verifies that when a license with a seat limit is active, new user creation (registration, invite, reactivation) is blocked with HTTP 402. """ from datetime import datetime, timedelta, timezone import redis from ee.onyx.server.license.models im...
156
4,950
onyx
backend/tests/integration/tests/users/test_password_signup_upgrade.py
.py
"""Integration tests for password signup upgrade paths. Verifies that when a BOT or EXT_PERM_USER user signs up via email/password: - Their account_type is upgraded to STANDARD - They are assigned to the Basic default group - They gain the correct effective permissions """ import pytest from onyx.auth.schemas import...
136
4,737
onyx
backend/tests/integration/tests/users/test_reactivation_groups.py
.py
"""Integration tests for default group reconciliation on user reactivation. Verifies that: - A deactivated user retains default group membership after reactivation - Reactivation via the admin API reconciles missing group membership """ from tests.integration.common_utils.managers.user import UserManager from tests.i...
55
1,970
onyx
backend/tests/integration/tests/mobile_auth/test_mobile_sso_exchange.py
.py
"""Integration test for the mobile SSO code-exchange endpoint (PR 4). Exercises the real `/auth/mobile/sso/exchange` endpoint end-to-end: a real session token is stashed behind a one-time PKCE-bound code (as `complete_mobile_sso` would do), the app swaps the code for the token, the token authenticates `/me`, and repla...
57
2,246
onyx
backend/tests/integration/tests/mobile_auth/_helpers.py
.py
"""Shared helpers for the mobile-auth integration tests.""" import httpx from tests.integration.common_utils.constants import API_SERVER_URL, GENERAL_HEADERS from tests.integration.common_utils.http_client import client def mobile_login(email: str, password: str) -> httpx.Response: # Form-encoded credentials, e...
22
682
onyx
backend/tests/integration/tests/mobile_auth/test_mobile_bearer_auth.py
.py
"""Integration tests for the mobile bearer-token auth gateway (PR 1). Verifies that a native client can obtain / use / refresh / revoke the existing session token as a Bearer (Authorization header) instead of the web cookie, and that the web cookie flow is unaffected. """ from onyx.configs.constants import FASTAPI_US...
78
3,332
onyx
backend/tests/integration/tests/gateway_clients/test_codex_gateway.py
.py
"""Integration tests for the Codex CLI against the gateway's Responses API passthrough (ee.onyx.server.gateway.openai_passthrough). Test Suite: 1. test_basic_codex_turn - `codex exec` answers correctly through the gateway 2. test_encrypted_reasoning_statelessness - encrypted reasoning replay across turns, store forced...
181
5,982
onyx
backend/tests/integration/tests/gateway_clients/test_claude_code_gateway.py
.py
"""Integration tests for the Claude Code CLI against the gateway's Anthropic Messages API passthrough (ee.onyx.server.gateway.anthropic_passthrough). Test Suite: 1. test_basic_turn_answers_correctly - `claude -p` answers correctly through the gateway 2. test_tool_use_turn_replays_thinking - tool-use turn proves thinki...
175
6,279
onyx
backend/tests/integration/tests/gateway_clients/conftest.py
.py
"""Fixtures for gateway client integration tests. These tests drive REAL coding-agent CLIs (Claude Code, Codex) against the gateway's Anthropic/OpenAI passthrough endpoints. Unlike the rest of tests/integration, the request is made by an external subprocess, not by this test process, so the in-process FastAPI TestClie...
305
10,702
onyx
backend/tests/integration/tests/llm/test_bedrock_auth.py
.py
"""Integration coverage for `/admin/llm/test` against AWS Bedrock. The Onyx admin UI calls this endpoint when a user clicks "Test" on the Bedrock provider page; if the credentials are wrong the UI surfaces the response body verbatim. This test pins the contract: - HTTP 400 when Bedrock rejects the credentials, AND - ...
52
1,886
onyx
backend/tests/integration/tests/no_vectordb/test_no_vectordb_chat.py
.py
"""Integration tests for chat in no-vector-DB mode. Covers: - Uploading a file to a project, sending a chat message, and verifying the LLM receives the file content (small project β€” fits in context window). - Creating a persona with user_files and verifying chat works. - Verifying that persona creation with document...
230
8,166
onyx
backend/tests/integration/tests/no_vectordb/test_no_vectordb_endpoints.py
.py
"""Integration tests for endpoint gating when DISABLE_VECTOR_DB is set. Vector-DB-dependent endpoints should return HTTP 501. Non-dependent endpoints (settings, document sets, chat, etc.) should work normally. """ from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils....
162
4,415
onyx
backend/tests/integration/tests/no_vectordb/test_no_vectordb_file_lifecycle.py
.py
"""Integration test for the full user-file lifecycle in no-vector-DB mode. Covers: upload β†’ COMPLETED β†’ unlink from project β†’ delete β†’ gone. The entire lifecycle is handled by FastAPI BackgroundTasks (no Celery workers needed). The conftest-level ``pytestmark`` ensures these tests are skipped when the server is runn...
157
5,567
onyx
backend/tests/integration/tests/no_vectordb/conftest.py
.py
"""Fixtures for no-vector-DB integration tests. These tests are intended to run against an Onyx deployment started with DISABLE_VECTOR_DB=true. They are automatically **skipped** when the env var is unset. """ import os import pytest from tests.integration.common_utils.managers.llm_provider import LLMProviderManage...
31
1,127
onyx
backend/tests/integration/tests/mcp_oauth/test_mcp_oauth_cimd_integration.py
.py
"""Verify CIMD-only OAuth through Onyx API endpoints and a protected MCP server.""" from urllib.parse import parse_qs, urlparse import httpx from onyx.db.enums import ( MCPAuthenticationPerformer, MCPAuthenticationType, MCPOAuthProviderMode, MCPTransport, ) from tests.integration.common_utils.cimd_oa...
187
6,415
onyx
backend/tests/integration/tests/mcp_oauth/conftest.py
.py
"""Test-owned HTTPS proxy and OAuth service fixtures for CIMD.""" from __future__ import annotations import ipaddress import os import socket import subprocess import sys import threading import time from collections.abc import Generator from datetime import UTC, datetime, timedelta from pathlib import Path import h...
304
9,526
onyx
backend/tests/integration/tests/tools/test_image_generation_streaming.py
.py
""" Integration test for image generation heartbeat streaming through the /send-message API. This test verifies that heartbeat packets are properly streamed through the complete API flow. """ import time import pytest from onyx.server.query_and_chat.streaming_models import StreamingType from onyx.tools.tool_implemen...
95
3,681
onyx
backend/tests/integration/tests/tools/test_force_tool_use.py
.py
""" Integration test for forced tool use to verify that web_search can be forced. This test verifies that forcing a tool use works through the complete API flow. """ import pytest from sqlalchemy import select from onyx.db.engine.sql_engine import get_session_with_current_tenant from onyx.db.models import Tool from t...
59
2,054
onyx
backend/tests/integration/tests/code_interpreter/test_code_interpreter_api.py
.py
from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.test_models import DATestUser CODE_INTERPRETER_URL = f"{API_SERVER_URL}/admin/code-interpreter" CODE_INTERPRETER_HEALTH_URL = f"{CODE_INTERPRETER_URL}/he...
99
2,890
onyx
backend/tests/integration/tests/code_interpreter/conftest.py
.py
from collections.abc import Generator import pytest from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.test_models import DATestUser CODE_INTERPRETER_URL = f"{API_SERVER_URL}/admin/code-interpreter" @...
33
953
onyx
backend/tests/integration/tests/craft/test_file_ops_api.py
.py
"""File ops security boundary tests (HTTP boundary half).""" from __future__ import annotations from urllib.parse import quote from uuid import UUID import pytest from onyx.server.features.build.sandbox.factory import get_sandbox_manager from tests.integration.common_utils.constants import API_SERVER_URL from tests...
331
9,973
onyx
backend/tests/integration/tests/craft/test_messages_api.py
.py
"""Interactive Craft turn API tests against a real sandbox.""" from __future__ import annotations from uuid import UUID, uuid4 from tests.integration.common_utils.constants import API_SERVER_URL from tests.integration.common_utils.http_client import client from tests.integration.common_utils.managers.build_session i...
106
3,226
onyx
backend/tests/integration/tests/craft/webapp_preview.py
.py
"""Shared helpers for webapp-preview tests. The proxy contracts these pin (Origin/Sec-Fetch header stripping, basePath serving) must hold identically on every sandbox backend, so the k8s and docker suites assert them through this single implementation. Provisioning is lazy β€” setup only writes ``start-webapp.sh`` β€” so...
164
5,844