mirror of
https://github.com/TencentCloud/Octop.git
synced 2026-09-28 19:33:02 +08:00
Separate instance KB toggle from page CRUD with knowledge_settings, probe embedding endpoints correctly, and polish ONNX download/settings UX. Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""HTTP ACL for knowledge-base instance settings vs page CRUD."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from tests.support.auth import create_user
|
|
|
|
|
|
async def test_feature_toggle_requires_knowledge_settings(env: Any) -> None:
|
|
client, _server, admin_auth = env
|
|
page_auth = await create_user(client, admin_auth, username="kb_page_user")
|
|
denied = await client.put(
|
|
"/api/knowledge-bases/feature",
|
|
headers=page_auth,
|
|
json={"enabled": False},
|
|
)
|
|
assert denied.status_code == 403, denied.text
|
|
assert denied.json()["error"]["code"] == "FORBIDDEN"
|
|
|
|
settings_auth = await create_user(
|
|
client,
|
|
admin_auth,
|
|
username="kb_settings_user",
|
|
permissions=["knowledge_bases", "knowledge_settings"],
|
|
)
|
|
allowed = await client.put(
|
|
"/api/knowledge-bases/feature",
|
|
headers=settings_auth,
|
|
json={"enabled": False},
|
|
)
|
|
assert allowed.status_code == 200, allowed.text
|
|
assert allowed.json()["feature_enabled"] is False
|
|
|
|
|
|
async def test_embedding_options_require_knowledge_settings(env: Any) -> None:
|
|
client, _server, admin_auth = env
|
|
page_auth = await create_user(client, admin_auth, username="kb_options_user")
|
|
denied = await client.get("/api/knowledge-bases/embedding-options", headers=page_auth)
|
|
assert denied.status_code == 403, denied.text
|
|
|
|
settings_auth = await create_user(
|
|
client,
|
|
admin_auth,
|
|
username="kb_options_admin",
|
|
permissions=["knowledge_settings"],
|
|
)
|
|
allowed = await client.get("/api/knowledge-bases/embedding-options", headers=settings_auth)
|
|
assert allowed.status_code == 200, allowed.text
|
|
assert "onnx" in allowed.json()
|