Protect private API routes and scope agent data

This commit is contained in:
Hamza Ayed
2026-10-03 00:34:49 +03:00
parent 1c1f662850
commit b0cd825838
17 changed files with 313 additions and 95 deletions
@@ -9,10 +9,9 @@ if "SOVEREIGNAI_DATA_DIR" not in os.environ:
_TEST_DATA_DIR = tempfile.TemporaryDirectory(prefix="sovereignai-mixed-pdf-index-tests-")
os.environ["SOVEREIGNAI_DATA_DIR"] = _TEST_DATA_DIR.name
from fastapi.testclient import TestClient
from app import database, knowledge
from app.main import app
from tests.api_client import authenticated_client
from tests.test_pdf_analysis import make_mixed_pdf
@@ -25,7 +24,6 @@ class MixedPdfKnowledgeIntegrationTests(unittest.TestCase):
pdf_path = workspace / "mixed.pdf"
pdf_path.write_bytes(make_mixed_pdf())
database_path = data_dir / "mixed-pdf-knowledge.sqlite3"
client = TestClient(app)
ocr = {
"engine": "easyocr-local-ar-en",
"text": "ScannedIndexMarker ArabicPageText",
@@ -45,6 +43,7 @@ class MixedPdfKnowledgeIntegrationTests(unittest.TestCase):
):
database.initialize_database()
knowledge.initialize()
client = authenticated_client(app)
with patch("app.main.recognize_image_text", return_value=ocr):
indexed = client.post(
"/v1/agent/knowledge/index",