Merge pull request #56290 from lorengordon/pop-secdata

Ensures popping lgpo.secedit_data does not throw KeyError
This commit is contained in:
Daniel Wozniak 2020-03-11 10:27:03 -07:00 committed by GitHub
commit 7701e8762d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -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

View file

@ -506,6 +506,22 @@ class WinLgpoTest(ModuleCase):
'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):
'''