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("//base/security/huks/build/config.gni") 18import("//build/test.gni") 19 20module_output_path = "device_auth/deviceauth_test" 21 22ohos_unittest("deviceauth_llt") { 23 module_out_path = module_output_path 24 25 include_dirs = inc_path 26 include_dirs += hals_inc_path 27 28 include_dirs += [ 29 "./include", 30 "./unit_test/include", 31 "${dev_frameworks_path}/inc/hiview_adapter", 32 ] 33 34 include_dirs += [ 35 "//third_party/cJSON", 36 "//commonlibrary/c_utils/base/include", 37 "//third_party/openssl/include/", 38 "//third_party/mbedtls/include", 39 "//third_party/mbedtls/include/mbedtls", 40 ] 41 42 sources = hal_common_files 43 sources -= [ "${common_lib_path}/impl/src/json_utils.c" ] 44 sources += [ 45 "${key_management_adapter_path}/impl/src/huks_adapter.c", 46 "${key_management_adapter_path}/impl/src/mbedtls_ec_adapter.c", 47 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 48 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 49 "${os_adapter_path}/impl/src/hc_log.c", 50 "${os_adapter_path}/impl/src/linux/hc_condition.c", 51 "${os_adapter_path}/impl/src/linux/hc_file.c", 52 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 53 "${os_adapter_path}/impl/src/linux/hc_thread.c", 54 "${os_adapter_path}/impl/src/linux/hc_types.c", 55 "source/hc_dev_info_mock.c", 56 "source/json_utils_mock.c", 57 ] 58 59 sources += dev_frameworks_files 60 sources += deviceauth_common_files 61 sources += database_manager_files 62 sources += cred_manager_files 63 sources += session_manager_files 64 sources += session_v1_files 65 sources += session_v2_mock_files 66 sources += creds_manager_files 67 sources += broadcast_manager_files 68 sources += soft_bus_channel_mock_files 69 70 sources += group_auth_files 71 sources += group_auth_account_unrelated_files 72 73 sources += group_manager_files 74 sources += group_manager_peer_to_peer_files 75 76 sources += authenticators_p2p_files 77 sources += authenticators_p2p_iso_files 78 sources += authenticators_p2p_pake_files 79 sources += authenticators_standard_exchange_task_files 80 81 sources += account_related_files 82 83 sources += privacy_enhancement_files 84 sources += mk_agree_files 85 86 sources += security_label_adapter_files 87 88 include_dirs += identity_manager_inc 89 sources += identity_manager_files 90 91 sources -= [ 92 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 93 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 94 ] 95 96 sources += [ 97 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 98 "source/creds_manager_test.cpp", 99 "source/device_auth_ext_mock.c", 100 "source/deviceauth_standard_test.cpp", 101 "source/group_operation_common_test.cpp", 102 "source/iso_auth_task_test.cpp", 103 "source/os_account_adapter_mock.c", 104 "source/protocol_task_main_mock.c", 105 "source/standard_exchange_task_test.cpp", 106 "unit_test/source/account_related_group_auth_dir_test.cpp", 107 "unit_test/source/pake_v2_auth_task_test.cpp", 108 ] 109 defines = [ 110 "P2P_PAKE_DL_PRIME_LEN_384", 111 "P2P_PAKE_EC_TYPE", 112 "ENABLE_ACCOUNT_AUTH_ISO", 113 "ENABLE_ACCOUNT_AUTH_EC_SPEKE", 114 "ENABLE_P2P_BIND_ISO", 115 "ENABLE_P2P_BIND_EC_SPEKE", 116 "ENABLE_P2P_AUTH_ISO", 117 "ENABLE_P2P_AUTH_EC_SPEKE", 118 "DEV_AUTH_FUNC_TEST", 119 "ENABLE_PSEUDONYM", 120 ] 121 122 cflags = [ "-DHILOG_ENABLE" ] 123 cflags += [ 124 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${deviceauth_hichain_thread_stack_size}", 125 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 126 ] 127 128 cflags += 129 [ "-DDEVICE_AUTH_TEST_HKS_DATA_PATH=\"${huks_key_store_standard_path}\"" ] 130 131 deps = [ 132 "//third_party/cJSON:cjson", 133 "//third_party/googletest:gmock_main", 134 "//third_party/googletest:gtest_main", 135 "//third_party/mbedtls:mbedtls_shared", 136 "//third_party/openssl:libcrypto_static", 137 ] 138 139 external_deps = [ 140 "c_utils:utils", 141 "hilog:libhilog", 142 "huks:libhukssdk", 143 ] 144} 145 146ohos_unittest("device_auth_func_test") { 147 module_out_path = module_output_path 148 149 include_dirs = inc_path 150 include_dirs += hals_inc_path 151 152 include_dirs += [ 153 "./include", 154 "./unit_test/include", 155 "${dev_frameworks_path}/inc/hiview_adapter", 156 ] 157 158 include_dirs += [ 159 "//third_party/cJSON", 160 "//commonlibrary/c_utils/base/include", 161 "//third_party/openssl/include/", 162 "//third_party/mbedtls/include", 163 "//third_party/mbedtls/include/mbedtls", 164 ] 165 166 sources = hal_common_files 167 sources -= [ "${common_lib_path}/impl/src/json_utils.c" ] 168 sources += [ 169 "${key_management_adapter_path}/impl/src/huks_adapter.c", 170 "${key_management_adapter_path}/impl/src/mbedtls_ec_adapter.c", 171 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 172 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 173 "${os_adapter_path}/impl/src/hc_log.c", 174 "${os_adapter_path}/impl/src/linux/hc_condition.c", 175 "${os_adapter_path}/impl/src/linux/hc_file.c", 176 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 177 "${os_adapter_path}/impl/src/linux/hc_thread.c", 178 "${os_adapter_path}/impl/src/linux/hc_types.c", 179 "source/hc_dev_info_mock.c", 180 "source/json_utils_mock.c", 181 ] 182 183 sources += dev_frameworks_files 184 sources += deviceauth_common_files 185 sources += database_manager_files 186 sources += cred_manager_files 187 sources += session_manager_files 188 sources += session_v1_files 189 sources += session_v2_files 190 sources += iso_protocol_files 191 sources += ec_speke_protocol_files 192 sources += auth_code_import_files 193 sources += pub_key_exchange_files 194 sources += save_trusted_info_files 195 sources += creds_manager_files 196 sources += broadcast_manager_files 197 sources += soft_bus_channel_mock_files 198 199 sources += group_auth_files 200 sources += group_auth_account_unrelated_files 201 202 sources += group_manager_files 203 sources += group_manager_peer_to_peer_files 204 205 sources += authenticators_p2p_files 206 sources += authenticators_p2p_iso_files 207 sources += authenticators_p2p_pake_files 208 sources += authenticators_standard_exchange_task_files 209 210 sources += account_related_files 211 212 sources += privacy_enhancement_files 213 sources += mk_agree_files 214 215 sources += security_label_adapter_files 216 217 sources -= [ 218 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 219 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 220 ] 221 222 sources += [ 223 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 224 "source/creds_manager_test.cpp", 225 "source/device_auth_ext_mock.c", 226 "source/deviceauth_standard_test.cpp", 227 "source/group_operation_common_test.cpp", 228 "source/iso_auth_task_test.cpp", 229 "source/os_account_adapter_mock.c", 230 "source/protocol_task_main_mock.c", 231 "source/standard_exchange_task_test.cpp", 232 "unit_test/source/account_related_group_auth_dir_test.cpp", 233 "unit_test/source/pake_v2_auth_task_test.cpp", 234 ] 235 defines = [ 236 "P2P_PAKE_DL_PRIME_LEN_384", 237 "P2P_PAKE_EC_TYPE", 238 "ENABLE_EC_SPEKE", 239 "ENABLE_ISO", 240 "ENABLE_AUTH_CODE_IMPORT", 241 "ENABLE_PUB_KEY_EXCHANGE", 242 "ENABLE_SAVE_TRUSTED_INFO", 243 "ENABLE_ACCOUNT_AUTH_ISO", 244 "ENABLE_ACCOUNT_AUTH_EC_SPEKE", 245 "ENABLE_P2P_BIND_ISO", 246 "ENABLE_P2P_BIND_EC_SPEKE", 247 "ENABLE_P2P_AUTH_ISO", 248 "ENABLE_P2P_AUTH_EC_SPEKE", 249 "DEV_AUTH_FUNC_TEST", 250 "ENABLE_PSEUDONYM", 251 ] 252 253 sources += identity_manager_files 254 include_dirs += identity_manager_inc 255 sources += [ "source/deviceauth_func_test.cpp" ] 256 257 cflags = [ "-DHILOG_ENABLE" ] 258 cflags += [ 259 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${deviceauth_hichain_thread_stack_size}", 260 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 261 ] 262 263 cflags += 264 [ "-DDEVICE_AUTH_TEST_HKS_DATA_PATH=\"${huks_key_store_standard_path}\"" ] 265 266 deps = [ 267 "//third_party/cJSON:cjson", 268 "//third_party/googletest:gmock_main", 269 "//third_party/googletest:gtest_main", 270 "//third_party/mbedtls:mbedtls_shared", 271 "//third_party/openssl:libcrypto_static", 272 ] 273 274 external_deps = [ 275 "c_utils:utils", 276 "hilog:libhilog", 277 "huks:libhukssdk", 278 ] 279} 280 281ohos_unittest("deviceauth_unit_test") { 282 module_out_path = module_output_path 283 284 include_dirs = inc_path 285 include_dirs += hals_inc_path 286 287 include_dirs += [ 288 "./include", 289 "./unit_test/include", 290 "${dev_frameworks_path}/inc/hiview_adapter", 291 ] 292 293 include_dirs += [ 294 "//third_party/cJSON", 295 "//commonlibrary/c_utils/base/include", 296 "//third_party/openssl/include/", 297 "//third_party/mbedtls/include", 298 "//third_party/mbedtls/include/mbedtls", 299 ] 300 301 sources = hal_common_files 302 sources += [ 303 "${key_management_adapter_path}/impl/src/huks_adapter.c", 304 "${key_management_adapter_path}/impl/src/mbedtls_ec_adapter.c", 305 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 306 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 307 "${os_adapter_path}/impl/src/hc_log.c", 308 "${os_adapter_path}/impl/src/linux/hc_condition.c", 309 "${os_adapter_path}/impl/src/linux/hc_file.c", 310 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 311 "${os_adapter_path}/impl/src/linux/hc_thread.c", 312 "${os_adapter_path}/impl/src/linux/hc_types.c", 313 "source/hc_dev_info_mock.c", 314 ] 315 316 include_dirs += identity_manager_inc 317 sources += identity_manager_files 318 sources += dev_frameworks_files 319 sources += deviceauth_common_files 320 sources += database_manager_files 321 sources += cred_manager_files 322 sources += session_manager_files 323 sources += session_v1_files 324 sources += session_v2_files 325 sources += iso_protocol_files 326 sources += ec_speke_protocol_files 327 sources += auth_code_import_files 328 sources += pub_key_exchange_files 329 sources += save_trusted_info_files 330 sources += creds_manager_files 331 sources += broadcast_manager_files 332 sources += soft_bus_channel_mock_files 333 334 sources += group_auth_files 335 sources += group_auth_account_unrelated_files 336 337 sources += group_manager_files 338 sources += group_manager_peer_to_peer_files 339 340 sources += authenticators_p2p_files 341 sources += authenticators_p2p_iso_files 342 sources += authenticators_p2p_pake_files 343 sources += authenticators_standard_exchange_task_files 344 345 sources += account_related_files 346 347 sources += privacy_enhancement_files 348 sources += mk_agree_files 349 350 sources += security_label_adapter_files 351 352 sources -= [ 353 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 354 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 355 ] 356 357 sources -= [ 358 "${authenticators_path}/src/account_related/creds_manager/asy_token_manager.c", 359 "${group_manager_path}/src/group_operation/across_account_group/across_account_group.c", 360 "${group_manager_path}/src/group_operation/identical_account_group/identical_account_group.c", 361 "${group_manager_path}/src/group_operation/peer_to_peer_group/peer_to_peer_group.c", 362 ] 363 364 sources += [ 365 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 366 "source/os_account_adapter_mock.c", 367 "source/protocol_task_main_mock.c", 368 "unit_test/source/account_related_creds_manager_dir_test.cpp", 369 "unit_test/source/across_account_group_test.cpp", 370 "unit_test/source/common_lib_test.cpp", 371 "unit_test/source/identical_account_group_test.cpp", 372 "unit_test/source/key_management_test.cpp", 373 "unit_test/source/peer_to_peer_group_test.cpp", 374 ] 375 376 defines = [ 377 "P2P_PAKE_DL_PRIME_LEN_384", 378 "P2P_PAKE_EC_TYPE", 379 "ENABLE_EC_SPEKE", 380 "ENABLE_ISO", 381 "ENABLE_AUTH_CODE_IMPORT", 382 "ENABLE_PUB_KEY_EXCHANGE", 383 "ENABLE_SAVE_TRUSTED_INFO", 384 "ENABLE_PSEUDONYM", 385 ] 386 387 cflags = [ "-DHILOG_ENABLE" ] 388 cflags += [ 389 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${deviceauth_hichain_thread_stack_size}", 390 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 391 ] 392 393 deps = [ 394 "//third_party/cJSON:cjson", 395 "//third_party/googletest:gmock_main", 396 "//third_party/googletest:gtest_main", 397 "//third_party/mbedtls:mbedtls_shared", 398 "//third_party/openssl:libcrypto_static", 399 ] 400 401 external_deps = [ 402 "c_utils:utils", 403 "hilog:libhilog", 404 "huks:libhukssdk", 405 ] 406} 407 408ohos_unittest("device_auth_ipc_test") { 409 module_out_path = module_output_path 410 411 include_dirs = hals_inc_path 412 include_dirs += [ 413 "//base/security/device_auth/interfaces/inner_api", 414 "//base/security/access_token/interfaces/innerkits/nativetoken/include", 415 "//base/security/access_token/interfaces/innerkits/token_setproc/include", 416 ] 417 418 sources = [ 419 "source/device_auth_ipc_test.cpp", 420 "source/p2p_bind_ipc_test.cpp", 421 ] 422 423 deps = [ 424 "${deps_adapter_path}:${hal_module_name}", 425 "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", 426 "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", 427 "//third_party/cJSON:cjson", 428 "//third_party/googletest:gmock_main", 429 "//third_party/googletest:gtest_main", 430 ] 431 432 cflags = [ "-DHILOG_ENABLE" ] 433 434 external_deps = [ 435 "c_utils:utils", 436 "device_auth:deviceauth_sdk", 437 "hilog:libhilog", 438 ] 439} 440