فهرست منبع

test(配置安全): 覆盖相对资源路径与数据库隔离

验证 Settings 从项目根解析相对路径,同时继续隐藏 DSN 并约束生产数据库账号分离。确保可移植 legacy-inputs 配置不会削弱既有敏感信息保护。
SamLee 15 ساعت پیش
والد
کامیت
71d14ccdbd
1فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  1. 21 1
      script_build_host/tests/test_canonical_security.py

+ 21 - 1
script_build_host/tests/test_canonical_security.py

@@ -10,7 +10,7 @@ from pydantic import ValidationError
 from script_build_host.domain.digests import Sha256Digest
 from script_build_host.domain.errors import ProtocolViolation, UnsafeOutboundTarget
 from script_build_host.infrastructure.canonical_json import canonical_json_text, canonical_sha256
-from script_build_host.infrastructure.config import ScriptBuildSettings
+from script_build_host.infrastructure.config import PROJECT_ROOT, ScriptBuildSettings
 from script_build_host.infrastructure.outbound import OutboundPolicy
 from script_build_host.infrastructure.redaction import redact, redact_text
 
@@ -83,6 +83,26 @@ def test_settings_hide_dsns_and_enforce_production_user_separation(tmp_path: Pat
         )
 
 
+def test_settings_resolve_relative_paths_from_project_root(
+    tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+    monkeypatch.chdir(tmp_path)
+    settings = _settings(
+        Path(".local/agent-data"),
+        persona_root=Path(".local/legacy-inputs/persona"),
+        section_pattern_root=Path(".local/legacy-inputs/sections"),
+        decode_index_root=Path(".local/legacy-inputs/decode/index"),
+        decode_raw_root=Path(".local/legacy-inputs/decode/raw"),
+        knowledge_root=Path(".local/legacy-inputs/knowledge/knowledge.json"),
+        prompt_fallback_root=Path("src/script_build_host/agents/prompts"),
+    )
+
+    assert settings.agent_data_root == PROJECT_ROOT / ".local/agent-data"
+    assert settings.persona_root == PROJECT_ROOT / ".local/legacy-inputs/persona"
+    assert settings.decode_raw_root == PROJECT_ROOT / ".local/legacy-inputs/decode/raw"
+    assert settings.prompt_fallback_root == PROJECT_ROOT / "src/script_build_host/agents/prompts"
+
+
 @pytest.mark.asyncio
 async def test_outbound_policy_revalidates_dns_and_redirects() -> None:
     calls: list[tuple[str, int]] = []