#
# LDAP integration test - test updating the sysdb and timestamp
# cache
#
# Copyright (c) 2016 Red Hat, Inc.
#
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
import stat
import ent
import grp
import pwd
import config
import signal
import subprocess
import time
import ldap
import pytest
import ds_openldap
import ldap_ent
import sssd_ldb
import sssd_id
LDAP_BASE_DN = "dc=example,dc=com"
"""LDAP server instance fixture"""
"cn=admin", "Secret123")
try:
except:
raise
return ds_inst
"""LDAP server connection fixture"""
return ldap_conn
"""Add LDAP entries and add teardown for removing them"""
def teardown():
try:
except ldap.NO_SUCH_OBJECT:
# if the test already removed an object, it's fine
# to not care in the teardown
pass
"""Generate sssd.conf and add teardown for removing it"""
def stop_sssd():
while True:
try:
except:
break
"""Start sssd and add teardown for stopping it and removing state"""
raise Exception("sssd start failed")
def teardown():
try:
except:
pass
if schema == SCHEMA_RFC2307_BIS:
elif schema == SCHEMA_RFC2307:
[sssd]
domains = LDAP
services = nss
[nss]
memcache_timeout = 1
ldap_schema = rfc2307bis
id_provider = ldap
auth_provider = ldap
sudo_provider = ldap
ldap_group_object_class = groupOfNames
ldap_uri = {ldap_conn.ds_inst.ldap_url}
ldap_search_base = {ldap_conn.ds_inst.base_dn}
return None
[sssd]
domains = LDAP
services = nss
[nss]
memcache_timeout = 1
ldap_schema = rfc2307
id_provider = ldap
auth_provider = ldap
sudo_provider = ldap
ldap_uri = {ldap_conn.ds_inst.ldap_url}
ldap_search_base = {ldap_conn.ds_inst.base_dn}
return None
return ldb_conn
sysdb_attrs = dict()
return (sysdb_attrs, ts_attrs)
name,
# just to force different stamps and make sure memcache is gone
return sysdb_attrs, ts_attrs
# calling initgroups would add the initgExpire timestamp attribute and
# make sure that sss_cache doesn't add it with a value of 1,
# triggering a sysdb update
# just to force different stamps and make sure memcache is gone
return sysdb_attrs, ts_attrs
"""
Test that a group update with the same modifyTimestamp does not trigger
sysdb cache update
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
"group1",
"originalModifyTimestamp")
"""
Test that a group update with a different modifyTimestamp but the same
attrs does not trigger sysdb cache update
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
# modify an argument we don't save to the cache. This will bump the
# modifyTimestamp attribute, but the attributes themselves will be the same
# from sssd's point of view
# wait for slapd to change its database
"group1",
"originalModifyTimestamp")
"""
Test that a group update with different attribute triggers cache update
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
# wait for slapd to change its database
"group1",
"originalModifyTimestamp")
"""
Test that deleting a group removes it from both caches
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
# wait for slapd to change its database
"""
Test that a group update with the same modifyTimestamp does not trigger
sysdb cache update
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
"group1",
"originalModifyTimestamp")
"""
Test that a group update with a different modifyTimestamp but the same
attrs does not trigger sysdb cache update
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
# modify an argument we don't save to the cache. This will bump the
# modifyTimestamp attribute, but the attributes themselves will be the same
# from sssd's point of view
# wait for slapd to change its database
"group1",
"originalModifyTimestamp")
"""
Test that a group update with different attribute triggers cache update
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
# wait for slapd to change its database
"group1",
"originalModifyTimestamp")
"""
Test that deleting a group removes it from both caches
"""
ldb_conn, "group1",
("user1", "user11", "user21"))
# wait for slapd to change its database
"""
Test that a user update with the same modifyTimestamp does not trigger
sysdb cache update
"""
"originalModifyTimestamp")
"""
Test that a user update with the same modifyTimestamp does not trigger
sysdb cache update
"""
# modify an argument we don't save to the cache. This will bump the
# modifyTimestamp attribute, but the attributes themselves will be the same
# from sssd's point of view
# wait for slapd to change its database
"originalModifyTimestamp")
"""
Test that a user update with the same modifyTimestamp does not trigger
sysdb cache update
"""
# modify an argument we don't save to the cache. This will bump the
# modifyTimestamp attribute, but the attributes themselves will be the same
# from sssd's point of view
# wait for slapd to change its database
"originalModifyTimestamp")
"""
Test that deleting a user removes it from both caches
"""
# wait for slapd to change its database