ldap auth: fixed unit test.

This commit is contained in:
Antoine Nguyen
2020-03-30 12:33:08 +02:00
parent 56a9c44b93
commit 5b9b494593
2 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -119,7 +119,7 @@ class LDAPAuthenticationTestCase(LDAPTestCaseMixin, ModoTestCase):
})
username = "mailadmin"
self.authenticate(username, "test", False)
self.check_created_user(username, "DomainAdmins", False)
self.check_created_user("mailadmin@example.com", "DomainAdmins", False)
class ProfileTestCase(LDAPTestCaseMixin, ModoTestCase):
+7 -3
View File
@@ -92,9 +92,13 @@ try:
if attr in ldap_user.attrs:
email = ldap_user.attrs[attr][0]
break
if email is None and group == "SimpleUsers":
return None
username = email
if email is None:
if group == "SimpleUsers":
# Only DomainAdmins can have a username which
# is not an email address
return None
else:
username = email
user, created = User.objects.get_or_create(
username__iexact=username,
defaults={