Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
changing unit tests to account for defaults in redis flags redis/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 <acwangpython@gmail.com>
  • Loading branch information
Andrew-Chen-Wang committed Oct 4, 2021
1 parent 38a023f commit d37bb21
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d37bb21

Please sign in to comment.