#
# LDAP integration test
#
# Copyright (c) 2015 Red Hat, Inc.
# Author: Lukas Slebodnik <lslebodn@redhat.com>
#
# 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 pytest
import ds_openldap
import ldap_ent
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():
"""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
[sssd]
domains = LDAP
services = nss
[nss]
ldap_auth_disable_tls_never_use_in_production = true
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
[sssd]
domains = LDAP
services = nss
[nss]
ldap_auth_disable_tls_never_use_in_production = true
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}
use_fully_qualified_names = true
return None
[sssd]
domains = LDAP
services = nss
[nss]
ldap_auth_disable_tls_never_use_in_production = true
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}
use_fully_qualified_names = true
case_sensitive = false
return None
'user1',
1001,
'user2',
1002,
'user3',
1003,
'user11',
1011,
'user12',
1012,
'user13',
1013,
'user21',
1021,
'user22',
1022,
'user23',
1023,
"group1",
2001,
"group2",
2002,
"group3",
2003,
"group0x",
2000,
"group1x",
2010,
"group2x",
2020,
"result: %s\n expected %s" % (
)
"result: %s\n expected %s" % (
)
# Just last invocation of initgroups shoudl PASS
# Otherwise, we would not be able to invalidate it
user1_case1 = 'User1@LDAP'
user1_case2 = 'uSer1@LDAP'
user1_case_last = 'usEr1@LDAP'
primary_gid = 2001
user1_case1 = 'usEr1@LDAP'
user1_case2 = 'User1@LDAP'
user1_case_last = 'uSer1@LDAP'
primary_gid = 2001
user1_case1 = 'uSer1@LDAP'
user1_case2 = 'usEr1@LDAP'
user1_case_last = 'User1@LDAP'
primary_gid = 2001
'user1',
1001,
"group1",
2001,
# unrelated group to user1
"group2",
2002,
# the sssd cache was empty and not all user's group were
# resolved with getgr{nm,gid}. Therefore there is a change in
# group membership => user groups should be invalidated
'user1',
1001,
# unrelated group to user1 must be returned
"group2",
2002,
# user groups must be invalidated
# the sssd cache was empty and not all user's group were
# resolved with getgr{nm,gid}. Therefore there is a change in
# group membership => user groups should be invalidated
# invalidate cache
# all users and groups will be just refreshed from LDAP
# but there will not be a change in group membership
# user groups should not be invlaidated
# everything should be in memory cache
def assert_mc_records_for_user1():
'user1',
1001,
"group1",
2001,
"group0x",
2000,
"Initgroups should not find anything after invalidation of mc.\n" \
"User user1, errno:%d" % err
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
# initialize cache with full ID
"Could not find groups for user1, %d" % errno
"""
Regression test for ticket:
"""
'user1',
1001,
# remove cache without invalidation
# sssd is stopped; so the memory cache should not be used
# in long living clients (py.test in this case)