>From 11b4e1012b8c54050c46ca4f8387992f2a3d5f09 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Fri, 6 Nov 2015 11:37:54 +0100 Subject: [PATCH 3/4] 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 --- src/tests/intg/test_local_domain.py | 6 ++---- src/tests/intg/test_memory_cache.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/tests/intg/test_local_domain.py b/src/tests/intg/test_local_domain.py index c62de16ce04b640503250c926d6eb3d199ed0728..4de0f5da2da38b71fef07d0a993fc4beaca39d9a 100644 --- a/src/tests/intg/test_local_domain.py +++ b/src/tests/intg/test_local_domain.py @@ -61,10 +61,8 @@ def create_sssd_fixture(request): subprocess.call(["sss_cache", "-E"]) for path in os.listdir(config.DB_PATH): os.unlink(config.DB_PATH + "/" + path) - # FIXME: Uncomment this when ticket #2726 is solved - # https://fedorahosted.org/sssd/ticket/2726 - # for path in os.listdir(config.MCACHE_PATH): - # os.unlink(config.MCACHE_PATH + "/" + path) + for path in os.listdir(config.MCACHE_PATH): + os.unlink(config.MCACHE_PATH + "/" + path) request.addfinalizer(teardown) diff --git a/src/tests/intg/test_memory_cache.py b/src/tests/intg/test_memory_cache.py index a8d6d8f5c87bdea517a00b5a703b9658ebb1fe0a..c88bd896aa8620c2670c7181f09bf31744aa32cc 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) -- 2.5.0