• 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 = "security"
19  part_name = "access_token"
20  module_out_path = part_name + "/" + part_name
21  sanitize = {
22    cfi = true
23    cfi_cross_dso = true
24    debug = false
25  }
26  branch_protector_ret = "pac_ret"
27
28  include_dirs = [
29    "${access_token_path}/frameworks/accesstoken/include",
30    "${access_token_path}/frameworks/common/include",
31    "${access_token_path}/frameworks/tokensync/include",
32    "${access_token_innerkit_path}/include",
33    "${access_token_innerkit_path}/src",
34    "common",
35    "${access_token_path}/interfaces/innerkits/nativetoken/include",
36    "${access_token_path}/interfaces/innerkits/token_setproc/include",
37  ]
38
39  sources = [
40    "Coverage/accesstoken_kit_coverage_test.cpp",
41    "DistributedTest/alloc_local_token_id_test.cpp",
42    "DistributedTest/delete_remote_device_tokens_test.cpp",
43    "DistributedTest/delete_remote_token_test.cpp",
44    "DistributedTest/get_hap_token_info_from_remote_test.cpp",
45    "DistributedTest/get_remote_native_tokenid_test.cpp",
46    "DistributedTest/register_token_sync_callback_test.cpp",
47    "DistributedTest/set_remote_hap_token_info_test.cpp",
48    "EdmPolicyTest/edm_policy_set_test.cpp",
49    "HapAttributeTest/get_hap_dlp_flag_test.cpp",
50    "HapAttributeTest/get_permission_flag_test.cpp",
51    "HapAttributeTest/get_permissions_status_test.cpp",
52    "HapAttributeTest/permission_request_toggle_status_test.cpp",
53    "HapTokenTest/alloc_hap_token_test.cpp",
54    "HapTokenTest/app_installation_optimized_test.cpp",
55    "HapTokenTest/delete_token_test.cpp",
56    "HapTokenTest/get_hap_token_test.cpp",
57    "HapTokenTest/get_token_type_test.cpp",
58    "HapTokenTest/init_hap_token_test.cpp",
59    "HapTokenTest/update_hap_token_test.cpp",
60    "PermDenyTest/accesstoken_deny_test.cpp",
61    "PermisionDialogTest/accesstoken_location_request_test.cpp",
62    "PermisionDialogTest/get_self_permission_state_test.cpp",
63    "PermisionDialogTest/request_permission_on_setting_test.cpp",
64    "PermisionDialogTest/set_perm_dialog_cap_test.cpp",
65    "PermissionsTest/check_permission_map_test.cpp",
66    "PermissionsTest/clear_user_granted__permission_state_test.cpp",
67    "PermissionsTest/get_permission_test.cpp",
68    "PermissionsTest/grant_permission_for_specified_time_test.cpp",
69    "PermissionsTest/grant_permission_test.cpp",
70    "PermissionsTest/revoke_permission_test.cpp",
71    "PermissionsTest/verify_access_token_test.cpp",
72    "RegisterCallbackTest/register_perm_state_change_callback_test.cpp",
73    "RegisterCallbackTest/un_register_perm_state_change_callback_test.cpp",
74    "SaTest/dump_token_info_test.cpp",
75    "SaTest/get_native_token_id_test.cpp",
76    "SaTest/get_native_token_info_test.cpp",
77    "SaTest/get_version_test.cpp",
78    "SecurityComponentTest/security_component_grant_test.cpp",
79    "common/test_common.cpp",
80  ]
81
82  cflags_cc = [ "-DHILOG_ENABLE" ]
83
84  configs = [ "${access_token_path}/config:coverage_flags" ]
85
86  deps = [
87    "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx",
88    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
89    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
90    "${access_token_path}/interfaces/innerkits/accesstoken:libtokenid_sdk",
91    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
92    "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc",
93    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
94  ]
95
96  external_deps = [
97    "cJSON:cjson",
98    "c_utils:utils",
99    "hilog:libhilog",
100    "ipc:ipc_single",
101    "samgr:samgr_proxy",
102  ]
103  if (token_sync_enable == true) {
104    cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ]
105    external_deps += [
106      "device_manager:devicemanagersdk",
107      "json:nlohmann_json_static",
108    ]
109  }
110  if (dlp_permission_enable == true) {
111    cflags_cc += [ "-DSUPPORT_SANDBOX_APP" ]
112    sources += [
113      "DlpTest/clone_app_permission_test.cpp",
114      "DlpTest/share_permission_with_sandbox_test.cpp",
115    ]
116  }
117  if (build_variant == "user") {
118    cflags_cc += [ "-DATM_BUILD_VARIANT_USER_ENABLE" ]
119  }
120}
121
122ohos_unittest("accesstoken_mock_test") {
123  subsystem_name = "security"
124  part_name = "access_token"
125  module_out_path = part_name + "/" + part_name
126  sanitize = {
127    cfi = true
128    cfi_cross_dso = true
129    debug = false
130  }
131  branch_protector_ret = "pac_ret"
132
133  include_dirs = [
134    "${access_token_path}/frameworks/common/include",
135    "${access_token_path}/frameworks/accesstoken/include",
136    "${access_token_path}/frameworks/tokensync/include",
137    "${access_token_path}/interfaces/innerkits/nativetoken/include",
138    "${access_token_path}/interfaces/innerkits/token_setproc/include",
139    "${access_token_innerkit_path}/include",
140    "${access_token_innerkit_path}/src",
141  ]
142
143  sources = [
144    "${access_token_innerkit_path}/src/accesstoken_callback_stubs.cpp",
145    "${access_token_innerkit_path}/src/accesstoken_callbacks.cpp",
146    "${access_token_innerkit_path}/src/accesstoken_death_recipient.cpp",
147    "${access_token_innerkit_path}/src/accesstoken_kit.cpp",
148    "${access_token_innerkit_path}/src/accesstoken_manager_client.cpp",
149    "${access_token_innerkit_path}/src/accesstoken_manager_proxy.cpp",
150    "${access_token_innerkit_path}/src/perm_state_change_callback_customize.cpp",
151    "../mock/src/iservice_registry.cpp",
152    "ProxyMockTest/accesstoken_mock_test.cpp",
153  ]
154
155  cflags_cc = [ "-DHILOG_ENABLE" ]
156  configs = [ "${access_token_path}/config:coverage_flags" ]
157
158  deps = [
159    "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx",
160    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
161    "${access_token_path}/interfaces/innerkits/accesstoken:libtokenid_sdk",
162    "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc",
163    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
164  ]
165
166  external_deps = [
167    "c_utils:utils",
168    "googletest:gmock",
169    "googletest:gtest_main",
170    "hilog:libhilog",
171    "init:libbeget_proxy",
172    "init:libbegetutil",
173    "ipc:ipc_single",
174    "ipc:libdbinder",
175    "safwk:system_ability_fwk",
176    "samgr:samgr_proxy",
177  ]
178  if (eventhandler_enable == true) {
179    cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
180    external_deps += [ "eventhandler:libeventhandler" ]
181  }
182  if (token_sync_enable == true) {
183    cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ]
184  }
185  if (build_variant == "user") {
186    cflags_cc += [ "-DATM_BUILD_VARIANT_USER_ENABLE" ]
187  }
188}
189