Example #1
0
 def test_set_setting(self):
     names = ['Credential Validation', 'IPsec Driver', 'File System', 'SAM']
     mock_set = MagicMock(return_value={'retcode': 0, 'stdout': 'Success'})
     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:
                 value = random.choice(settings)
                 win_lgpo_auditpol.set_setting(name=name, value=value)
                 switches = win_lgpo_auditpol.settings[value]
                 cmd = 'auditpol /set /subcategory:"{0}" {1}' \
                       ''.format(name, switches)
                 mock_set.assert_called_once_with(cmd=cmd,
                                                  python_shell=True)
                 mock_set.reset_mock()
Example #2
0
 def test_set_setting(self):
     names = ["Credential Validation", "IPsec Driver", "File System", "SAM"]
     mock_set = MagicMock(return_value={"retcode": 0, "stdout": "Success"})
     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:
                 value = random.choice(settings)
                 win_lgpo_auditpol.set_setting(name=name, value=value)
                 switches = win_lgpo_auditpol.settings[value]
                 cmd = 'auditpol /set /subcategory:"{}" {}' "".format(name, switches)
                 mock_set.assert_called_once_with(cmd=cmd, python_shell=True)
                 mock_set.reset_mock()