Skip to content

Commit da6e352

Browse files
authored
Adding DELUSER list of users support (#1562)
Adding support for ACL help Part of #1546
1 parent 51516cb commit da6e352

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

redis/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ class Redis(Commands, object):
659659
'ACL DELUSER': int,
660660
'ACL GENPASS': str_if_bytes,
661661
'ACL GETUSER': parse_acl_getuser,
662+
'ACL HELP': lambda r: list(map(str_if_bytes, r)),
662663
'ACL LIST': lambda r: list(map(str_if_bytes, r)),
663664
'ACL LOAD': bool_ok,
664665
'ACL LOG': parse_acl_log,

redis/commands.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def acl_cat(self, category=None):
4848
pieces = [category] if category else []
4949
return self.execute_command('ACL CAT', *pieces)
5050

51-
def acl_deluser(self, username):
51+
def acl_deluser(self, *username):
5252
"Delete the ACL for the specified ``username``"
53-
return self.execute_command('ACL DELUSER', username)
53+
return self.execute_command('ACL DELUSER', *username)
5454

5555
def acl_genpass(self, bits=None):
5656
"""Generate a random password value.
@@ -77,6 +77,12 @@ def acl_getuser(self, username):
7777
"""
7878
return self.execute_command('ACL GETUSER', username)
7979

80+
def acl_help(self):
81+
"""The ACL HELP command returns helpful text describing
82+
the different subcommands.
83+
"""
84+
return self.execute_command('ACL HELP')
85+
8086
def acl_list(self):
8187
"Return a list of all ACLs on the server"
8288
return self.execute_command('ACL LIST')

tests/test_commands.py

+17
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ def teardown():
9393
assert r.acl_setuser(username, enabled=False, reset=True)
9494
assert r.acl_deluser(username) == 1
9595

96+
# now, a group of users
97+
users = ['bogususer_%d' % r for r in range(0, 5)]
98+
for u in users:
99+
r.acl_setuser(u, enabled=False, reset=True)
100+
assert r.acl_deluser(*users) > 1
101+
assert r.acl_getuser(users[0]) is None
102+
assert r.acl_getuser(users[1]) is None
103+
assert r.acl_getuser(users[2]) is None
104+
assert r.acl_getuser(users[3]) is None
105+
assert r.acl_getuser(users[4]) is None
106+
96107
@skip_if_server_version_lt(REDIS_6_VERSION)
97108
def test_acl_genpass(self, r):
98109
password = r.acl_genpass()
@@ -193,6 +204,12 @@ def teardown():
193204
hashed_passwords=['-' + hashed_password])
194205
assert len(r.acl_getuser(username)['passwords']) == 1
195206

207+
@skip_if_server_version_lt(REDIS_6_VERSION)
208+
def test_acl_help(self, r):
209+
res = r.acl_help()
210+
assert isinstance(res, list)
211+
assert len(res) != 0
212+
196213
@skip_if_server_version_lt(REDIS_6_VERSION)
197214
def test_acl_list(self, r, request):
198215
username = 'redis-py-user'

0 commit comments

Comments
 (0)