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!" (vesoft-inc#2450)

If user does not exist `desc user xxx` will be raise "User not existed!"

<!--
Thanks for your contribution!
In order to review PR more efficiently, please add information according to the template.
-->

## What type of PR is this?
- [x] bug
- [ ] feature
- [ ] enhancement

## What problem(s) does this PR solve?
#### Issue(s) number: 
Close vesoft-inc#5141

#### Description:
If use does not exist `desc user xxx` will be raise "User not existed!"

## How do you solve it?
add account exist verify in meta service

## Special notes for your reviewer, ex. impact of this fix, design document, etc:

## Checklist:
Tests:
manunal test:
```
(root@nebula) [(none)]> desc user u6
[ERROR (-1005)]: User not existed!

Wed, 15 Feb 2023 22:43:06 CST
```
- [ ] Unit test(positive and negative cases)
- [ ] Function test
- [ ] Performance test
- [ ] N/A

Affects:
- [ ] Documentation affected (Please add the label if documentation needs to be modified.)
- [ ] Incompatibility (If it breaks the compatibility, please describe it and add the label.)
- [ ] If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
- [ ] Performance impacted: Consumes more CPU/Memory


## Release notes:

Please confirm whether to be reflected in release notes and how to describe:
> ex. Fixed the bug .....


Migrated from vesoft-inc#5345

Co-authored-by: Milittle <[email protected]>
  • Loading branch information
nebula-bots and Milittle authored Feb 21, 2023
1 parent d3468d7 commit 2c8d0ff
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 @@ -449,10 +449,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,6 +763,11 @@ Feature: User & privilege Test
DESC USER root
"""
Then a PermissionError should be raised at runtime:
When executing query:
"""
DESCRIBE USER not_exists
"""
Then a ExecutionError should be raised at runtime: User not existed!
When executing query:
"""
DROP SPACE IF EXISTS user_tmp_space_4;
Expand Down Expand Up @@ -848,10 +850,3 @@ Feature: User & privilege Test
"""
Then a SyntaxError should be raised at runtime: syntax error near `xxx'
When verify login with user "user_ip4" and password "pwd1"

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

0 comments on commit 2c8d0ff

Please sign in to comment.