Skip to content

Commit

Permalink
chore:add redis-py 5.3.0b3 to test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Dec 22, 2024
1 parent c10a34b commit 9279c7c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 1 addition & 5 deletions fakeredis/_basefakesocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ def __init__(self, server: "FakeServer", db: int, *args: Any, **kwargs: Any) ->
self._pubsub: int
self._transaction_failed: bool
self._current_user: bytes = b"default"
# TODO fix
self._client_info: bytes = kwargs.pop(
"client_info",
b"id=3 addr=127.0.0.1:57275 laddr=127.0.0.1:6379 fd=8 name= age=16 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=48 qbuf-free=16842 argv-mem=25 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=18737 events=r cmd=auth user=default redir=-1 resp=2",
)
self._client_info: bytes = kwargs.pop("client_info", b"")

@property
def version(self) -> Tuple[int, ...]:
Expand Down
7 changes: 6 additions & 1 deletion fakeredis/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def connect(self) -> None:
def _connect(self) -> FakeSocket:
if not self._server.connected:
raise redis.ConnectionError(msgs.CONNECTION_ERROR_MSG)
return FakeSocket(self._server, db=self.db, lua_modules=self._lua_modules, client_info=self)
return FakeSocket(
self._server,
db=self.db,
lua_modules=self._lua_modules,
client_info=b"id=3 addr=127.0.0.1:57275 laddr=127.0.0.1:6379 fd=8 name= age=16 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=48 qbuf-free=16842 argv-mem=25 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=18737 events=r cmd=auth user=default redir=-1 resp=2",
)

def can_read(self, timeout: Optional[float] = 0) -> bool:
if not self._server.connected:
Expand Down
2 changes: 2 additions & 0 deletions fakeredis/model/_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def validate_command(self, username: bytes, fields: List[bytes]):
raise SimpleError("User disabled")

command, args = fields[0], fields[1:]
if command.lower() == b"auth":
return
if command.lower() not in user_acl._commands:
raise SimpleError(msgs.NO_PERMISSION_ERROR.format(username.decode(), command.lower().decode()))
# todo
1 change: 1 addition & 0 deletions test/test_mixins/test_acl_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def test_acl_log_invalid_key(r: redis.Redis, request, create_redis):
username = "fredis-py-user"

def teardown():
r.auth("", username="default")
r.acl_deluser(username)

request.addfinalizer(teardown)
Expand Down

0 comments on commit 9279c7c

Please sign in to comment.