diff --git a/frameworks/ets/ani/common/src/ani_utils.cpp b/frameworks/ets/ani/common/src/ani_utils.cpp index 499be6e8f584a233ad29067cc4627a5d5bc408c4..d2664afda26cea052db2d89a8b683ab6559c3ffc 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 07f13b00767d74261254f2d090d59f79c505594c..740c8a98d5c82c9f0659b0a6f9c98f36103e33f0 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 954d49109a5cfb672a3eced7b462dfb1bffc6a56..a6409e89e911711bb05c82fc73661ae809700f99 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 4759e7d9e41af08fed8a8be7de8ed2feb7ec3cea..2d7743081d4c39df71d1a2ed0dea95b9c70c41cc 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 d636dba18a0439bf2a3cc6ab5204bd195c966492..6e3e865eb62b4bb90581f504fda6f8e73962847c 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 26cdf7c64f9ab77b47b3703faa9fc59c0e66a5e2..f3c5c238f0704c0c9ac8637db30d9908d6d5e30c 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 342d76d4a087023d6e9c98d840ccfaec5e4c0491..f8e3e81a3dc1af0749aab618bd724303b3ee5c1a 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