redis-py
redis-py copied to clipboard
auth method works wrong for default username
Version: 4.2.2
Platform: Docker image python:3.10
Description: Can not connect to Redis with Sentinel and with protection by password.
>>> from redis import Sentinel
>>>
>>> PASSWORD = 'some password'
>>> sentinel = Sentinel(
... [('redis', 26379)],
... sentinel_kwargs={'password': PASSWORD},
... socket_timeout=0.1
... )
>>> sentinel.sentinel_masters() # Check sentinel authentication works correctly
True
>>> master = sentinel.master_for('mymaster', socket_timeout=0.1)
>>> master.auth(PASSWORD)
<bound method Redis.execute_command of Redis<SentinelConnectionPool<service=mymaster(master)>>
Expects authentication to be done but got bound method
instead. This behaviour does not correspond to docstring content:
def auth(self, password, username=None, **kwargs):
"""
Authenticates the user. If you do not pass username, Redis will try to
authenticate for the "default" user. If you do pass username, it will
authenticate for the given user.
For more information see https://redis.io/commands/auth
"""
Suppose it is a bug:
if username:
return self.execute_command("AUTH", username, password, **kwargs)
return self.execute_command
Why return execute_command
instead of calling it ?