From 23b06b8f07779fc3a86ab7a78cb0a56c77960fbb Mon Sep 17 00:00:00 2001 From: zuojiangjiang Date: Tue, 10 May 2022 22:41:41 +0800 Subject: [PATCH] accesstoken bugfix Signed-off-by: zuojiangjiang --- .../adapter/permission/src/bundle_checker.cpp | 2 +- .../framework/test/BUILD.gn | 36 ++++--------------- .../framework/test/checker_manager_test.cpp | 8 +++-- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/services/distributeddataservice/adapter/permission/src/bundle_checker.cpp b/services/distributeddataservice/adapter/permission/src/bundle_checker.cpp index 4a1080f46..ed58ac9a8 100644 --- a/services/distributeddataservice/adapter/permission/src/bundle_checker.cpp +++ b/services/distributeddataservice/adapter/permission/src/bundle_checker.cpp @@ -65,7 +65,7 @@ std::string BundleChecker::GetAppId(const CheckerManager::StoreInfo &info) } ZLOGD("bundleName:%{public}s, appId:%{public}s", info.bundleName.c_str(), tokenInfo.appID.c_str()); - return Crypto::Sha256(tokenInfo.appID); + return Crypto::Sha256(tokenInfo.bundleName + "_" + tokenInfo.appID); } bool BundleChecker::IsValid(const CheckerManager::StoreInfo &info) diff --git a/services/distributeddataservice/framework/test/BUILD.gn b/services/distributeddataservice/framework/test/BUILD.gn index 94b2a099c..94783a7a9 100644 --- a/services/distributeddataservice/framework/test/BUILD.gn +++ b/services/distributeddataservice/framework/test/BUILD.gn @@ -21,28 +21,20 @@ config("module_private_config") { include_dirs = [ "../include/", - "../../service/", + "../../service/bootstrap/include/", ] ldflags = [ "-Wl,--whole-archive" ] } ohos_unittest("CheckerManagerTest") { module_out_path = module_output_path - sources = [ - "../checker/checker_manager.cpp", - "../utils/crypto.cpp", - "checker_manager_test.cpp", - ] + sources = [ "checker_manager_test.cpp" ] configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] @@ -51,6 +43,7 @@ ohos_unittest("CheckerManagerTest") { "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter:distributeddata_adapter", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter/permission:distributeddata_permission_static", + "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/framework:distributeddatasvcfwk", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/service:distributeddatasvc", "//third_party/googletest:gtest_main", "//third_party/openssl:libcrypto_shared", @@ -60,21 +53,11 @@ ohos_unittest("CheckerManagerTest") { ohos_unittest("EventCenterTest") { module_out_path = module_output_path - sources = [ - "../eventcenter/event.cpp", - "../eventcenter/event_center.cpp", - "event_center_test.cpp", - ] + sources = [ "event_center_test.cpp" ] configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", - "access_token:libaccesstoken_sdk", - "access_token:libnativetoken", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] @@ -82,6 +65,7 @@ ohos_unittest("EventCenterTest") { deps = [ "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter:distributeddata_adapter", + "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/framework:distributeddatasvcfwk", "//third_party/googletest:gtest_main", "//utils/native/base:utils", ] @@ -90,20 +74,13 @@ ohos_unittest("EventCenterTest") { ohos_unittest("SerializableTest") { module_out_path = module_output_path - sources = [ - "../serializable/serializable.cpp", - "serializable_test.cpp", - ] + sources = [ "serializable_test.cpp" ] configs = [ ":module_private_config" ] external_deps = [ "ability_base:base", "ability_base:want", - "access_token:libaccesstoken_sdk", - "access_token:libnativetoken", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] @@ -111,6 +88,7 @@ ohos_unittest("SerializableTest") { deps = [ "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter:distributeddata_adapter", + "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/framework:distributeddatasvcfwk", "//third_party/googletest:gtest_main", "//third_party/openssl:libcrypto_shared", "//utils/native/base:utils", diff --git a/services/distributeddataservice/framework/test/checker_manager_test.cpp b/services/distributeddataservice/framework/test/checker_manager_test.cpp index f39c9a206..59135adb8 100644 --- a/services/distributeddataservice/framework/test/checker_manager_test.cpp +++ b/services/distributeddataservice/framework/test/checker_manager_test.cpp @@ -15,7 +15,7 @@ #include "checker/checker_manager.h" #include "accesstoken_kit.h" -#include "bootstrap/include/bootstrap.h" +#include "bootstrap.h" #include "hap_token_info.h" #include "nativetoken_kit.h" #include "utils/crypto.h" @@ -29,13 +29,17 @@ public: static void TearDownTestCase(void) {} void SetUp(); void TearDown(); - NativeTokenInfoParams infoInstance; + NativeTokenInfoParams infoInstance{0}; }; void CheckerManagerTest::SetUp(void) { infoInstance.dcapsNum = 0; + infoInstance.permsNum = 0; + infoInstance.aclsNum = 0; infoInstance.dcaps = nullptr; + infoInstance.perms = nullptr; + infoInstance.acls = nullptr; infoInstance.processName = "foundation"; infoInstance.aplStr = "system_core"; -- Gitee