diff --git a/src/daemons/CMakeLists.txt b/src/daemons/CMakeLists.txt index d03edaa3b8b..b601b86ab53 100644 --- a/src/daemons/CMakeLists.txt +++ b/src/daemons/CMakeLists.txt @@ -87,7 +87,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( nebula-metad diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift index 768523374c1..b1991a78d59 100644 --- a/src/interface/meta.thrift +++ b/src/interface/meta.thrift @@ -107,14 +107,13 @@ struct UserItem { 1: string account, 2: string first_name, 3: string last_name, - 4: string email, - 5: string phone, + 4: bool is_lock, } struct RoleItem { 1: string account, 2: string space, - 3: RoleType RoleType, + 3: RoleType role_type, } struct ExecResp { @@ -356,14 +355,20 @@ struct GetUserReq { } struct GetUserResp { - 1: UserItem user_item, + 1: ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: UserItem user_item, } struct ListUsersReq { } struct ListUsersResp { - 1: list users, + 1: ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list users, } struct ListRolesReq { @@ -371,7 +376,10 @@ struct ListRolesReq { } struct ListRolesResp { - 1: list roles, + 1: ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list roles, } struct ChangePasswordReq { diff --git a/src/meta/CMakeLists.txt b/src/meta/CMakeLists.txt index 0cf9ae74d23..c052e282418 100644 --- a/src/meta/CMakeLists.txt +++ b/src/meta/CMakeLists.txt @@ -46,7 +46,6 @@ add_dependencies( kvstore_obj thread_obj stats_obj - dataman_obj ) add_library( diff --git a/src/meta/MetaServiceUtils.cpp b/src/meta/MetaServiceUtils.cpp index 60613a1c4fb..2ee2ca6a3a9 100644 --- a/src/meta/MetaServiceUtils.cpp +++ b/src/meta/MetaServiceUtils.cpp @@ -5,9 +5,6 @@ */ #include "meta/MetaServiceUtils.h" -#include "dataman/RowWriter.h" -#include "dataman/RowUpdater.h" -#include "dataman/RowReader.h" #include #include @@ -20,8 +17,8 @@ const std::string kHostsTable = "__hosts__"; // NOLINT const std::string kTagsTable = "__tags__"; // NOLINT const std::string kEdgesTable = "__edges__"; // NOLINT const std::string kIndexTable = "__index__"; // NOLINT -const std::string kUsersTable = "__user__"; // NOLINT -const std::string kRolesTable = "__role__"; // NOLINT +const std::string kUsersTable = "__users__"; // NOLINT +const std::string kRolesTable = "__roles__"; // NOLINT std::string MetaServiceUtils::spaceKey(GraphSpaceID spaceId) { std::string key; @@ -326,21 +323,14 @@ std::string MetaServiceUtils::userKey(UserID userId) { } std::string MetaServiceUtils::userVal(const std::string& password, - const cpp2::UserItem& userItem, - std::shared_ptr schema) { + const cpp2::UserItem& userItem) { auto len = password.size(); - std::string val; - RowWriter writer(std::move(schema)); - writer << userItem.get_account() - << userItem.get_first_name() - << userItem.get_last_name() - << userItem.get_email() - << userItem.get_phone(); - std::string encoded(writer.encode()); - val.reserve(sizeof(int32_t) + len + encoded.size()); + std::string val, userVal; + apache::thrift::CompactSerializer::serialize(userItem, &userVal); + val.reserve(sizeof(int32_t) + len + userVal.size()); val.append(reinterpret_cast(&len), sizeof(int32_t)); val.append(password); - val.append(encoded); + val.append(userVal); return val; } @@ -349,30 +339,25 @@ folly::StringPiece MetaServiceUtils::userItemVal(folly::StringPiece rawVal) { return rawVal.subpiece(offset, rawVal.size() - offset); } -std::string MetaServiceUtils::replaceUserVal(const cpp2::UserItem& user, folly::StringPiece val, - std::shared_ptr schema) { - auto reader = RowReader::getRowReader(MetaServiceUtils::userItemVal(val), schema); - RowUpdater updater(move(reader), schema); - +std::string MetaServiceUtils::replaceUserVal(const cpp2::UserItem& user, folly::StringPiece val) { + cpp2:: UserItem oldUser; + apache::thrift::CompactSerializer::deserialize(userItemVal(val), oldUser); if (user.__isset.first_name) { - updater.setString(GLOBAL_USER_ITEM_FIRSTNAME, user.first_name); + oldUser.set_first_name(user.get_first_name()); } if (user.__isset.last_name) { - updater.setString(GLOBAL_USER_ITEM_LASTNAME, user.get_last_name()); + oldUser.set_last_name(user.get_last_name()); } - if (user.__isset.email) { - updater.setString(GLOBAL_USER_ITEM_EMAIL, user.get_email()); + if (user.__isset.is_lock) { + oldUser.set_is_lock(user.get_is_lock()); } - if (user.__isset.phone) { - updater.setString(GLOBAL_USER_ITEM_PHONE, user.get_phone()); - } - auto newVal = updater.encode(); + std::string newVal, userVal; + apache::thrift::CompactSerializer::serialize(oldUser, &userVal); auto len = sizeof(int32_t) + *reinterpret_cast(val.begin()); - std::string userVal; - userVal.reserve(len + newVal.size()); - userVal.append(val.subpiece(0, len).str()); - userVal.append(newVal); - return userVal; + newVal.reserve(len + userVal.size()); + newVal.append(val.subpiece(0, len).str()); + newVal.append(userVal); + return newVal; } std::string MetaServiceUtils::roleKey(GraphSpaceID spaceId, UserID userId) { @@ -403,18 +388,10 @@ std::string MetaServiceUtils::changePassword(folly::StringPiece val, folly::Stri return newVal; } -cpp2::UserItem MetaServiceUtils::parseUserItem(folly::StringPiece val, - std::shared_ptr schema) { - auto reader = RowReader::getRowReader(userItemVal(val), schema); - folly::StringPiece accont, first, last, email, phone; - reader->getString(GLOBAL_USER_ITEM_ACCOUNT, accont); - reader->getString(GLOBAL_USER_ITEM_FIRSTNAME, first); - reader->getString(GLOBAL_USER_ITEM_LASTNAME, last); - reader->getString(GLOBAL_USER_ITEM_EMAIL, email); - reader->getString(GLOBAL_USER_ITEM_PHONE, phone); - cpp2::UserItem userItem(apache::thrift::FragileConstructor::FRAGILE, - accont.str(), first.str(), last.str(), email.str(), phone.str()); - return userItem; +cpp2::UserItem MetaServiceUtils::parseUserItem(folly::StringPiece val) { + cpp2:: UserItem user; + apache::thrift::CompactSerializer::deserialize(userItemVal(val), user); + return user; } std::string MetaServiceUtils::roleSpacePrefix(GraphSpaceID spaceId) { diff --git a/src/meta/MetaServiceUtils.h b/src/meta/MetaServiceUtils.h index 59ff3bc02d8..f044e23c94e 100644 --- a/src/meta/MetaServiceUtils.h +++ b/src/meta/MetaServiceUtils.h @@ -9,7 +9,6 @@ #include "base/Base.h" #include "interface/gen-cpp2/meta_types.h" -#include "SchemaProviderIf.h" namespace nebula { namespace meta { @@ -21,13 +20,6 @@ enum class EntryType : int8_t { USER = 0x04, }; -#define GLOBAL_USER_SCHEMA_TAG "global_user_schema_tag" -#define GLOBAL_USER_ITEM_ACCOUNT "account" -#define GLOBAL_USER_ITEM_FIRSTNAME "first-name" -#define GLOBAL_USER_ITEM_LASTNAME "last-name" -#define GLOBAL_USER_ITEM_EMAIL "email-addr" -#define GLOBAL_USER_ITEM_PHONE "phone-num" - class MetaServiceUtils final { public: MetaServiceUtils() = delete; @@ -101,13 +93,11 @@ class MetaServiceUtils final { static std::string userKey(UserID userId); static std::string userVal(const std::string& password, - const cpp2::UserItem& userItem, - std::shared_ptr schema); + const cpp2::UserItem& userItem); static folly::StringPiece userItemVal(folly::StringPiece rawVal); - static std::string replaceUserVal(const cpp2::UserItem& user, folly::StringPiece rawVal, - std::shared_ptr schema); + static std::string replaceUserVal(const cpp2::UserItem& user, folly::StringPiece rawVal); static std::string roleKey(GraphSpaceID spaceId, UserID userId); @@ -115,8 +105,7 @@ class MetaServiceUtils final { static std::string changePassword(folly::StringPiece val, folly::StringPiece newPwd); - static cpp2::UserItem parseUserItem(folly::StringPiece val, - std::shared_ptr schema); + static cpp2::UserItem parseUserItem(folly::StringPiece val); static std::string roleSpacePrefix(GraphSpaceID spaceId); diff --git a/src/meta/processors/BaseProcessor.h b/src/meta/processors/BaseProcessor.h index bc8dcd6b6fe..aafabb8bcb3 100644 --- a/src/meta/processors/BaseProcessor.h +++ b/src/meta/processors/BaseProcessor.h @@ -16,7 +16,6 @@ #include "kvstore/KVStore.h" #include "meta/MetaServiceUtils.h" #include "meta/common/MetaCommon.h" -#include "meta/NebulaSchemaProvider.h" #include "network/NetworkUtils.h" namespace nebula { @@ -98,6 +97,7 @@ class BaseProcessor { case Status::kSpaceNotFound: case Status::kHostNotFound: case Status::kTagNotFound: + case Status::kUserNotFound: return cpp2::ErrorCode::E_NOT_FOUND; default: return cpp2::ErrorCode::E_UNKNOWN; @@ -207,8 +207,6 @@ class BaseProcessor { StatusOr getUserId(const std::string& account); - StatusOr> getUserSchema(); - bool checkPassword(UserID userId, const std::string& password); StatusOr getUserAccount(UserID userId); diff --git a/src/meta/processors/BaseProcessor.inl b/src/meta/processors/BaseProcessor.inl index 622330a4428..341531798a5 100644 --- a/src/meta/processors/BaseProcessor.inl +++ b/src/meta/processors/BaseProcessor.inl @@ -215,35 +215,6 @@ StatusOr BaseProcessor::getUserId(const std::string& account) { return Status::UserNotFound(folly::stringPrintf("User %s not found", account.c_str())); } -template -StatusOr> BaseProcessor::getUserSchema() { - auto ret = getTagId(0, GLOBAL_USER_SCHEMA_TAG); - if (!ret.ok()) { - return Status::TagNotFound(folly::stringPrintf("Tag %s not found", GLOBAL_USER_SCHEMA_TAG)); - } - - std::unique_ptr iter; - auto tagPrefix = MetaServiceUtils::schemaTagPrefix(0, ret.value()); - auto code = kvstore_->prefix(kDefaultSpaceId_, kDefaultPartId_, tagPrefix, &iter); - if (code != kvstore::ResultCode::SUCCEEDED || !iter->valid()) { - return Status:: TagNotFound(folly::stringPrintf("Tag %s not found", - GLOBAL_USER_SCHEMA_TAG)); - } - - // Get last version of tag - auto version = MetaServiceUtils::parseTagVersion(iter->key()); - auto schema = MetaServiceUtils::parseSchema(iter->val()); - auto& columns = schema.get_columns(); - - std::shared_ptr schemaProv(new NebulaSchemaProvider(version)); - for (auto& column : columns) { - schemaProv->addField(column.get_name(), - const_cast(column.get_type())); - } - - return schemaProv; -} - template bool BaseProcessor::checkPassword(UserID userId, const std::string& password) { auto userKey = MetaServiceUtils::userKey(userId); @@ -266,12 +237,7 @@ StatusOr BaseProcessor::getUserAccount(UserID userId) { return Status::UserNotFound(folly::stringPrintf("User not found by id %d", userId)); } - auto schema = getUserSchema(); - if (!schema.ok()) { - return Status::TagNotFound("Global user tag not found."); - } - - auto user = MetaServiceUtils::parseUserItem(value, schema.value()); + auto user = MetaServiceUtils::parseUserItem(value); return user.get_account(); } diff --git a/src/meta/processors/usersMan/AuthenticationProcessor.cpp b/src/meta/processors/usersMan/AuthenticationProcessor.cpp index 96a49bb349e..06b9ab92d2a 100644 --- a/src/meta/processors/usersMan/AuthenticationProcessor.cpp +++ b/src/meta/processors/usersMan/AuthenticationProcessor.cpp @@ -30,14 +30,8 @@ void CreateUserProcessor::process(const cpp2::CreateUserReq& req) { data.emplace_back(MetaServiceUtils::indexUserKey(user.get_account()), std::string(reinterpret_cast(&userId), sizeof(userId))); LOG(INFO) << "Create User " << user.get_account() << ", userId " << userId; - auto schema = getUserSchema(); - if (!schema.ok()) { - resp_.set_code(to(ret.status())); - onFinished(); - return; - } data.emplace_back(MetaServiceUtils::userKey(userId), - MetaServiceUtils::userVal(req.get_encoded_pwd(), user, schema.value())); + MetaServiceUtils::userVal(req.get_encoded_pwd(), user)); resp_.set_code(cpp2::ErrorCode::SUCCEEDED); resp_.set_id(to(userId, EntryType::USER)); doPut(std::move(data)); @@ -62,16 +56,9 @@ void AlterUserProcessor::process(const cpp2::AlterUserReq& req) { onFinished(); return; } - - auto schema = getUserSchema(); - if (!schema.ok()) { - resp_.set_code(to(ret.status())); - onFinished(); - return; - } std::vector data; data.emplace_back(std::move(userKey), - MetaServiceUtils::replaceUserVal(user, val, schema.value())); + MetaServiceUtils::replaceUserVal(user, val)); resp_.set_code(cpp2::ErrorCode::SUCCEEDED); resp_.set_id(to(userId, EntryType::USER)); doPut(std::move(data)); @@ -134,7 +121,7 @@ void GrantProcessor::process(const cpp2::GrantRoleReq& req) { } std::vector data; data.emplace_back(MetaServiceUtils::roleKey(spaceRet.value(), userRet.value()), - MetaServiceUtils::roleVal(roleItem.get_RoleType())); + MetaServiceUtils::roleVal(roleItem.get_role_type())); resp_.set_code(cpp2::ErrorCode::SUCCEEDED); doPut(std::move(data)); } @@ -201,6 +188,7 @@ void GetUserProcessor::process(const cpp2::GetUserReq& req) { auto userRet = getUserId(req.get_account()); if (!userRet.ok()) { LOG(ERROR) << "User " << req.get_account() << " not found."; + resp_.set_code(cpp2::ErrorCode::E_NOT_FOUND); onFinished(); return; } @@ -208,17 +196,13 @@ void GetUserProcessor::process(const cpp2::GetUserReq& req) { std::string val; auto result = kvstore_->get(kDefaultSpaceId_, kDefaultPartId_, userKey, &val); if (result != kvstore::ResultCode::SUCCEEDED) { + resp_.set_code(cpp2::ErrorCode::E_NOT_FOUND); onFinished(); return; } - auto schema = getUserSchema(); - if (!schema.ok()) { - LOG(ERROR) << "Global schema " << GLOBAL_USER_SCHEMA_TAG << " not found."; - onFinished(); - return; - } - decltype(resp_.user_item) user = MetaServiceUtils::parseUserItem(val, schema.value()); + decltype(resp_.user_item) user = MetaServiceUtils::parseUserItem(val); resp_.set_user_item(user); + resp_.set_code(cpp2::ErrorCode::SUCCEEDED); onFinished(); } @@ -227,26 +211,22 @@ void ListUsersProcessor::process(const cpp2::ListUsersReq& req) { UNUSED(req); folly::SharedMutex::ReadHolder rHolder(LockUtils::userLock()); std::unique_ptr iter; - std::string prefix = "__user__"; + std::string prefix = "__users__"; auto ret = kvstore_->prefix(kDefaultSpaceId_, kDefaultPartId_, prefix, &iter); if (ret != kvstore::ResultCode::SUCCEEDED) { LOG(ERROR) << "Can't find any users."; - onFinished(); - return; - } - auto schema = getUserSchema(); - if (!schema.ok()) { - LOG(ERROR) << "Global schema " << GLOBAL_USER_SCHEMA_TAG << " not found."; + resp_.set_code(cpp2::ErrorCode::E_NOT_FOUND); onFinished(); return; } decltype(resp_.users) users; while (iter->valid()) { - cpp2::UserItem user = MetaServiceUtils::parseUserItem(iter->val(), schema.value()); + cpp2::UserItem user = MetaServiceUtils::parseUserItem(iter->val()); users.emplace_back(std::move(user)); iter->next(); } resp_.set_users(users); + resp_.set_code(cpp2::ErrorCode::SUCCEEDED); onFinished(); } @@ -275,6 +255,7 @@ void ListRolesProcessor::process(const cpp2::ListRolesReq& req) { folly::SharedMutex::ReadHolder rHolder(LockUtils::userLock()); auto spaceRet = getSpaceId(req.get_space()); if (!spaceRet.ok()) { + resp_.set_code(cpp2::ErrorCode::E_NOT_FOUND); onFinished(); return;; } @@ -283,6 +264,7 @@ void ListRolesProcessor::process(const cpp2::ListRolesReq& req) { auto ret = kvstore_->prefix(kDefaultSpaceId_, kDefaultPartId_, prefix, &iter); if (ret != kvstore::ResultCode::SUCCEEDED) { LOG(ERROR) << "Can't find any roles by space " << req.get_space(); + resp_.set_code(cpp2::ErrorCode::E_NOT_FOUND); onFinished(); return; } @@ -294,6 +276,7 @@ void ListRolesProcessor::process(const cpp2::ListRolesReq& req) { auto account = getUserAccount(userId); if (!account.ok()) { LOG(ERROR) << "Get user account failling by id : " << userId; + resp_.set_code(cpp2::ErrorCode::E_NOT_FOUND); onFinished(); return; } @@ -304,6 +287,7 @@ void ListRolesProcessor::process(const cpp2::ListRolesReq& req) { iter->next(); } resp_.set_roles(roles); + resp_.set_code(cpp2::ErrorCode::SUCCEEDED); onFinished(); } } // namespace meta diff --git a/src/meta/test/AuthProcessorTest.cpp b/src/meta/test/AuthProcessorTest.cpp index b15b889e22b..69e41d14c57 100644 --- a/src/meta/test/AuthProcessorTest.cpp +++ b/src/meta/test/AuthProcessorTest.cpp @@ -21,11 +21,10 @@ using apache::thrift::FragileConstructor::FRAGILE; TEST(AuthProcessorTest, CreateUserTest) { fs::TempDir rootPath("/tmp/CreateUserTest.XXXXXX"); std::unique_ptr kv(TestUtils::initKV(rootPath.path())); - TestUtils::mockUserTag(kv.get()); // Simple test auto code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "first name", "last name" , - "email@email.com", "+00-00000000"); + false); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); /** @@ -36,10 +35,10 @@ TEST(AuthProcessorTest, CreateUserTest) { * the result will be EXISTED if the user exists. **/ - code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "", "" , "", ""); + code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "", "" , false); ASSERT_EQ(cpp2::ErrorCode::E_EXISTED, code); - code = TestUtils::createUser(kv.get(), true, "user1", "pwd", "", "" , "", ""); + code = TestUtils::createUser(kv.get(), true, "user1", "pwd", "", "" , false); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); } @@ -47,12 +46,11 @@ TEST(AuthProcessorTest, CreateUserTest) { TEST(AuthProcessorTest, AlterUserTest) { fs::TempDir rootPath("/tmp/AlterUserTest.XXXXXX"); std::unique_ptr kv(TestUtils::initKV(rootPath.path())); - TestUtils::mockUserTag(kv.get()); // Setup { auto code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "first name", "last name" , - "email@email.com", "+00-00000000"); + false); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); } // Alter a few attributes @@ -87,8 +85,7 @@ TEST(AuthProcessorTest, AlterUserTest) { newUser.set_account("user1"); newUser.set_first_name("new first name"); newUser.set_last_name(""); - newUser.set_email("aaaa@ccccc.com"); - newUser.set_phone("1234567890"); + newUser.set_is_lock(false); req.set_user_item(std::move(newUser)); auto* processor = AlterUserProcessor::instance(kv.get()); auto f = processor->getFuture(); @@ -107,8 +104,7 @@ TEST(AuthProcessorTest, AlterUserTest) { user.set_account("user1"); user.set_first_name("new first name"); user.set_last_name(""); - user.set_email("aaaa@ccccc.com"); - user.set_phone("1234567890"); + user.set_is_lock(false); ASSERT_EQ(user, resp.get_user_item()); } } @@ -116,12 +112,11 @@ TEST(AuthProcessorTest, AlterUserTest) { TEST(AuthProcessorTest, DropUserTest) { fs::TempDir rootPath("/tmp/DropUserTest.XXXXXX"); std::unique_ptr kv(TestUtils::initKV(rootPath.path())); - TestUtils::mockUserTag(kv.get()); // Setup { auto code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "first name", "last name" , - "email@email.com", "+00-00000000"); + false); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); } // Simple drop. @@ -164,12 +159,11 @@ TEST(AuthProcessorTest, DropUserTest) { TEST(AuthProcessorTest, PasswordTest) { fs::TempDir rootPath("/tmp/PasswordTest.XXXXXX"); std::unique_ptr kv(TestUtils::initKV(rootPath.path())); - TestUtils::mockUserTag(kv.get()); // Setup { auto code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "first name", "last name" , - "email@email.com", "+00-00000000"); + false); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); } // verify password. @@ -227,12 +221,11 @@ TEST(AuthProcessorTest, PasswordTest) { TEST(AuthProcessorTest, GrantRevokeTest) { fs::TempDir rootPath("/tmp/GrantRevokeTest.XXXXXX"); std::unique_ptr kv(TestUtils::initKV(rootPath.path())); - TestUtils::mockUserTag(kv.get()); // Setup { auto code = TestUtils::createUser(kv.get(), false, "user1", "pwd", "first name", "last name", - "email@email.com", "+00-00000000"); + false); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); } // grant test : space does not exist diff --git a/src/meta/test/CMakeLists.txt b/src/meta/test/CMakeLists.txt index 912e1ac8d89..f1df70119a0 100644 --- a/src/meta/test/CMakeLists.txt +++ b/src/meta/test/CMakeLists.txt @@ -9,7 +9,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( meta_utils_test @@ -34,7 +33,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( processor_test @@ -60,7 +58,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( hb_processor_test @@ -87,7 +84,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( meta_client_test @@ -134,7 +130,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( meta_http_test @@ -160,7 +155,6 @@ add_executable( $ $ $ - $ ) nebula_link_libraries( authentication_test diff --git a/src/meta/test/TestUtils.h b/src/meta/test/TestUtils.h index fe895d9091d..33b6b6f50ec 100644 --- a/src/meta/test/TestUtils.h +++ b/src/meta/test/TestUtils.h @@ -179,38 +179,13 @@ class TestUtils { return sc; } - static void mockUserTag(kvstore::KVStore* kv, SchemaVer version = 0) { - std::vector tag; - SchemaVer ver = version; - TagID tagId = 1; - nebula::cpp2::Schema srcsch; - auto type = nebula::cpp2::ValueType(FRAGILE, SupportedType::STRING, nullptr, nullptr); - srcsch.columns.emplace_back(FRAGILE, GLOBAL_USER_ITEM_ACCOUNT, type); - srcsch.columns.emplace_back(FRAGILE, GLOBAL_USER_ITEM_FIRSTNAME, type); - srcsch.columns.emplace_back(FRAGILE, GLOBAL_USER_ITEM_LASTNAME, type); - srcsch.columns.emplace_back(FRAGILE, GLOBAL_USER_ITEM_EMAIL, type); - srcsch.columns.emplace_back(FRAGILE, GLOBAL_USER_ITEM_PHONE, type); - - auto tagIdVal = std::string(reinterpret_cast(&tagId), sizeof(tagId)); - tag.emplace_back(MetaServiceUtils::indexTagKey(0, GLOBAL_USER_SCHEMA_TAG), tagIdVal); - tag.emplace_back(MetaServiceUtils::schemaTagKey(0, tagId, ver), - MetaServiceUtils::schemaTagVal(GLOBAL_USER_SCHEMA_TAG, srcsch)); - - kv->asyncMultiPut(0, 0, std::move(tag), - [] (kvstore::ResultCode code, HostAddr leader) { - ASSERT_EQ(kvstore::ResultCode::SUCCEEDED, code); - UNUSED(leader); - }); - } - static cpp2::ErrorCode createUser(kvstore::KVStore* kv, bool missingOk, folly::StringPiece account, folly::StringPiece password, folly::StringPiece first, folly::StringPiece last, - folly::StringPiece email, - folly::StringPiece phone) { + bool isLock) { cpp2::CreateUserReq req; req.set_missing_ok(missingOk); req.set_encoded_pwd(password.str()); @@ -218,8 +193,7 @@ class TestUtils { account.str(), first.str(), last.str(), - email.str(), - phone.str()); + isLock); req.set_user(std::move(user)); auto* processor = CreateUserProcessor::instance(kv); auto f = processor->getFuture();