From f188f42b658fb0e936c97267a9068816a5450a13 Mon Sep 17 00:00:00 2001 From: Hollokin Date: Mon, 23 Jun 2025 20:36:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9TDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hollokin --- .../service/cloud/cloud_service_impl.cpp | 2 +- .../service/test/cloud_data_test.cpp | 8 ++++++-- .../service/test/cloud_service_impl_test.cpp | 10 +++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 4404b855a..75c4ae326 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -966,9 +966,9 @@ void CloudServiceImpl::UpdateE2eeEnable(const std::string &schemaKey, bool newE2 return; } ZLOGI("Update e2eeEnable: %{public}d->%{public}d", oldMeta.e2eeEnable, newE2eeEnable); - oldMeta.e2eeEnable = newE2eeEnable; Report(FT_ENCRYPT_CHANGED, Fault::CSF_APP_SCHEMA, bundleName, "oldE2eeEnable=" + std::to_string(oldMeta.e2eeEnable) + ",newE2eeEnable=" + std::to_string(newE2eeEnable)); + oldMeta.e2eeEnable = newE2eeEnable; MetaDataManager::GetInstance().SaveMeta(schemaKey, oldMeta, true); } diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index ce7e8d8c8..dbf378bb3 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1151,6 +1151,10 @@ HWTEST_F(CloudDataTest, CloudSync007, TestSize.Level0) uint32_t seqNum = 10; auto ret = cloudServiceImpl_->CloudSync("bundleName", "storeId", { syncMode, seqNum }, nullptr); EXPECT_EQ(ret, CloudData::CloudService::INVALID_ARGUMENT); + + CloudData::Details details{}; + uint32_t tokenId = 0; + cloudServiceImpl_->OnAsyncComplete(tokenId, seqNum, std::move(details)); } /** @@ -2216,8 +2220,8 @@ HWTEST_F(CloudDataTest, UpdateE2eeEnableTest, TestSize.Level1) EXPECT_EQ(schemaMeta.e2eeEnable, schemaMeta_.e2eeEnable); ASSERT_NE(cloudServiceImpl_, nullptr); - EXPECT_NO_FATAL_FAILURE(cloudServiceImpl_->UpdateE2eeEnable(schemaKey, false, TEST_CLOUD_BUNDLE)); - EXPECT_NO_FATAL_FAILURE(cloudServiceImpl_->UpdateE2eeEnable(schemaKey, true, TEST_CLOUD_BUNDLE)); + cloudServiceImpl_->UpdateE2eeEnable(schemaKey, false, TEST_CLOUD_BUNDLE); + cloudServiceImpl_->UpdateE2eeEnable(schemaKey, true, TEST_CLOUD_BUNDLE); } /** diff --git a/services/distributeddataservice/service/test/cloud_service_impl_test.cpp b/services/distributeddataservice/service/test/cloud_service_impl_test.cpp index 253832a64..ae91d87a4 100644 --- a/services/distributeddataservice/service/test/cloud_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/cloud_service_impl_test.cpp @@ -371,9 +371,12 @@ HWTEST_F(CloudServiceImplTest, CloudDriverCheckTest, TestSize.Level0) ZLOGI("CloudServiceImplTest CloudDriverCheckTest start"); ASSERT_NE(cloudServiceImpl_, nullptr); ASSERT_NE(cloudServiceImpl_->factory_.staticActs_, nullptr); + CloudServer cloudServer; + CloudServer::RegisterCloudInstance(&cloudServer); int32_t user = 0; auto result = cloudServiceImpl_->factory_.staticActs_->CloudDriverCheck(TEST_CLOUD_BUNDLE, user); EXPECT_EQ(result, false); + CloudServer::instance_ = nullptr; } /** @@ -426,8 +429,13 @@ HWTEST_F(CloudServiceImplTest, UpdateSchemaFromServerTest_002, TestSize.Level0) HWTEST_F(CloudServiceImplTest, UpdateE2eeEnableTest, TestSize.Level0) { ZLOGI("CloudServiceImplTest UpdateE2eeEnableTest start"); + ASSERT_NE(cloudServiceImpl_, nullptr); + CloudServer cloudServer; + auto result = cloudServer.CloudDriverUpdated(TEST_CLOUD_BUNDLE); + EXPECT_EQ(result, false); + std::string schemaKey = "schemaKey"; - EXPECT_NO_FATAL_FAILURE(cloudServiceImpl_->UpdateE2eeEnable(schemaKey, true, TEST_CLOUD_BUNDLE)); + cloudServiceImpl_->UpdateE2eeEnable(schemaKey, true, TEST_CLOUD_BUNDLE); } /** -- Gitee From 9f09f4279b55bddfaea25971a9fe41c110eb14d9 Mon Sep 17 00:00:00 2001 From: Hollokin Date: Tue, 24 Jun 2025 10:12:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9TDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hollokin --- .../service/test/cloud_data_test.cpp | 8 ++++---- .../service/test/cloud_service_impl_test.cpp | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index dbf378bb3..40d393946 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1151,10 +1151,6 @@ HWTEST_F(CloudDataTest, CloudSync007, TestSize.Level0) uint32_t seqNum = 10; auto ret = cloudServiceImpl_->CloudSync("bundleName", "storeId", { syncMode, seqNum }, nullptr); EXPECT_EQ(ret, CloudData::CloudService::INVALID_ARGUMENT); - - CloudData::Details details{}; - uint32_t tokenId = 0; - cloudServiceImpl_->OnAsyncComplete(tokenId, seqNum, std::move(details)); } /** @@ -2221,7 +2217,11 @@ HWTEST_F(CloudDataTest, UpdateE2eeEnableTest, TestSize.Level1) ASSERT_NE(cloudServiceImpl_, nullptr); cloudServiceImpl_->UpdateE2eeEnable(schemaKey, false, TEST_CLOUD_BUNDLE); + ASSERT_TRUE(MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)); + EXPECT_EQ(schemaMeta.e2eeEnable, schemaMeta_.e2eeEnable); cloudServiceImpl_->UpdateE2eeEnable(schemaKey, true, TEST_CLOUD_BUNDLE); + ASSERT_TRUE(MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)); + EXPECT_EQ(schemaMeta.e2eeEnable, true); } /** diff --git a/services/distributeddataservice/service/test/cloud_service_impl_test.cpp b/services/distributeddataservice/service/test/cloud_service_impl_test.cpp index ae91d87a4..dbe572a55 100644 --- a/services/distributeddataservice/service/test/cloud_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/cloud_service_impl_test.cpp @@ -436,6 +436,8 @@ HWTEST_F(CloudServiceImplTest, UpdateE2eeEnableTest, TestSize.Level0) std::string schemaKey = "schemaKey"; cloudServiceImpl_->UpdateE2eeEnable(schemaKey, true, TEST_CLOUD_BUNDLE); + SchemaMeta schemaMeta; + ASSERT_FALSE(MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)); } /** -- Gitee