mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Merge pull request #58971 from tommygrumheden/fix-pillar-obfuscate-module
Fixes bug in modules/pillar.py
This commit is contained in:
commit
609e5e1837
3 changed files with 14 additions and 3 deletions
1
changelog/58971.changed
Normal file
1
changelog/58971.changed
Normal file
|
@ -0,0 +1 @@
|
|||
Update pillar.obfuscate to accept kwargs in addition to args. This is useful when passing in keyword arguments like saltenv that are then passed along to pillar.items.
|
|
@ -298,7 +298,7 @@ def _obfuscate_inner(var):
|
|||
return "<{}>".format(var.__class__.__name__)
|
||||
|
||||
|
||||
def obfuscate(*args):
|
||||
def obfuscate(*args, **kwargs):
|
||||
"""
|
||||
.. versionadded:: 2015.8.0
|
||||
|
||||
|
@ -325,7 +325,7 @@ def obfuscate(*args):
|
|||
salt '*' pillar.obfuscate
|
||||
|
||||
"""
|
||||
return _obfuscate_inner(items(*args))
|
||||
return _obfuscate_inner(items(*args, **kwargs))
|
||||
|
||||
|
||||
# naming chosen for consistency with grains.ls, although it breaks the short
|
||||
|
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
|
||||
import salt.modules.pillar as pillarmod
|
||||
from salt.utils.odict import OrderedDict
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.mock import MagicMock, call, patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -37,6 +37,16 @@ def test_obfuscate(pillar_value):
|
|||
assert pillarmod.obfuscate() == dict(a="<int>", b="<str>")
|
||||
|
||||
|
||||
def test_obfuscate_with_kwargs(pillar_value):
|
||||
with patch(
|
||||
"salt.modules.pillar.items", MagicMock(return_value=pillar_value)
|
||||
) as pillar_items_mock:
|
||||
ret = pillarmod.obfuscate(saltenv="saltenv")
|
||||
# ensure the kwargs are passed along to pillar.items
|
||||
assert call(saltenv="saltenv") in pillar_items_mock.mock_calls
|
||||
assert ret == dict(a="<int>", b="<str>")
|
||||
|
||||
|
||||
def test_ls(pillar_value):
|
||||
with patch("salt.modules.pillar.items", MagicMock(return_value=pillar_value)):
|
||||
ls = sorted(pillarmod.ls())
|
||||
|
|
Loading…
Add table
Reference in a new issue