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