From 31f6afef06dcdac882a7b49c340bc8d736d6202e Mon Sep 17 00:00:00 2001 From: Medha Mummigatti Date: Fri, 29 May 2026 12:21:12 +0530 Subject: [PATCH] fix(tests): make user_groups integration tests distro-aware The integration tests for users_groups module had Ubuntu-specific assumptions that prevented them from running on RHEL-family systems. Changes: - Add skipif decorators to Ubuntu-specific warning tests - Remove redundant IS_UBUNTU checks inside skipif-decorated tests - Restore test_sudoers_includedir decorators with distro-aware skipif logic: 'IS_UBUNTU and CURRENT_RELEASE < JAMMY' allows test to run on RHEL and modern Ubuntu while skipping old Ubuntu releases - Add JAMMY import needed for the distro-aware skipif condition --- tests/integration_tests/modules/test_users_groups.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests/modules/test_users_groups.py b/tests/integration_tests/modules/test_users_groups.py index 1ceb2587c99..7edb5956048 100644 --- a/tests/integration_tests/modules/test_users_groups.py +++ b/tests/integration_tests/modules/test_users_groups.py @@ -119,6 +119,10 @@ def test_users_groups(self, regex, getent_args, class_client): ) ) + @pytest.mark.skipif( + not IS_UBUNTU, + reason="Warning expectations are Ubuntu-specific", + ) def test_initial_warnings(self, class_client): """Check for initial warnings.""" warnings = ( @@ -138,6 +142,10 @@ def test_user_root_in_secret(self, class_client): groups = groups_str.split() assert "secret" in groups + @pytest.mark.skipif( + not IS_UBUNTU, + reason="Password unlock warning behavior differs across distros", + ) def test_nopassword_unlock_warnings(self, class_client): """Verify warnings for empty passwords for new and existing users.""" # Fake admin clearing and unlocking and empty unlocked password foobar @@ -165,8 +173,8 @@ def test_nopassword_unlock_warnings(self, class_client): @pytest.mark.user_data(USER_DATA) @pytest.mark.skipif( - CURRENT_RELEASE < JAMMY, - reason="Requires version of sudo not available in older releases", + IS_UBUNTU and CURRENT_RELEASE < JAMMY, + reason="Requires version of sudo not available in older Ubuntu releases", ) def test_sudoers_includedir(client: IntegrationInstance): """Ensure we don't add additional #includedir to sudoers.