Fix tests

This commit is contained in:
Alexey Milovidov 2023-11-16 00:13:05 +01:00
parent a7543e3c7c
commit 3bbb329dd0
2 changed files with 14 additions and 3 deletions

View File

@ -587,8 +587,19 @@ void TCPHandler::runImpl()
}
catch (const Exception & e)
{
/// Authentication failure with interserver secret.
if (e.code() == ErrorCodes::AUTHENTICATION_FAILED)
/// Authentication failure with interserver secret
/// - early exit without trying to send the exception to the client.
/// Because the server should not try to skip (parse, decompress) the remaining packets sent by the client,
/// as it will lead to additional work and unneeded exposure to unauthenticated connections.
/// Note that the exception AUTHENTICATION_FAILED can be here in two cases:
/// 1. The authentication in receiveHello is skipped with "interserver secret",
/// postponed to receiving the query, and then failed.
/// 2. Receiving exception from a query using a table function to authenticate with another server.
/// In this case, the user is already authenticated with this server,
/// is_interserver_mode is false, and we can send the exception to the client normally.
if (is_interserver_mode && e.code() == ErrorCodes::AUTHENTICATION_FAILED)
throw;
state.io.onException();

View File

@ -4,7 +4,7 @@ select * from remote('127.0.0.2', system, one, 'default', '');
select * from remote('127.0.0.2', system, one, 'default', 'wrong password'); -- { serverError AUTHENTICATION_FAILED }
select * from remote('127.0.0.2', system, one, 'nonexistsnt_user_1119', ''); -- { serverError AUTHENTICATION_FAILED }
set receive_timeout=1;
select * from remote('127.0.0.2', system, one, ' INTERSERVER SECRET ', ''); -- { serverError NO_REMOTE_SHARD_AVAILABLE }
select * from remote('127.0.0.2', system, one, ' INTERSERVER SECRET ', ''); -- { serverError AUTHENTICATION_FAILED }
set receive_timeout=300;
select * from remote('127.0.0.2', system, one, ' ', ''); -- { serverError AUTHENTICATION_FAILED }