Merge pull request #51184 from twangboy/fix_auditpol

Fix win_lgpo_auditpol salt util on Windows
This commit is contained in:
Daniel Wozniak 2019-01-16 11:08:00 -07:00 committed by GitHub
commit 094bd33279
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -66,6 +66,7 @@ import re
import tempfile
# Import Salt libs
import salt.modules.cmdmod
import salt.utils.files
import salt.utils.platform
from salt.exceptions import CommandExecutionError
@ -117,8 +118,8 @@ def _auditpol_cmd(cmd):
Raises:
CommandExecutionError: If the command encounters an error
'''
ret = __salt__['cmd.run_all'](cmd='auditpol {0}'.format(cmd),
python_shell=True)
ret = salt.modules.cmdmod.run_all(cmd='auditpol {0}'.format(cmd),
python_shell=True)
if ret['retcode'] == 0:
return ret['stdout'].splitlines()

View File

@ -55,7 +55,7 @@ class WinLgpoAuditpolTestCase(TestCase, LoaderModuleMockMixin):
def test_set_setting(self):
names = ['Credential Validation', 'IPsec Driver', 'File System', 'SAM']
mock_set = MagicMock(return_value={'retcode': 0, 'stdout': 'Success'})
with patch.dict(win_lgpo_auditpol.__salt__, {'cmd.run_all': mock_set}):
with patch.object(salt.modules.cmdmod, 'run_all', mock_set):
with patch.object(win_lgpo_auditpol, '_get_valid_names',
return_value=[k.lower() for k in names]):
for name in names: