Skip to content

Add username to StrictRedis connection #223

@Luferov

Description

@Luferov

Checklist

  • Python version: 3.8.16
  • Using hiredis or just Python parser: yes
  • Using uvloop or just asyncio event loop: yes
  • Does issue exists against the master branch of aredis? Yes

Steps to reproduce

import asyncio
from aredis import StrictRedis

async def example():
    client = StrictRedis(host='127.0.0.1', port=6379, db=0, username='user', password='password')
    await client.flushdb()
    await client.set('foo', 1)
    assert await client.exists('foo') is True
    await client.incr('foo', 100)

    assert int(await client.get('foo')) == 101
    await client.expire('foo', 1)
    await asyncio.sleep(0.1)
    await client.ttl('foo')
    await asyncio.sleep(1)
    assert not await client.exists('foo')

loop = asyncio.get_event_loop()
loop.run_until_complete(example())

Expected behavior

All ok.

Actual behavior

Traceback (most recent call last):
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 415, in connect
    await self._connect()
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 620, in _connect
    await self.on_connect()
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 439, in on_connect
    if nativestr(await self.read_response()) != 'OK':
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 457, in read_response
    raise response
aredis.exceptions.ResponseError: AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/victor/PycharmProjects/aredis/aredis/client.py", line 155, in execute_command
    await connection.send_command(*args)
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 488, in send_command
    await self.connect()
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 419, in connect
    raise ConnectionError()
aredis.exceptions.ConnectionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 415, in connect
    await self._connect()
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 620, in _connect
    await self.on_connect()
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 439, in on_connect
    if nativestr(await self.read_response()) != 'OK':
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 457, in read_response
    raise response
aredis.exceptions.ResponseError: AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 21, in <module>
  File "/Users/victor/.pyenv/versions/3.8.16/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "<input>", line 8, in example
  File "/Users/victor/PycharmProjects/aredis/aredis/commands/server.py", line 232, in flushdb
    return await self.execute_command('FLUSHDB')
  File "/Users/victor/PycharmProjects/aredis/aredis/client.py", line 165, in execute_command
    await connection.send_command(*args)
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 488, in send_command
    await self.connect()
  File "/Users/victor/PycharmProjects/aredis/aredis/connection.py", line 419, in connect
    raise ConnectionError()
aredis.exceptions.ConnectionError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions