sync update from LAN repo (source dhk-1 @ 3e87be55)
This commit is contained in:
1 parent
ab6068a7c1
commit
42f2a26fa8
1482 files changed
+227759
-9584
No files matched your search
@@ -0,0 +1,58 @@
|
||||
"""Regression tests for self-contained API documentation pages."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.gateway import config as gateway_config
|
||||
from app.gateway.app import create_app
|
||||
|
||||
|
||||
def test_config_yaml_docs_switch_overrides_stale_legacy_environment(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.setenv("GATEWAY_ENABLE_DOCS", "false")
|
||||
monkeypatch.setattr(gateway_config, "_gateway_config", None)
|
||||
monkeypatch.setattr(
|
||||
gateway_config,
|
||||
"get_app_config",
|
||||
lambda: SimpleNamespace(gateway=SimpleNamespace(enable_docs=True)),
|
||||
)
|
||||
|
||||
assert gateway_config.get_gateway_config().enable_docs is True
|
||||
|
||||
|
||||
def test_docs_and_redoc_use_vendored_assets_behind_proxy_prefix(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Docs must not need internet access and must retain a reverse-proxy prefix."""
|
||||
monkeypatch.setenv("GATEWAY_ENABLE_DOCS", "true")
|
||||
monkeypatch.setattr(gateway_config, "_gateway_config", None)
|
||||
app = create_app()
|
||||
|
||||
with TestClient(app, root_path="/deerflow") as client:
|
||||
swagger = client.get("/deerflow/docs")
|
||||
redoc = client.get("/deerflow/redoc")
|
||||
swagger_bundle = client.get("/deerflow/docs/static/swagger-ui-bundle.js")
|
||||
redoc_bundle = client.get("/deerflow/docs/static/redoc.standalone.js")
|
||||
openapi = client.get("/deerflow/openapi.json")
|
||||
|
||||
assert swagger.status_code == 200
|
||||
assert "./docs/static/swagger-ui-bundle.js" in swagger.text
|
||||
assert "./docs/static/swagger-ui.css" in swagger.text
|
||||
assert "url: './openapi.json'" in swagger.text
|
||||
assert "https://" not in swagger.text
|
||||
|
||||
assert redoc.status_code == 200
|
||||
assert "./docs/static/redoc.standalone.js" in redoc.text
|
||||
assert "./openapi.json" in redoc.text
|
||||
assert "https://" not in redoc.text
|
||||
|
||||
assert swagger_bundle.status_code == 200
|
||||
assert swagger_bundle.headers["content-type"].startswith("text/javascript")
|
||||
assert redoc_bundle.status_code == 200
|
||||
assert redoc_bundle.headers["content-type"].startswith("text/javascript")
|
||||
assert openapi.status_code == 200
|
||||
Reference in new issue
Block a user