|
|
6cf099 |
From a45f9034e912b6242459a8d576f60ff829508bc3 Mon Sep 17 00:00:00 2001
|
|
|
6cf099 |
From: Lukas Slebodnik <lslebodn@redhat.com>
|
|
|
6cf099 |
Date: Tue, 21 Jul 2015 08:55:14 +0200
|
|
|
6cf099 |
Subject: [PATCH 43/47] intg_test: Add integration test for memory cache
|
|
|
6cf099 |
MIME-Version: 1.0
|
|
|
6cf099 |
Content-Type: text/plain; charset=UTF-8
|
|
|
6cf099 |
Content-Transfer-Encoding: 8bit
|
|
|
6cf099 |
|
|
|
6cf099 |
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
|
6cf099 |
(cherry picked from commit a2c10cf31d14bac598f5cd008973375c3f9575a6)
|
|
|
6cf099 |
---
|
|
|
6cf099 |
src/tests/intg/Makefile.am | 1 +
|
|
|
6cf099 |
src/tests/intg/test_memory_cache.py | 347 ++++++++++++++++++++++++++++++++++++
|
|
|
6cf099 |
2 files changed, 348 insertions(+)
|
|
|
6cf099 |
create mode 100644 src/tests/intg/test_memory_cache.py
|
|
|
6cf099 |
|
|
|
6cf099 |
diff --git a/src/tests/intg/Makefile.am b/src/tests/intg/Makefile.am
|
|
|
6cf099 |
index 7488022ed59dd894ba7b6808c5573706412098c7..6819c2f2cea137c7544e94b0b29391611533b20c 100644
|
|
|
6cf099 |
--- a/src/tests/intg/Makefile.am
|
|
|
6cf099 |
+++ b/src/tests/intg/Makefile.am
|
|
|
6cf099 |
@@ -8,6 +8,7 @@ dist_noinst_DATA = \
|
|
|
6cf099 |
ldap_ent.py \
|
|
|
6cf099 |
ldap_test.py \
|
|
|
6cf099 |
util.py \
|
|
|
6cf099 |
+ test_memory_cache.py \
|
|
|
6cf099 |
$(NULL)
|
|
|
6cf099 |
|
|
|
6cf099 |
config.py: config.py.m4
|
|
|
6cf099 |
diff --git a/src/tests/intg/test_memory_cache.py b/src/tests/intg/test_memory_cache.py
|
|
|
6cf099 |
new file mode 100644
|
|
|
6cf099 |
index 0000000000000000000000000000000000000000..5a1f07651b70a5bf1fbacceeae6825ea4341e3b5
|
|
|
6cf099 |
--- /dev/null
|
|
|
6cf099 |
+++ b/src/tests/intg/test_memory_cache.py
|
|
|
6cf099 |
@@ -0,0 +1,347 @@
|
|
|
6cf099 |
+#
|
|
|
6cf099 |
+# LDAP integration test
|
|
|
6cf099 |
+#
|
|
|
6cf099 |
+# Copyright (c) 2015 Red Hat, Inc.
|
|
|
6cf099 |
+# Author: Lukas Slebodnik <lslebodn@redhat.com>
|
|
|
6cf099 |
+#
|
|
|
6cf099 |
+# This is free software; you can redistribute it and/or modify it
|
|
|
6cf099 |
+# under the terms of the GNU General Public License as published by
|
|
|
6cf099 |
+# the Free Software Foundation; version 2 only
|
|
|
6cf099 |
+#
|
|
|
6cf099 |
+# This program is distributed in the hope that it will be useful, but
|
|
|
6cf099 |
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
6cf099 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
6cf099 |
+# General Public License for more details.
|
|
|
6cf099 |
+#
|
|
|
6cf099 |
+# You should have received a copy of the GNU General Public License
|
|
|
6cf099 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
6cf099 |
+#
|
|
|
6cf099 |
+import os
|
|
|
6cf099 |
+import stat
|
|
|
6cf099 |
+import ent
|
|
|
6cf099 |
+import config
|
|
|
6cf099 |
+import signal
|
|
|
6cf099 |
+import subprocess
|
|
|
6cf099 |
+import time
|
|
|
6cf099 |
+import pytest
|
|
|
6cf099 |
+import ds_openldap
|
|
|
6cf099 |
+import ldap_ent
|
|
|
6cf099 |
+import sssd_id
|
|
|
6cf099 |
+from util import unindent
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+LDAP_BASE_DN = "dc=example,dc=com"
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+@pytest.fixture(scope="module")
|
|
|
6cf099 |
+def ds_inst(request):
|
|
|
6cf099 |
+ """LDAP server instance fixture"""
|
|
|
6cf099 |
+ ds_inst = ds_openldap.DSOpenLDAP(
|
|
|
6cf099 |
+ config.PREFIX, 10389, LDAP_BASE_DN,
|
|
|
6cf099 |
+ "cn=admin", "Secret123")
|
|
|
6cf099 |
+ try:
|
|
|
6cf099 |
+ ds_inst.setup()
|
|
|
6cf099 |
+ except:
|
|
|
6cf099 |
+ ds_inst.teardown()
|
|
|
6cf099 |
+ raise
|
|
|
6cf099 |
+ request.addfinalizer(lambda: ds_inst.teardown())
|
|
|
6cf099 |
+ return ds_inst
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+@pytest.fixture(scope="module")
|
|
|
6cf099 |
+def ldap_conn(request, ds_inst):
|
|
|
6cf099 |
+ """LDAP server connection fixture"""
|
|
|
6cf099 |
+ ldap_conn = ds_inst.bind()
|
|
|
6cf099 |
+ ldap_conn.ds_inst = ds_inst
|
|
|
6cf099 |
+ request.addfinalizer(lambda: ldap_conn.unbind_s())
|
|
|
6cf099 |
+ return ldap_conn
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def create_ldap_fixture(request, ldap_conn, ent_list):
|
|
|
6cf099 |
+ """Add LDAP entries and add teardown for removing them"""
|
|
|
6cf099 |
+ for entry in ent_list:
|
|
|
6cf099 |
+ ldap_conn.add_s(entry[0], entry[1])
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ def teardown():
|
|
|
6cf099 |
+ for entry in ent_list:
|
|
|
6cf099 |
+ ldap_conn.delete_s(entry[0])
|
|
|
6cf099 |
+ request.addfinalizer(teardown)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def create_conf_fixture(request, contents):
|
|
|
6cf099 |
+ """Generate sssd.conf and add teardown for removing it"""
|
|
|
6cf099 |
+ conf = open(config.CONF_PATH, "w")
|
|
|
6cf099 |
+ conf.write(contents)
|
|
|
6cf099 |
+ conf.close()
|
|
|
6cf099 |
+ os.chmod(config.CONF_PATH, stat.S_IRUSR | stat.S_IWUSR)
|
|
|
6cf099 |
+ request.addfinalizer(lambda: os.unlink(config.CONF_PATH))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def stop_sssd():
|
|
|
6cf099 |
+ pid_file = open(config.PIDFILE_PATH, "r")
|
|
|
6cf099 |
+ pid = int(pid_file.read())
|
|
|
6cf099 |
+ os.kill(pid, signal.SIGTERM)
|
|
|
6cf099 |
+ while True:
|
|
|
6cf099 |
+ try:
|
|
|
6cf099 |
+ os.kill(pid, signal.SIGCONT)
|
|
|
6cf099 |
+ except:
|
|
|
6cf099 |
+ break
|
|
|
6cf099 |
+ time.sleep(1)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def create_sssd_fixture(request):
|
|
|
6cf099 |
+ """Start sssd and add teardown for stopping it and removing state"""
|
|
|
6cf099 |
+ if subprocess.call(["sssd", "-D", "-f"]) != 0:
|
|
|
6cf099 |
+ raise Exception("sssd start failed")
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ def teardown():
|
|
|
6cf099 |
+ try:
|
|
|
6cf099 |
+ stop_sssd()
|
|
|
6cf099 |
+ except:
|
|
|
6cf099 |
+ pass
|
|
|
6cf099 |
+ subprocess.call(["sss_cache", "-E"])
|
|
|
6cf099 |
+ for path in os.listdir(config.DB_PATH):
|
|
|
6cf099 |
+ os.unlink(config.DB_PATH + "/" + path)
|
|
|
6cf099 |
+ for path in os.listdir(config.MCACHE_PATH):
|
|
|
6cf099 |
+ os.unlink(config.MCACHE_PATH + "/" + path)
|
|
|
6cf099 |
+ request.addfinalizer(teardown)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+@pytest.fixture
|
|
|
6cf099 |
+def sanity_rfc2307(request, ldap_conn):
|
|
|
6cf099 |
+ ent_list = ldap_ent.List(LDAP_BASE_DN)
|
|
|
6cf099 |
+ ent_list.add_user("user1", 1001, 2001)
|
|
|
6cf099 |
+ ent_list.add_user("user2", 1002, 2002)
|
|
|
6cf099 |
+ ent_list.add_user("user3", 1003, 2003)
|
|
|
6cf099 |
+ ent_list.add_user("user11", 1011, 2001)
|
|
|
6cf099 |
+ ent_list.add_user("user12", 1012, 2002)
|
|
|
6cf099 |
+ ent_list.add_user("user13", 1013, 2003)
|
|
|
6cf099 |
+ ent_list.add_user("user21", 1021, 2001)
|
|
|
6cf099 |
+ ent_list.add_user("user22", 1022, 2002)
|
|
|
6cf099 |
+ ent_list.add_user("user23", 1023, 2003)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent_list.add_group("group1", 2001, ["user1", "user11", "user21"])
|
|
|
6cf099 |
+ ent_list.add_group("group2", 2002, ["user2", "user12", "user22"])
|
|
|
6cf099 |
+ ent_list.add_group("group3", 2003, ["user3", "user13", "user23"])
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent_list.add_group("group0x", 2000, ["user1", "user2", "user3"])
|
|
|
6cf099 |
+ ent_list.add_group("group1x", 2010, ["user11", "user12", "user13"])
|
|
|
6cf099 |
+ ent_list.add_group("group2x", 2020, ["user21", "user22", "user23"])
|
|
|
6cf099 |
+ create_ldap_fixture(request, ldap_conn, ent_list)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ conf = unindent("""\
|
|
|
6cf099 |
+ [sssd]
|
|
|
6cf099 |
+ config_file_version = 2
|
|
|
6cf099 |
+ domains = LDAP
|
|
|
6cf099 |
+ services = nss
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ [nss]
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ [domain/LDAP]
|
|
|
6cf099 |
+ ldap_auth_disable_tls_never_use_in_production = true
|
|
|
6cf099 |
+ ldap_schema = rfc2307
|
|
|
6cf099 |
+ id_provider = ldap
|
|
|
6cf099 |
+ auth_provider = ldap
|
|
|
6cf099 |
+ sudo_provider = ldap
|
|
|
6cf099 |
+ ldap_uri = {ldap_conn.ds_inst.ldap_url}
|
|
|
6cf099 |
+ ldap_search_base = {ldap_conn.ds_inst.base_dn}
|
|
|
6cf099 |
+ """).format(**locals())
|
|
|
6cf099 |
+ create_conf_fixture(request, conf)
|
|
|
6cf099 |
+ create_sssd_fixture(request)
|
|
|
6cf099 |
+ return None
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_getpwnam(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user1',
|
|
|
6cf099 |
+ dict(name='user1', passwd='*', uid=1001, gid=2001,
|
|
|
6cf099 |
+ gecos='1001', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1001,
|
|
|
6cf099 |
+ dict(name='user1', passwd='*', uid=1001, gid=2001,
|
|
|
6cf099 |
+ gecos='1001', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user2',
|
|
|
6cf099 |
+ dict(name='user2', passwd='*', uid=1002, gid=2002,
|
|
|
6cf099 |
+ gecos='1002', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1002,
|
|
|
6cf099 |
+ dict(name='user2', passwd='*', uid=1002, gid=2002,
|
|
|
6cf099 |
+ gecos='1002', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user3',
|
|
|
6cf099 |
+ dict(name='user3', passwd='*', uid=1003, gid=2003,
|
|
|
6cf099 |
+ gecos='1003', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1003,
|
|
|
6cf099 |
+ dict(name='user3', passwd='*', uid=1003, gid=2003,
|
|
|
6cf099 |
+ gecos='1003', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user11',
|
|
|
6cf099 |
+ dict(name='user11', passwd='*', uid=1011, gid=2001,
|
|
|
6cf099 |
+ gecos='1011', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1011,
|
|
|
6cf099 |
+ dict(name='user11', passwd='*', uid=1011, gid=2001,
|
|
|
6cf099 |
+ gecos='1011', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user12',
|
|
|
6cf099 |
+ dict(name='user12', passwd='*', uid=1012, gid=2002,
|
|
|
6cf099 |
+ gecos='1012', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1012,
|
|
|
6cf099 |
+ dict(name='user12', passwd='*', uid=1012, gid=2002,
|
|
|
6cf099 |
+ gecos='1012', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user13',
|
|
|
6cf099 |
+ dict(name='user13', passwd='*', uid=1013, gid=2003,
|
|
|
6cf099 |
+ gecos='1013', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1013,
|
|
|
6cf099 |
+ dict(name='user13', passwd='*', uid=1013, gid=2003,
|
|
|
6cf099 |
+ gecos='1013', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user21',
|
|
|
6cf099 |
+ dict(name='user21', passwd='*', uid=1021, gid=2001,
|
|
|
6cf099 |
+ gecos='1021', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1021,
|
|
|
6cf099 |
+ dict(name='user21', passwd='*', uid=1021, gid=2001,
|
|
|
6cf099 |
+ gecos='1021', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user22',
|
|
|
6cf099 |
+ dict(name='user22', passwd='*', uid=1022, gid=2002,
|
|
|
6cf099 |
+ gecos='1022', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1022,
|
|
|
6cf099 |
+ dict(name='user22', passwd='*', uid=1022, gid=2002,
|
|
|
6cf099 |
+ gecos='1022', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_passwd_by_name(
|
|
|
6cf099 |
+ 'user23',
|
|
|
6cf099 |
+ dict(name='user23', passwd='*', uid=1023, gid=2003,
|
|
|
6cf099 |
+ gecos='1023', shell='/bin/bash'))
|
|
|
6cf099 |
+ ent.assert_passwd_by_uid(
|
|
|
6cf099 |
+ 1023,
|
|
|
6cf099 |
+ dict(name='user23', passwd='*', uid=1023, gid=2003,
|
|
|
6cf099 |
+ gecos='1023', shell='/bin/bash'))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_getpwnam_with_mc(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ test_getpwnam(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+ stop_sssd()
|
|
|
6cf099 |
+ test_getpwnam(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_getgrnam_simple(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ ent.assert_group_by_name("group1", dict(name="group1", gid=2001))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(2001, dict(name="group1", gid=2001))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name("group2", dict(name="group2", gid=2002))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(2002, dict(name="group2", gid=2002))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name("group3", dict(name="group3", gid=2003))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(2003, dict(name="group3", gid=2003))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name("group0x", dict(name="group0x", gid=2000))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(2000, dict(name="group0x", gid=2000))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name("group1x", dict(name="group1x", gid=2010))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(2010, dict(name="group1x", gid=2010))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name("group2x", dict(name="group2x", gid=2020))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(2020, dict(name="group2x", gid=2020))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_getgrnam_simple_with_mc(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ test_getgrnam_simple(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+ stop_sssd()
|
|
|
6cf099 |
+ test_getgrnam_simple(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_getgrnam_membership(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ ent.assert_group_by_name(
|
|
|
6cf099 |
+ "group1",
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user1", "user11", "user21")))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(
|
|
|
6cf099 |
+ 2001,
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user1", "user11", "user21")))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name(
|
|
|
6cf099 |
+ "group2",
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user2", "user12", "user22")))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(
|
|
|
6cf099 |
+ 2002,
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user2", "user12", "user22")))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name(
|
|
|
6cf099 |
+ "group3",
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user3", "user13", "user23")))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(
|
|
|
6cf099 |
+ 2003,
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user3", "user13", "user23")))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name(
|
|
|
6cf099 |
+ "group0x",
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user1", "user2", "user3")))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(
|
|
|
6cf099 |
+ 2000,
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user1", "user2", "user3")))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name(
|
|
|
6cf099 |
+ "group1x",
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user11", "user12", "user13")))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(
|
|
|
6cf099 |
+ 2010,
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user11", "user12", "user13")))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ent.assert_group_by_name(
|
|
|
6cf099 |
+ "group2x",
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user21", "user22", "user23")))
|
|
|
6cf099 |
+ ent.assert_group_by_gid(
|
|
|
6cf099 |
+ 2020,
|
|
|
6cf099 |
+ dict(mem=ent.contains_only("user21", "user22", "user23")))
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_getgrnam_membership_with_mc(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ test_getgrnam_membership(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+ stop_sssd()
|
|
|
6cf099 |
+ test_getgrnam_membership(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def assert_user_gids_equal(user, expected_gids):
|
|
|
6cf099 |
+ (res, errno, gids) = sssd_id.get_user_gids(user)
|
|
|
6cf099 |
+ assert res == sssd_id.NssReturnCode.SUCCESS, \
|
|
|
6cf099 |
+ "Could not find groups for user %s, %d" % (user, errno)
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ assert sorted(gids) == sorted(expected_gids), \
|
|
|
6cf099 |
+ "result: %s\n expected %s" % (
|
|
|
6cf099 |
+ ", ".join(["%s" % s for s in sorted(gids)]),
|
|
|
6cf099 |
+ ", ".join(["%s" % s for s in sorted(expected_gids)])
|
|
|
6cf099 |
+ )
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_initgroups(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ assert_user_gids_equal('user1', [2000, 2001])
|
|
|
6cf099 |
+ assert_user_gids_equal('user2', [2000, 2002])
|
|
|
6cf099 |
+ assert_user_gids_equal('user3', [2000, 2003])
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ assert_user_gids_equal('user11', [2010, 2001])
|
|
|
6cf099 |
+ assert_user_gids_equal('user12', [2010, 2002])
|
|
|
6cf099 |
+ assert_user_gids_equal('user13', [2010, 2003])
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ assert_user_gids_equal('user21', [2020, 2001])
|
|
|
6cf099 |
+ assert_user_gids_equal('user22', [2020, 2002])
|
|
|
6cf099 |
+ assert_user_gids_equal('user23', [2020, 2003])
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+def test_initgroups_with_mc(ldap_conn, sanity_rfc2307):
|
|
|
6cf099 |
+ test_initgroups(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
+ stop_sssd()
|
|
|
6cf099 |
+ test_initgroups(ldap_conn, sanity_rfc2307)
|
|
|
6cf099 |
--
|
|
|
6cf099 |
2.4.3
|
|
|
6cf099 |
|