Blame src/tests/t_kdb_locking.py

Packit fd8b60
# This is a regression test for
Packit fd8b60
# https://bugzilla.redhat.com/show_bug.cgi?id=586032 .
Packit fd8b60
#
Packit fd8b60
# We start a KDC, remove the kadm5 lock file, use the KDC, re-create the
Packit fd8b60
# kadm5 lock file, and use kadmin.local.  The kinit should fail, and the
Packit fd8b60
# kadmin.local should succeed.
Packit fd8b60
Packit fd8b60
Packit fd8b60
import os
Packit fd8b60
Packit fd8b60
from k5test import *
Packit fd8b60
Packit fd8b60
p = 'foo'
Packit fd8b60
realm = K5Realm(create_user=False, bdb_only=True)
Packit fd8b60
realm.addprinc(p, p)
Packit fd8b60
Packit fd8b60
kadm5_lock = os.path.join(realm.testdir, 'db.kadm5.lock')
Packit fd8b60
if not os.path.exists(kadm5_lock):
Packit fd8b60
    fail('kadm5 lock file not created: ' + kadm5_lock)
Packit fd8b60
os.unlink(kadm5_lock)
Packit fd8b60
Packit fd8b60
realm.kinit(p, p, [], expected_code=1,
Packit fd8b60
            expected_msg='A service is not available')
Packit fd8b60
Packit fd8b60
f = open(kadm5_lock, 'w')
Packit fd8b60
f.close()
Packit fd8b60
Packit fd8b60
output = realm.run([kadminl, 'modprinc', '-allow_tix', p])
Packit fd8b60
if 'Cannot lock database' in output:
Packit fd8b60
    fail('krb5kdc still holds a lock on the principal db')
Packit fd8b60
Packit fd8b60
success('KDB locking tests')