serialize no_password

This commit is contained in:
Arthur Passos 2024-06-25 20:02:19 -03:00
parent 907a54e9f6
commit 57afc5f035
5 changed files with 21 additions and 8 deletions

View File

@ -356,7 +356,8 @@ std::shared_ptr<ASTAuthenticationData> AuthenticationData::toAST() const
break;
}
case AuthenticationType::NO_PASSWORD: [[fallthrough]];
case AuthenticationType::NO_PASSWORD:
break;
case AuthenticationType::MAX:
throw Exception(ErrorCodes::LOGICAL_ERROR, "AST: Unexpected authentication type {}", toString(auth_type));
}

View File

@ -66,10 +66,7 @@ namespace
for (const auto & authentication_method : user.authentication_methods)
{
if (authentication_method.getType() != AuthenticationType::NO_PASSWORD)
{
query->auth_data.push_back(authentication_method.toAST());
}
query->auth_data.push_back(authentication_method.toAST());
}
if (user.valid_until)

View File

@ -44,7 +44,7 @@ void ASTAuthenticationData::formatImpl(const FormatSettings & settings, FormatSt
{
if (type && *type == AuthenticationType::NO_PASSWORD)
{
settings.ostr << (settings.hilite ? IAST::hilite_keyword : "") << " NOT IDENTIFIED"
settings.ostr << (settings.hilite ? IAST::hilite_keyword : "") << " IDENTIFIED WITH no_password"
<< (settings.hilite ? IAST::hilite_none : "");
return;
}

View File

@ -189,8 +189,15 @@ ASTPtr ASTCreateUserQuery::clone() const
if (settings)
res->settings = std::static_pointer_cast<ASTSettingsProfileElements>(settings->clone());
// this is weird.
if (!auth_data.empty())
if (auth_data.empty())
{
auto ast = std::make_shared<ASTAuthenticationData>();
ast->type = AuthenticationType::NO_PASSWORD;
res->auth_data.push_back(ast);
res->children.push_back(ast);
}
else
{
for (const auto & authentication_method : auth_data)
{

View File

@ -284,6 +284,14 @@ INSTANTIATE_TEST_SUITE_P(ParserCreateUserQuery, ParserTest,
"CREATE USER user1 IDENTIFIED WITH sha256_password BY 'qwe123'",
"CREATE USER user1 IDENTIFIED WITH sha256_password BY 'qwe123'"
},
{
"CREATE USER user1 IDENTIFIED WITH no_password",
"CREATE USER user1 IDENTIFIED WITH no_password"
},
{
"CREATE USER user1",
"CREATE USER user1 IDENTIFIED WITH no_password"
},
{
"CREATE USER user1 IDENTIFIED WITH plaintext_password BY 'abc123' ADD IDENTIFIED WITH plaintext_password BY 'def123' ADD IDENTIFIED WITH sha256_password BY 'ghi123'",
"CREATE USER user1 IDENTIFIED WITH plaintext_password BY 'abc123' ADD IDENTIFIED WITH plaintext_password BY 'def123' ADD IDENTIFIED WITH sha256_password BY 'ghi123'"