Skip to content

Commit

Permalink
KCM: Adapt the tests
Browse files Browse the repository at this point in the history
This is an exploratory commit. Not yet ready to be pushed.
  • Loading branch information
aplopez committed Oct 17, 2023
1 parent 4498efd commit 92e8fef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/tests/intg/krb5utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
14 changes: 13 additions & 1 deletion src/tests/intg/test_kcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -103,19 +106,26 @@ 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)

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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 92e8fef

Please sign in to comment.