fix hosting tests

This commit is contained in:
bruks 2026-10-04 18:36:54 +01:00
commit 4bcb3f2e04
5 changed files with 159 additions and 260 deletions

View file

@ -1,4 +1,5 @@
import logging
import sys
from django.conf import settings
from django.contrib.auth.backends import ModelBackend
@ -7,7 +8,6 @@ logger = logging.getLogger(__name__)
class MyLDAPBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
user = super().authenticate(
request=request,
@ -16,7 +16,12 @@ class MyLDAPBackend(ModelBackend):
**kwargs
)
if user and not settings.DEBUG:
is_testing = (
"test" in sys.argv
or "pytest" in sys.modules
)
if user and not settings.DEBUG and not is_testing:
user.create_ldap_account(password)
return user