Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions changelog/69405.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Decode binary pillars for salt-ssh to align the behaviour with salt-minion.
2 changes: 2 additions & 0 deletions salt/client/ssh/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import salt.minion
import salt.roster
import salt.state
import salt.utils.data
import salt.utils.files
import salt.utils.json
import salt.utils.path
Expand Down Expand Up @@ -220,6 +221,7 @@ def prep_trans_tar(
salt.utils.json.dump(chunks, fp_)
if pillar:
with salt.utils.files.fopen(pillarfn, "w+") as fp_:
pillar = salt.utils.data.decode_dict(pillar)
salt.utils.json.dump(pillar, fp_)
if roster_grains:
with salt.utils.files.fopen(roster_grainsfn, "w+") as fp_:
Expand Down
56 changes: 56 additions & 0 deletions tests/pytests/unit/client/ssh/test_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest

from salt.client.ssh.state import prep_trans_tar
from tests.support.mock import patch


@pytest.mark.parametrize(
"inpt,expected",
[
(
{
"pillar_data_n1": 1,
"pillar_data_t2": "text2",
"pillar_data_d3": {
"text1": "text1",
"text2": "text2",
},
},
{
"pillar_data_n1": 1,
"pillar_data_t2": "text2",
"pillar_data_d3": {
"text1": "text1",
"text2": "text2",
},
},
),
(
{
"pillar_data_n1": 1,
"pillar_data_t2": "text2",
"pillar_data_b3": b"text3",
"pillar_data_d4": {
"bin1": b"bin1",
"bin2": b"bin2",
},
},
{
"pillar_data_n1": 1,
"pillar_data_t2": "text2",
"pillar_data_b3": "text3",
"pillar_data_d4": {
"bin1": "bin1",
"bin2": "bin2",
},
},
),
],
)
def test_prep_trans_tar_with_binary_pillar(inpt, expected):
"""
Test binary pillar serialization
"""
with patch("salt.utils.json.dump", return_value="") as json_dump_mock:
trans_tar = prep_trans_tar(None, [], [], pillar=inpt)
assert expected == json_dump_mock.call_args[0][0]
Loading