• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/test.gni")
15import("../../../../../access_token.gni")
16
17ohos_unittest("libaccesstoken_sdk_test") {
18  subsystem_name = "accesscontrol"
19  module_out_path = module_output_path_unittest_accesstoken
20  sanitize = {
21    cfi = true
22    cfi_cross_dso = true
23    debug = false
24  }
25  branch_protector_ret = "pac_ret"
26
27  include_dirs = [
28    "${access_token_path}/frameworks/accesstoken/include",
29    "${access_token_path}/frameworks/common/include",
30    "${access_token_path}/frameworks/tokensync/include",
31    "${access_token_innerkit_path}/include",
32    "${access_token_innerkit_path}/src",
33    "common",
34    "${access_token_path}/interfaces/innerkits/nativetoken/include",
35    "${access_token_path}/interfaces/innerkits/token_setproc/include",
36  ]
37
38  sources = [
39    "Coverage/accesstoken_kit_coverage_test.cpp",
40    "DistributedTest/alloc_local_token_id_test.cpp",
41    "DistributedTest/delete_remote_device_tokens_test.cpp",
42    "DistributedTest/delete_remote_token_test.cpp",
43    "DistributedTest/get_hap_token_info_from_remote_test.cpp",
44    "DistributedTest/get_remote_native_tokenid_test.cpp",
45    "DistributedTest/register_token_sync_callback_test.cpp",
46    "DistributedTest/set_remote_hap_token_info_test.cpp",
47    "EdmPolicyTest/edm_policy_set_test.cpp",
48    "HapAttributeTest/get_hap_dlp_flag_test.cpp",
49    "HapAttributeTest/get_permission_flag_test.cpp",
50    "HapAttributeTest/get_permissions_status_test.cpp",
51    "HapAttributeTest/permission_request_toggle_status_test.cpp",
52    "HapTokenTest/alloc_hap_token_test.cpp",
53    "HapTokenTest/app_installation_optimized_test.cpp",
54    "HapTokenTest/delete_token_test.cpp",
55    "HapTokenTest/get_hap_token_test.cpp",
56    "HapTokenTest/get_token_type_test.cpp",
57    "HapTokenTest/init_hap_token_test.cpp",
58    "HapTokenTest/update_hap_token_test.cpp",
59    "PermDenyTest/accesstoken_deny_test.cpp",
60    "PermisionDialogTest/accesstoken_location_request_test.cpp",
61    "PermisionDialogTest/get_self_permission_state_test.cpp",
62    "PermisionDialogTest/get_self_permission_status_test.cpp",
63    "PermisionDialogTest/request_permission_on_setting_test.cpp",
64    "PermisionDialogTest/set_perm_dialog_cap_test.cpp",
65    "PermissionsTest/clear_user_granted__permission_state_test.cpp",
66    "PermissionsTest/get_permission_test.cpp",
67    "PermissionsTest/grant_permission_for_specified_time_test.cpp",
68    "PermissionsTest/grant_permission_test.cpp",
69    "PermissionsTest/revoke_permission_test.cpp",
70    "PermissionsTest/verify_access_token_test.cpp",
71    "RegisterCallbackTest/register_perm_state_change_callback_test.cpp",
72    "RegisterCallbackTest/un_register_perm_state_change_callback_test.cpp",
73    "SaTest/dump_token_info_test.cpp",
74    "SaTest/get_native_token_id_test.cpp",
75    "SaTest/get_native_token_info_test.cpp",
76    "SaTest/get_version_test.cpp",
77    "SecurityComponentTest/security_component_grant_test.cpp",
78    "common/test_common.cpp",
79  ]
80
81  cflags_cc = [ "-DHILOG_ENABLE" ]
82
83  configs = [ "${access_token_path}/config:coverage_flags" ]
84
85  deps = [
86    "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx",
87    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
88    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
89    "${access_token_path}/interfaces/innerkits/accesstoken:libtokenid_sdk",
90    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
91    "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc",
92    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
93  ]
94
95  external_deps = [
96    "cJSON:cjson",
97    "c_utils:utils",
98    "hilog:libhilog",
99    "init:libbegetutil",
100    "ipc:ipc_single",
101    "samgr:samgr_proxy",
102  ]
103  if (token_sync_enable == true) {
104    cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ]
105    external_deps += [ "device_manager:devicemanagersdk" ]
106  }
107  if (dlp_permission_enable == true) {
108    cflags_cc += [ "-DSUPPORT_SANDBOX_APP" ]
109    sources += [
110      "DlpTest/clone_app_permission_test.cpp",
111      "DlpTest/share_permission_with_sandbox_test.cpp",
112    ]
113  }
114  if (security_component_enhance_enable == true) {
115    cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
116  }
117}
118
119ohos_unittest("accesstoken_mock_test") {
120  subsystem_name = "accesscontrol"
121  module_out_path = module_output_path_unittest_accesstoken
122  sanitize = {
123    cfi = true
124    cfi_cross_dso = true
125    debug = false
126  }
127  branch_protector_ret = "pac_ret"
128
129  include_dirs = [
130    "${access_token_path}/frameworks/common/include",
131    "${access_token_path}/frameworks/accesstoken/include",
132    "${access_token_path}/frameworks/tokensync/include",
133    "${access_token_path}/interfaces/innerkits/nativetoken/include",
134    "${access_token_path}/interfaces/innerkits/token_setproc/include",
135    "${access_token_innerkit_path}/include",
136    "${access_token_innerkit_path}/src",
137  ]
138
139  sources = [
140    "${access_token_innerkit_path}/src/accesstoken_callback_stubs.cpp",
141    "${access_token_innerkit_path}/src/accesstoken_callbacks.cpp",
142    "${access_token_innerkit_path}/src/accesstoken_death_recipient.cpp",
143    "${access_token_innerkit_path}/src/accesstoken_kit.cpp",
144    "${access_token_innerkit_path}/src/accesstoken_manager_client.cpp",
145    "${access_token_innerkit_path}/src/perm_state_change_callback_customize.cpp",
146    "../mock/src/iservice_registry.cpp",
147    "ProxyMockTest/accesstoken_mock_test.cpp",
148  ]
149
150  cflags_cc = [ "-DHILOG_ENABLE" ]
151  configs = [
152    "${access_token_path}/config:coverage_flags",
153    "${access_token_path}/services/accesstokenmanager/idl:access_token_manager_gen_config",
154  ]
155
156  deps = [
157    "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx",
158    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
159    "${access_token_path}/interfaces/innerkits/accesstoken:libtokenid_sdk",
160    "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc",
161    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
162    "${access_token_path}/services/accesstokenmanager/idl:access_token_manager_proxy",
163  ]
164
165  external_deps = [
166    "c_utils:utils",
167    "googletest:gmock",
168    "googletest:gtest_main",
169    "hilog:libhilog",
170    "init:libbeget_proxy",
171    "init:libbegetutil",
172    "ipc:ipc_single",
173    "ipc:libdbinder",
174    "safwk:system_ability_fwk",
175    "samgr:samgr_proxy",
176  ]
177  if (eventhandler_enable == true) {
178    cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
179    external_deps += [ "eventhandler:libeventhandler" ]
180  }
181  if (token_sync_enable == true) {
182    cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ]
183  }
184}
185