-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
- Loading branch information
Showing
7 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from .utils import KerberosTestCase, random_string | ||
|
||
import kadmin | ||
|
||
|
||
class TestPolicy(KerberosTestCase): | ||
def test_list_policies(self): | ||
kadm = kadmin.KAdmin.with_password( | ||
self.realm.admin_princ, self.realm.password("admin") | ||
) | ||
self.assertEqual( | ||
kadm.list_policies("*"), | ||
[], | ||
) | ||
|
||
def test_policy_exists(self): | ||
kadm = kadmin.KAdmin.with_password( | ||
self.realm.admin_princ, self.realm.password("admin") | ||
) | ||
polname = random_string(16) | ||
kadm.add_policy(polname) | ||
self.assertTrue(kadm.policy_exists(polname)) | ||
kadm.delete_policy(polname) | ||
|
||
def test_create_policy(self): | ||
kadm = kadmin.KAdmin.with_password( | ||
self.realm.admin_princ, self.realm.password("admin") | ||
) | ||
polname = random_string(16) | ||
policy = kadm.add_policy(polname) | ||
self.assertEqual(policy.name, polname) | ||
self.assertIsNone(policy.password_max_life) | ||
self.assertEqual(policy.attributes, 0) | ||
kadm.delete_policy(polname) | ||
|
||
def test_delete_policy(self): | ||
kadm = kadmin.KAdmin.with_password( | ||
self.realm.admin_princ, self.realm.password("admin") | ||
) | ||
polname = random_string(16) | ||
policy = kadm.add_policy(polname) | ||
self.assertTrue(kadm.policy_exists(polname)) | ||
policy.delete() | ||
self.assertFalse(kadm.policy_exists(polname)) | ||
|
||
def test_modify(self): | ||
kadm = kadmin.KAdmin.with_password( | ||
self.realm.admin_princ, self.realm.password("admin") | ||
) | ||
polname = random_string(16) | ||
policy = kadm.add_policy(polname) | ||
policy = policy.modify(password_min_length=42) | ||
self.assertEqual(policy.password_min_length, 42) | ||
policy = kadm.get_policy(polname) | ||
self.assertEqual(policy.password_min_length, 42) | ||
kadm.delete_policy(polname) | ||
|
||
def test_setter(self): | ||
kadm = kadmin.KAdmin.with_password( | ||
self.realm.admin_princ, self.realm.password("admin") | ||
) | ||
polname = random_string(16) | ||
policy = kadm.add_policy(polname) | ||
policy.password_min_length = 42 | ||
self.assertEqual(policy.password_min_length, 42) | ||
policy = kadm.get_policy(polname) | ||
self.assertEqual(policy.password_min_length, 42) | ||
kadm.delete_policy(polname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters