From 87af3a1e57e8ddbffe847748b170a9a4f2ac8c1e Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Nov 12 2015 05:43:10 +0000 Subject: test_memory_cache: Test removing mc without invalidation Long living clients should be able to reinitialize memory cache which was removed but it not initialized. This patch also remove workaround in test_local_domain.py Test for: https://fedorahosted.org/sssd/ticket/2726 Reviewed-by: Michal Židek (cherry picked from commit b28f5fb097e06a97a45e0ae348e506d9d1432cc8) --- diff --git a/src/tests/intg/test_memory_cache.py b/src/tests/intg/test_memory_cache.py index 76d85fd..1501a7a 100644 --- a/src/tests/intg/test_memory_cache.py +++ b/src/tests/intg/test_memory_cache.py @@ -743,3 +743,39 @@ def test_invalidate_everything_after_stop(ldap_conn, sanity_rfc2307): subprocess.call(["sss_cache", "-E"]) assert_missing_mc_records_for_user1() + + +def test_removed_mc(ldap_conn, sanity_rfc2307): + """ + Regression test for ticket: + https://fedorahosted.org/sssd/ticket/2726 + """ + + ent.assert_passwd_by_name( + 'user1', + dict(name='user1', passwd='*', uid=1001, gid=2001, + gecos='1001', shell='/bin/bash')) + ent.assert_passwd_by_uid( + 1001, + dict(name='user1', passwd='*', uid=1001, gid=2001, + gecos='1001', shell='/bin/bash')) + + ent.assert_group_by_name("group1", dict(name="group1", gid=2001)) + ent.assert_group_by_gid(2001, dict(name="group1", gid=2001)) + stop_sssd() + + # remove cache without invalidation + for path in os.listdir(config.MCACHE_PATH): + os.unlink(config.MCACHE_PATH + "/" + path) + + # sssd is stopped; so the memory cache should not be used + # in long living clients (py.test in this case) + with pytest.raises(KeyError): + pwd.getpwnam('user1') + with pytest.raises(KeyError): + pwd.getpwuid(1001) + + with pytest.raises(KeyError): + grp.getgrnam('group1') + with pytest.raises(KeyError): + grp.getgrgid(2001)