diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-09-01 17:14:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 17:14:55 +0300 |
commit | 42a050c6c0d120104c7433e825e7a798ba411e55 (patch) | |
tree | 26dd64f55b74b9a830620b567139f221b6507081 /tests/test_commands.py | |
parent | febede19423c95515a7548cd73aa1a90c639ba1f (diff) | |
download | redis-py-42a050c6c0d120104c7433e825e7a798ba411e55.tar.gz |
CLIENT LIST fix to allow multiple client_ids (#1563)
* CLIENT LIST fix to allow multiple client_ids
Support for CLIENT KILL with the USER filter
Part of #1546
* test fix
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r-- | tests/test_commands.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 24c528d..254aba5 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -321,13 +321,19 @@ class TestRedisCommands: assert isinstance(clients, list) @skip_if_server_version_lt('6.2.0') - def test_client_list_client_id(self, r): + def test_client_list_client_id(self, r, request): clients = r.client_list() - client_id = clients[0]['id'] - clients = r.client_list(client_id=client_id) + clients = r.client_list(client_id=[clients[0]['id']]) assert len(clients) == 1 assert 'addr' in clients[0] + # testing multiple client ids + _get_client(redis.Redis, request, flushdb=False) + _get_client(redis.Redis, request, flushdb=False) + _get_client(redis.Redis, request, flushdb=False) + clients_listed = r.client_list(client_id=clients[:-1]) + assert len(clients_listed) > 1 + @skip_if_server_version_lt('5.0.0') def test_client_id(self, r): assert r.client_id() > 0 @@ -448,6 +454,19 @@ class TestRedisCommands: client_2_addr = clients_by_name['redis-py-c2'].get('laddr') assert r.client_kill_filter(laddr=client_2_addr) + @skip_if_server_version_lt('2.8.12') + def test_client_kill_filter_by_user(self, r, request): + killuser = 'user_to_kill' + r.acl_setuser(killuser, enabled=True, reset=True, + commands=['+get', '+set', '+select'], + keys=['cache:*'], nopass=True) + _get_client(redis.Redis, request, flushdb=False, username=killuser) + r.client_kill_filter(user=killuser) + clients = r.client_list() + for c in clients: + assert c['user'] != killuser + r.acl_deluser(killuser) + @skip_if_server_version_lt('2.9.50') def test_client_pause(self, r): assert r.client_pause(1) |