diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-09-01 14:57:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 14:57:07 +0300 |
commit | da6e3524622c9e9862ac57de60d9f188e106b29d (patch) | |
tree | 9c81fdde269f0297ce76963d65669f86e899946e | |
parent | 51516cbd16b538584b7ea8c6a0cdbc76cda3d90a (diff) | |
download | redis-py-da6e3524622c9e9862ac57de60d9f188e106b29d.tar.gz |
Adding DELUSER list of users support (#1562)
Adding support for ACL help
Part of #1546
-rwxr-xr-x | redis/client.py | 1 | ||||
-rw-r--r-- | redis/commands.py | 10 | ||||
-rw-r--r-- | tests/test_commands.py | 17 |
3 files changed, 26 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py index 6eee391..8979280 100755 --- a/redis/client.py +++ b/redis/client.py @@ -659,6 +659,7 @@ class Redis(Commands, object): 'ACL DELUSER': int, 'ACL GENPASS': str_if_bytes, 'ACL GETUSER': parse_acl_getuser, + 'ACL HELP': lambda r: list(map(str_if_bytes, r)), 'ACL LIST': lambda r: list(map(str_if_bytes, r)), 'ACL LOAD': bool_ok, 'ACL LOG': parse_acl_log, diff --git a/redis/commands.py b/redis/commands.py index 27276bc..c49f043 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -48,9 +48,9 @@ class Commands: pieces = [category] if category else [] return self.execute_command('ACL CAT', *pieces) - def acl_deluser(self, username): + def acl_deluser(self, *username): "Delete the ACL for the specified ``username``" - return self.execute_command('ACL DELUSER', username) + return self.execute_command('ACL DELUSER', *username) def acl_genpass(self, bits=None): """Generate a random password value. @@ -77,6 +77,12 @@ class Commands: """ return self.execute_command('ACL GETUSER', username) + def acl_help(self): + """The ACL HELP command returns helpful text describing + the different subcommands. + """ + return self.execute_command('ACL HELP') + def acl_list(self): "Return a list of all ACLs on the server" return self.execute_command('ACL LIST') diff --git a/tests/test_commands.py b/tests/test_commands.py index fd77cc8..fde1c01 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -93,6 +93,17 @@ class TestRedisCommands: assert r.acl_setuser(username, enabled=False, reset=True) assert r.acl_deluser(username) == 1 + # now, a group of users + users = ['bogususer_%d' % r for r in range(0, 5)] + for u in users: + r.acl_setuser(u, enabled=False, reset=True) + assert r.acl_deluser(*users) > 1 + assert r.acl_getuser(users[0]) is None + assert r.acl_getuser(users[1]) is None + assert r.acl_getuser(users[2]) is None + assert r.acl_getuser(users[3]) is None + assert r.acl_getuser(users[4]) is None + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_genpass(self, r): password = r.acl_genpass() @@ -194,6 +205,12 @@ class TestRedisCommands: assert len(r.acl_getuser(username)['passwords']) == 1 @skip_if_server_version_lt(REDIS_6_VERSION) + def test_acl_help(self, r): + res = r.acl_help() + assert isinstance(res, list) + assert len(res) != 0 + + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_list(self, r, request): username = 'redis-py-user' |