test: hard-fail the suite when the tenant resolves to production
Session-scoped autouse guard in tests/conftest.py refuses to run any test (pytest.exit, returncode 1) when the effective tenant resolves to the production tenant jpmschweitzer - the same guard library-desk applies on its side. _initialize_app now depends on the guard so the refusal happens before any initialization. Suite-level assertions pin that the live session runs under the llm_tester namespaces: Qdrant memories_llm_tester collection and Redis session:llm_tester:* keys. The biographer/memory unit tests already run fully mocked (no shared-service writes); the e2e isolation tests already used llm_tester - their constants now derive from the shared TEST_TENANT/PRODUCTION_TENANT config constants so a drift fails loudly instead of silently splitting. Verified: ENVIRONMENT=production pytest run exits 1 with the TENANT GUARD message and zero tests executed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,12 +26,18 @@ from typing import AsyncGenerator
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
from src.core.config import PRODUCTION_TENANT, TEST_TENANT
|
||||
|
||||
# Test configuration
|
||||
BASE_URL = "http://localhost:8777"
|
||||
QDRANT_URL = "http://localhost:6333"
|
||||
API_TIMEOUT = 120.0 # LLM calls can be slow
|
||||
TEST_USER = "llm_tester"
|
||||
# All e2e writes to shared services go to the reserved test tenant's
|
||||
# namespaces (Qdrant memories_llm_tester, wiki llm_tester scope) - never
|
||||
# the production tenant's.
|
||||
TEST_USER = TEST_TENANT
|
||||
TEST_COLLECTION = f"memories_{TEST_USER}"
|
||||
assert TEST_USER != PRODUCTION_TENANT
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -986,7 +992,7 @@ class TestUserContextIsolation:
|
||||
in_test_collection = any(unique_value in v for v in test_values)
|
||||
|
||||
# Check production collection (should NOT be there)
|
||||
prod_collection = "memories_jpmschweitzer"
|
||||
prod_collection = f"memories_{PRODUCTION_TENANT}"
|
||||
if await qdrant.collection_exists(prod_collection):
|
||||
prod_points = await qdrant.scroll_points(prod_collection)
|
||||
prod_values = [str(p.get("payload", {})) for p in prod_points]
|
||||
|
||||
Reference in New Issue
Block a user