Skip to content

Commit 82a57f3

Browse files
committed
Adding DELUSER list of users support
Adding support for ACL help Part of redis#1546
1 parent 879584b commit 82a57f3

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Diff for: redis/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ class Redis(Commands, object):
654654
'ACL DELUSER': int,
655655
'ACL GENPASS': str_if_bytes,
656656
'ACL GETUSER': parse_acl_getuser,
657+
'ACL HELP': lambda r: list(map(str_if_bytes, r)),
657658
'ACL LIST': lambda r: list(map(str_if_bytes, r)),
658659
'ACL LOAD': bool_ok,
659660
'ACL LOG': parse_acl_log,

Diff for: 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):
5656
"Generate a random password value"
@@ -64,6 +64,12 @@ def acl_getuser(self, username):
6464
"""
6565
return self.execute_command('ACL GETUSER', username)
6666

67+
def acl_help(self):
68+
"""The ACL HELP command returns helpful text describing
69+
the different subcommands.
70+
"""
71+
return self.execute_command('ACL HELP')
72+
6773
def acl_list(self):
6874
"Return a list of all ACLs on the server"
6975
return self.execute_command('ACL LIST')

Diff for: 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()
@@ -185,6 +196,12 @@ def teardown():
185196
hashed_passwords=['-' + hashed_password])
186197
assert len(r.acl_getuser(username)['passwords']) == 1
187198

199+
@skip_if_server_version_lt(REDIS_6_VERSION)
200+
def test_acl_help(self, r):
201+
res = r.acl_help()
202+
assert isinstance(res, list)
203+
assert len(res) != 0
204+
188205
@skip_if_server_version_lt(REDIS_6_VERSION)
189206
def test_acl_list(self, r, request):
190207
username = 'redis-py-user'

0 commit comments

Comments
 (0)