You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that Mocking methodology described in Mocking doesn't work correctly when using a ServerPool instead of a single Server. This limits the usefulness of the Mocking if the connection setup must be completely changed.
Test Case
importldap3server=ldap3.Server('my_fake_server')
server_pool=ldap3.ServerPool(
[server],
ldap3.FIRST,
active=1, # Loop through all servers once.exhaust=10, # Remove unreachable servers for 10 seconds.
)
connection=ldap3.Connection(server_pool,
user='cn=my_user,ou=test,o=lab',
password='my_password',
client_strategy=ldap3.MOCK_SYNC)
connection.bind()
print("Test Complete")
Expected Result
Code to run without error using a mocked connection and print Test Complete at the end.
Actual Result
Traceback (most recent call last):
File "ldap3_mock_test.py", line 13, in <module>
connection.bind()
File "/home/andrew/IdeaProjects/flask-ldap3-login/venv/lib/python3.8/site-packages/ldap3/core/connection.py", line 589, in bind
self.open(read_server_info=False)
File "/home/andrew/IdeaProjects/flask-ldap3-login/venv/lib/python3.8/site-packages/ldap3/strategy/sync.py", line 57, in open
BaseStrategy.open(self, reset_usage, read_server_info)
File "/home/andrew/IdeaProjects/flask-ldap3-login/venv/lib/python3.8/site-packages/ldap3/strategy/base.py", line 122, in open
new_server = self.connection.server_pool.get_server(self.connection) # get a server from the server_pool if available
File "/home/andrew/IdeaProjects/flask-ldap3-login/venv/lib/python3.8/site-packages/ldap3/core/pooling.py", line 317, in get_server
return self.pool_states[connection].get_server()
File "/home/andrew/IdeaProjects/flask-ldap3-login/venv/lib/python3.8/site-packages/ldap3/core/pooling.py", line 84, in get_server
self.last_used_server = self.find_active_server(starting=0)
File "/home/andrew/IdeaProjects/flask-ldap3-login/venv/lib/python3.8/site-packages/ldap3/core/pooling.py", line 187, in find_active_server
raise LDAPServerPoolExhaustedError('no active server available in server pool after maximum number of tries')
ldap3.core.exceptions.LDAPServerPoolExhaustedError: no active server available in server pool after maximum number of tries
The text was updated successfully, but these errors were encountered:
Fixescannatag#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.
Hello,
It seems that Mocking methodology described in Mocking doesn't work correctly when using a ServerPool instead of a single Server. This limits the usefulness of the Mocking if the connection setup must be completely changed.
Test Case
Expected Result
Code to run without error using a mocked connection and print
Test Complete
at the end.Actual Result
The text was updated successfully, but these errors were encountered: