From d37bb2103f3603d0617d1326bb3871fe6011fb6c Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Mon, 4 Oct 2021 15:29:50 -0400 Subject: [PATCH] Add andymccurdy/redis-py@cb97b9bdd47bf5a92f4efa88e52591344a08b98e changing unit tests to account for defaults in redis flags andymccurdy/redis-py#1499 * This does not include the changes in tests/test_pubsub.py because we do not implement threading. Signed-off-by: Andrew-Chen-Wang --- tests/test_commands.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 0ee3277c8..fc2efabe9 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -118,27 +118,24 @@ def teardown(): # test enabled=False assert await r.acl_setuser(username, enabled=False, reset=True) - assert await r.acl_getuser(username) == { - "categories": ["-@all"], - "commands": [], - "channels": [b"*"], - "enabled": False, - "flags": ["off", "allchannels", "sanitize-payload"], - "keys": [], - "passwords": [], - } + acl = await 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 await r.acl_setuser(username, enabled=True, reset=True, nopass=True) - assert await r.acl_getuser(username) == { - "categories": ["-@all"], - "commands": [], - "channels": [b"*"], - "enabled": True, - "flags": ["on", "allchannels", "nopass", "sanitize-payload"], - "keys": [], - "passwords": [], - } + acl = await 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 await r.acl_setuser( @@ -155,7 +152,7 @@ def teardown(): assert set(acl["commands"]) == {"+get", "+mget", "-hset"} assert acl["enabled"] is True assert acl["channels"] == [b"*"] - assert acl["flags"] == ["on", "allchannels", "sanitize-payload"] + assert "on" in acl["flags"] assert set(acl["keys"]) == {b"cache:*", b"objects:*"} assert len(acl["passwords"]) == 2 @@ -182,7 +179,7 @@ def teardown(): assert set(acl["commands"]) == {"+get", "+mget"} assert acl["enabled"] is True assert acl["channels"] == [b"*"] - assert acl["flags"] == ["on", "allchannels", "sanitize-payload"] + assert "on" in acl["flags"] assert set(acl["keys"]) == {b"cache:*", b"objects:*"} assert len(acl["passwords"]) == 2 @@ -233,7 +230,7 @@ def teardown(): assert await r.acl_setuser(username, enabled=False, reset=True) users = await r.acl_list() - assert "user %s off sanitize-payload &* -@all" % username in users + assert len(users) == 2 @skip_if_server_version_lt(REDIS_6_VERSION) async def test_acl_log(self, r: aioredis.Redis, request, event_loop, create_redis):