From 1b71adbf82c02e5bdc5585d4ce56c1bd155237f6 Mon Sep 17 00:00:00 2001 From: wuminjie Date: Wed, 27 Nov 2024 14:09:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?access=5Ftoken=E5=8E=BB=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuminjie --- interfaces/innerkits/rust/tests/BUILD.gn | 11 ++- .../native/source/system_ability_manager.cpp | 5 + .../source/system_ability_manager_dumper.cpp | 8 ++ .../source/system_ability_manager_stub.cpp | 16 ++++ .../source/system_ability_manager_util.cpp | 8 ++ services/samgr/native/test/unittest/BUILD.gn | 96 +++++++++++++++---- .../test/unittest/rust/service/BUILD.gn | 16 ++-- .../unittest/src/manual_ondemand_helper.cpp | 4 + .../unittest/src/mock_accesstoken_kit.cpp | 4 +- .../test/unittest/src/mock_permission.cpp | 6 ++ .../test/unittest/src/ondemand_helper.cpp | 4 + .../src/system_ability_mgr_proxy_test.cpp | 5 + .../unittest/src/system_ability_test_tool.cpp | 10 ++ services/samgr/var.gni | 5 + 14 files changed, 169 insertions(+), 29 deletions(-) diff --git a/interfaces/innerkits/rust/tests/BUILD.gn b/interfaces/innerkits/rust/tests/BUILD.gn index ac817642..a1a3dc33 100644 --- a/interfaces/innerkits/rust/tests/BUILD.gn +++ b/interfaces/innerkits/rust/tests/BUILD.gn @@ -69,12 +69,19 @@ ohos_rust_systemtest("rust_samgr_sdv_test") { "//third_party/rust/crates/cxx:lib", ] external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "hilog:hilog_rust", "ipc:ipc_rust", "safwk:system_ability_fwk_rust", ] + defines = [] + if (defined(global_parts_info) && + defined(global_parts_info.security_access_token)) { + external_deps += [ + "access_token:libnativetoken", + "access_token:libtoken_setproc", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } subsystem_name = "systemabilitymgr" part_name = "samgr" diff --git a/services/samgr/native/source/system_ability_manager.cpp b/services/samgr/native/source/system_ability_manager.cpp index ec3d8c96..5dc9cc6e 100644 --- a/services/samgr/native/source/system_ability_manager.cpp +++ b/services/samgr/native/source/system_ability_manager.cpp @@ -20,7 +20,9 @@ #include #include "ability_death_recipient.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "datetime_ex.h" #include "directory_ex.h" #include "errors.h" @@ -2034,6 +2036,8 @@ int32_t SystemAbilityManager::GetOnDemandSystemAbilityIds(std::vector& int32_t SystemAbilityManager::SendStrategy(int32_t type, std::vector& systemAbilityIds, int32_t level, std::string& action) { +#ifdef support_access_token + HILOGE("SendStrategy if start"); HILOGD("SendStrategy begin"); uint32_t accessToken = IPCSkeleton::GetCallingTokenID(); Security::AccessToken::NativeTokenInfo nativeTokenInfo; @@ -2042,6 +2046,7 @@ int32_t SystemAbilityManager::SendStrategy(int32_t type, std::vector& s HILOGW("SendStrategy reject used by %{public}s", nativeTokenInfo.processName.c_str()); return ERR_PERMISSION_DENIED; } +#endif for (auto saId : systemAbilityIds) { CommonSaProfile saProfile; diff --git a/services/samgr/native/source/system_ability_manager_dumper.cpp b/services/samgr/native/source/system_ability_manager_dumper.cpp index 1dfcd431..d89ec377 100644 --- a/services/samgr/native/source/system_ability_manager_dumper.cpp +++ b/services/samgr/native/source/system_ability_manager_dumper.cpp @@ -15,7 +15,9 @@ #include "system_ability_manager_dumper.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "ffrt_inner.h" #include "file_ex.h" #include "ipc_skeleton.h" @@ -500,6 +502,8 @@ bool SystemAbilityManagerDumper::Dump(std::shared_ptr #include +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "datetime_ex.h" #include "errors.h" #include "hitrace_meter.h" @@ -102,7 +104,9 @@ namespace { } } +#ifdef SUPPORT_ACCESS_TOKEN using namespace OHOS::Security; +#endif namespace OHOS { namespace { constexpr const char *EXT_TRANSACTION_PERMISSION = "ohos.permission.ACCESS_EXT_SYSTEM_ABILITY"; @@ -1083,20 +1087,32 @@ int32_t SystemAbilityManagerStub::GetOnDemandSystemAbilityIdsInner(MessageParcel bool SystemAbilityManagerStub::CanRequest() { +#ifdef SUPPORT_ACCESS_TOKEN auto tid = IPCSkeleton::GetCallingTokenID(); + HILOGE("CanRequest if start tid:%{public}u", tid); AccessToken::ATokenTypeEnum tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(tid); if (tokenType != AccessToken::ATokenTypeEnum::TOKEN_NATIVE) { KHILOGE("CanRequest callingTkid:%{public}u, tokenType:%{public}d", tid, tokenType); return false; } return true; +#else + HILOGE("CanRequest else start"); + return true; +#endif } bool SystemAbilityManagerStub::CheckPermission(const std::string& permission) { +#ifdef SUPPORT_ACCESS_TOKEN + HILOGE("CheckPermission if start"); uint32_t accessToken = IPCSkeleton::GetCallingTokenID(); int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(accessToken, permission); return (ret == Security::AccessToken::PermissionState::PERMISSION_GRANTED); +#else + HILOGE("CheckPermission else start"); + return true; +#endif } int32_t SystemAbilityManagerStub::GetExtensionSaIdsInner(MessageParcel& data, MessageParcel& reply) diff --git a/services/samgr/native/source/system_ability_manager_util.cpp b/services/samgr/native/source/system_ability_manager_util.cpp index bd8aa7f9..c018db4d 100644 --- a/services/samgr/native/source/system_ability_manager_util.cpp +++ b/services/samgr/native/source/system_ability_manager_util.cpp @@ -17,7 +17,9 @@ #include "system_ability_manager.h" #include "system_ability_manager_util.h" #include "parameter.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "ipc_skeleton.h" #include "string_ex.h" #include "tools.h" @@ -108,6 +110,8 @@ bool SamgrUtil::CheckCallerProcess(const CommonSaProfile& saProfile) bool SamgrUtil::CheckCallerProcess(const std::string& callProcess) { +#ifdef SUPPORT_ACCESS_TOKEN + HILOGE("CheckCallerProcess if start"); uint32_t accessToken = IPCSkeleton::GetCallingTokenID(); Security::AccessToken::NativeTokenInfo nativeTokenInfo; int32_t tokenInfoResult = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo); @@ -121,6 +125,10 @@ bool SamgrUtil::CheckCallerProcess(const std::string& callProcess) return false; } return true; +#else + HILOGE("CheckCallerProcess else start"); + return true; +#endif } bool SamgrUtil::CheckAllowUpdate(OnDemandPolicyType type, const CommonSaProfile& saProfile) diff --git a/services/samgr/native/test/unittest/BUILD.gn b/services/samgr/native/test/unittest/BUILD.gn index 5b33a54b..46adabb3 100644 --- a/services/samgr/native/test/unittest/BUILD.gn +++ b/services/samgr/native/test/unittest/BUILD.gn @@ -101,8 +101,6 @@ ohos_unittest("SystemAbilityMgrTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -123,6 +121,13 @@ ohos_unittest("SystemAbilityMgrTest") { defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ] } } + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (hicollie_able) { external_deps += [ "hicollie:libhicollie" ] defines += [ "HICOLLIE_ENABLE" ] @@ -202,8 +207,6 @@ ohos_unittest("SystemAbilityMgrCollectTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -229,6 +232,14 @@ ohos_unittest("SystemAbilityMgrCollectTest") { defines += [ "HICOLLIE_ENABLE" ] } + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } + if (preferences_enable) { external_deps += [ "preferences:native_preferences" ] sources += @@ -316,8 +327,6 @@ ohos_unittest("SystemAbilityMgrDeviceNetworkingTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -338,6 +347,13 @@ ohos_unittest("SystemAbilityMgrDeviceNetworkingTest") { defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ] } } + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (hicollie_able) { external_deps += [ "hicollie:libhicollie" ] defines += [ "HICOLLIE_ENABLE" ] @@ -403,8 +419,6 @@ ohos_unittest("SystemAbilityMgrStubTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -436,6 +450,14 @@ ohos_unittest("SystemAbilityMgrStubTest") { external_deps += [ "device_manager:devicemanagersdk" ] defines += [ "SUPPORT_DEVICE_MANAGER" ] } + + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } ohos_unittest("SystemAbilityMgrProxyTest") { @@ -476,8 +498,6 @@ ohos_unittest("SystemAbilityMgrProxyTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "googletest:gtest_main", "hilog:libhilog", @@ -485,6 +505,14 @@ ohos_unittest("SystemAbilityMgrProxyTest") { "ipc:ipc_single", "json:nlohmann_json_static", ] + defines = [] + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } ohos_unittest("LocalAbilityManagerProxyTest") { @@ -571,8 +599,6 @@ ohos_unittest("SystemAbilityStateSchedulerTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -587,6 +613,14 @@ ohos_unittest("SystemAbilityStateSchedulerTest") { "json:nlohmann_json_static", "safwk:system_ability_fwk", ] + defines = [] + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (support_device_manager) { external_deps += [ "device_manager:devicemanagersdk" ] @@ -635,8 +669,6 @@ ohos_unittest("SystemAbilityMgrDumperTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "ffrt:libffrt", "googletest:gtest_main", @@ -650,6 +682,14 @@ ohos_unittest("SystemAbilityMgrDumperTest") { "json:nlohmann_json_static", "safwk:system_ability_fwk", ] + defines = [] + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } ohos_executable("manual_ondemand") { @@ -669,8 +709,6 @@ ohos_executable("manual_ondemand") { cflags += [ "-DBINDER_IPC_32BIT" ] } external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "hilog:libhilog", "init:libbeget_proxy", @@ -684,6 +722,13 @@ ohos_executable("manual_ondemand") { external_deps += [ "dsoftbus:softbus_client" ] defines += [ "SUPPORT_SOFTBUS" ] } + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } part_name = "samgr" subsystem_name = "systemabilitymgr" } @@ -705,8 +750,6 @@ ohos_executable("ondemand") { cflags += [ "-DBINDER_IPC_32BIT" ] } external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "hilog:libhilog", "init:libbeget_proxy", @@ -720,6 +763,13 @@ ohos_executable("ondemand") { external_deps += [ "dsoftbus:softbus_client" ] defines += [ "SUPPORT_SOFTBUS" ] } + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } part_name = "samgr" subsystem_name = "systemabilitymgr" } @@ -788,6 +838,14 @@ ohos_executable("TestTool") { defines += [ "SUPPORT_SOFTBUS" ] } + if (support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } + if (support_device_manager) { sources += [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ] @@ -796,8 +854,6 @@ ohos_executable("TestTool") { } external_deps += [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", diff --git a/services/samgr/native/test/unittest/rust/service/BUILD.gn b/services/samgr/native/test/unittest/rust/service/BUILD.gn index c1e6701a..1f4cd215 100644 --- a/services/samgr/native/test/unittest/rust/service/BUILD.gn +++ b/services/samgr/native/test/unittest/rust/service/BUILD.gn @@ -18,12 +18,16 @@ ohos_rust_shared_library("test_access_token") { "src/access_token.rs", "src/lib.rs", ] - - external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", - ] - + external_deps = [] + defines = [] + if (defined(global_parts_info) && + defined(global_parts_info.security_access_token)) { + external_deps += [ + "access_token:libnativetoken", + "access_token:libtoken_setproc", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } crate_name = "test_access_token" crate_type = "dylib" subsystem_name = "systemabilitymgr" diff --git a/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp b/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp index 1951a872..c0cd116f 100644 --- a/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp +++ b/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp @@ -27,14 +27,18 @@ #include "iremote_object.h" #include "iservice_registry.h" #include "isystem_ability_load_callback.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" +#endif #include "sam_mock_permission.h" #ifdef SUPPORT_SOFTBUS #include "softbus_bus_center.h" #endif #include "system_ability_ondemand_reason.h" #include "system_ability_definition.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "token_setproc.h" +#endif #include "parameter.h" #include "parameters.h" diff --git a/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp b/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp index 44d6ed2c..a49a0f17 100644 --- a/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp +++ b/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" namespace OHOS { @@ -22,4 +23,5 @@ int AccessTokenKit::VerifyAccessToken(AccessTokenID tokenID, const std::string& return PERMISSION_GRANTED; } } // namespace Security::AccessToken -} // namespace OHOS \ No newline at end of file +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/mock_permission.cpp b/services/samgr/native/test/unittest/src/mock_permission.cpp index b5c444bf..e9352ee2 100644 --- a/services/samgr/native/test/unittest/src/mock_permission.cpp +++ b/services/samgr/native/test/unittest/src/mock_permission.cpp @@ -15,12 +15,15 @@ #include "sam_mock_permission.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" #include "token_setproc.h" +#endif namespace OHOS { void SamMockPermission::MockPermission() { +#ifdef SUPPORT_ACCESS_TOKEN static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC", "ohos.permission.ACCESS_EXT_SYSTEM_ABILITY" @@ -38,10 +41,12 @@ void SamMockPermission::MockPermission() }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif } void SamMockPermission::MockProcess(const char* processName) { +#ifdef SUPPORT_ACCESS_TOKEN static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC" }; @@ -58,5 +63,6 @@ void SamMockPermission::MockProcess(const char* processName) }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif } } \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/ondemand_helper.cpp b/services/samgr/native/test/unittest/src/ondemand_helper.cpp index 78a8da1c..42c6a509 100644 --- a/services/samgr/native/test/unittest/src/ondemand_helper.cpp +++ b/services/samgr/native/test/unittest/src/ondemand_helper.cpp @@ -27,14 +27,18 @@ #include "iremote_object.h" #include "iservice_registry.h" #include "isystem_ability_load_callback.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" +#endif #include "sam_mock_permission.h" #ifdef SUPPORT_SOFTBUS #include "softbus_bus_center.h" #endif #include "system_ability_ondemand_reason.h" #include "system_ability_definition.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "token_setproc.h" +#endif #include "parameter.h" #include "parameters.h" diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp index 46b7e501..7a6c8338 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp @@ -1223,6 +1223,11 @@ HWTEST_F(SystemAbilityMgrProxyTest, GetRunningSaExtensionInfoList001, TestSize.L std::vector infoList; int32_t ret = samgrProxy->GetRunningSaExtensionInfoList("backup_test", infoList); EXPECT_EQ(ret, 1); +#ifdef SUPPORT_ACCESS_TOKEN + DTEST_LOG << "ret 1" << std::endl; +#else + DTEST_LOG << "ret 0" << std::endl; +#endif EXPECT_EQ(infoList.size(), 0); } diff --git a/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp b/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp index 04035884..1f62ee66 100644 --- a/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp @@ -21,7 +21,9 @@ #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "itest_transaction_service.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" +#endif #include "sam_log.h" #ifdef SUPPORT_SOFTBUS #include "softbus_bus_center.h" @@ -30,7 +32,9 @@ #include "system_ability_definition.h" #include "system_ability_load_callback_stub.h" #include "system_ability_status_change_stub.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "token_setproc.h" +#endif #define private public #include "system_ability_manager.h" @@ -281,6 +285,8 @@ namespace { static void MockProcess(const char* processName) { +#ifdef SUPPORT_ACCESS_TOKEN + HILOGE("MockProcess if tool start"); uint64_t tokenId; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, @@ -294,6 +300,7 @@ namespace { }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif } static void DoSend(int32_t said, int32_t rssProcess) @@ -415,9 +422,11 @@ static void DoRemote(char* argv[]) int main(int argc, char* argv[]) { +#ifdef SUPPORT_ACCESS_TOKEN static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC" }; + HILOGE("main if tool start"); uint64_t tokenId; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, @@ -431,6 +440,7 @@ int main(int argc, char* argv[]) }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif if (argc == ARGC_DEFAULT_LENTH) { DoDefault(argv); } else if (argc == ARGC_EXTEND_LENTH) { diff --git a/services/samgr/var.gni b/services/samgr/var.gni index 2fd2d341..61012199 100644 --- a/services/samgr/var.gni +++ b/services/samgr/var.gni @@ -18,6 +18,7 @@ declare_args() { support_device_manager = false support_common_event = false support_softbus = true + support_access_token = true if (!defined(global_parts_info) || defined(global_parts_info.communication_bluetooth)) { bluetooth_part_enable = true @@ -42,4 +43,8 @@ declare_args() { !defined(global_parts_info.communication_dsoftbus)) { support_softbus = false } + if (defined(global_parts_info) && + !defined(global_parts_info.security_access_token)) { + support_access_token = false + } } -- Gitee From f6b90f0560d8245869694e17c1858990966a223d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Mon, 9 Dec 2024 01:09:32 +0000 Subject: [PATCH 2/4] update services/samgr/native/test/unittest/src/mock_permission.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- services/samgr/native/test/unittest/src/mock_permission.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/samgr/native/test/unittest/src/mock_permission.cpp b/services/samgr/native/test/unittest/src/mock_permission.cpp index e9352ee2..3b84a2ec 100644 --- a/services/samgr/native/test/unittest/src/mock_permission.cpp +++ b/services/samgr/native/test/unittest/src/mock_permission.cpp @@ -14,6 +14,7 @@ */ #include "sam_mock_permission.h" +#include "sam_log.h" #ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" @@ -24,6 +25,7 @@ namespace OHOS { void SamMockPermission::MockPermission() { #ifdef SUPPORT_ACCESS_TOKEN + HILOGE("MockPermission if start"); static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC", "ohos.permission.ACCESS_EXT_SYSTEM_ABILITY" @@ -47,6 +49,7 @@ void SamMockPermission::MockPermission() void SamMockPermission::MockProcess(const char* processName) { #ifdef SUPPORT_ACCESS_TOKEN + HILOGE("MockProcess if start"); static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC" }; -- Gitee From 29be6dfad38d2cf16b33cd451f57b7b4c8748044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 12 Dec 2024 01:00:34 +0000 Subject: [PATCH 3/4] update services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- .../test/unittest/src/system_ability_mgr_proxy_test.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp index 7a6c8338..abbe7bcb 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp @@ -1183,7 +1183,12 @@ HWTEST_F(SystemAbilityMgrProxyTest, SendStrategy001, TestSize.Level1) int32_t level = 1; std::string action = ""; int32_t res = samgrProxy->SendStrategy(type, saIds, level, action); +#ifdef SUPPORT_ACCESS_TOKEN EXPECT_EQ(res, ERR_PERMISSION_DENIED); + DTEST_LOG << "SendStrategy001 ERR_PERMISSION_DENIED" << std::endl; +#else + EXPECT_EQ(res, ERR_INVALID_VALUE); + DTEST_LOG << "SendStrategy001 ERR_INVALID_VALUE" << std::endl; } /** @@ -1222,10 +1227,11 @@ HWTEST_F(SystemAbilityMgrProxyTest, GetRunningSaExtensionInfoList001, TestSize.L std::vector infoList; int32_t ret = samgrProxy->GetRunningSaExtensionInfoList("backup_test", infoList); - EXPECT_EQ(ret, 1); #ifdef SUPPORT_ACCESS_TOKEN + EXPECT_EQ(ret, 1); DTEST_LOG << "ret 1" << std::endl; #else + EXPECT_EQ(ret, 0); DTEST_LOG << "ret 0" << std::endl; #endif EXPECT_EQ(infoList.size(), 0); -- Gitee From e352a757f718802e3f824bd4d82d571efe656a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 12 Dec 2024 02:15:58 +0000 Subject: [PATCH 4/4] update services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- .../native/test/unittest/src/system_ability_mgr_proxy_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp index abbe7bcb..ac9ee905 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp @@ -1189,6 +1189,7 @@ HWTEST_F(SystemAbilityMgrProxyTest, SendStrategy001, TestSize.Level1) #else EXPECT_EQ(res, ERR_INVALID_VALUE); DTEST_LOG << "SendStrategy001 ERR_INVALID_VALUE" << std::endl; +#endif } /** -- Gitee