1# Copyright (c) 2022 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("../../../../../os_account.gni")
16
17module_output_path = "os_account/services/account_iam"
18
19config("account_iam_native_config_unittest") {
20  visibility = [ ":*" ]
21
22  include_dirs = [
23    "include",
24    "${services_path}/accountmgr/include/account_iam",
25  ]
26
27  cflags = []
28  if (target_cpu == "arm") {
29    cflags += [ "-DBINDER_IPC_32BIT" ]
30  }
31
32  defines = [
33    "ACCOUNT_LOG_TAG = \"AccountIAMUTestFwk\"",
34    "LOG_DOMAIN = 0xD001B00",
35  ]
36}
37
38ohos_unittest("account_iam_service_test") {
39  branch_protector_ret = "pac_ret"
40
41  sanitize = {
42    cfi = true
43    cfi_cross_dso = true
44    debug = false
45  }
46
47  module_out_path = module_output_path
48
49  sources = [ "account_iam_service_test.cpp" ]
50
51  configs = [ ":account_iam_native_config_unittest" ]
52
53  deps = [
54    "${account_iam_framework_path}:account_iam_innerkits",
55    "${common_path}:libaccount_common",
56    "${os_account_innerkits_native_path}:os_account_innerkits",
57    "${services_path}/accountmgr:accountmgr",
58    "//third_party/googletest:gmock_main",
59    "//third_party/googletest:gtest_main",
60  ]
61
62  external_deps = [
63    "access_token:libaccesstoken_sdk",
64    "access_token:libtokensetproc_shared",
65    "c_utils:utils",
66    "hilog:libhilog",
67    "ipc:ipc_single",
68  ]
69
70  cflags_cc = []
71  if (has_pin_auth_part) {
72    cflags_cc += [ "-DHAS_PIN_AUTH_PART" ]
73    external_deps += [ "pin_auth:pinauth_framework" ]
74  }
75
76  if (has_user_auth_part) {
77    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
78    external_deps += [ "user_auth_framework:userauth_client" ]
79  }
80}
81
82ohos_unittest("account_iam_stub_test") {
83  branch_protector_ret = "pac_ret"
84
85  sanitize = {
86    cfi = true
87    cfi_cross_dso = true
88    debug = false
89  }
90
91  module_out_path = module_output_path
92
93  sources = [
94    "${services_path}/accountmgr/src/account_iam/account_iam_mgr_stub.cpp",
95    "account_iam_stub_test.cpp",
96  ]
97
98  configs = [ ":account_iam_native_config_unittest" ]
99
100  deps = [
101    "${account_iam_framework_path}:account_iam_innerkits",
102    "${common_path}:libaccount_common",
103    "${os_account_innerkits_native_path}:os_account_innerkits",
104    "${services_path}/accountmgr:accountmgr",
105    "//third_party/googletest:gmock_main",
106    "//third_party/googletest:gtest_main",
107  ]
108
109  external_deps = [
110    "access_token:libaccesstoken_sdk",
111    "access_token:libtokensetproc_shared",
112    "c_utils:utils",
113    "hilog:libhilog",
114    "ipc:ipc_single",
115  ]
116
117  cflags_cc = []
118  if (has_pin_auth_part) {
119    cflags_cc += [ "-DHAS_PIN_AUTH_PART" ]
120    external_deps += [ "pin_auth:pinauth_framework" ]
121  }
122
123  if (has_user_auth_part) {
124    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
125    external_deps += [ "user_auth_framework:userauth_client" ]
126  }
127}
128
129ohos_unittest("account_iam_callback_test") {
130  branch_protector_ret = "pac_ret"
131
132  sanitize = {
133    cfi = true
134    cfi_cross_dso = true
135    debug = false
136  }
137
138  module_out_path = module_output_path
139
140  sources = [
141    "${domain_account_framework_path}/test/moduletest/src/mock_domain_plugin.cpp",
142    "account_iam_callback_test.cpp",
143  ]
144
145  configs = [ ":account_iam_native_config_unittest" ]
146
147  deps = [
148    "${account_iam_framework_path}:account_iam_innerkits",
149    "${common_path}:libaccount_common",
150    "${domain_account_framework_path}:domain_account_innerkits",
151    "${os_account_core_path}:os_account_core",
152    "${os_account_innerkits_native_path}:os_account_innerkits",
153    "${services_path}/accountmgr:accountmgr",
154    "//third_party/googletest:gmock_main",
155    "//third_party/googletest:gtest_main",
156  ]
157
158  include_dirs = [
159    "${os_account_path}/frameworks/domain_account/test/moduletest/include/",
160    "${os_account_interfaces_native_path}/include/",
161  ]
162
163  external_deps = [
164    "access_token:libaccesstoken_sdk",
165    "access_token:libtokensetproc_shared",
166    "c_utils:utils",
167    "hilog:libhilog",
168    "ipc:ipc_single",
169  ]
170
171  cflags_cc = []
172  if (has_pin_auth_part) {
173    cflags_cc += [ "-DHAS_PIN_AUTH_PART" ]
174    external_deps += [ "pin_auth:pinauth_framework" ]
175  }
176
177  if (has_user_auth_part) {
178    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
179    external_deps += [ "user_auth_framework:userauth_client" ]
180  }
181}
182
183ohos_unittest("account_iam_manager_test") {
184  branch_protector_ret = "pac_ret"
185
186  sanitize = {
187    cfi = true
188    cfi_cross_dso = true
189    debug = false
190    blocklist = "${os_account_path}/cfi_blocklist.txt"
191  }
192
193  module_out_path = module_output_path
194
195  sources = [ "account_iam_manager_test.cpp" ]
196
197  configs = [
198    ":account_iam_native_config_unittest",
199    "${services_path}/accountmgr:account_iam_config",
200  ]
201
202  deps = [
203    "${account_iam_framework_path}:account_iam_innerkits",
204    "${common_path}:libaccount_common",
205    "${services_path}/accountmgr:accountmgr",
206    "//third_party/googletest:gmock_main",
207    "//third_party/googletest:gtest_main",
208  ]
209
210  cflags_cc = []
211  if (has_user_auth_part) {
212    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
213  }
214
215  external_deps = [
216    "ability_base:want",
217    "access_token:libaccesstoken_sdk",
218    "access_token:libtokensetproc_shared",
219    "c_utils:utils",
220    "hilog:libhilog",
221    "init:libbegetutil",
222    "ipc:ipc_single",
223    "user_auth_framework:userauth_client",
224  ]
225
226  if (has_storage_service_part) {
227    cflags_cc += [ "-DHAS_STORAGE_PART" ]
228    external_deps += [ "storage_service:storage_manager_sa_proxy" ]
229  }
230
231  if (has_pin_auth_part) {
232    cflags_cc += [ "-DHAS_PIN_AUTH_PART" ]
233    external_deps += [ "pin_auth:pinauth_framework" ]
234  }
235}
236
237group("unittest") {
238  testonly = true
239  deps = []
240  if (!use_libfuzzer) {
241    deps += [
242      ":account_iam_callback_test",
243      ":account_iam_manager_test",
244      ":account_iam_service_test",
245      ":account_iam_stub_test",
246    ]
247  }
248}
249