1# Copyright (C) 2021-2023 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("//base/security/device_auth/deps_adapter/deviceauth_hals.gni") 15import("//base/security/device_auth/services/deviceauth.gni") 16import("//base/security/device_auth/services/key_agree_sdk/key_agree_sdk.gni") 17import("//build/test.gni") 18 19module_output_path = "device_auth/deviceauth_test" 20 21ohos_unittest("deviceauth_llt") { 22 module_out_path = module_output_path 23 24 include_dirs = inc_path 25 include_dirs += hals_inc_path 26 27 include_dirs += [ 28 "./include", 29 "./unit_test/include", 30 "${dev_frameworks_path}/inc/hiview_adapter", 31 ] 32 33 include_dirs += [] 34 35 sources = hal_common_files 36 sources -= [ "${common_lib_path}/impl/src/json_utils.c" ] 37 sources += [ 38 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 39 "${key_management_adapter_path}/impl/src/huks_adapter.c", 40 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 41 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 42 "${os_adapter_path}/impl/src/hc_log.c", 43 "${os_adapter_path}/impl/src/linux/hc_condition.c", 44 "${os_adapter_path}/impl/src/linux/hc_file.c", 45 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 46 "${os_adapter_path}/impl/src/linux/hc_thread.c", 47 "${os_adapter_path}/impl/src/linux/hc_types.c", 48 "source/hc_dev_info_mock.c", 49 "source/json_utils_mock.c", 50 ] 51 52 sources += dev_frameworks_files 53 sources += deviceauth_common_files 54 sources += database_manager_files 55 sources += cred_manager_files 56 sources += session_manager_files 57 sources += session_v1_files 58 sources += session_v2_mock_files 59 sources += creds_manager_files 60 sources += broadcast_manager_files 61 sources += soft_bus_channel_mock_files 62 63 sources += group_auth_files 64 sources += group_auth_account_unrelated_files 65 66 sources += group_manager_files 67 sources += group_manager_peer_to_peer_files 68 69 sources += authenticators_p2p_files 70 sources += authenticators_p2p_iso_files 71 sources += authenticators_p2p_pake_files 72 sources += authenticators_standard_exchange_task_files 73 74 sources += account_related_files 75 76 sources += privacy_enhancement_files 77 sources += mk_agree_files 78 79 sources += security_label_adapter_files 80 81 include_dirs += identity_manager_inc 82 sources += identity_manager_files 83 84 sources -= [ 85 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 86 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 87 ] 88 89 sources += [ 90 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 91 "source/creds_manager_test.cpp", 92 "source/device_auth_ext_mock.c", 93 "source/deviceauth_standard_auth_test.cpp", 94 "source/deviceauth_standard_member_test.cpp", 95 "source/deviceauth_standard_test.cpp", 96 "source/group_operation_common_test.cpp", 97 "source/identity_manager_test.cpp", 98 "source/iso_auth_task_test.cpp", 99 "source/mk_agree_test.cpp", 100 "source/os_account_adapter_mock.c", 101 "source/privacy_enhancement_test.cpp", 102 "source/protocol_task_main_mock.c", 103 "source/standard_exchange_task_test.cpp", 104 "unit_test/source/account_related_group_auth_dir_test.cpp", 105 "unit_test/source/pake_v2_auth_task_test.cpp", 106 ] 107 defines = [ 108 "P2P_PAKE_DL_PRIME_LEN_384", 109 "P2P_PAKE_EC_TYPE", 110 "ENABLE_ACCOUNT_AUTH_ISO", 111 "ENABLE_ACCOUNT_AUTH_EC_SPEKE", 112 "ENABLE_P2P_BIND_ISO", 113 "ENABLE_P2P_BIND_EC_SPEKE", 114 "ENABLE_P2P_AUTH_ISO", 115 "ENABLE_P2P_AUTH_EC_SPEKE", 116 "DEV_AUTH_FUNC_TEST", 117 "ENABLE_PSEUDONYM", 118 "DEFAULT_V2_NOT_SUPPORT", 119 ] 120 121 cflags = [ "-DHILOG_ENABLE" ] 122 cflags += [ 123 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 124 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 125 ] 126 127 deps = [] 128 129 external_deps = [ 130 "cJSON:cjson", 131 "c_utils:utils", 132 "googletest:gmock_main", 133 "googletest:gtest_main", 134 "hilog:libhilog", 135 "huks:libhukssdk", 136 "mbedtls:mbedtls_shared", 137 "openssl:libcrypto_static", 138 ] 139} 140 141ohos_unittest("device_auth_func_test") { 142 module_out_path = module_output_path 143 144 include_dirs = inc_path 145 include_dirs += hals_inc_path 146 147 include_dirs += [ 148 "./include", 149 "./unit_test/include", 150 "${dev_frameworks_path}/inc/hiview_adapter", 151 ] 152 153 sources = hal_common_files 154 sources -= [ "${common_lib_path}/impl/src/json_utils.c" ] 155 sources += [ 156 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 157 "${key_management_adapter_path}/impl/src/huks_adapter.c", 158 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 159 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 160 "${os_adapter_path}/impl/src/hc_log.c", 161 "${os_adapter_path}/impl/src/linux/hc_condition.c", 162 "${os_adapter_path}/impl/src/linux/hc_file.c", 163 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 164 "${os_adapter_path}/impl/src/linux/hc_thread.c", 165 "${os_adapter_path}/impl/src/linux/hc_types.c", 166 "source/hc_dev_info_mock.c", 167 "source/json_utils_mock.c", 168 ] 169 170 sources += dev_frameworks_files 171 sources += deviceauth_common_files 172 sources += database_manager_files 173 sources += cred_manager_files 174 sources += session_manager_files 175 sources += session_v1_files 176 sources += session_v2_files 177 sources += iso_protocol_files 178 sources += ec_speke_protocol_files 179 sources += auth_code_import_files 180 sources += pub_key_exchange_files 181 sources += save_trusted_info_files 182 sources += creds_manager_files 183 sources += broadcast_manager_files 184 sources += soft_bus_channel_mock_files 185 186 sources += group_auth_files 187 sources += group_auth_account_unrelated_files 188 189 sources += group_manager_files 190 sources += group_manager_peer_to_peer_files 191 192 sources += authenticators_p2p_files 193 sources += authenticators_p2p_iso_files 194 sources += authenticators_p2p_pake_files 195 sources += authenticators_standard_exchange_task_files 196 197 sources += account_related_files 198 199 sources += privacy_enhancement_files 200 sources += mk_agree_files 201 202 sources += security_label_adapter_files 203 204 sources += hiview_adapter_files 205 206 sources -= [ 207 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 208 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 209 ] 210 211 sources += [ 212 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 213 "source/creds_manager_test.cpp", 214 "source/device_auth_ext_mock.c", 215 "source/deviceauth_standard_auth_test.cpp", 216 "source/deviceauth_standard_member_test.cpp", 217 "source/deviceauth_standard_test.cpp", 218 "source/group_operation_common_test.cpp", 219 "source/iso_auth_task_test.cpp", 220 "source/os_account_adapter_mock.c", 221 "source/protocol_task_main_mock.c", 222 "source/standard_exchange_task_test.cpp", 223 "unit_test/source/account_related_group_auth_dir_test.cpp", 224 "unit_test/source/pake_v2_auth_task_test.cpp", 225 ] 226 defines = [ 227 "P2P_PAKE_DL_PRIME_LEN_384", 228 "P2P_PAKE_EC_TYPE", 229 "ENABLE_EC_SPEKE", 230 "ENABLE_ISO", 231 "ENABLE_AUTH_CODE_IMPORT", 232 "ENABLE_PUB_KEY_EXCHANGE", 233 "ENABLE_SAVE_TRUSTED_INFO", 234 "ENABLE_ACCOUNT_AUTH_ISO", 235 "ENABLE_ACCOUNT_AUTH_EC_SPEKE", 236 "ENABLE_P2P_BIND_ISO", 237 "ENABLE_P2P_BIND_EC_SPEKE", 238 "ENABLE_P2P_AUTH_ISO", 239 "ENABLE_P2P_AUTH_EC_SPEKE", 240 "DEV_AUTH_FUNC_TEST", 241 "ENABLE_PSEUDONYM", 242 "DEV_AUTH_HIVIEW_ENABLE", 243 ] 244 245 sources += identity_manager_files 246 include_dirs += identity_manager_inc 247 sources += [ "source/deviceauth_func_test.cpp" ] 248 249 cflags = [ "-DHILOG_ENABLE" ] 250 cflags += [ 251 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 252 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 253 ] 254 255 deps = [] 256 257 external_deps = [ 258 "cJSON:cjson", 259 "c_utils:utils", 260 "googletest:gmock_main", 261 "googletest:gtest_main", 262 "hilog:libhilog", 263 "hisysevent:libhisysevent", 264 "hitrace:hitrace_meter", 265 "huks:libhukssdk", 266 "mbedtls:mbedtls_shared", 267 "openssl:libcrypto_static", 268 ] 269} 270 271ohos_unittest("device_auth_interface_test") { 272 module_out_path = module_output_path 273 274 include_dirs = inc_path 275 include_dirs += hals_inc_path 276 277 include_dirs += [ 278 "./include", 279 "./unit_test/include", 280 "${dev_frameworks_path}/inc/hiview_adapter", 281 "${frameworks_path}/inc/standard", 282 "${dev_frameworks_path}/inc/permission_adapter", 283 ] 284 285 sources = hal_common_files 286 sources -= [ "${common_lib_path}/impl/src/json_utils.c" ] 287 sources += [ 288 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 289 "${key_management_adapter_path}/impl/src/huks_adapter.c", 290 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 291 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 292 "${os_adapter_path}/impl/src/hc_log.c", 293 "${os_adapter_path}/impl/src/linux/hc_condition.c", 294 "${os_adapter_path}/impl/src/linux/hc_file.c", 295 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 296 "${os_adapter_path}/impl/src/linux/hc_thread.c", 297 "${os_adapter_path}/impl/src/linux/hc_types.c", 298 "source/hc_dev_info_mock.c", 299 "source/json_utils_mock.c", 300 ] 301 302 sources += dev_frameworks_files 303 sources += deviceauth_common_files 304 sources += database_manager_files 305 sources += cred_manager_files 306 sources += session_manager_files 307 sources += session_v1_files 308 sources += session_v2_files 309 sources += iso_protocol_files 310 sources += ec_speke_protocol_files 311 sources += auth_code_import_files 312 sources += pub_key_exchange_files 313 sources += save_trusted_info_files 314 sources += creds_manager_files 315 sources += broadcast_manager_files 316 sources += soft_bus_channel_files 317 sources += deviceauth_ipc_files 318 sources += permission_adapter_files 319 320 sources += group_auth_files 321 sources += group_auth_account_unrelated_files 322 323 sources += group_manager_files 324 sources += group_manager_peer_to_peer_files 325 326 sources += authenticators_p2p_files 327 sources += authenticators_p2p_iso_files 328 sources += authenticators_p2p_pake_files 329 sources += authenticators_standard_exchange_task_files 330 331 sources += account_related_files 332 333 sources += privacy_enhancement_files 334 sources += mk_agree_files 335 336 sources += security_label_adapter_files 337 338 sources += hiview_adapter_files 339 340 sources += [ 341 "${dev_frameworks_path}/src/plugin_adapter/ext_part/account_auth_plugin_proxy.c", 342 "source/device_auth_ext_mock.c", 343 "source/os_account_adapter_mock.c", 344 ] 345 defines = [ 346 "P2P_PAKE_DL_PRIME_LEN_384", 347 "P2P_PAKE_EC_TYPE", 348 "ENABLE_EC_SPEKE", 349 "ENABLE_ISO", 350 "ENABLE_AUTH_CODE_IMPORT", 351 "ENABLE_PUB_KEY_EXCHANGE", 352 "ENABLE_SAVE_TRUSTED_INFO", 353 "ENABLE_ACCOUNT_AUTH_ISO", 354 "ENABLE_ACCOUNT_AUTH_EC_SPEKE", 355 "ENABLE_P2P_BIND_ISO", 356 "ENABLE_P2P_BIND_EC_SPEKE", 357 "ENABLE_P2P_AUTH_ISO", 358 "ENABLE_P2P_AUTH_EC_SPEKE", 359 "ENABLE_PSEUDONYM", 360 "DEV_AUTH_HIVIEW_ENABLE", 361 ] 362 363 sources += identity_manager_files 364 include_dirs += identity_manager_inc 365 sources += [ "source/deviceauth_interface_test.cpp" ] 366 367 cflags = [ "-DHILOG_ENABLE" ] 368 cflags += [ 369 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 370 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 371 ] 372 373 deps = [] 374 375 external_deps = [ 376 "access_token:libaccesstoken_sdk", 377 "bounds_checking_function:libsec_shared", 378 "cJSON:cjson", 379 "c_utils:utils", 380 "dsoftbus:softbus_client", 381 "googletest:gmock_main", 382 "googletest:gtest_main", 383 "hilog:libhilog", 384 "hisysevent:libhisysevent", 385 "hitrace:hitrace_meter", 386 "huks:libhukssdk", 387 "init:libbegetutil", 388 "ipc:ipc_single", 389 "mbedtls:mbedtls_shared", 390 "openssl:libcrypto_static", 391 "samgr:samgr_proxy", 392 ] 393} 394 395ohos_unittest("deviceauth_unit_test") { 396 module_out_path = module_output_path 397 398 include_dirs = inc_path 399 include_dirs += hals_inc_path 400 401 include_dirs += [ 402 "./include", 403 "./unit_test/include", 404 "${dev_frameworks_path}/inc/hiview_adapter", 405 ] 406 407 sources = hal_common_files 408 sources += [ 409 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 410 "${key_management_adapter_path}/impl/src/huks_adapter.c", 411 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 412 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 413 "${os_adapter_path}/impl/src/hc_log.c", 414 "${os_adapter_path}/impl/src/linux/hc_condition.c", 415 "${os_adapter_path}/impl/src/linux/hc_file.c", 416 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 417 "${os_adapter_path}/impl/src/linux/hc_thread.c", 418 "${os_adapter_path}/impl/src/linux/hc_types.c", 419 "source/hc_dev_info_mock.c", 420 ] 421 422 include_dirs += identity_manager_inc 423 sources += identity_manager_files 424 sources += dev_frameworks_files 425 sources += deviceauth_common_files 426 sources += database_manager_files 427 sources += cred_manager_files 428 sources += session_manager_files 429 sources += session_v1_files 430 sources += session_v2_files 431 sources += iso_protocol_files 432 sources += ec_speke_protocol_files 433 sources += auth_code_import_files 434 sources += pub_key_exchange_files 435 sources += save_trusted_info_files 436 sources += creds_manager_files 437 sources += broadcast_manager_files 438 sources += soft_bus_channel_mock_files 439 440 sources += group_auth_files 441 sources += group_auth_account_unrelated_files 442 443 sources += group_manager_files 444 sources += group_manager_peer_to_peer_files 445 446 sources += authenticators_p2p_files 447 sources += authenticators_p2p_iso_files 448 sources += authenticators_p2p_pake_files 449 sources += authenticators_standard_exchange_task_files 450 451 sources += account_related_files 452 453 sources += privacy_enhancement_files 454 sources += mk_agree_files 455 456 sources += security_label_adapter_files 457 458 sources -= [ 459 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 460 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 461 ] 462 463 sources += [ 464 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 465 "source/os_account_adapter_mock.c", 466 "source/protocol_task_main_mock.c", 467 "unit_test/source/account_related_creds_manager_dir_test.cpp", 468 "unit_test/source/common_lib_test.cpp", 469 "unit_test/source/key_management_test.cpp", 470 ] 471 472 defines = [ 473 "P2P_PAKE_DL_PRIME_LEN_384", 474 "P2P_PAKE_EC_TYPE", 475 "ENABLE_EC_SPEKE", 476 "ENABLE_ISO", 477 "ENABLE_AUTH_CODE_IMPORT", 478 "ENABLE_PUB_KEY_EXCHANGE", 479 "ENABLE_SAVE_TRUSTED_INFO", 480 "ENABLE_PSEUDONYM", 481 "DEV_AUTH_FUNC_TEST", 482 ] 483 484 cflags = [ "-DHILOG_ENABLE" ] 485 cflags += [ 486 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 487 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 488 ] 489 490 deps = [] 491 492 external_deps = [ 493 "cJSON:cjson", 494 "c_utils:utils", 495 "googletest:gmock_main", 496 "googletest:gtest_main", 497 "hilog:libhilog", 498 "huks:libhukssdk", 499 "mbedtls:mbedtls_shared", 500 "openssl:libcrypto_static", 501 ] 502} 503 504ohos_unittest("device_auth_ipc_test") { 505 module_out_path = module_output_path 506 507 include_dirs = hals_inc_path 508 include_dirs += [] 509 510 sources = [ 511 "source/device_auth_ipc_test.cpp", 512 "source/p2p_bind_ipc_test.cpp", 513 ] 514 515 deps = [ "${deps_adapter_path}:${hal_module_test_name}" ] 516 517 cflags = [ "-DHILOG_ENABLE" ] 518 519 external_deps = [ 520 "access_token:libnativetoken", 521 "access_token:libtoken_setproc", 522 "cJSON:cjson", 523 "c_utils:utils", 524 "device_auth:deviceauth_sdk", 525 "googletest:gmock_main", 526 "googletest:gtest_main", 527 "hilog:libhilog", 528 ] 529} 530