Skip to content

Commit

Permalink
fix if user does not exist, desc user xxx will be raise "User not e…
Browse files Browse the repository at this point in the history
…xisted!"
  • Loading branch information
Milittle committed Feb 16, 2023
1 parent 0f11fa1 commit 0aa2fc9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
15 changes: 14 additions & 1 deletion src/meta/processors/user/AuthenticationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,23 @@ void GetUserRolesProcessor::process(const cpp2::GetUserRolesReq& req) {
folly::SharedMutex::ReadHolder holder(LockUtils::lock());
const auto& act = req.get_account();

auto retCode = userExist(act);
if (retCode != nebula::cpp2::ErrorCode::SUCCEEDED) {
if (retCode == nebula::cpp2::ErrorCode::E_USER_NOT_FOUND) {
LOG(INFO) << "Get User Roles Failed: " << act << " not found.";
} else {
LOG(INFO) << "Get User Roles Failed, User " << act
<< " error: " << apache::thrift::util::enumNameSafe(retCode);
}
handleErrorCode(retCode);
onFinished();
return;
}

auto prefix = MetaKeyUtils::rolesPrefix();
auto ret = doPrefix(prefix);
if (!nebula::ok(ret)) {
auto retCode = nebula::error(ret);
retCode = nebula::error(ret);
LOG(INFO) << "Prefix roles failed, error: " << apache::thrift::util::enumNameSafe(retCode);
handleErrorCode(retCode);
onFinished();
Expand Down
34 changes: 15 additions & 19 deletions tests/tck/features/user/User.feature
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,11 @@ Feature: User & privilege Test
DROP USER IF EXISTS u6;
"""
Then the execution should be successful
# TODO(shylock) fix it
# When executing query:
# """
# DESC USER u6;
# """
# Then a ExecutionError should be raised at runtime: User not existed!
When executing query:
"""
DESC USER u6;
"""
Then a ExecutionError should be raised at runtime: User not existed!
When executing query:
"""
DROP USER IF EXISTS u6;
Expand Down Expand Up @@ -186,12 +185,11 @@ Feature: User & privilege Test
DROP USER user_mlt_roles;
"""
Then the execution should be successful
# TODO(shylock) fix me
# When executing query:
# """
# DESC USER user_mlt_roles
# """
# Then a ExecutionError should be raised at runtime: User not existed!
When executing query:
"""
DESC USER user_mlt_roles
"""
Then a ExecutionError should be raised at runtime: User not existed!
When executing query:
"""
CREATE USER user_mlt_roles;
Expand Down Expand Up @@ -766,10 +764,8 @@ Feature: User & privilege Test
DESC USER root
"""
Then a PermissionError should be raised at runtime:

# TODO(shylock) fix it
# When executing query:
# """
# DESCRIBE USER not_exists
# """
# Then a ExecutionError should be raised at runtime: User not existed!
When executing query:
"""
DESCRIBE USER not_exists
"""
Then a ExecutionError should be raised at runtime: User not existed!

0 comments on commit 0aa2fc9

Please sign in to comment.