forked from pool/python-redis
taking into consideration redis defaults, not overwriting them (gh#andymccurdy/redis-py#1499). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-redis?expand=0&rev=58
88 lines
3.3 KiB
Diff
88 lines
3.3 KiB
Diff
From fea5d60c4426ec31a0e309a2efb2be62f6b2a412 Mon Sep 17 00:00:00 2001
|
|
From: "Chayim I. Kirshen" <c@kirshen.com>
|
|
Date: Mon, 28 Jun 2021 16:34:00 +0300
|
|
Subject: [PATCH 1/3] changing unit tests to account for defaults in redis
|
|
flags
|
|
|
|
Some versions of redis (validated against 6.2.4) set extra flags, making the tests fail.
|
|
|
|
Modified the tests to validate the specific flags pertaining to the test case are in place.
|
|
|
|
Similarly with acl_list, as other tests validate the specifics of acl_setuser, I changed it to validate against the acl list.
|
|
|
|
Finally, while here, I added python 3.9 to tox
|
|
---
|
|
tests/test_commands.py | 37 ++++++++++++++++++-------------------
|
|
1 file changed, 18 insertions(+), 19 deletions(-)
|
|
|
|
--- a/tests/test_commands.py
|
|
+++ b/tests/test_commands.py
|
|
@@ -105,25 +105,24 @@ class TestRedisCommands(object):
|
|
|
|
# test enabled=False
|
|
assert r.acl_setuser(username, enabled=False, reset=True)
|
|
- assert r.acl_getuser(username) == {
|
|
- 'categories': ['-@all'],
|
|
- 'commands': [],
|
|
- 'enabled': False,
|
|
- 'flags': ['off'],
|
|
- 'keys': [],
|
|
- 'passwords': [],
|
|
- }
|
|
+ acl = r.acl_getuser(username)
|
|
+ assert acl['categories'] == ['-@all']
|
|
+ assert acl['commands'] == []
|
|
+ assert acl['keys'] == []
|
|
+ assert acl['passwords'] == []
|
|
+ assert 'off' in acl['flags']
|
|
+ assert acl['enabled'] is False
|
|
|
|
# test nopass=True
|
|
assert r.acl_setuser(username, enabled=True, reset=True, nopass=True)
|
|
- assert r.acl_getuser(username) == {
|
|
- 'categories': ['-@all'],
|
|
- 'commands': [],
|
|
- 'enabled': True,
|
|
- 'flags': ['on', 'nopass'],
|
|
- 'keys': [],
|
|
- 'passwords': [],
|
|
- }
|
|
+ acl = r.acl_getuser(username)
|
|
+ assert acl['categories'] == ['-@all']
|
|
+ assert acl['commands'] == []
|
|
+ assert acl['keys'] == []
|
|
+ assert acl['passwords'] == []
|
|
+ assert 'on' in acl['flags']
|
|
+ assert 'nopass' in acl['flags']
|
|
+ assert acl['enabled'] is True
|
|
|
|
# test all args
|
|
assert r.acl_setuser(username, enabled=True, reset=True,
|
|
@@ -135,7 +134,7 @@ class TestRedisCommands(object):
|
|
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
|
|
assert set(acl['commands']) == set(['+get', '+mget', '-hset'])
|
|
assert acl['enabled'] is True
|
|
- assert acl['flags'] == ['on']
|
|
+ assert 'on' in acl['flags']
|
|
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
|
|
assert len(acl['passwords']) == 2
|
|
|
|
@@ -154,7 +153,7 @@ class TestRedisCommands(object):
|
|
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
|
|
assert set(acl['commands']) == set(['+get', '+mget'])
|
|
assert acl['enabled'] is True
|
|
- assert acl['flags'] == ['on']
|
|
+ assert 'on' in acl['flags']
|
|
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
|
|
assert len(acl['passwords']) == 2
|
|
|
|
@@ -193,7 +192,7 @@ class TestRedisCommands(object):
|
|
|
|
assert r.acl_setuser(username, enabled=False, reset=True)
|
|
users = r.acl_list()
|
|
- assert 'user %s off -@all' % username in users
|
|
+ assert len(users) == 2
|
|
|
|
@skip_if_server_version_lt(REDIS_6_VERSION)
|
|
def test_acl_setuser_categories_without_prefix_fails(self, r, request):
|