-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added "ACL LOG" command new in Redis 6 RC2 #1307
Changes from 8 commits
6f3d00d
09c07c2
38a74a2
6e212d1
ee25e2f
e53a8c0
85254af
0a37ea8
47d8b03
d978efd
0e63f21
7995723
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,39 @@ def teardown(): | |
users = r.acl_list() | ||
assert 'user %s off -@all' % username in users | ||
|
||
@skip_if_server_version_lt(REDIS_6_VERSION) | ||
def test_acl_log(self, r, request): | ||
username = 'redis-py-user' | ||
|
||
def teardown(): | ||
r.acl_deluser(username) | ||
|
||
request.addfinalizer(teardown) | ||
r.acl_setuser(username, enabled=True, reset=True, | ||
commands=['+get', '+set', '+select'], | ||
keys=['cache:*'], nopass=True) | ||
r.acl_log_reset() | ||
|
||
r_test = redis.Redis(host='localhost', port=6379, db=9, | ||
username=username) | ||
# Valid operation and key | ||
r_test.set("cache:0", 1) | ||
r_test.get("cache:0") | ||
# Invalid key | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be: with pytest.raises(exceptions.NoPermissionError):
r_test.get('violated_cache:0') There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thanks. |
||
r_test.get("violated_cache:0") | ||
except exceptions.NoPermissionError: | ||
pass | ||
# Invalid operation | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: with pytest.raises(exceptions.NoPermissionError):
r_test.hset('cache:0', 'hkey', 'hval') There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thanks. |
||
r_test.hset("cache:0", "hkey", "hval") | ||
except exceptions.NoPermissionError: | ||
pass | ||
|
||
assert len(r.acl_log()) == 2 | ||
assert len(r.acl_log(count=1)) == 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to assert that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added few return type assertion now. |
||
assert r.acl_log_reset() | ||
|
||
@skip_if_server_version_lt(REDIS_6_VERSION) | ||
def test_acl_setuser_categories_without_prefix_fails(self, r, request): | ||
username = 'redis-py-user' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to hardcode connection info in a test. Instead, use the
_get_client
function fromconftest.py
. Something like:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep please check the comment below