From a6a346dc9b71aff7db673c6580422451d8cfc125 Mon Sep 17 00:00:00 2001 From: Markus Bach Date: Fri, 9 Feb 2024 18:56:57 +0100 Subject: [PATCH] fix using ServerPools with MOCK_* strategy Fixes #1007 When using ServerPool's the Server to use is checked with check_availability. Since neither the Server nor the ServerPool know about the chosen connection strategy, we can just override the check_availability function when creating the Connection with a MOCK_* strategy. --- ldap3/core/connection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ldap3/core/connection.py b/ldap3/core/connection.py index c062d3aa..3884a4d0 100644 --- a/ldap3/core/connection.py +++ b/ldap3/core/connection.py @@ -315,6 +315,9 @@ def __init__(self, if isinstance(server, ServerPool): self.server_pool = server self.server_pool.initialize(self) + if self.strategy_type in [MOCK_SYNC,MOCK_ASYNC]: + for server in self.server_pool.servers: + server.check_availability = lambda *_args, **_kwargs: True self.server = self.server_pool.get_current_server(self) else: self.server_pool = None