From 92e8fef25460fb5aff45cf1f67d9ea820668f0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20L=C3=B3pez?= Date: Thu, 12 Oct 2023 09:44:10 +0200 Subject: [PATCH] KCM: Adapt the tests This is an exploratory commit. Not yet ready to be pushed. --- src/tests/intg/krb5utils.py | 1 + src/tests/intg/test_kcm.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tests/intg/krb5utils.py b/src/tests/intg/krb5utils.py index 2d1b79e7688..688766d5169 100644 --- a/src/tests/intg/krb5utils.py +++ b/src/tests/intg/krb5utils.py @@ -40,6 +40,7 @@ def __init__(self, krb5_conf_path): def spawn_in_env(self, args, stdin=None, extra_env=None): my_env = os.environ.copy() my_env['KRB5_CONFIG'] = self.krb5_conf_path + my_env['KRB5_TRACE'] = "/dev/stdout" # [ALE] if 'KRB5CCNAME' in my_env: del my_env['KRB5CCNAME'] diff --git a/src/tests/intg/test_kcm.py b/src/tests/intg/test_kcm.py index 0d2638f211f..078942547f7 100644 --- a/src/tests/intg/test_kcm.py +++ b/src/tests/intg/test_kcm.py @@ -91,10 +91,13 @@ def create_sssd_kcm_fixture(sock_path, krb5_conf_path, request): if kcm_pid == 0: my_env = os.environ.copy() my_env["KRB5_CONFIG"] = krb5_conf_path - if subprocess.call([resp_path, "--uid=0", "--gid=0"], env=my_env) != 0: + if subprocess.call([resp_path, "--uid=0", "--gid=0", "-d=9", "--logger=stderr", "--debug-timestamps=1"], env=my_env) != 0: print("sssd_kcm failed to start") sys.exit(99) + print("[ALE] KCM launched", file=sys.stderr) + # Let's give KCM some time to initialize else: + print("[ALE] Connecting to KCM", file=sys.stderr) abs_sock_path = os.path.join(config.RUNSTATEDIR, sock_path) sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) for _ in range(1, 100): @@ -103,6 +106,7 @@ def create_sssd_kcm_fixture(sock_path, krb5_conf_path, request): except Exception: time.sleep(0.1) else: + print("[ALE] Connected to KCM", file=sys.stderr) break sck.close() assert os.path.exists(abs_sock_path) @@ -110,12 +114,18 @@ def create_sssd_kcm_fixture(sock_path, krb5_conf_path, request): def kcm_teardown(): if kcm_pid == 0: return + print("[ALE] Shutting down", file=sys.stderr) os.kill(kcm_pid, signal.SIGTERM) try: os.unlink(os.path.join(config.SECDB_PATH, "secrets.ldb")) except OSError as osex: if osex.errno == 2: pass + try: + os.unlink(abs_sock_path) + except OSError as osex: + if osex.errno == 2: + pass request.addfinalizer(kcm_teardown) return kcm_pid @@ -150,6 +160,7 @@ def create_sssd_conf_renewals(kcm_path, ccache_storage, renew_lifetime, proxy_lib_name = files [kcm] + debug_level = 9 socket_path = {kcm_path} ccache_storage = {ccache_storage} tgt_renewal = true @@ -300,6 +311,7 @@ def collection_init_list_destroy(testenv): assert testenv.k5util.num_princs() == 0 + os.environ["KRB5_TRACE"] = "/dev/stdout" out, _, _ = testenv.k5util.kinit("alice", "alicepw") assert out == 0 assert testenv.k5util.default_principal() == 'alice@KCMTEST'