From b28f5fb097e06a97a45e0ae348e506d9d1432cc8 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Fri, 6 Nov 2015 11:37:54 +0100 Subject: test_memory_cache: Test removing mc without invalidation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/tests/intg/test_local_domain.py | 6 ++---- src/tests/intg/test_memory_cache.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tests/intg/test_local_domain.py b/src/tests/intg/test_local_domain.py index c62de16c..4de0f5da 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 a8d6d8f5..c88bd896 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) -- cgit