k5test is a Python library designed for testing applications that interact with Kerberos 5. It allows for the creation of self-contained, temporary Kerberos environments, including a KDC (Key Distribution Center) and Kadmin server, simplifying integration and unit testing. The current version is 0.10.4, and it maintains an active release cadence with regular updates.
pip install k5testVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a temporary Kerberos 5 environment using `k5test.K5Context`. It initializes a KDC, provides a credential cache and keytab, and configures `krb5.conf`. The example then uses `subprocess` to run `kinit` to authenticate 'testuser' and `kadmin.local` to list principals, showcasing how to interact with the managed Kerberos services within your tests. Note that system Kerberos binaries must be installed.
Install the appropriate Kerberos packages for your operating system (e.g., `sudo apt install krb5-kdc krb5-admin-server krb5-user` on Debian/Ubuntu or `sudo dnf install krb5-server krb5-workstation` on RHEL/Fedora).
Upgrade to k5test v0.10.2 or newer, which uses `shutil.which()` for more robust executable discovery. If upgrading is not an option, ensure `which(1)` is installed and Kerberos binaries are in standard PATH locations.
If Heimdal Kerberos support is desired, explicitly specify `kdc_type='heimdal'` when creating the context: `K5Context(kdc_type='heimdal')`. The default is `kdc_type='mit'`.
No dependency data recorded yet.