diff --git a/tests/hermes_cli/test_kanban_notify.py b/tests/hermes_cli/test_kanban_notify.py index 1a0388e1e65..44a0bd90a03 100644 --- a/tests/hermes_cli/test_kanban_notify.py +++ b/tests/hermes_cli/test_kanban_notify.py @@ -487,7 +487,7 @@ async def test_gateway_create_autosubscribes_on_explicit_board(kanban_home): @pytest.mark.asyncio -async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path): +async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path, monkeypatch): """When a completed event carries ``artifacts`` in its payload, the notifier uploads each file to the subscribed chat as a native attachment. Images batch through send_multiple_images; documents @@ -499,6 +499,13 @@ async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path): from gateway.config import Platform from tools import kanban_tools as kt + # ``_deliver_kanban_artifacts`` routes candidates through + # ``BasePlatformAdapter.filter_local_delivery_paths``, which only accepts + # paths under ``MEDIA_DELIVERY_SAFE_ROOTS`` or roots explicitly allowlisted + # via ``HERMES_MEDIA_ALLOW_DIRS``. Test fixtures live under ``tmp_path``, + # so allowlist it for the duration of the test. + monkeypatch.setenv("HERMES_MEDIA_ALLOW_DIRS", str(tmp_path)) + # Materialize real files so os.path.isfile passes inside the helper. chart_path = tmp_path / "q3-revenue.png" chart_path.write_bytes(b"PNG-fake-bytes") @@ -577,7 +584,7 @@ async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path): @pytest.mark.asyncio -async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_path): +async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_path, monkeypatch): """Missing artifact paths are silently skipped — they may have been referenced by name only. The notifier must not crash and must still deliver any artifacts that do exist.""" @@ -586,6 +593,10 @@ async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_p from gateway.config import Platform from tools import kanban_tools as kt + # Allow ``tmp_path`` through the media-delivery safety filter. See the + # companion test for the full explanation. + monkeypatch.setenv("HERMES_MEDIA_ALLOW_DIRS", str(tmp_path)) + real_pdf = tmp_path / "real.pdf" real_pdf.write_bytes(b"%PDF-fake")