From 43e2919122f6ca0d6c8a6bd18d29151a15d115c8 Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Thu, 31 Oct 2019 22:06:09 +0100 Subject: [PATCH] user: don't throw C++ exception from user_find_by_name This function is supposed to return NULL on an error. For exceptions there is user_find_by_name_xc. (cherry picked from commit 8b6bdb435cb6b41375d8e550cc2d9c14c1d1f742) --- src/box/user.cc | 2 +- test/box/access.result | 11 +++++++++++ test/box/access.test.lua | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/box/user.cc b/src/box/user.cc index 82ee6a0504..28bbdc8956 100644 --- a/src/box/user.cc +++ b/src/box/user.cc @@ -494,7 +494,7 @@ user_find_by_name(const char *name, uint32_t len) { uint32_t uid; if (schema_find_id(BOX_USER_ID, 2, name, len, &uid) != 0) - diag_raise(); + return NULL; struct user *user = user_by_id(uid); if (user == NULL || user->def->type != SC_USER) { diag_set(ClientError, ER_NO_SUCH_USER, tt_cstr(name, len)); diff --git a/test/box/access.result b/test/box/access.result index ba72b5f742..f7d00354a1 100644 --- a/test/box/access.result +++ b/test/box/access.result @@ -239,6 +239,17 @@ session.user() --- - admin ... +-- Invalid user. +session.su('does not exist') +--- +- error: User 'does not exist' is not found +... +-- The point of this test is to try a name > max +-- allowed name. +session.su(string.rep('a', 66000)) +--- +- error: name length 66000 is greater than BOX_NAME_MAX +... -------------------------------------------------------------------------------- -- Check if identifiers obey the common constraints -------------------------------------------------------------------------------- diff --git a/test/box/access.test.lua b/test/box/access.test.lua index 219cdb04a1..c99e823644 100644 --- a/test/box/access.test.lua +++ b/test/box/access.test.lua @@ -100,6 +100,12 @@ session.su('admin') box.schema.user.drop('tester') session.user() +-- Invalid user. +session.su('does not exist') +-- The point of this test is to try a name > max +-- allowed name. +session.su(string.rep('a', 66000)) + -------------------------------------------------------------------------------- -- Check if identifiers obey the common constraints -------------------------------------------------------------------------------- -- GitLab