[配置]:完成 .env 文件读取配置,包含自动加载、CLI 参数、测试覆盖和中文说明
This commit is contained in:
@@ -27,6 +27,19 @@ class CliAcceptanceTests(unittest.TestCase):
|
||||
self.assertEqual(code, 0)
|
||||
self.assertTrue(data["valid"])
|
||||
|
||||
def test_show_config_reads_env_file_without_printing_secret(self) -> None:
|
||||
import tempfile
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = f"{tmp}/.env"
|
||||
with open(path, "w", encoding="utf-8") as handle:
|
||||
handle.write("OWNER_LLM_API_KEY=secret-value\nOWNER_LLM_MODEL=file-model\n")
|
||||
code, data = self.call("--env-file", path, "--show-config")
|
||||
self.assertEqual(code, 0)
|
||||
self.assertTrue(data["llm_api_key_present"])
|
||||
self.assertEqual(data["llm_model"], "file-model")
|
||||
self.assertNotIn("secret-value", str(data))
|
||||
|
||||
def test_security_check_command_has_no_leaks(self) -> None:
|
||||
code, data = self.call("security-check")
|
||||
self.assertEqual(code, 0)
|
||||
|
||||
Reference in New Issue
Block a user