28 lines
1,015 B
Python
28 lines
1,015 B
Python
|
from django.test import override_settings, TestCase
|
||
|
|
||
|
from userausfall.ldap import LDAPManager
|
||
|
|
||
|
|
||
|
@override_settings(USERAUSFALL_LDAP_IS_TEST=True)
|
||
|
class LDAPTestCase(TestCase):
|
||
|
def setUp(self) -> None:
|
||
|
self.username = "test"
|
||
|
self.password = "test12345"
|
||
|
self.ldap = LDAPManager()
|
||
|
|
||
|
def test_create_has_account(self):
|
||
|
exists = self.ldap.has_account(self.username)
|
||
|
self.assertFalse(exists)
|
||
|
is_created = self.ldap.create_account(self.username, self.password)
|
||
|
self.assertTrue(is_created)
|
||
|
exists = self.ldap.has_account(self.username)
|
||
|
self.assertTrue(exists)
|
||
|
|
||
|
def test_create_account_data(self):
|
||
|
is_valid = self.ldap.is_valid_account_data(self.username, self.password)
|
||
|
self.assertFalse(is_valid)
|
||
|
is_created = self.ldap.create_account(self.username, self.password)
|
||
|
self.assertTrue(is_created)
|
||
|
is_valid = self.ldap.is_valid_account_data(self.username, self.password)
|
||
|
self.assertTrue(is_valid)
|