diff --git a/src/tests/multihost/alltests/test_sssctl_local.py b/src/tests/multihost/alltests/test_sssctl_local.py index ed36711c8dc..4ec8d430afa 100644 --- a/src/tests/multihost/alltests/test_sssctl_local.py +++ b/src/tests/multihost/alltests/test_sssctl_local.py @@ -6,6 +6,7 @@ :upstream: yes :status: approved """ + from __future__ import print_function import pytest from sssd.testlib.common.utils import sssdTools @@ -17,17 +18,18 @@ def client_version(multihost): return True -@pytest.mark.usefixtures('default_sssd') +@pytest.mark.usefixtures("default_sssd") @pytest.mark.sssctl class Testsssctl(object): """ This is test case class for sssctl suite """ - @pytest.mark.converted('test_sssctl.py', 'test_sssctl__user_show_cache_expiration_time') + + @pytest.mark.converted( + "test_tools.py", "test_sssctl__user_show_cache_expiration_time" + ) @pytest.mark.tier1_2 - def test_0001_bz1640576(self, multihost, - backupsssdconf, - localusers): + def test_0001_bz1640576(self, multihost, backupsssdconf, localusers): """ :title: IDM-SSSD-TC: sssctl: sssctl reports incorrect information about local user's cache entry expiration time @@ -37,27 +39,22 @@ def test_0001_bz1640576(self, multihost, pytest.skip("Files Provider support isn't available, skipping") users = localusers tools = sssdTools(multihost.client[0]) - multihost.client[0].service_sssd('stop') - tools.remove_sss_cache('/var/lib/sss/db') - tools.remove_sss_cache('/var/log/sssd') - sssd_param = {'domains': 'local'} - tools.sssd_conf('sssd', sssd_param) - param = {'id_provider': 'files', - 'passwd_files': '/etc/passwd'} - tools.sssd_conf('domain/local', param) - multihost.client[0].service_sssd('start') + multihost.client[0].service_sssd("stop") + tools.remove_sss_cache("/var/lib/sss/db") + tools.remove_sss_cache("/var/log/sssd") + sssd_param = {"domains": "local"} + tools.sssd_conf("sssd", sssd_param) + param = {"id_provider": "files", "passwd_files": "/etc/passwd"} + tools.sssd_conf("domain/local", param) + multihost.client[0].service_sssd("start") for user in users.keys(): - sssctl_cmd = 'sssctl user-show %s' % user - cmd = multihost.client[0].run_command(sssctl_cmd, - raiseonerr=False) - assert 'Cache entry expiration time: Never'\ - in cmd.stdout_text + sssctl_cmd = "sssctl user-show %s" % user + cmd = multihost.client[0].run_command(sssctl_cmd, raiseonerr=False) + assert "Cache entry expiration time: Never" in cmd.stdout_text - @pytest.mark.converted('test_sssctl.py', 'test_sssctl__handle_implicit_domain') + @pytest.mark.converted("test_sssctl.py", "test_sssctl__handle_implicit_domain") @pytest.mark.tier1_2 - def test_0002_bz1599207(self, multihost, - backupsssdconf, - localusers): + def test_0002_bz1599207(self, multihost, backupsssdconf, localusers): """ :title: IDM-SSSD-TC: sssctl: sssd tools do not handle the implicit domain @@ -67,28 +64,27 @@ def test_0002_bz1599207(self, multihost, pytest.skip("Files Provider support isn't available, skipping") users = localusers tools = sssdTools(multihost.client[0]) - multihost.client[0].service_sssd('stop') - tools.remove_sss_cache('/var/lib/sss/db') - tools.remove_sss_cache('/var/log/sssd') - tools.sssd_conf("sssd", - {'enable_files_domain': 'true'}, - action='update') - multihost.client[0].service_sssd('start') + multihost.client[0].service_sssd("stop") + tools.remove_sss_cache("/var/lib/sss/db") + tools.remove_sss_cache("/var/log/sssd") + tools.sssd_conf("sssd", {"enable_files_domain": "true"}, action="update") + multihost.client[0].service_sssd("start") for user in users.keys(): - cmd = multihost.client[0].run_command('getent' - ' -s sss' - ' passwd %s ' - '&& sssctl ' - 'user-show %s' % - (user, user), - raiseonerr=False) - assert 'Cache entry creation date' in \ - cmd.stdout_text and cmd.returncode == 0 + cmd = multihost.client[0].run_command( + "getent" + " -s sss" + " passwd %s " + "&& sssctl " + "user-show %s" % (user, user), + raiseonerr=False, + ) + assert ( + "Cache entry creation date" in cmd.stdout_text and cmd.returncode == 0 + ) - @pytest.mark.converted('test_sss_cache.py', 'test_sss_cache__cache_expire_message') + @pytest.mark.converted("test_cache.py", "test_sss_cache__cache_expire_message") @pytest.mark.tier1_2 - def test_0003_bz1661182(self, multihost, - backupsssdconf): + def test_0003_bz1661182(self, multihost, backupsssdconf): """ :title: sss_cache prints spurious error messages when invoked from shadow-utils on package install @@ -111,24 +107,24 @@ def test_0003_bz1661182(self, multihost, if not multihost.client[0].detect_files_provider(): pytest.skip("Files Provider support isn't available, skipping") tools = sssdTools(multihost.client[0]) - ldap_params = {'enable_files_domain': 'false'} - tools.sssd_conf('sssd', ldap_params) + ldap_params = {"enable_files_domain": "false"} + tools.sssd_conf("sssd", ldap_params) with pytest.raises(SSSDException): - multihost.client[0].service_sssd('restart') + multihost.client[0].service_sssd("restart") ps_cmd = "> /var/log/sssd/sssd.log" multihost.client[0].run_command(ps_cmd) ps_cmd = "useradd user1_test" multihost.client[0].run_command(ps_cmd, raiseonerr=False) ps_cmd = "usermod -a -G wheel user1_test" cmd = multihost.client[0].run_command(ps_cmd) - assert 'No domains configured, fatal error!' \ - not in cmd.stdout_text + assert "No domains configured, fatal error!" not in cmd.stdout_text ps_cmd = "userdel user1_test" multihost.client[0].run_command(ps_cmd) - for ps_cmd in ('sss_cache -U', - 'sss_cache -G', - 'sss_cache -E', - 'sss_cache -u non-existinguser'): + for ps_cmd in ( + "sss_cache -U", + "sss_cache -G", + "sss_cache -E", + "sss_cache -u non-existinguser", + ): cmd = multihost.client[0].run_command(ps_cmd) - assert 'No domains configured, fatal error!' \ - not in cmd.stdout_text + assert "No domains configured, fatal error!" not in cmd.stdout_text diff --git a/src/tests/system/tests/test_sss_cache.py b/src/tests/system/tests/test_cache.py similarity index 50% rename from src/tests/system/tests/test_sss_cache.py rename to src/tests/system/tests/test_cache.py index 7ab5eabce8a..092241d1e11 100644 --- a/src/tests/system/tests/test_sss_cache.py +++ b/src/tests/system/tests/test_cache.py @@ -1,7 +1,13 @@ """ -sss_cache tests. +SSSD Cache Tests. -:requirement: IDM-SSSD-REQ: Status utility +Tests pertaining SSSD caches, the following types are tested and some will be in other python files. + +* Local cache (LDB) +* Negative cache (ncache) +* In-memory cache (memcache): test_memcache.py + +:requirement: Cache """ from __future__ import annotations @@ -9,64 +15,29 @@ import time import pytest -from pytest_mh.ssh import SSHProcessError from sssd_test_framework.roles.client import Client from sssd_test_framework.roles.generic import GenericProvider from sssd_test_framework.topology import KnownTopology, KnownTopologyGroup -@pytest.mark.ticket(bz=1661182) -@pytest.mark.topology(KnownTopology.Client) -def test_sss_cache__cache_expire_message(client: Client): - """ - :title: sss_cache do not print fake error messages - :setup: - 1. Configure SSSD without any domain - 2. Set to sssd section "enable_files_domain" to "false" - 3. Create local user - :steps: - 1. Restart SSSD - 2. Modify existing local user - 3. Expire cache with specific options - :expectedresults: - 1. Error is raised, SSSD is not running - 2. Modified successfully - 3. Output did not contain wrong messages - :customerscenario: True - """ - client.sssd.sssd["enable_files_domain"] = "false" - client.local.user("user1").add() - - with pytest.raises(SSHProcessError): - client.sssd.restart() - - res = client.host.ssh.run("usermod -a -G wheel user1") - assert "No domains configured, fatal error!" not in res.stdout - - for cmd in ("sss_cache -U", "sss_cache -G", "sss_cache -E", "sss_cache --user=nonexisting"): - res = client.host.ssh.run(cmd) - assert "No domains configured, fatal error!" not in res.stdout - - @pytest.mark.importance("critical") -@pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_sss_cache__ldb_database_is_refreshed_as_configured(client: Client, provider: GenericProvider): +def test_cache__is_refreshed_as_configured(client: Client, provider: GenericProvider): """ - :title: Ensuring ldb cache data is refreshed correctly + :title: Ensuring LDB cache refreshes at configured intervals :setup: - 1. Create provider user - 2. Create provider group - 3. Create provider netgroup - 4. Configure SSSD and set 'entry_cache_timeout' to 1 and 'refresh_expired_interval' to 2 + 1. Create user + 2. Create group + 3. Create netgroup + 4. Configure SSSD and set 'entry_cache_timeout to 1' and 'refresh_expired_interval to 2' 5. Restart SSSD - 6. Populate the cache by performing 'getent' on the user, group and netgroup + 6. Lookup user, group and netgroup :steps: - 1. Search for user, group and netgroup lastUpdate and dataExpireTimestamp in the ldb database - 2. Wait 5 seconds and search for all timestamp in the cache again + 1. Search for objects lastUpdate and dataExpireTimestamp in ldb database + 2. Wait 5 seconds and repeat search :expectedresults: 1. The 'dataExpireTimestamp' value equals the 'lastUpdate + entry_cache_timeout' value - 2. User, group and netgroup 'lastUpdate' timestamp value has been refreshed + 2. Objects 'lastUpdate' timestamp value has been refreshed :customerscenario: False """ user = provider.user("test_user").add() @@ -101,7 +72,9 @@ def test_sss_cache__ldb_database_is_refreshed_as_configured(client: Client, prov expire_time = expire_time + [(int(y[1][0]))] for m, n in enumerate(last_update): - assert last_update[m] + entry_cache_timeout == expire_time[m] + assert ( + last_update[m] + entry_cache_timeout == expire_time[m] + ), f"{expire_time[m]} != {last_update[m]} + {entry_cache_timeout}" time.sleep(5) @@ -110,31 +83,30 @@ def test_sss_cache__ldb_database_is_refreshed_as_configured(client: Client, prov for k, v in result.items(): for y in v.items(): if y[0] == "lastUpdate": - assert last_update[s] <= (int(y[1][0])) + assert last_update[s] <= (int(y[1][0])), f"{s} lastUpdate value is greater than expected!" @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_sss_cache__check_timestamp_value_in_ldb(client: Client, provider: GenericProvider): +def test_cache__search_for_user_in_ldb_databases(client: Client, provider: GenericProvider): """ - :title: Verify the existence of timestamp cache and use lsbsearch on those files + :title: Search for user in the following ldb databases, cache_*.ldb and timestamp_*.ldb :setup: - 1. Add user + 1. Create user 2. Start SSSD :steps: - 1. Execute getent passwd to fetch user details - 2. Check if timestamps cache file exists - 3. Get user information using ldbsearch on cache_test.ldb - 4. Get user timestamp information using ldbsearch on timestamps_test.ldb + 1. Lookup user + 2. Check cache + 3. Lookup user in cache ldb database + 4. Lookup user in timestamp ldb database :expectedresults: - 1. User details should be successfully fetched - 2. Cache file should be present - 3. User information were successfully fetched - 4. User information were successfully fetched + 1. User is found + 2. Cache file exists + 3. User found + 4. User found :customerscenario: False """ provider.user("user1").add() client.sssd.start() - client.tools.getent.passwd("user1") cache = "/var/lib/sss/db/cache_test.ldb" timestamps = "/var/lib/sss/db/timestamps_test.ldb" @@ -147,22 +119,20 @@ def test_sss_cache__check_timestamp_value_in_ldb(client: Client, provider: Gener @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_sss_cache__check_timestamp_value_in_ldb_when_fully_qualified_names_enabled( - client: Client, provider: GenericProvider -): +def test_cache__search_for_user_using_fully_qualified_name_in_ldb_databases(client: Client, provider: GenericProvider): """ - :title: Set use fully qualified names to true and verify cache updates + :title: Search for user using fully qualified name in the following ldb databases, cache_*.ldb and timestamp_*.ldb :setup: - 1. Add user - 2. Set use_fully_qualified_names to True in the sssd.conf - 3. Start SSSD - 4. Execute getent passwd user1@test + 1. Create user + 2. Start SSSD :steps: - 1. Get user information using ldbsearch on cache_test.ldb - 2. Get user timestamp information using ldbsearch on timestamps_test.ldb + 1. Lookup user + 2. Lookup user in cache ldb database + 3. Lookup user in timestamp ldb database :expectedresults: - 1. User information were successfully fetched - 2. User information were successfully fetched + 1. User found + 2. User found + 3. User found :customerscenario: False """ provider.user("user1").add() @@ -181,22 +151,25 @@ def test_sss_cache__check_timestamp_value_in_ldb_when_fully_qualified_names_enab @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_sss_cache__check_ldb_updates_when_user_is_deleted_and_modified(client: Client, provider: GenericProvider): +def test_cache__check_ldb_database_for_latest_user_changes_when_modified_and_deleted( + client: Client, provider: GenericProvider +): """ - :title: Modify user attribute and verify cache updates + :title: Check ldb database for latest user changes when modified and deleted :setup: - 1. Add users - 3. Start SSSD - 4. Execute getent passwd to fetch cache - 5. Expire whole cache - 6. Modify and delete user attribute - 7. Execute getent passwd again + 1. Add users 'user-modify' and 'user-delete' + 2. Start SSSD + 3. Lookup users :steps: - 1. Try to login - 2. Check that modified user was modified + 1. Login as users + 2. Modify 'user-modify' shell and delete 'user-delete' and clear cache + 3. Login as users + 4. Lookup user 'user-modify' :expectedresults: - 1. Modified user can login, Deleted usec cannot login - 2. Modified user has correct attributes + 1. Users logged in + 2. User is modified and user is deleted + 3. User 'user-modify' logged in + 4. User's shell was updated :customerscenario: False """ provider.user("user-modify").add(shell="/bin/bash") @@ -204,17 +177,16 @@ def test_sss_cache__check_ldb_updates_when_user_is_deleted_and_modified(client: client.sssd.start() client.tools.getent.passwd("user-modify") client.tools.getent.passwd("user-delete") - client.sssctl.cache_expire(everything=True) + + assert client.auth.ssh.password("user-modify", "Secret123"), "Login failed!" + assert client.auth.ssh.password("user-delete", "Secret123"), "Login failed!" provider.user("user-delete").delete() provider.user("user-modify").modify(shell="/bin/sh") - client.tools.getent.passwd("user-delete") - client.tools.getent.passwd("user-modify") + client.sssctl.cache_expire(everything=True) - assert client.auth.ssh.password("user-modify", "Secret123") - assert not client.auth.ssh.password("user-delete", "Secret123") + assert client.auth.ssh.password("user-modify", "Secret123"), "Login failed!" + assert not client.auth.ssh.password("user-delete", "Secret123"), "Login successful!" - modify = client.tools.getent.passwd("user-modify") - assert modify is not None - assert modify.shell == "/bin/sh" + assert client.tools.getent.passwd("user-modify").shell == "/bin/sh", "User shell did not update!" diff --git a/src/tests/system/tests/test_memory_cache.py b/src/tests/system/tests/test_memcache.py similarity index 96% rename from src/tests/system/tests/test_memory_cache.py rename to src/tests/system/tests/test_memcache.py index 7c743e35511..ab476552463 100644 --- a/src/tests/system/tests/test_memory_cache.py +++ b/src/tests/system/tests/test_memcache.py @@ -1,5 +1,5 @@ """ -SSSD Memory cache-related Test Cases +SSSD In-Memory Cache (memcache) Test Cases. :requirement: IDM-SSSD-REQ: Client side performance improvements """ @@ -16,7 +16,7 @@ @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_users(client: Client, provider: GenericProvider): +def test_memcache__lookup_users(client: Client, provider: GenericProvider): """ :title: Lookup user by name uses memory cache when SSSD is stopped :setup: @@ -57,7 +57,7 @@ def check(users): @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_groups(client: Client, provider: GenericProvider): +def test_memcache__lookup_groups(client: Client, provider: GenericProvider): """ :title: Lookup group by groupname uses memory cache when SSSD is stopped :setup: @@ -98,7 +98,7 @@ def check(groups): @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__user_cache_is_disabled_and_lookup_groups(client: Client, provider: GenericProvider): +def test_memcache__user_cache_is_disabled_and_lookup_groups(client: Client, provider: GenericProvider): """ :title: Lookup group by groupname uses memory cache when SSSD is stopped and 'memcache_size_passwd' = 0 :setup: @@ -141,7 +141,7 @@ def check(groups): @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__user_cache_is_disabled_and_lookup_users(client: Client, provider: GenericProvider): +def test_memcache__user_cache_is_disabled_and_lookup_users(client: Client, provider: GenericProvider): """ :title: Lookup user by name when SSSD is stopped and 'memcache_size_passwd' = 0 uses memory cache therefore user is not found @@ -188,7 +188,7 @@ def test_memory_cache__user_cache_is_disabled_and_lookup_users(client: Client, p @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__initgroup_cache_is_disabled_and_lookup_groups(client: Client, provider: GenericProvider): +def test_memcache__initgroup_cache_is_disabled_and_lookup_groups(client: Client, provider: GenericProvider): """ :title: Lookup group by groupname when SSSD is stopped and 'memcache_size_initgroups' = 0 uses memory cache :setup: @@ -231,7 +231,7 @@ def check(groups): @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__initgroup_cache_is_disabled_and_lookup_users(client: Client, provider: GenericProvider): +def test_memcache__initgroup_cache_is_disabled_and_lookup_users(client: Client, provider: GenericProvider): """ :title: Lookup user by name and id when SSSD is stopped and 'memcache_size_initgroups' = 0 uses memory cache :setup: @@ -286,7 +286,7 @@ def check(ids): @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__group_cache_disabled_and_lookup_groups(client: Client, provider: GenericProvider): +def test_memcache__group_cache_disabled_and_lookup_groups(client: Client, provider: GenericProvider): """ :title: Lookup user by name and id when SSSD is stopped and 'memcache_size_group' = 0 uses memory cache, but lookup groups is not possible @@ -360,7 +360,7 @@ def check(users): @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__all_caches_disabled_and_all_lookups_fails(client: Client, provider: GenericProvider): +def test_memcache__all_caches_disabled_and_all_lookups_fails(client: Client, provider: GenericProvider): """ :title: Lookup user and group when SSSD is stopped and whole cache disabled uses memory cache and therefore it is not possible @@ -437,7 +437,7 @@ def test_memory_cache__all_caches_disabled_and_all_lookups_fails(client: Client, @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_users_check_group_memberships(client: Client, provider: GenericProvider): +def test_memcache__lookup_users_check_group_memberships(client: Client, provider: GenericProvider): """ :title: Lookup user by name and test membership by name use memory cache when SSSD is stopped :setup: @@ -490,7 +490,7 @@ def check(): @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_users_and_check_membership_by_gid(client: Client, provider: GenericProvider): +def test_memcache__lookup_users_and_check_membership_by_gid(client: Client, provider: GenericProvider): """ :title: Lookup user by name and test membership by gid use memory cache when SSSD is stopped :setup: @@ -546,7 +546,7 @@ def check(): @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_uids_and_check_membership_by_gid(client: Client, provider: GenericProvider): +def test_memcache__lookup_uids_and_check_membership_by_gid(client: Client, provider: GenericProvider): """ :title: Lookup user by id and test membership by gid use memory cache when SSSD is stopped :setup: @@ -602,7 +602,7 @@ def check(): @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_users_by_fully_qualified_names(client: Client, provider: GenericProvider): +def test_memcache__lookup_users_by_fully_qualified_names(client: Client, provider: GenericProvider): """ :title: Lookup user by full name when 'use_fully_qualified_names' is 'true' uses memory cache when sssd is stopped @@ -655,7 +655,7 @@ def check(): @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_users_when_case_insensitive_is_false(client: Client, provider: GenericProvider): +def test_memcache__lookup_users_when_case_insensitive_is_false(client: Client, provider: GenericProvider): """ :title: Lookup user by case insensitive name when 'case_sensitive' is 'false' uses memory cache when SSSD is stopped @@ -718,7 +718,7 @@ def test_memory_cache__lookup_users_when_case_insensitive_is_false(client: Clien @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_users_when_fully_qualified_name_is_true_and_case_ins_is_false( +def test_memcache__lookup_users_when_fully_qualified_name_is_true_and_case_ins_is_false( client: Client, provider: GenericProvider ): """ @@ -780,7 +780,7 @@ def test_memory_cache__lookup_users_when_fully_qualified_name_is_true_and_case_i @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidation_of_gids_after_initgroups(client: Client, provider: GenericProvider): +def test_memcache__invalidation_of_gids_after_initgroups(client: Client, provider: GenericProvider): """ :title: Invalidate groups after initgroups call when SSSD is stopped :setup: @@ -860,7 +860,7 @@ def check_group(name, gid): @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__lookup_initgroups_without_change_in_membership(client: Client, provider: GenericProvider): +def test_memcache__lookup_initgroups_without_change_in_membership(client: Client, provider: GenericProvider): """ :title: Invalidated cache, after refresh and stopped SSSD, has everything loaded in memory :setup: @@ -949,7 +949,7 @@ def check(): @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_user_cache_before_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_user_cache_before_stop(client: Client, provider: GenericProvider): """ :title: Invalidate user cache before SSSD is stopped :setup: @@ -1005,7 +1005,7 @@ def test_memory_cache__invalidate_user_cache_before_stop(client: Client, provide @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_user_cache_after_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_user_cache_after_stop(client: Client, provider: GenericProvider): """ :title: Invalidate user cache after SSSD is stopped :setup: @@ -1061,7 +1061,7 @@ def test_memory_cache__invalidate_user_cache_after_stop(client: Client, provider @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_users_cache_before_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_users_cache_before_stop(client: Client, provider: GenericProvider): """ :title: Invalidate users cache before SSSD is stopped :setup: @@ -1125,7 +1125,7 @@ def test_memory_cache__invalidate_users_cache_before_stop(client: Client, provid @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_users_cache_after_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_users_cache_after_stop(client: Client, provider: GenericProvider): """ :title: Invalidate users cache after SSSD is stopped :setup: @@ -1189,7 +1189,7 @@ def test_memory_cache__invalidate_users_cache_after_stop(client: Client, provide @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_group_cache_before_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_group_cache_before_stop(client: Client, provider: GenericProvider): """ :title: Invalidate group cache before SSSD is stopped :setup: @@ -1232,7 +1232,7 @@ def test_memory_cache__invalidate_group_cache_before_stop(client: Client, provid @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_group_cache_after_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_group_cache_after_stop(client: Client, provider: GenericProvider): """ :title: Invalidate group cache after SSSD is stopped :setup: @@ -1275,7 +1275,7 @@ def test_memory_cache__invalidate_group_cache_after_stop(client: Client, provide @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_groups_cache_before_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_groups_cache_before_stop(client: Client, provider: GenericProvider): """ :title: Invalidate groups cache before SSSD is stopped :setup: @@ -1322,7 +1322,7 @@ def test_memory_cache__invalidate_groups_cache_before_stop(client: Client, provi @pytest.mark.importance("high") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_groups_cache_after_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_groups_cache_after_stop(client: Client, provider: GenericProvider): """ :title: Invalidate groups cache after SSSD is stopped :setup: @@ -1369,7 +1369,7 @@ def test_memory_cache__invalidate_groups_cache_after_stop(client: Client, provid @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_everything_before_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_everything_before_stop(client: Client, provider: GenericProvider): """ :title: Invalidate all parts of cache before SSSD is stopped :setup: @@ -1440,7 +1440,7 @@ def test_memory_cache__invalidate_everything_before_stop(client: Client, provide @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__invalidate_everything_after_stop(client: Client, provider: GenericProvider): +def test_memcache__invalidate_everything_after_stop(client: Client, provider: GenericProvider): """ :title: Invalidate all parts of cache after SSSD is stopped :setup: @@ -1511,7 +1511,7 @@ def test_memory_cache__invalidate_everything_after_stop(client: Client, provider @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__memcache_timeout_zero(client: Client, provider: GenericProvider): +def test_memcache__memcache_timeout_zero(client: Client, provider: GenericProvider): """ :title: Cache is not created at all when 'memcache_timeout' set to '0' :setup: @@ -1571,7 +1571,7 @@ def test_memory_cache__memcache_timeout_zero(client: Client, provider: GenericPr @pytest.mark.importance("critical") @pytest.mark.cache @pytest.mark.topology(KnownTopologyGroup.AnyProvider) -def test_memory_cache__removed_cache_without_invalidation(client: Client, provider: GenericProvider): +def test_memcache__removed_cache_without_invalidation(client: Client, provider: GenericProvider): """ :title: SSSD is stopped, cache removed then users and groups cannot be lookedup :setup: @@ -1629,7 +1629,7 @@ def test_memory_cache__removed_cache_without_invalidation(client: Client, provid @pytest.mark.topology(KnownTopology.LDAP) @pytest.mark.ticket(bz=2226021) -def test_memory_cache__truncate_in_memory_cache_no_sigbus(client: Client, ldap: LDAP): +def test_memcache__truncate_in_memory_cache_no_sigbus(client: Client, ldap: LDAP): """ :title: Accessing truncated in-memory cache file does not cause SIGBUS :setup: diff --git a/src/tests/system/tests/test_tools.py b/src/tests/system/tests/test_tools.py new file mode 100644 index 00000000000..bf69d14f2a7 --- /dev/null +++ b/src/tests/system/tests/test_tools.py @@ -0,0 +1,61 @@ +""" +Tools Tests. + +Tests pertaining to command line tools, some tools will have their own file. + +* sssctl: test_sssctl.py +* sss_cache +* sss_obfuscate +* sss_seed +* sss_debuglevel +* sss_override: sss_override.py +* sss_ssh_authorizedkeys +* sss_ssh_knownhostsproxy + +:requirement: Tools +""" + +from __future__ import annotations + +import pytest +from pytest_mh.ssh import SSHProcessError +from sssd_test_framework.roles.client import Client +from sssd_test_framework.topology import KnownTopology + + +@pytest.mark.importance("medium") +@pytest.mark.ticket(bz=1661182) +@pytest.mark.topology(KnownTopology.Client) +def test_tools__sss_cache_expired_does_not_print_unrelated_message(client: Client): + """ + :title: Usermod command does not print unrelated sss_cache messages + :setup: + 1. Configure SSSD without any domain + 2. Set to sssd section "enable_files_domain" to "false" + 3. Create local user + :steps: + 1. Restart SSSD + 2. Modify existing local user + 3. Expire cache with specific options + :expectedresults: + 1. Error is raised, SSSD is not running + 2. Modified successfully + 3. Output did not contain wrong messages + :customerscenario: True + """ + client.sssd.sssd["enable_files_domain"] = "false" + client.local.user("user1").add() + + with pytest.raises(SSHProcessError): + client.sssd.restart() + + res = client.host.ssh.run("usermod -a -G wheel user1") + assert ( + "No domains configured, fatal error!" not in res.stdout + ), "'No domains configured, fatal error!' printed to stdout!" + + for cmd in ("sss_cache -U", "sss_cache -G", "sss_cache -E", "sss_cache --user=nonexisting"): + res = client.host.ssh.run(cmd) + assert ( + "No domains configured, fatal error!" not in res.stdout + ), "'No domains configured, fatal error!' printed to stdout!"