JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
f
chen hui68798b64cca5
diff --git a/tests/unit_tests/agentserver/test_debug_trace.py b/tests/unit_tests/agentserver/test_debug_trace.pyindex a7abb4c166..a8c29f81b7 100644--- a/tests/unit_tests/agentserver/test_debug_trace.py+++ b/tests/unit_tests/agentserver/test_debug_trace.py@@ -440,16 +440,12 @@ class TestTruncationAndRedaction:assert _looks_secret("password")assert _looks_secret("set-cookie")- def test_tool_args_secret_masked_even_when_shown(self, tmp_path, monkeypatch):+ def test_tool_args_secret_masked_even_when_shown(self, tmp_path):# include_tool_args=True: arguments are SHOWN, yet secret values are# still masked as ***. Arguments are fed as a JSON STRING — the real# shape LLM tool-calls deliver — so this guards the parse-then-mask path# (without it, _mask_secrets would skip the string and leak the secret).- # 附指纹(与 SensitiveDataFilter / masked_with_fp 一致)。- monkeypatch.setattr(- "jiuwenswarm.common.local_env_config.is_enterprise",- lambda: False,- )+ # 附指纹(与 SensitiveDataFilter / masked_with_fp 一致;脱敏与版本无关)。s = debug_config.DebugTraceSettings(mode="code.normal",enabled=True,@@ -495,15 +491,11 @@ class TestTruncationAndRedaction:# plural token count must not be mis-maskedassert '"tokens_used": 42' in out- def test_nested_secrets_masked_and_original_unchanged(self, tmp_path, monkeypatch):+ def test_nested_secrets_masked_and_original_unchanged(self, tmp_path):# Secrets buried deep in nested dict/list must still be masked, AND the# masking must not mutate the original payload (the live chunk is shared# with the agent pipeline / real tool execution — mutating it would# corrupt the run). Dict shape is used so non-mutation is observable.- monkeypatch.setattr(- "jiuwenswarm.common.local_env_config.is_enterprise",- lambda: False,- )import copys = debug_config.DebugTraceSettings(mode="code.normal",diff --git a/tests/unit_tests/gateway/test_log_masking.py b/tests/unit_tests/gateway/test_log_masking.pyindex 1c45d3ec24..5cf2e01e8c 100644--- a/tests/unit_tests/gateway/test_log_masking.py+++ b/tests/unit_tests/gateway/test_log_masking.py@@ -87,10 +87,7 @@ def test_compile_masking_rows_reads_with_fingerprint_default_false():def test_with_fingerprint_false_masks_without_fp(monkeypatch):- monkeypatch.setattr(- "jiuwenswarm.common.local_env_config.is_enterprise",- lambda: False,- )+ monkeypatch.setenv("JIUWENSWARM_EDITION", "personal")LogMaskingEngine.reload_from_rows([{@@ -116,10 +113,7 @@ def test_builtin_kv_with_fingerprint_even_in_enterprise(monkeypatch):"""敏感 KV(with_fingerprint=True)企业版同样附指纹。"""from jiuwenswarm.infrastructure.utils import fingerprint- monkeypatch.setattr(- "jiuwenswarm.common.local_env_config.is_enterprise",- lambda: True,- )+ monkeypatch.setenv("JIUWENSWARM_EDITION", "enterprise")LogMaskingEngine.reset_for_tests()secret = "mySecretValue"out = LogMaskingEngine.get_instance().sanitize(f"api_key={secret}")diff --git a/tests/unit_tests/test_file_transfer_gates.py b/tests/unit_tests/test_file_transfer_gates.pyindex 3287449a50..83d2035c55 100644--- a/tests/unit_tests/test_file_transfer_gates.py+++ b/tests/unit_tests/test_file_transfer_gates.py@@ -48,30 +48,14 @@ def test_file_transfer_config_default_disabled():assert FileTransferConfig().enabled is False-def test_resolve_enabled_defaults_false_even_for_enterprise():- with patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=True,- ):- assert resolve_file_transfer_enabled({}) is False- with patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=False,- ):- assert resolve_file_transfer_enabled({}) is False+def test_resolve_enabled_defaults_false():+ # 默认关闭(个人/企业均如此,OBS 为主路径,不再读 is_enterprise)。+ assert resolve_file_transfer_enabled({}) is Falsedef test_resolve_enabled_yaml_override():- with patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=True,- ):- assert resolve_file_transfer_enabled({"enabled": False}) is False- with patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=False,- ):- assert resolve_file_transfer_enabled({"enabled": True}) is True+ assert resolve_file_transfer_enabled({"enabled": False}) is False+ assert resolve_file_transfer_enabled({"enabled": True}) is Truedef test_resolve_enabled_escape_env(monkeypatch):diff --git a/tests/unit_tests/test_send_file_obs_download.py b/tests/unit_tests/test_send_file_obs_download.pyindex 07fd39eaf0..dd268fed41 100644--- a/tests/unit_tests/test_send_file_obs_download.py+++ b/tests/unit_tests/test_send_file_obs_download.py@@ -26,6 +26,7 @@ def _clear_dedup():def test_send_file_obs_enterprise_writes_stream(tmp_path, monkeypatch):+ monkeypatch.setenv("JIUWENSWARM_EDITION", "enterprise")monkeypatch.delenv("JIUWENSWARM_FILE_DOWNLOAD_VIA_PUSH", raising=False)file_path = tmp_path / "out.docx"file_path.write_bytes(b"docx-bytes")@@ -39,10 +40,6 @@ def test_send_file_obs_enterprise_writes_stream(tmp_path, monkeypatch):mock_session.write_stream = AsyncMock()with (- patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=True,- ),patch("jiuwenswarm.agents.harness.common.tools.subagent_executor.context_vars.get_subagent_parent_session",return_value=mock_session,@@ -78,6 +75,7 @@ def test_send_file_obs_enterprise_writes_stream(tmp_path, monkeypatch):def test_send_file_obs_skipped_when_personal(tmp_path, monkeypatch):"""Personal edition must keep send_push local path (no MinIO)."""+ monkeypatch.setenv("JIUWENSWARM_EDITION", "personal")monkeypatch.delenv("JIUWENSWARM_FILE_DOWNLOAD_VIA_PUSH", raising=False)file_path = tmp_path / "local.txt"file_path.write_text("hi", encoding="utf-8")@@ -103,10 +101,6 @@ def test_send_file_obs_skipped_when_personal(tmp_path, monkeypatch):upload = MagicMock()with (- patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=False,- ),patch("jiuwenswarm.channels.web.minio_upload.upload_local_file_to_minio",upload,@@ -123,6 +117,7 @@ def test_send_file_obs_skipped_when_personal(tmp_path, monkeypatch):def test_distributed_fails_when_delivered_zero(tmp_path, monkeypatch):+ monkeypatch.setenv("JIUWENSWARM_EDITION", "personal")monkeypatch.delenv("JIUWENSWARM_FILE_DOWNLOAD_VIA_PUSH", raising=False)file_path = tmp_path / "big.bin"file_path.write_bytes(b"0123456789")@@ -150,10 +145,6 @@ def test_distributed_fails_when_delivered_zero(tmp_path, monkeypatch):ft_cfg.enabled = Truewith (- patch(- "jiuwenswarm.common.local_env_config.is_enterprise",- return_value=False,- ),patch("jiuwenswarm.common.file_transfer_config.get_file_transfer_config",return_value=ft_cfg,diff --git a/tests/unit_tests/test_send_file_session_dedup.py b/tests/unit_tests/test_send_file_session_dedup.pyindex 7213eedac9..aa95a0fdfc 100644--- a/tests/unit_tests/test_send_file_session_dedup.py+++ b/tests/unit_tests/test_send_file_session_dedup.py@@ -18,11 +18,8 @@ from jiuwenswarm.agents.harness.common.tools.send_file_to_user import (def _clear_dedup_registry(monkeypatch):"""Personal-path send_file tests must not enter enterprise OBS branch."""_SENT_FILE_PATHS_BY_SESSION.clear()+ monkeypatch.setenv("JIUWENSWARM_EDITION", "personal")monkeypatch.delenv("JIUWENSWARM_FILE_DOWNLOAD_VIA_PUSH", raising=False)- monkeypatch.setattr(- "jiuwenswarm.common.local_env_config.is_enterprise",- lambda: False,- )yield_SENT_FILE_PATHS_BY_SESSION.clear()