Skip to content

Add end-to-end tests for whitelist_modules exec-dispatch dichotomy - #70778

Merged
dwoz merged 2 commits into
saltstack:3008.xfrom
dwoz:dwoz/test/whitelist-modules-exec-dispatch
Nov 13, 2026
Merged

dwoz merged 2 commits into
saltstack:3008.xfrom
dwoz:dwoz/test/whitelist-modules-exec-dispatch

Conversation

@dwoz

@dwoz dwoz commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Verifies the user-facing behavior of the two-loader whitelist_modules model from #69983 (VCOPS-90587) — specifically, what happens when an SLS tries to invoke an execution module that isn't on the whitelist.

The existing suite covers the loader plumbing (which packed loader a state module sees as __salt__, that _wire_salt() returns the gated loader, etc.). These new tests exercise State.call_high end-to-end and observe the chunk result dicts, which is what users actually see.

Three cases, all under a narrow whitelist_modules fixture that deliberately excludes cmd:

  • test_module_run_rejects_non_whitelisted_exec — SLS module.run: cmd.run returns result: False with "cmd.run is not available" in the comment.
  • test_module_run_allows_whitelisted_exec — counterpart; module.run of a whitelisted function (test.ping) succeeds. Proves the whitelist is the discriminator, not some incidental module.run breakage.
  • test_shipped_state_reaches_non_whitelisted_exec — the cmd.run state runs /bin/true successfully even though cmd is not whitelisted, because the state module's packed __salt__ is the unfiltered inner loader. Skipped on Windows.

Test-only; no production code change.

Test plan

  • pytest tests/pytests/functional/loader/test_state_whitelist_dunder.py — 11/11 pass locally (8 existing + 3 new) against origin/3008.x
  • Pre-commit clean (isort, black, Ruff, bandit)

@dwoz
dwoz requested a review from a team as a code owner November 12, 2026 01:29
dwoz added a commit to dwoz/salt that referenced this pull request Nov 12, 2026
@dwoz dwoz added the test:full Run the full test suite label Nov 12, 2026
@dwoz dwoz added this to the Argon v3008.7 milestone Nov 12, 2026
dwoz added 2 commits November 12, 2026 23:41
Verify the user-facing behavior of the two-loader model from saltstack#69983
(VCOPS-90587):

- SLS-authored `module.run: <mod>.<fun>` is wire-filtered; dispatch to
  a non-whitelisted exec module fails with `result: False` and a
  `"<mod>.<fun> is not available"` comment.
- A whitelisted function under `module.run` still succeeds, proving
  the whitelist is the discriminator (not some incidental breakage).
- A shipped state's internal `__salt__[<mod>.<fun>]` dispatch is NOT
  gated: the `cmd.run` state runs `/bin/true` successfully even when
  `cmd` is absent from `whitelist_modules`, because state modules get
  the unfiltered inner loader as `__salt__`.

All three tests exercise `State.call_high` end-to-end rather than
introspecting the loader pack -- the existing suite covers plumbing;
these cover the observable result.
@dwoz
dwoz merged commit 4bb3629 into saltstack:3008.x Nov 13, 2026
1428 of 1432 checks passed

This branch was previously deployed

1 inactive deployment
ci — d16c74f5 Deployed Nov 13, 2026 by dwoz via Build Onedir Packages / macOS (arm64) #28899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants