n8n/packages/@n8n/task-runner-python/tests/unit
Mutasem Aldmour 8f758f48ef
test(core): Cover the Python import allowlist across the n8n/runner seam
n8n now parses the same allowlist the Python runner enforces, so the two can
drift: the runner's suite and n8n's unit tests could both stay green while the
builder describes a policy that is not applied.

- Add a shared fixture, read by a test on each side, pinning how
  N8N_RUNNERS_STDLIB_ALLOW / N8N_RUNNERS_EXTERNAL_ALLOW parse. It caught a real
  divergence on the first run: the runner returns a set and collapses
  duplicates, n8n's parser did not. Fixed.
- Add an integration test that starts the Python runner for real and drives a
  Code node through the broker, covering config -> spawned runner env ->
  enforcement in one path: import-free code runs, an allowlisted import runs, a
  non-allowlisted one is rejected, and the rejection names the configured list
  (so it cannot pass against an empty default).

The integration test needs the runner's virtualenv and skips without it, which
is most Node CI lanes today; verified it skips rather than fails. Making
`getVenvPath` public is what lets it decide that synchronously.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 11:42:14 +02:00
..
test_allowlist_parsing_contract.py test(core): Cover the Python import allowlist across the n8n/runner seam 2026-08-27 11:42:14 +02:00
test_env.py feat(core): Add profiling support via sentry (#25049) 2026-01-30 09:49:50 +00:00
test_import_validation.py fix(core): Let allowlisted Python packages import their own submodules via relative imports (#32772) 2026-06-23 08:32:02 +00:00
test_sandbox_hardening.py fix(core): Let allowlisted Python packages import their own submodules via relative imports (#32772) 2026-06-23 08:32:02 +00:00
test_sentry.py feat(core): Add profiling support via sentry (#25049) 2026-01-30 09:49:50 +00:00
test_task_analyzer.py chore: Bundle/2.x (#31173) 2026-05-27 08:36:28 +03:00
test_task_executor.py chore: Bundle/2.x (#31173) 2026-05-27 08:36:28 +03:00
test_task_runner_config.py feat(core): Add N8N_RUNNERS_ALLOW_TRANSITIVE_IMPORTS for the Python task runner (#33130) 2026-06-30 08:20:12 +00:00
test_task_runner.py refactor: Assign task runner IDs from n8n (#35494) 2026-08-10 11:20:37 +00:00
test_transitive_dependency_trust.py feat(core): Add N8N_RUNNERS_ALLOW_TRANSITIVE_IMPORTS for the Python task runner (#33130) 2026-06-30 08:20:12 +00:00