From a150e016e2a46d18a01934b25d532a342cfb95e4 Mon Sep 17 00:00:00 2001 From: zhouyan Date: Mon, 25 Aug 2025 20:06:39 +0800 Subject: [PATCH] =?UTF-8?q?6.0release=E5=91=8A=E8=AD=A6=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=B8=BB=E5=B9=B2+=E8=A1=A5=E5=85=85=E9=9A=90=E7=A7=81?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyan Change-Id: I154d298ee1efd69086de375807807050c75d9f37 --- frameworks/ets/ani/common/src/ani_utils.cpp | 2 +- .../test/unittest/src/privacy_kit_test.cpp | 18 ++++++------ .../accesstoken_manager_service_test.cpp | 2 +- ...ermission_record_manager_coverage_test.cpp | 29 +++++++++++++++++++ .../privacymanager/test/unittest/BUILD.gn | 2 ++ .../gethaptokenidservice_fuzzer/corpus/init | 13 +++++++++ .../gethaptokeninfoservice_fuzzer/corpus/init | 13 +++++++++ 7 files changed, 68 insertions(+), 11 deletions(-) diff --git a/frameworks/ets/ani/common/src/ani_utils.cpp b/frameworks/ets/ani/common/src/ani_utils.cpp index 499be6e8f..d2664afda 100644 --- a/frameworks/ets/ani/common/src/ani_utils.cpp +++ b/frameworks/ets/ani/common/src/ani_utils.cpp @@ -514,7 +514,7 @@ bool GetIntProperty(ani_env* env, const ani_object& object, const std::string& p return false; } if (AniIsRefUndefined(env, ref)) { - LOGI(ATM_DOMAIN, ATM_TAG, "Property(%{public}s) is undefned!", property.c_str()); + LOGI(ATM_DOMAIN, ATM_TAG, "Property(%{public}s) is undefined!", property.c_str()); return true; } diff --git a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp index 07f13b007..740c8a98d 100644 --- a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp +++ b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp @@ -194,6 +194,14 @@ static BundleUsedRecord g_bundleUsedRecord = { .bundleName = "com.ohos.test", }; +PermissionStateFull g_infoManagerTestStateD = { + .permissionName = "ohos.permission.MICROPHONE_BACKGROUND", + .isGeneral = true, + .resDeviceID = {"localC"}, + .grantStatus = {PermissionState::PERMISSION_GRANTED}, + .grantFlags = {1} +}; + static AccessTokenID g_selfTokenId = 0; static AccessTokenID g_tokenIdA = 0; static AccessTokenID g_tokenIdB = 0; @@ -1556,19 +1564,11 @@ HWTEST_F(PrivacyKitTest, IsAllowedUsingPermission006, TestSize.Level0) .appIDDesc = "privacy_test.microphone" }; - PermissionStateFull infoManagerTestStateD = { - .permissionName = "ohos.permission.MICROPHONE_BACKGROUND", - .isGeneral = true, - .resDeviceID = {"localC"}, - .grantStatus = {PermissionState::PERMISSION_GRANTED}, - .grantFlags = {1} - }; - HapPolicyParams policy = { .apl = APL_NORMAL, .domain = "test.domain", .permList = {}, - .permStateList = {infoManagerTestStateD} + .permStateList = {g_infoManagerTestStateD} }; AccessTokenIDEx tokenIdEx = PrivacyTestCommon::AllocTestHapToken(info, policy); diff --git a/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp b/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp index 954d49109..a6409e89e 100644 --- a/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp +++ b/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp @@ -309,7 +309,7 @@ HWTEST_F(AccessTokenManagerServiceTest, UpdateHapTokenTest001, TestSize.Level0) ASSERT_EQ(1, results2.size()); ASSERT_EQ(static_cast(tokenId), results2[0].GetInt(TokenFiledConst::FIELD_TOKEN_ID)); // undefine permission change from INVALIDA to INVALIDB - ASSERT_EQ(g_state3.permissionName, results2[0].GetString(TokenFiledConst::FIELD_PERMISSION_NAME)); + ASSERT_EQ(g_state3.permissionName, results2[0].GetString(TokenFiledConst::FIELD_PERMISSION_NAME)); ASSERT_EQ(0, atManagerService_->DeleteToken(tokenId)); } diff --git a/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp b/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp index 4759e7d9e..2d7743081 100644 --- a/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp +++ b/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp @@ -1200,6 +1200,35 @@ HWTEST_F(PermissionRecordManagerTest, InsertPermissionUsedTypeColumn001, TestSiz ASSERT_EQ(Constant::FAILURE, PermissionUsedRecordDb::GetInstance().InsertPermissionUsedTypeColumn()); PermissionUsedRecordDb::GetInstance().dataTypeToSqlTable_ = dataTypeToSqlTable; // recovery } + +/* + * @tc.name: OnUpdate001 + * @tc.desc: PermissionUsedRecordDb::OnUpdate function test + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PermissionRecordManagerTest, OnUpdate001, TestSize.Level4) +{ + int32_t version = static_cast(PermissionUsedRecordDb::DataBaseVersion::VERISION_0); + PermissionUsedRecordDb::GetInstance().OnUpdate(version); + + version = static_cast(PermissionUsedRecordDb::DataBaseVersion::VERISION_1); + PermissionUsedRecordDb::GetInstance().OnUpdate(version); + + version = static_cast(PermissionUsedRecordDb::DataBaseVersion::VERISION_2); + PermissionUsedRecordDb::GetInstance().OnUpdate(version); + + version = static_cast(PermissionUsedRecordDb::DataBaseVersion::VERISION_3); + PermissionUsedRecordDb::GetInstance().OnUpdate(version); + + version = static_cast(PermissionUsedRecordDb::DataBaseVersion::VERISION_4); + PermissionUsedRecordDb::GetInstance().OnUpdate(version); + + auto it = PermissionUsedRecordDb::GetInstance().dataTypeToSqlTable_.find( + PermissionUsedRecordDb::DataType::PERMISSION_USED_RECORD_TOGGLE_STATUS); + ASSERT_NE(it, PermissionUsedRecordDb::GetInstance().dataTypeToSqlTable_.end()); + ASSERT_EQ(std::string(PermissionUsedRecordDb::PERMISSION_USED_RECORD_TOGGLE_STATUS_TABLE), it->second.tableName_); +} } // namespace AccessToken } // namespace Security } // namespace OHOS diff --git a/services/privacymanager/test/unittest/BUILD.gn b/services/privacymanager/test/unittest/BUILD.gn index d636dba18..6e3e865eb 100644 --- a/services/privacymanager/test/unittest/BUILD.gn +++ b/services/privacymanager/test/unittest/BUILD.gn @@ -156,6 +156,8 @@ if (is_standard_system && ability_base_enable == true) { "ability_runtime:ability_manager", "ability_runtime:app_manager", ] + include_dirs += + [ "${access_token_path}/services/common/ability_manager/include" ] sources += [ "client_code_compare_test.cpp" ] } } diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init index 26cdf7c64..f3c5c238f 100644 --- a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init +++ b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init @@ -1 +1,14 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + 0x6f0x680x6f0x730x2e0x670x6c0x6f0x620x610x6c0x2e0x730x790x730x740x650x6d0x720x650x735c0000000000 \ No newline at end of file diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init index 342d76d4a..f8e3e81a3 100644 --- a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init +++ b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init @@ -1 +1,14 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + 15460020 \ No newline at end of file -- Gitee