#
# KCM responder integration tests
#
# 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 subprocess
import pytest
import socket
import time
import signal
import kdc
import krb5utils
import config
if my_uid is None:
return "KCM:%d" % my_uid
"""Kerberos server instance fixture"""
try:
except:
raise
return kdc_instance
"""Generate sssd.conf and add teardown for removing it"""
raise Exception("failed to regenerate confdb")
# It would be cleaner to use pytest.mark.skipif on the package level
# but upstream insists on supporting RHEL-6..
assert kcm_pid >= 0
if kcm_pid == 0:
print("sssd_kcm failed to start")
else:
try:
except:
else:
break
def kcm_teardown():
if kcm_pid == 0:
return
return kcm_pid
return unindent("""\
[sssd]
domains = local
services = nss
id_provider = local
[kcm]
socket_path = {kcm_path}
ccache_storage = {ccache_storage}
[secrets]
max_secrets = {max_secrets}
[libdefaults]
default_ccache_name = KCM:
kcm_socket = {kcm_path}
"""
Just set up the local provider for tests and enable the KCM
responder
"""
"""
Just set up the local provider for tests and enable the KCM
responder
"""
"""
Test that kinit, kdestroy and klist work with KCM
"""
assert nprincs == 0
assert out == 0
assert nprincs == 1
assert out == 0
assert nprincs == 0
"""
Test that reusing a ccache reinitializes the cache and doesn't
add the same principal twice
"""
assert out == 0
assert out == 0
"""
Test that multiple principals and service tickets can be stored
in a collection.
"""
assert out == 0
assert 'bob@KCMTEST' not in cc_coll
assert 'carol@KCMTEST' not in cc_coll
assert out == 0
assert 'carol@KCMTEST' not in cc_coll
assert out == 0
assert out == 0
'host/somehostname@KCMTEST'])
assert out == 0
# If the default is removed, KCM just uses whetever is the first entry
# in the collection as the default. And sine the KCM back ends don't
# guarantee if they are FIFO or LIFO, just check for either alice or bob
['alice@KCMTEST', 'bob@KCMTEST']
assert 'carol@KCMTEST' not in cc_coll
"""
Test switching between principals
"""
assert out == 0
assert out == 0
assert out == 0
'host/somehostname@KCMTEST'])
assert out == 0
'host/somehostname@KCMTEST'])
'host/differenthostname@KCMTEST'])
"""
Test that subsidiary caches are usable and KCM: without specifying UID
can be used to identify the collection
"""
assert out == 0
assert out == 0
exp_cc_coll = dict()
princ_ccache = dict()
'host/somehostname@KCMTEST'])
'host/differenthostname@KCMTEST'])
"""
Destroying a non-existing ccache should not throw an error
"""
assert out == 0
assert out == 0
assert out == 0
"""
Test that parallel operations from a single UID are handled well.
Regression test for https://pagure.io/SSSD/sssd/issue/3372
"""
assert out == 0
processes = []
for p in processes:
assert rc == 0
def get_secrets_socket():
return cli
# Make sure the secrets store is depleted first
sec_value = "value"
for i in range(MAX_SECRETS):
# We should still be able to store KCM ccaches, but no more
# than MAX_SECRETS
for i in range(MAX_SECRETS):
assert out == 0
# we stored 0 to MAX_SECRETS-1, storing another one must fail
assert out != 0