sync update from LAN repo (source dhk-1 @ 3b1ec5b4)
This commit is contained in:
1 parent
da6521b6cb
commit
264e2200d6
995 files changed
+148105
-13399
No files matched your search
@@ -181,7 +181,8 @@ def test_configured_weknora_address_enables_weknora_mode() -> None:
|
||||
assert runtime.admin_password == "secret"
|
||||
|
||||
|
||||
def test_default_weknora_client_is_reused_for_the_same_runtime() -> None:
|
||||
@pytest.mark.asyncio
|
||||
async def test_default_weknora_client_is_reused_on_the_same_event_loop() -> None:
|
||||
runtime = resolve_llmwiki_runtime(
|
||||
LlmWikiConfig.model_validate(
|
||||
{
|
||||
@@ -200,6 +201,30 @@ def test_default_weknora_client_is_reused_for_the_same_runtime() -> None:
|
||||
assert second is first
|
||||
|
||||
|
||||
def test_default_weknora_client_is_isolated_between_event_loops() -> None:
|
||||
runtime = resolve_llmwiki_runtime(
|
||||
LlmWikiConfig.model_validate(
|
||||
{
|
||||
"weknora": {
|
||||
"api_base_url": "http://loop-local-weknora.test:8080",
|
||||
"admin_email": "admin@example.test",
|
||||
"admin_password": "secret",
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
async def build_pair() -> tuple[WeKnoraClient, WeKnoraClient]:
|
||||
return build_weknora_client(runtime), build_weknora_client(runtime)
|
||||
|
||||
first_loop_pair = asyncio.run(build_pair())
|
||||
second_loop_pair = asyncio.run(build_pair())
|
||||
|
||||
assert first_loop_pair[0] is first_loop_pair[1]
|
||||
assert second_loop_pair[0] is second_loop_pair[1]
|
||||
assert first_loop_pair[0] is not second_loop_pair[0]
|
||||
|
||||
|
||||
def test_runtime_override_can_force_legacy_or_reset_to_file() -> None:
|
||||
config = LlmWikiConfig.model_validate({"weknora": {"api_base_url": "http://weknora:8080"}})
|
||||
|
||||
@@ -386,14 +411,27 @@ async def test_weknora_session_endpoint_preserves_reverse_proxy_prefix(monkeypat
|
||||
response = await llmwiki_router.create_weknora_detail_session(
|
||||
_request(
|
||||
"/api/llmwiki/knowledge-bases/local-kb/weknora/session",
|
||||
request_headers={"X-Forwarded-Prefix": "/deerflow"},
|
||||
request_headers={"X-Forwarded-Prefix": "/deerflow-api/"},
|
||||
),
|
||||
"local-kb",
|
||||
tab="wiki",
|
||||
)
|
||||
|
||||
payload = json.loads(response.body)
|
||||
assert payload["frame_path"] == "/deerflow/platform/knowledge-bases/remote-kb?tab=wiki"
|
||||
assert payload["frame_path"] == "/deerflow-api/platform/knowledge-bases/remote-kb?tab=wiki"
|
||||
set_cookie_headers = [value.decode("latin-1") for key, value in response.raw_headers if key.lower() == b"set-cookie"]
|
||||
assert any("Path=/deerflow-api" in value for value in set_cookie_headers)
|
||||
|
||||
|
||||
def test_weknora_public_prefix_rejects_protocol_relative_header() -> None:
|
||||
from app.gateway.routers import llmwiki as llmwiki_router
|
||||
|
||||
request = _request(
|
||||
"/api/llmwiki/knowledge-bases/local-kb/weknora/session",
|
||||
request_headers={"X-Forwarded-Prefix": "//untrusted.example"},
|
||||
)
|
||||
|
||||
assert llmwiki_router._request_public_prefix(request) == "/deerflow"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -785,6 +823,32 @@ async def test_weknora_client_resolves_default_embedding_model_inside_weknora()
|
||||
assert created["id"] == "kb-created"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_wiki_create_reuses_catalog_models_without_debug_probe() -> None:
|
||||
requests: list[tuple[str, str, dict[str, object]]] = []
|
||||
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
payload = json.loads(request.content) if request.content else {}
|
||||
requests.append((request.method, request.url.path, payload))
|
||||
assert request.method == "POST"
|
||||
assert request.url.path == "/api/v1/knowledge-bases"
|
||||
return httpx.Response(201, json={"success": True, "data": {"id": "wiki-created", "name": "Wiki"}})
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
|
||||
await client.create_knowledge_base(
|
||||
name="Wiki",
|
||||
embedding_model_id="embedding-id",
|
||||
knowledge_qa_model_id="qa-id",
|
||||
wiki_enabled=True,
|
||||
)
|
||||
|
||||
assert len(requests) == 1
|
||||
assert requests[0][2]["embedding_model_id"] == "embedding-id"
|
||||
assert requests[0][2]["summary_model_id"] == "qa-id"
|
||||
assert requests[0][2]["wiki_config"]["synthesis_model_id"] == "qa-id"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_gateway_lists_safe_embedding_models_and_uses_explicit_selection(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
@@ -825,6 +889,7 @@ async def test_gateway_lists_safe_embedding_models_and_uses_explicit_selection(
|
||||
"status": "inactive",
|
||||
},
|
||||
{"id": "chat-one", "type": "LLM", "name": "chat"},
|
||||
{"id": "qa-default", "type": "KnowledgeQA", "name": "wiki-answer", "status": "active", "is_default": True},
|
||||
]
|
||||
|
||||
async def create_knowledge_base(self, **kwargs: object) -> dict[str, object]:
|
||||
@@ -867,7 +932,6 @@ async def test_gateway_lists_safe_embedding_models_and_uses_explicit_selection(
|
||||
llmwiki_router.KnowledgeBaseCreate(
|
||||
name="OpenAI docs",
|
||||
embedding_model_id="embed-openai",
|
||||
wiki_enabled=True,
|
||||
wiki_config=llmwiki_router.WikiGenerationInstructions(
|
||||
content_instructions="按事件时间线生成页面",
|
||||
extraction_instructions="重点提取人物和组织关系",
|
||||
@@ -876,9 +940,16 @@ async def test_gateway_lists_safe_embedding_models_and_uses_explicit_selection(
|
||||
)
|
||||
|
||||
assert create_calls[0]["embedding_model_id"] == "embed-openai"
|
||||
assert create_calls[0]["knowledge_qa_model_id"] == "qa-default"
|
||||
assert create_calls[0]["wiki_enabled"] is True
|
||||
assert create_calls[0]["wiki_content_instructions"] == "按事件时间线生成页面"
|
||||
assert create_calls[0]["wiki_extraction_instructions"] == "重点提取人物和组织关系"
|
||||
assert created["embedding_model_id"] == "embed-openai"
|
||||
assert created["retrieval_settings"] == {
|
||||
"entity_expansion_enabled": True,
|
||||
"max_related_terms": 6,
|
||||
"statistics_enabled": True,
|
||||
}
|
||||
|
||||
for rejected_model_id in ("embed-disabled", "chat-one", "missing"):
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
@@ -911,6 +982,19 @@ async def test_gateway_forwards_wiki_instructions_on_knowledge_base_edit(
|
||||
}
|
||||
|
||||
class Client:
|
||||
async def get_knowledge_base(
|
||||
self,
|
||||
knowledge_base_id: str,
|
||||
) -> dict[str, object]:
|
||||
return {
|
||||
"id": knowledge_base_id,
|
||||
"name": row["name"],
|
||||
"description": row["description"],
|
||||
"type": "document",
|
||||
"indexing_strategy": {"wiki_enabled": True},
|
||||
"wiki_config": {},
|
||||
}
|
||||
|
||||
async def update_knowledge_base(
|
||||
self,
|
||||
knowledge_base_id: str,
|
||||
@@ -927,8 +1011,12 @@ async def test_gateway_forwards_wiki_instructions_on_knowledge_base_edit(
|
||||
}
|
||||
|
||||
class Store:
|
||||
async def update_mapping(self, *_: object, **__: object) -> dict[str, object]:
|
||||
return row
|
||||
async def update_mapping(
|
||||
self,
|
||||
*_: object,
|
||||
**changes: object,
|
||||
) -> dict[str, object]:
|
||||
return {**row, **changes}
|
||||
|
||||
async def authorized_mapping(*_: object, **__: object) -> tuple[dict[str, object], str, bool]:
|
||||
return row, "user-a", False
|
||||
@@ -959,7 +1047,11 @@ async def test_gateway_forwards_wiki_instructions_on_knowledge_base_edit(
|
||||
},
|
||||
)
|
||||
]
|
||||
assert updated["wiki_config"] == forwarded[0][1]["wiki_config"]
|
||||
assert updated["wiki_config"]["content_instructions"] == "正式、简洁,保留关键数字"
|
||||
assert updated["wiki_config"]["extraction_instructions"] == "优先人物、组织和时间线"
|
||||
assert updated["wiki_config"]["wiki_config_schema_version"] == 3
|
||||
assert updated["wiki_config"]["wiki_config_revision"] == 1
|
||||
assert updated["wiki_config"]["apply_status"] == "active"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -1001,6 +1093,11 @@ async def test_weknora_client_creates_wiki_with_weknora_owned_models() -> None:
|
||||
]
|
||||
},
|
||||
)
|
||||
if request.url.path == "/api/v1/models/qa-one/debug":
|
||||
assert request.method == "POST"
|
||||
assert request.headers["content-type"].startswith("multipart/form-data;")
|
||||
assert b"Reply with OK." in request.content
|
||||
return httpx.Response(200, json={"data": {"ok": True, "elapsed_ms": 12}})
|
||||
payload = json.loads(request.content)
|
||||
assert payload["embedding_model_id"] == "embed-one"
|
||||
assert payload["summary_model_id"] == "qa-one"
|
||||
@@ -1028,6 +1125,181 @@ async def test_weknora_client_creates_wiki_with_weknora_owned_models() -> None:
|
||||
assert model_reads == 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_prefers_a_healthy_explicit_knowledge_qa_default() -> None:
|
||||
attempts: list[str] = []
|
||||
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
if request.method == "GET" and request.url.path == "/api/v1/models":
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"data": [
|
||||
{
|
||||
"id": "alphabetical-fallback",
|
||||
"name": "Alpha",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
"is_default": False,
|
||||
},
|
||||
{
|
||||
"id": "configured-default",
|
||||
"name": "Zulu",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
"is_default": True,
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
attempts.append(request.url.path)
|
||||
return httpx.Response(200, json={"data": {"ok": True}})
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
|
||||
model_id = await client.get_default_knowledge_qa_model_id()
|
||||
|
||||
assert model_id == "configured-default"
|
||||
assert attempts == ["/api/v1/models/configured-default/debug"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_uses_a_stable_healthy_knowledge_qa_fallback() -> None:
|
||||
attempts: list[str] = []
|
||||
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
if request.method == "GET" and request.url.path == "/api/v1/models":
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"data": [
|
||||
{
|
||||
"id": "healthy-zulu",
|
||||
"display_name": "Zulu",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
"is_default": False,
|
||||
},
|
||||
{
|
||||
"id": "inactive-alpha",
|
||||
"display_name": "Alpha",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "inactive",
|
||||
"is_default": False,
|
||||
},
|
||||
{
|
||||
"id": "disabled-beta",
|
||||
"display_name": "Beta",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
"is_default": False,
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
attempts.append(request.url.path)
|
||||
ok = request.url.path.endswith("/healthy-zulu/debug")
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={"data": {"ok": ok, "error": "Model disabled." if not ok else ""}},
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
|
||||
model_id = await client.get_default_knowledge_qa_model_id()
|
||||
|
||||
assert model_id == "healthy-zulu"
|
||||
assert attempts == [
|
||||
"/api/v1/models/disabled-beta/debug",
|
||||
"/api/v1/models/healthy-zulu/debug",
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_rejects_wiki_creation_when_no_knowledge_qa_model_is_usable() -> None:
|
||||
knowledge_base_creates = 0
|
||||
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
nonlocal knowledge_base_creates
|
||||
if request.method == "GET" and request.url.path == "/api/v1/models":
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"data": [
|
||||
{"id": "embed-one", "type": "Embedding", "is_default": True},
|
||||
{
|
||||
"id": "disabled-alpha",
|
||||
"display_name": "Alpha disabled",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
"is_default": False,
|
||||
},
|
||||
{
|
||||
"id": "broken-zulu",
|
||||
"display_name": "Zulu broken",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
"is_default": False,
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
if request.url.path == "/api/v1/models/disabled-alpha/debug":
|
||||
return httpx.Response(200, json={"data": {"ok": False, "error": "Model disabled."}})
|
||||
if request.url.path == "/api/v1/models/broken-zulu/debug":
|
||||
return httpx.Response(200, json={"data": {"ok": False, "error": "Provider rejected the model."}})
|
||||
knowledge_base_creates += 1
|
||||
return httpx.Response(201, json={"data": {"id": "must-not-be-created"}})
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
|
||||
with pytest.raises(WeKnoraError) as raised:
|
||||
await client.create_knowledge_base(name="Wiki", wiki_enabled=True)
|
||||
|
||||
assert raised.value.status_code == 400
|
||||
assert "Zulu broken, Alpha disabled" in str(raised.value)
|
||||
assert "working default model" in str(raised.value)
|
||||
assert knowledge_base_creates == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_preserves_model_debug_service_failures() -> None:
|
||||
attempts: list[str] = []
|
||||
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
if request.method == "GET" and request.url.path == "/api/v1/models":
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"data": [
|
||||
{
|
||||
"id": "alpha",
|
||||
"name": "Alpha",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"id": "zulu",
|
||||
"name": "Zulu",
|
||||
"type": "KnowledgeQA",
|
||||
"status": "active",
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
attempts.append(request.url.path)
|
||||
return httpx.Response(503, json={"message": "model debug service unavailable"})
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
|
||||
with pytest.raises(WeKnoraError) as raised:
|
||||
await client.get_default_knowledge_qa_model_id()
|
||||
|
||||
assert raised.value.status_code == 502
|
||||
assert str(raised.value) == "model debug service unavailable"
|
||||
assert attempts == ["/api/v1/models/alpha/debug"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_ignores_wiki_instructions_when_wiki_is_disabled() -> None:
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
@@ -1084,6 +1356,44 @@ async def test_weknora_client_imports_url_manual_content_and_lists_wiki_pages()
|
||||
assert pages["pages"][0]["slug"] == "guide"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_uses_native_wiki_regex_search_contract() -> None:
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
assert request.method == "GET"
|
||||
assert request.url.path == "/api/v1/knowledgebase/kb-one/wiki/search"
|
||||
assert request.url.params["q"] == "火炬|开幕|闭幕"
|
||||
# WeKnora v0.7.2 caps the endpoint at 50.
|
||||
assert request.url.params["limit"] == "50"
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"pages": [
|
||||
{
|
||||
"slug": "games/timeline",
|
||||
"title": "赛事时间线",
|
||||
"content": "火炬传递、开幕和闭幕安排。",
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
|
||||
pages = await client.search_wiki_pages(
|
||||
"kb-one",
|
||||
"火炬|开幕|闭幕",
|
||||
limit=500,
|
||||
)
|
||||
|
||||
assert pages == [
|
||||
{
|
||||
"slug": "games/timeline",
|
||||
"title": "赛事时间线",
|
||||
"content": "火炬传递、开幕和闭幕安排。",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weknora_client_reads_ordered_wiki_index_groups() -> None:
|
||||
async def handler(request: httpx.Request) -> httpx.Response:
|
||||
@@ -1417,7 +1727,11 @@ async def test_listing_conversation_deposit_refreshes_remote_description(monkeyp
|
||||
monkeypatch.setattr(llmwiki_router, "_store", lambda _: store)
|
||||
monkeypatch.setattr(llmwiki_router, "_client_or_503", lambda: Client())
|
||||
|
||||
payload = await llmwiki_router.list_knowledge_bases(object(), scope="public")
|
||||
payload = await llmwiki_router.list_knowledge_bases(
|
||||
object(),
|
||||
scope="public",
|
||||
refresh=True,
|
||||
)
|
||||
|
||||
assert payload["knowledge_bases"][0]["description"] == llmwiki_deposit.CONVERSATION_DEPOSIT_KB_DESCRIPTION
|
||||
assert "DeerFlow" not in json.dumps(payload, ensure_ascii=False)
|
||||
@@ -1447,6 +1761,47 @@ def test_conversation_deposit_history_hides_legacy_brand() -> None:
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_agent_bound_knowledge_base_list_uses_local_mapping_only(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app.gateway.routers import llmwiki as llmwiki_router
|
||||
from deerflow.persistence.agents import MemoryAgentStore
|
||||
from deerflow.persistence.llmwiki import MemoryLlmWikiStore
|
||||
|
||||
store = MemoryLlmWikiStore()
|
||||
mapping = await store.create_mapping(
|
||||
weknora_id="remote-agent-kb",
|
||||
owner_user_id="user-a",
|
||||
name="本地目录缓存",
|
||||
description="",
|
||||
kb_type="document",
|
||||
)
|
||||
agent_store = MemoryAgentStore()
|
||||
await agent_store.ensure_builtin({"id": "agent-a", "name": "Agent A", "published": True})
|
||||
|
||||
async def actor(_: object) -> tuple[str, bool]:
|
||||
return "user-a", False
|
||||
|
||||
monkeypatch.setattr(llmwiki_router, "_actor", actor)
|
||||
monkeypatch.setattr(llmwiki_router, "_store", lambda _: store)
|
||||
monkeypatch.setattr(llmwiki_router, "get_agent_store", lambda _: agent_store)
|
||||
monkeypatch.setattr(
|
||||
llmwiki_router,
|
||||
"load_agent_config",
|
||||
lambda _agent_id: SimpleNamespace(llmwiki_knowledge_base_ids=[mapping["id"]]),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
llmwiki_router,
|
||||
"_client_or_503",
|
||||
lambda: (_ for _ in ()).throw(AssertionError("normal listing must not call WeKnora")),
|
||||
)
|
||||
|
||||
payload = await llmwiki_router.list_agent_knowledge_bases(object(), "agent-a")
|
||||
assert [item["id"] for item in payload["knowledge_bases"]] == [mapping["id"]]
|
||||
assert payload["knowledge_bases"][0]["remote_status"] == "cached"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_knowledge_bases_personal_scope_filters_to_actor_for_admin(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from app.gateway.routers import llmwiki as llmwiki_router
|
||||
@@ -1758,7 +2113,7 @@ async def test_prefixed_weknora_proxy_serves_page_static_assets_and_api_without_
|
||||
if path == "/platform/knowledge-bases/remote-kb":
|
||||
return httpx.Response(
|
||||
200,
|
||||
text=('<html><head><script src="/assets/main.js"></script><link rel="stylesheet" href="css/app.css"><script src="/config.js"></script></head><body></body></html>'),
|
||||
text=('<html><head><script src="/assets/main.js"></script><link rel="stylesheet" href="css/app.css"><script src="/config.js"></script><script src="runtime-config.js"></script></head><body></body></html>'),
|
||||
headers={"content-type": "text/html; charset=utf-8"},
|
||||
)
|
||||
if path == "/assets/main.js":
|
||||
@@ -1773,7 +2128,7 @@ async def test_prefixed_weknora_proxy_serves_page_static_assets_and_api_without_
|
||||
text='@font-face{src:url("/fonts/app.woff2")}',
|
||||
headers={"content-type": "text/css"},
|
||||
)
|
||||
if path in {"/config.js", "/static/chunk.js", "/assets/deep.js"}:
|
||||
if path in {"/config.js", "/runtime-config.js", "/static/chunk.js", "/assets/deep.js"}:
|
||||
return httpx.Response(200, text=f'window.loaded="{path}"', headers={"content-type": "application/javascript"})
|
||||
if path == "/fonts/app.woff2":
|
||||
return httpx.Response(200, content=b"font", headers={"content-type": "font/woff2"})
|
||||
@@ -1812,6 +2167,18 @@ async def test_prefixed_weknora_proxy_serves_page_static_assets_and_api_without_
|
||||
assert 'src="/deerflow/assets/main.js"' in page.text
|
||||
assert 'href="/deerflow/css/app.css"' in page.text
|
||||
assert 'src="/deerflow/config.js"' in page.text
|
||||
assert 'src="/deerflow/runtime-config.js"' in page.text
|
||||
|
||||
# The release Nginx strips /deerflow-api before forwarding and tells
|
||||
# the Gateway which public prefix to put back into iframe asset URLs.
|
||||
release_page = await client.get(
|
||||
"/platform/knowledge-bases/remote-kb?tab=wiki",
|
||||
headers={"X-Forwarded-Prefix": "/deerflow-api"},
|
||||
)
|
||||
assert release_page.status_code == 200
|
||||
assert 'src="/deerflow-api/assets/main.js"' in release_page.text
|
||||
assert 'href="/deerflow-api/css/app.css"' in release_page.text
|
||||
assert '"apiPrefix":"/deerflow-api/api/llmwiki/weknora-embed"' in release_page.text
|
||||
|
||||
script = await client.get("/deerflow/assets/main.js")
|
||||
assert script.status_code == 200
|
||||
@@ -1828,6 +2195,8 @@ async def test_prefixed_weknora_proxy_serves_page_static_assets_and_api_without_
|
||||
|
||||
for path in (
|
||||
"/deerflow/config.js",
|
||||
"/deerflow/runtime-config.js",
|
||||
"/deerflow/platform/knowledge-bases/runtime-config.js",
|
||||
"/deerflow/static/chunk.js",
|
||||
"/deerflow/fonts/app.woff2",
|
||||
"/deerflow/platform/knowledge-bases/remote-kb/assets/deep.js",
|
||||
|
||||
Reference in new issue
Block a user