From d1f776178c929563c688e6fa85f2893829bb14c0 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Mon, 2 Mar 2020 17:53:41 -0800 Subject: [PATCH 1/2] Ensures popping lgpo.secedit_data does not throw KeyError Fixes #56288 --- salt/modules/win_lgpo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2979158a8b82660126742cf7011ef46b3fc0543b Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Tue, 3 Mar 2020 07:29:46 -0800 Subject: [PATCH 2/2] Tests the `if _secedits:` logic path in `lgpo.set_` Other "secedit" tests are actually testing `_modal_sets`... --- tests/integration/modules/test_win_lgpo.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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): '''