diff --git a/salt/modules/win_lgpo.py b/salt/modules/win_lgpo.py index 1892fa497f88..2baab285b05f 100644 --- a/salt/modules/win_lgpo.py +++ b/salt/modules/win_lgpo.py @@ -5526,7 +5526,7 @@ def _write_secedit_data(inf_data): # Success if retcode == 0: # Pop secedit data so it will always be current - __context__.pop('lgpo.secedit_data') + __context__.pop('lgpo.secedit_data', None) return True # Failure return False diff --git a/tests/integration/modules/test_win_lgpo.py b/tests/integration/modules/test_win_lgpo.py index a66e4e51c577..d4b0d7f30db8 100644 --- a/tests/integration/modules/test_win_lgpo.py +++ b/tests/integration/modules/test_win_lgpo.py @@ -506,6 +506,22 @@ def test_set_computer_policy_ClipboardRedirection(self): 'Not Configured', [r'; Source file: c:\\windows\\system32\\grouppolicy\\machine\\registry.pol[\s]*; PARSING COMPLETED.']) + @destructiveTest + def test_set_computer_policy_GuestAccountStatus(self): + ''' + Test setting/unsetting/changing GuestAccountStatus + ''' + # disable GuestAccountStatus + self._testSeceditPolicy( + 'GuestAccountStatus', + 'Disabled', + [r'^EnableGuestAccount = 0']) + # enable GuestAccountStatus + self._testSeceditPolicy( + 'GuestAccountStatus', + 'Enabled', + [r'^EnableGuestAccount = 1']) + @destructiveTest def test_set_computer_policy_PasswordComplexity(self): '''