diff --git a/changelog/62058.fixed b/changelog/62058.fixed new file mode 100644 index 00000000000..9329631635c --- /dev/null +++ b/changelog/62058.fixed @@ -0,0 +1 @@ +Fixed issue with some LGPO policies having whitespace at the beginning or end of the element alias diff --git a/salt/modules/win_lgpo.py b/salt/modules/win_lgpo.py index 155b5c04db6..4521be68195 100644 --- a/salt/modules/win_lgpo.py +++ b/salt/modules/win_lgpo.py @@ -5956,9 +5956,9 @@ def _getAdmlPresentationRefId(adml_data, ref_id): "multiTextBox", ]: if result.text: - return result.text.rstrip().rstrip(":") + return result.text.rstrip().rstrip(":").strip() else: - return alternate_label.rstrip(":") + return alternate_label.rstrip(":").strip() return None diff --git a/tests/pytests/functional/modules/win_lgpo/test_get_policy_info.py b/tests/pytests/functional/modules/win_lgpo/test_get_policy_info.py new file mode 100644 index 00000000000..83c70f6cd35 --- /dev/null +++ b/tests/pytests/functional/modules/win_lgpo/test_get_policy_info.py @@ -0,0 +1,34 @@ +""" +Unit tests for the LGPO module +""" + +import platform + +import pytest +from packaging import version + +pytestmark = [ + pytest.mark.windows_whitelisted, + pytest.mark.skip_unless_on_windows, +] + + +@pytest.fixture(scope="module") +def lgpo(modules): + return modules.lgpo + + +# The "Allow Online Tips" policy only became available in version 10.0.16299 +@pytest.mark.skipif( + version.parse(platform.version()) < version.parse("10.0.16299"), + reason="Policy only available on 10.0.16299 or later", +) +def test_62058_whitespace(lgpo): + result = lgpo.get_policy_info("Allow Online Tips", "machine") + for element in result["policy_elements"]: + if "element_aliases" in element: + assert ( + "Allow Settings to retrieve online tips." in element["element_aliases"] + ) + return + assert False