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!" (#5345)
  • Loading branch information
Milittle authored Feb 20, 2023
1 parent a1a37b9 commit 9845dd7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 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
37 changes: 16 additions & 21 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 @@ -731,8 +729,7 @@ Feature: User & privilege Test
"""
DESC USER user_not_exist
"""
Then the result should be, in any order, with relax comparison:
| role | space |
Then a ExecutionError should be raised at runtime: User not existed!
When executing query with user "user1" and password "pwd1":
"""
DESC USER user1
Expand Down Expand Up @@ -766,10 +763,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 9845dd7

Please sign in to comment.