#
# Infopipe integration test
#
# Copyright (c) 2017 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 pwd
import signal
import subprocess
import errno
import time
import ldap
import pytest
import dbus
import config
import ds_openldap
import ldap_ent
LDAP_BASE_DN = "dc=example,dc=com"
"""Start the SSSD process"""
dbus_commands = [
"--nosyslog", "--fork"],
]
for dbus_command in dbus_commands:
try:
break
else:
pass
if not dbus_started:
raise Exception("dbus-daemon start failed")
# wait 10 seconds for pidfile
wait_time = 10
break
"""Stop the SSSD process and remove its state"""
# stop process only if running
try:
while True:
try:
except:
break
except:
pass
# clean pid so we can start service one more time
# dbus-daemon 1.2.24 does not clean pid file after itself
try:
raise
def cleanup_dbus_process():
"""LDAP server instance fixture"""
"cn=admin", "Secret123"
)
try:
except:
raise
return ds_inst
"""LDAP server connection fixture"""
return ldap_conn
"""Add LDAP entries from ent_list"""
if ent_list is not None:
"""Remove LDAP entries added by create_ldap_entries"""
if ent_list is None:
attrlist=[]):
else:
"""Add LDAP entries and add teardown for removing them"""
"""Format a basic SSSD configuration"""
if schema == SCHEMA_RFC2307_BIS:
schema_conf += "ldap_group_object_class = groupOfNames\n"
return unindent("""\
[sssd]
debug_level = 0xffff
domains = LDAP, app
services = nss, ifp
enable_files_domain = false
[nss]
memcache_timeout = 0
[ifp]
# it need to be executed with valgrind because there is a problem
# problem with "ifp" + client regristration in monitor
# There is not such problem in 1st test. Just in following tests.
command = {ifp_command} --uid 0 --gid 0 --debug-to-files
{schema_conf}
id_provider = ldap
ldap_uri = {ldap_conn.ds_inst.ldap_url}
ldap_search_base = {ldap_conn.ds_inst.base_dn}
inherit_from = LDAP
"""Format an SSSD configuration with all caches refreshing in 4 seconds"""
return \
unindent("""
[nss]
memcache_timeout = 0
entry_negative_timeout = 0
ldap_purge_cache_timeout = 1
entry_cache_timeout = {0}
"""Create sssd.conf with specified contents"""
def cleanup_conf_file():
"""Remove sssd.conf, if it exists"""
"""Add teardown for removing sssd.conf"""
"""
Create sssd.conf with specified contents and add teardown for removing it
"""
def create_sssd_process():
"""Start the SSSD process"""
raise Exception("sssd start failed")
def cleanup_sssd_process():
"""Stop the SSSD process and remove its state"""
try:
while True:
try:
except:
break
except:
pass
"""Add teardown for stopping SSSD and removing its state"""
"""Start SSSD and add teardown for stopping it and removing its state"""
return None
return None
# test with disabled introspection
'/org/freedesktop/sssd/infopipe',
# test missing parameter
'"string", but is actually of type ' \
'"invalid"\n'
# test wrong parameter type
'"string", but is actually of type ' \
'"int32"\n'
# test wrong parameter value
# positive test
assert ret == "PONG"
# test case insensitive input
assert ret == "PONG"
assert ret == "PONG"
'/org/freedesktop/sssd/infopipe')
# test missing parameter
'arguments'
# test wrong parameter type
# test wrong parameter value
# positive test
assert ret == "PONG"
# test case insensitive input
assert ret == "PONG"
assert ret == "PONG"
'/org/freedesktop/sssd/infopipe')
'loginShell']
loginShell='/bin/bash')
# check values of attributes
for attr in user_attrs:
'/org/freedesktop/sssd/infopipe')
# negative test
# test 0 attributes
# expect empty sequence; len(user_attrs) == 0
assert not user_attrs
# positive test
'loginShell']
loginShell='/bin/bash')
# check values of attributes
for attr in user_attrs:
'/org/freedesktop/sssd/infopipe')
# negative test
# the same test via nss responder
# 0 groups
# expect empty sequence; len(res) == 0
assert not res
# single group
# more groups
assert "Error" not in output