fix(acl): return -NOPERM instead of response error (#3049)

This commit is contained in:
Kostas Kyrimis 2024-05-27 09:25:54 +03:00 committed by GitHub
parent 0dea257f41
commit 2391f49e1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -1000,7 +1000,7 @@ static optional<ErrorReply> VerifyConnectionAclStatus(const CommandId* cid,
cntx = cntx->conn_state.squashing_info->owner;
if (!acl::IsUserAllowedToInvokeCommand(*cntx, *cid, tail_args)) {
return ErrorReply(absl::StrCat("NOPERM: ", cntx->authed_username, " ", error_msg));
return ErrorReply(absl::StrCat("-NOPERM ", cntx->authed_username, " ", error_msg));
}
return nullopt;
}

View file

@ -159,7 +159,7 @@ async def test_acl_cat_commands_multi_exec_squash(df_local_factory):
await client.execute_command("MULTI")
assert res == b"OK"
with pytest.raises(redis.exceptions.ResponseError):
with pytest.raises(redis.exceptions.NoPermissionError):
await client.execute_command(f"SET x{x} {x}")
await client.close()
@ -186,7 +186,7 @@ async def test_acl_cat_commands_multi_exec_squash(df_local_factory):
# return multiple errors for each command failed. Since the nature of the error
# is the same, that a rule has changed we should squash those error messages into
# one.
assert res[0].args[0] == "NOPERM: kk ACL rules changed between the MULTI and EXEC"
assert res[0].args[0] == "kk ACL rules changed between the MULTI and EXEC"
await admin_client.close()
await client.close()
@ -213,7 +213,7 @@ async def test_acl_cat_commands_multi_exec_squash(df_local_factory):
# NOPERM while executing multi
await client.execute_command("MULTI")
with pytest.raises(redis.exceptions.ResponseError):
with pytest.raises(redis.exceptions.NoPermissionError):
await client.execute_command(f"SET x{x} {x}")
await admin_client.close()