Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongqiang YANG committed Dec 8, 2024
1 parent 4892cdd commit b05efba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
10 changes: 5 additions & 5 deletions cloud/src/meta-service/meta_service_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ int decrypt_instance_info(InstanceInfoPB& instance, const std::string& instance_
return 0;
}

int decrypt_and_update_ak_sk(ObjectStoreInfoPB& obj_info, MetaServiceCode& code,
std::string& msg) {
int decrypt_and_update_ak_sk(ObjectStoreInfoPB& obj_info, MetaServiceCode& code, std::string& msg) {
if (obj_info.has_encryption_info()) {
AkSkPair plain_ak_sk_pair;
if (int ret = decrypt_ak_sk_helper(obj_info.ak(), obj_info.sk(), obj_info.encryption_info(),
Expand Down Expand Up @@ -476,8 +475,9 @@ static void create_object_info_with_encrypt(const InstanceInfoPB& instance, Obje
obj->set_sse_enabled(sse_enabled);
}

static int check_duplicated_vault_name(const InstanceInfoPB& instance, const std::string& candidate_name,
MetaServiceCode& code, std::string& msg) {
static int check_duplicated_vault_name(const InstanceInfoPB& instance,
const std::string& candidate_name, MetaServiceCode& code,
std::string& msg) {
if (std::find_if(instance.storage_vault_names().begin(), instance.storage_vault_names().end(),
[&candidate_name](const auto& name) { return name == candidate_name; }) !=
instance.storage_vault_names().end()) {
Expand All @@ -495,7 +495,7 @@ static int check_new_vault_name(const InstanceInfoPB& instance, const std::strin
code = MetaServiceCode::INVALID_ARGUMENT;
std::stringstream ss;
ss << "invalid storage vault name =" << candidate_name << " the name must satisfy "
<< pattern_str;
<< pattern_str;
msg = ss.str();
return -1;
}
Expand Down
27 changes: 16 additions & 11 deletions cloud/test/meta_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ static void get_all_vaults(const MetaServiceProxy* meta_service, const InstanceI
EXPECT_EQ(all_vaults.size(), instance.resource_ids().size());
}

static void check_vault_name_consistency(const MetaServiceProxy* meta_service, const InstanceInfoPB& instance) {
static void check_vault_name_consistency(const MetaServiceProxy* meta_service,
const InstanceInfoPB& instance) {
std::vector<StorageVaultPB> all_vaults;

get_all_vaults(meta_service, instance, all_vaults);
Expand All @@ -487,7 +488,8 @@ static void check_vault_name_consistency(const MetaServiceProxy* meta_service, c
found++;
}
}
ASSERT_EQ(found, 1) << "vault_name " << vault_name << " does not exists in objinfo";
ASSERT_EQ(found, 1) << "vault_name " << vault_name
<< " does not exists in objinfo";
}

for (const auto& vault_pb : all_vaults) {
Expand Down Expand Up @@ -594,7 +596,6 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {

// can not change ak without sk
{

StorageVaultPB orig_vault = get_vault_pb("2");

AlterObjStoreInfoRequest req;
Expand All @@ -619,7 +620,6 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {

// can not change sk without ak
{

StorageVaultPB orig_vault = get_vault_pb("2");

AlterObjStoreInfoRequest req;
Expand Down Expand Up @@ -671,7 +671,6 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {

// alter ak sk
{

LOG(INFO) << "alter ak sk";

StorageVaultPB orig_vault = get_vault_pb("2");
Expand Down Expand Up @@ -702,7 +701,8 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {
EXPECT_EQ(orig_vault.obj_info().region(), new_vault.obj_info().region());
EXPECT_EQ(orig_vault.obj_info().bucket(), new_vault.obj_info().bucket());
EXPECT_EQ(orig_vault.obj_info().prefix(), new_vault.obj_info().prefix());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(), new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(),
new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().provider(), new_vault.obj_info().provider());
ASSERT_NE(orig_vault.obj_info().ak(), new_vault.obj_info().ak());
ASSERT_NE(orig_vault.obj_info().sk(), new_vault.obj_info().sk());
Expand Down Expand Up @@ -752,7 +752,8 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {
EXPECT_EQ(orig_vault.obj_info().region(), new_vault.obj_info().region());
EXPECT_EQ(orig_vault.obj_info().bucket(), new_vault.obj_info().bucket());
EXPECT_EQ(orig_vault.obj_info().prefix(), new_vault.obj_info().prefix());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(), new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(),
new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().provider(), new_vault.obj_info().provider());
EXPECT_EQ(orig_vault.obj_info().ak(), new_vault.obj_info().ak());
EXPECT_EQ(orig_vault.obj_info().sk(), new_vault.obj_info().sk());
Expand Down Expand Up @@ -784,7 +785,8 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {
EXPECT_EQ(orig_vault.obj_info().region(), new_vault.obj_info().region());
EXPECT_EQ(orig_vault.obj_info().bucket(), new_vault.obj_info().bucket());
EXPECT_EQ(orig_vault.obj_info().prefix(), new_vault.obj_info().prefix());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(), new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(),
new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().provider(), new_vault.obj_info().provider());
EXPECT_EQ(orig_vault.obj_info().ak(), new_vault.obj_info().ak());
EXPECT_EQ(orig_vault.obj_info().sk(), new_vault.obj_info().sk());
Expand Down Expand Up @@ -819,7 +821,8 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {
EXPECT_EQ(orig_vault.obj_info().region(), new_vault.obj_info().region());
EXPECT_EQ(orig_vault.obj_info().bucket(), new_vault.obj_info().bucket());
EXPECT_EQ(orig_vault.obj_info().prefix(), new_vault.obj_info().prefix());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(), new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(),
new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().provider(), new_vault.obj_info().provider());
EXPECT_EQ(orig_vault.obj_info().ak(), new_vault.obj_info().ak());
EXPECT_EQ(orig_vault.obj_info().sk(), new_vault.obj_info().sk());
Expand Down Expand Up @@ -860,7 +863,8 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {
EXPECT_EQ(orig_vault.obj_info().region(), new_vault.obj_info().region());
EXPECT_EQ(orig_vault.obj_info().bucket(), new_vault.obj_info().bucket());
EXPECT_EQ(orig_vault.obj_info().prefix(), new_vault.obj_info().prefix());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(), new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(),
new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().provider(), new_vault.obj_info().provider());
EXPECT_EQ(orig_vault.obj_info().ak(), new_vault.obj_info().ak());
EXPECT_EQ(orig_vault.obj_info().sk(), new_vault.obj_info().sk());
Expand Down Expand Up @@ -899,7 +903,8 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) {
EXPECT_EQ(orig_vault.obj_info().region(), new_vault.obj_info().region());
EXPECT_EQ(orig_vault.obj_info().bucket(), new_vault.obj_info().bucket());
EXPECT_EQ(orig_vault.obj_info().prefix(), new_vault.obj_info().prefix());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(), new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().external_endpoint(),
new_vault.obj_info().external_endpoint());
EXPECT_EQ(orig_vault.obj_info().provider(), new_vault.obj_info().provider());
EXPECT_EQ(orig_vault.obj_info().ak(), new_vault.obj_info().ak());
EXPECT_EQ(orig_vault.obj_info().sk(), new_vault.obj_info().sk());
Expand Down

0 comments on commit b05efba

Please sign in to comment.