1# Copyright (c) 2022-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("../../../../os_account.gni") 16 17module_output_path = "os_account/account_iam" 18 19config("account_iam_native_config_unittest") { 20 visibility = [ ":*" ] 21 22 include_dirs = [ "include" ] 23 24 cflags = [] 25 if (target_cpu == "arm") { 26 cflags += [ "-DBINDER_IPC_32BIT" ] 27 } 28 29 defines = [ 30 "ACCOUNT_LOG_TAG = \"AccountIAMUTestFwk\"", 31 "LOG_DOMAIN = 0xD001B00", 32 ] 33} 34 35ohos_unittest("account_iam_client_test") { 36 branch_protector_ret = "pac_ret" 37 38 sanitize = { 39 cfi = true 40 cfi_cross_dso = true 41 debug = false 42 blocklist = "${os_account_path}/cfi_blocklist.txt" 43 } 44 45 module_out_path = module_output_path 46 47 sources = [ 48 "src/account_iam_callback_service_test.cpp", 49 "src/account_iam_client_test.cpp", 50 "src/test_common.cpp", 51 ] 52 53 configs = [ ":account_iam_native_config_unittest" ] 54 55 deps = [ 56 "${account_iam_framework_path}:account_iam_innerkits", 57 "${account_test_common}:account_test_common_source_set", 58 "${common_path}:libaccount_common", 59 "${domain_account_framework_path}:domain_account_innerkits", 60 ] 61 62 external_deps = [ 63 "ability_base:want", 64 "access_token:libaccesstoken_sdk", 65 "access_token:libtokensetproc_shared", 66 "c_utils:utils", 67 "googletest:gmock_main", 68 "googletest:gtest_main", 69 "hilog:libhilog", 70 "ipc:ipc_single", 71 ] 72 73 cflags_cc = [] 74 if (has_pin_auth_part) { 75 cflags_cc += [ "-DHAS_PIN_AUTH_PART" ] 76 external_deps += [ "pin_auth:pinauth_framework" ] 77 } 78 79 if (has_user_auth_part) { 80 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 81 external_deps += [ "user_auth_framework:userauth_client" ] 82 } 83 84 if (os_account_support_domain_accounts) { 85 cflags_cc += [ "-DSUPPORT_DOMAIN_ACCOUNTS" ] 86 } 87} 88 89ohos_unittest("account_iam_client_proxy_mock_test") { 90 branch_protector_ret = "pac_ret" 91 92 sanitize = { 93 cfi = true 94 cfi_cross_dso = true 95 debug = false 96 blocklist = "${os_account_path}/cfi_blocklist.txt" 97 } 98 99 module_out_path = module_output_path 100 101 sources = [ 102 "src/account_iam_callback_service_test.cpp", 103 "src/account_iam_client_test.cpp", 104 "src/test_common.cpp", 105 ] 106 107 configs = [ ":account_iam_native_config_unittest" ] 108 109 deps = [ 110 "${account_iam_framework_path}:account_iam_innerkits", 111 "${account_test_common}:account_test_common_source_set", 112 "${app_account_services_path}:accountmgr", 113 "${common_path}:libaccount_common", 114 "${domain_account_framework_path}:domain_account_innerkits", 115 ] 116 117 external_deps = [ 118 "ability_base:want", 119 "access_token:libaccesstoken_sdk", 120 "access_token:libtokensetproc_shared", 121 "c_utils:utils", 122 "googletest:gmock_main", 123 "googletest:gtest_main", 124 "hilog:libhilog", 125 "ipc:ipc_single", 126 ] 127 128 cflags_cc = [] 129 if (has_pin_auth_part) { 130 cflags_cc += [ "-DHAS_PIN_AUTH_PART" ] 131 external_deps += [ "pin_auth:pinauth_framework" ] 132 } 133 134 if (has_user_auth_part) { 135 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 136 external_deps += [ "user_auth_framework:userauth_client" ] 137 } 138 cflags_cc += [ "-DPROXY_MOCK" ] 139 if (os_account_support_domain_accounts) { 140 cflags_cc += [ "-DSUPPORT_DOMAIN_ACCOUNTS" ] 141 } 142} 143 144ohos_unittest("account_iam_client_no_permission_proxy_mock_test") { 145 branch_protector_ret = "pac_ret" 146 147 sanitize = { 148 cfi = true 149 cfi_cross_dso = true 150 debug = false 151 } 152 153 module_out_path = module_output_path 154 155 sources = [ "src/account_iam_client_no_permission_test.cpp" ] 156 157 configs = [ ":account_iam_native_config_unittest" ] 158 159 deps = [ 160 "${account_iam_framework_path}:account_iam_innerkits", 161 "${app_account_services_path}:accountmgr", 162 "${common_path}:libaccount_common", 163 "${domain_account_framework_path}:domain_account_innerkits", 164 ] 165 166 external_deps = [ 167 "ability_base:want", 168 "access_token:libaccesstoken_sdk", 169 "access_token:libtokensetproc_shared", 170 "c_utils:utils", 171 "googletest:gmock_main", 172 "googletest:gtest_main", 173 "hilog:libhilog", 174 "ipc:ipc_single", 175 ] 176 177 cflags_cc = [] 178 if (has_pin_auth_part) { 179 cflags_cc += [ "-DHAS_PIN_AUTH_PART" ] 180 external_deps += [ "pin_auth:pinauth_framework" ] 181 } 182 183 if (has_user_auth_part) { 184 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 185 external_deps += [ "user_auth_framework:userauth_client" ] 186 } 187 cflags_cc += [ "-DPROXY_MOCK" ] 188} 189 190ohos_unittest("account_iam_client_no_permission_test") { 191 branch_protector_ret = "pac_ret" 192 193 sanitize = { 194 cfi = true 195 cfi_cross_dso = true 196 debug = false 197 } 198 199 module_out_path = module_output_path 200 201 sources = [ "src/account_iam_client_no_permission_test.cpp" ] 202 203 configs = [ ":account_iam_native_config_unittest" ] 204 205 deps = [ 206 "${account_iam_framework_path}:account_iam_innerkits", 207 "${common_path}:libaccount_common", 208 "${domain_account_framework_path}:domain_account_innerkits", 209 ] 210 211 external_deps = [ 212 "ability_base:want", 213 "access_token:libaccesstoken_sdk", 214 "access_token:libtokensetproc_shared", 215 "c_utils:utils", 216 "googletest:gmock_main", 217 "googletest:gtest_main", 218 "hilog:libhilog", 219 "ipc:ipc_single", 220 ] 221 222 cflags_cc = [] 223 if (has_pin_auth_part) { 224 cflags_cc += [ "-DHAS_PIN_AUTH_PART" ] 225 external_deps += [ "pin_auth:pinauth_framework" ] 226 } 227 228 if (has_user_auth_part) { 229 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 230 external_deps += [ "user_auth_framework:userauth_client" ] 231 } 232} 233 234ohos_unittest("account_iam_mgr_proxy_test") { 235 branch_protector_ret = "pac_ret" 236 237 sanitize = { 238 cfi = true 239 cfi_cross_dso = true 240 debug = false 241 } 242 243 module_out_path = module_output_path 244 245 sources = [ 246 "src/account_iam_mgr_proxy_test.cpp", 247 "src/test_common.cpp", 248 ] 249 250 configs = [ ":account_iam_native_config_unittest" ] 251 252 deps = [ 253 "${account_iam_framework_path}:account_iam_innerkits", 254 "${common_path}:libaccount_common", 255 "${domain_account_framework_path}:domain_account_innerkits", 256 ] 257 258 external_deps = [ 259 "access_token:libaccesstoken_sdk", 260 "c_utils:utils", 261 "googletest:gmock_main", 262 "googletest:gtest_main", 263 "hilog:libhilog", 264 "ipc:ipc_single", 265 ] 266 267 cflags_cc = [] 268 if (has_pin_auth_part) { 269 cflags_cc += [ "-DHAS_PIN_AUTH_PART" ] 270 external_deps += [ "pin_auth:pinauth_framework" ] 271 } 272 273 if (has_user_auth_part) { 274 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 275 external_deps += [ "user_auth_framework:userauth_client" ] 276 } 277} 278 279ohos_unittest("account_iam_info_test") { 280 branch_protector_ret = "pac_ret" 281 282 sanitize = { 283 cfi = true 284 cfi_cross_dso = true 285 debug = false 286 } 287 288 module_out_path = module_output_path 289 290 sources = [ 291 "src/account_iam_info_test.cpp", 292 "src/test_common.cpp", 293 ] 294 295 configs = [ ":account_iam_native_config_unittest" ] 296 297 deps = [ 298 "${account_iam_framework_path}:account_iam_innerkits", 299 "${app_account_services_path}:accountmgr", 300 "${common_path}:libaccount_common", 301 "${domain_account_framework_path}:domain_account_innerkits", 302 ] 303 304 external_deps = [ 305 "ability_base:want", 306 "access_token:libaccesstoken_sdk", 307 "c_utils:utils", 308 "googletest:gmock_main", 309 "googletest:gtest_main", 310 "hilog:libhilog", 311 "ipc:ipc_single", 312 ] 313 314 cflags_cc = [] 315 if (has_pin_auth_part) { 316 cflags_cc += [ "-DHAS_PIN_AUTH_PART" ] 317 external_deps += [ "pin_auth:pinauth_framework" ] 318 } 319 320 if (has_user_auth_part) { 321 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 322 external_deps += [ "user_auth_framework:userauth_client" ] 323 } 324} 325 326group("unittest") { 327 testonly = true 328 329 deps = [ 330 ":account_iam_client_no_permission_proxy_mock_test", 331 ":account_iam_client_no_permission_test", 332 ":account_iam_client_proxy_mock_test", 333 ":account_iam_client_test", 334 ":account_iam_mgr_proxy_test", 335 ":account_iam_info_test", 336 ] 337} 338