Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
initial commit
  • Loading branch information
bertdawg76 committed Sep 16, 2025
commit acbef026de77bc8b236af5fc0e8af72b4cad8c98
1 change: 1 addition & 0 deletions changelog/68188.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixes salt runner mine.get not returning value if allow_tgt is defined in mine function
2 changes: 1 addition & 1 deletion salt/runners/mine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get(tgt, fun, tgt_type="glob"):
"""
masterapi = salt.daemons.masterapi.RemoteFuncs(__opts__)
load = {
"id": __opts__["id"],
"id": __opts__["id"].removesuffix("_master"),
"fun": fun,
"tgt": tgt,
"tgt_type": tgt_type,
Expand Down
77 changes: 77 additions & 0 deletions tests/pytests/integration/runners/test_mine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""
integration tests for the mine runner
"""

import pytest

import salt.config
import salt.runners.mine as mine_runner
from tests.support.mock import patch


@pytest.fixture(scope="module")
def mine(runners):
return runners.mine


@pytest.fixture(scope="module")
def minion_opts():
return salt.config.minion_config(None)


@pytest.fixture(scope="module")
def pillar_tree(salt_master, salt_call_cli, salt_run_cli, salt_minion):
top_file = """
base:
'*':
- mine
"""

mine_file = """
mine_functions:
test_fun:
mine_function: cmd.run
cmd: 'echo hello test'
test_no_allow:
mine_function: cmd.run
cmd: 'echo hello no allow'
"""

top_tempfile = salt_master.pillar_tree.base.temp_file("top.sls", top_file)
mine_tempfile = salt_master.pillar_tree.base.temp_file("mine.sls", mine_file)
try:
with top_tempfile, mine_tempfile:
ret = salt_call_cli.run("saltutil.refresh_pillar", wait=True)
assert ret.returncode == 0
assert ret.data is True
ret = salt_run_cli.run("mine.update", salt_minion.id)
assert ret.returncode == 0
ret = salt_call_cli.run("pillar.items")
assert ret.returncode == 0
yield
finally:
ret = salt_call_cli.run("saltutil.refresh_pillar", wait=True)
assert ret.returncode == 0
assert ret.data is True
ret = salt_run_cli.run("mine.update", salt_minion.id)
assert ret.returncode == 0


@pytest.mark.usefixtures("pillar_tree")
def test_allow_tgt(salt_run_cli, salt_minion, minion_opts):
tgt = salt_minion.id
fun = "test_fun"
with patch("salt.runners.mine.__opts__", minion_opts, create=True):
ret = mine_runner.get(tgt, fun)

ret = salt_run_cli.run("mine.get", tgt, fun)
assert ret.data == {salt_minion.id: "hello test"}


@pytest.mark.usefixtures("pillar_tree")
def test_no_allow_tgt(salt_run_cli, salt_minion):
tgt = salt_minion.id
fun = "test_no_allow"

ret = salt_run_cli.run("mine.get", tgt, fun)
assert ret.data == {salt_minion.id: "hello no allow"}