Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:GA
salt.17883
sanitize-grains-loaded-from-roster_grains.json....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sanitize-grains-loaded-from-roster_grains.json.patch of Package salt.17883
From 83a2a79ed3834a1cfd90941d0075d1c38341dc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= <psuarezhernandez@suse.com> Date: Wed, 1 Apr 2020 12:27:30 +0100 Subject: [PATCH] Sanitize grains loaded from roster_grains.json Ensure _format_cached_grains is called on state.pkg test --- salt/modules/state.py | 3 ++- tests/unit/modules/test_state.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/salt/modules/state.py b/salt/modules/state.py index ec1e1edb42e9d8d5bc1e991434eb187e3b65ab89..a4f3f8c37086a79a60f85b5ca4b71d2af1e1f90f 100644 --- a/salt/modules/state.py +++ b/salt/modules/state.py @@ -43,6 +43,7 @@ import salt.defaults.exitcodes from salt.exceptions import CommandExecutionError, SaltInvocationError from salt.runners.state import orchestrate as _orchestrate from salt.utils.odict import OrderedDict +from salt.loader import _format_cached_grains # Import 3rd-party libs from salt.ext import six @@ -2188,7 +2189,7 @@ def pkg(pkg_path, roster_grains_json = os.path.join(root, 'roster_grains.json') if os.path.isfile(roster_grains_json): with salt.utils.files.fopen(roster_grains_json, 'r') as fp_: - roster_grains = salt.utils.json.load(fp_) + roster_grains = _format_cached_grains(salt.utils.json.load(fp_)) if os.path.isfile(roster_grains_json): popts['grains'] = roster_grains diff --git a/tests/unit/modules/test_state.py b/tests/unit/modules/test_state.py index e3c3dc8fc62efa848603082c3d8f3a8f09d5c426..cda846595eeec9788d17b55fcad5cab7a49a62c2 100644 --- a/tests/unit/modules/test_state.py +++ b/tests/unit/modules/test_state.py @@ -1129,8 +1129,10 @@ class StateTestCase(TestCase, LoaderModuleMockMixin): MockTarFile.path = "" with patch('salt.utils.files.fopen', mock_open()), \ - patch.object(salt.utils.json, 'loads', mock_json_loads_true): + patch.object(salt.utils.json, 'loads', mock_json_loads_true), \ + patch.object(state, '_format_cached_grains', MagicMock()): self.assertEqual(state.pkg(tar_file, 0, "md5"), True) + state._format_cached_grains.assert_called_once() MockTarFile.path = "" if six.PY2: -- 2.23.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor