1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(accounts): an LDAP login waits a bounded time for the directory

python-ldap waits for a server without end, to connect and for each
answer: a directory that stopped answering held every login's thread.
The settings template's LDAP block sets 5 seconds to connect and 10 for
each answer.
This commit is contained in:
catborise 2026-11-05 10:50:18 +03:00
parent cbd4374f4f
commit 245ed12aad
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,20 @@
"""A login through LDAP waits a bounded time for the directory."""
import unittest
from django.test import SimpleTestCase
try:
import ldap
from django_auth_ldap.backend import LDAPBackend
except ImportError: # LDAP is optional (conf/requirements-ldap.txt)
ldap = None
@unittest.skipIf(ldap is None, "python-ldap is not installed")
class LdapTimeoutTests(SimpleTestCase):
def test_the_connection_and_each_answer_have_a_timeout(self):
# python-ldap's default for both is to wait without end
options = LDAPBackend().settings.CONNECTION_OPTIONS
self.assertGreater(options.get(ldap.OPT_NETWORK_TIMEOUT, -1), 0)
self.assertGreater(options.get(ldap.OPT_TIMEOUT, -1), 0)