-
Notifications
You must be signed in to change notification settings - Fork 883
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
feat(AclFamily): add acl whoami command #1774
Changes from all commits
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 |
---|---|---|
|
@@ -196,22 +196,20 @@ async def test_acl_categories_multi_exec_squash(df_local_factory): | |
async def test_acl_deluser(df_server): | ||
client = aioredis.Redis(port=df_server.port) | ||
|
||
try: | ||
res = await client.execute_command("ACL DELUSER adi") | ||
except redis.exceptions.ResponseError as e: | ||
assert e.args[0] == "User adi does not exist" | ||
with pytest.raises(redis.exceptions.ResponseError): | ||
await client.execute_command("ACL DELUSER random") | ||
|
||
res = await client.execute_command("ACL SETUSER adi ON >pass +@transaction +@string") | ||
res = await client.execute_command("ACL SETUSER george ON >pass +@transaction +@string") | ||
assert res == b"OK" | ||
|
||
res = await client.execute_command("AUTH adi pass") | ||
res = await client.execute_command("AUTH george pass") | ||
assert res == b"OK" | ||
|
||
await client.execute_command("MULTI") | ||
await client.execute_command("SET key 44") | ||
|
||
admin_client = aioredis.Redis(port=df_server.port) | ||
await admin_client.execute_command("ACL DELUSER adi") | ||
await admin_client.execute_command("ACL DELUSER george") | ||
|
||
with pytest.raises(redis.exceptions.ConnectionError): | ||
await client.execute_command("EXEC") | ||
|
@@ -220,7 +218,7 @@ async def test_acl_deluser(df_server): | |
|
||
|
||
script = """ | ||
for i = 1, 10000 do | ||
for i = 1, 100000 do | ||
redis.call('SET', 'key', i) | ||
redis.call('SET', 'key1', i) | ||
redis.call('SET', 'key2', i) | ||
|
@@ -244,7 +242,7 @@ async def test_acl_del_user_while_running_lua_script(df_server): | |
|
||
for i in range(1, 4): | ||
res = await admin_client.get(f"key{i}") | ||
assert res == b"10000" | ||
assert res == b"100000" | ||
|
||
await admin_client.close() | ||
|
||
|
@@ -258,12 +256,28 @@ async def test_acl_with_long_running_script(df_server): | |
|
||
await asyncio.gather( | ||
client.eval(script, 4, "key", "key1", "key2", "key3"), | ||
admin_client.execute_command("ACL SETUSER -@string -@scripting"), | ||
admin_client.execute_command("ACL SETUSER roman -@string -@scripting"), | ||
) | ||
|
||
for i in range(1, 4): | ||
res = await admin_client.get(f"key{i}") | ||
assert res == b"10000" | ||
assert res == b"100000" | ||
|
||
await client.close() | ||
await admin_client.close() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_acl_whoami(async_client): | ||
await async_client.execute_command("ACL SETUSER kostas >kk +@ALL ON") | ||
|
||
with pytest.raises(redis.exceptions.ResponseError): | ||
await async_client.execute_command("ACL WHOAMI WHO") | ||
|
||
result = await async_client.execute_command("ACL WHOAMI") | ||
assert result == "User is default" | ||
|
||
result = await async_client.execute_command("AUTH kostas kk") | ||
|
||
result = await async_client.execute_command("ACL WHOAMI") | ||
assert result == "User is kostas" | ||
Comment on lines
+270
to
+283
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. Please stop using pytests 😆 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. I agree. This type of logic we test with unit tests 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. I promise I will move these to units next week after the release ❤️ |
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.
I slightly increased this to avoid flakes but what I run locally won't necessary reflect the gh runners since the machines we are running on the regressions tests are far more powerful than mine
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.
They're less powerful. The flakes I was worried about is that it setuser migth run to quickly