1# Copyright (c) 2022-2024 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("../../../../common/config/common.gni") 16 17module_output_path = "enterprise_device_management/enterprise_device_management" 18 19config("module_private_config") { 20 visibility = [ ":*" ] 21} 22 23ohos_unittest("EdmPluginTest") { 24 module_out_path = module_output_path 25 26 include_dirs = [ 27 "../../common/mock/include", 28 "../../external_mock/include", 29 "../../../../common/native/include/plugin_kits", 30 "../../../../services/edm_plugin/include", 31 "../../../../services/edm_plugin/include/utils", 32 "../../../../services/edm_plugin/include/network", 33 "../../../../services/edm_plugin/include/network/executer", 34 "../../../../services/edm_plugin/include/network/rule", 35 "./include", 36 "./include/network", 37 "./include/network/executer", 38 "./include/utils", 39 ] 40 41 sources = [ 42 "../../common/mock/src/edm_data_ability_utils_mock.cpp", 43 "./src/bundle_install_plugin_test.cpp", 44 "./src/device_info_plugin_test.cpp", 45 "./src/disallow_modify_datetime_plugin_test.cpp", 46 "./src/get_device_encryption_status_plugin_test.cpp", 47 "./src/get_security_patch_tag_plugin_test.cpp", 48 "./src/install_plugin_test.cpp", 49 "./src/network/executer/executer_utils_mock.cpp", 50 "./src/ntp_server_plugin_test.cpp", 51 "./src/password_policy_plugin_test.cpp", 52 "./src/power_policy_plugin_test.cpp", 53 "./src/screen_off_time_plugin_test.cpp", 54 "./src/uninstall_plugin_test.cpp", 55 "./src/utils/password_policy_serializer_test.cpp", 56 ] 57 58 configs = [ 59 ":module_private_config", 60 "../../../../common/config:coverage_flags", 61 ] 62 63 deps = [ 64 ":edm_all_plugin_static", 65 "../../../../common/external:edm_external_adapters", 66 "../../../../common/native:edm_commom", 67 "../../../../interfaces/inner_api:edmservice_kits", 68 "../../../../interfaces/inner_api/plugin_kits:plugin_kits", 69 "../../test_bundle/ohos_test:copy_ohos_test", 70 "../../test_bundle/right_hap:right", 71 "../../utils:edm_unittest_utils", 72 "//third_party/googletest:gmock_main", 73 ] 74 75 external_deps = [ 76 "ability_base:want", 77 "access_token:libaccesstoken_sdk", 78 "access_token:libnativetoken", 79 "access_token:libtoken_setproc", 80 "bundle_framework:appexecfwk_base", 81 "bundle_framework:appexecfwk_core", 82 "cJSON:cjson", 83 "c_utils:utils", 84 "hilog:libhilog", 85 "init:libbegetutil", 86 "ipc:ipc_core", 87 "safwk:system_ability_fwk", 88 "samgr:samgr_proxy", 89 ] 90 91 defines = [] 92 if (os_account_edm_enable) { 93 external_deps += [ 94 "ability_runtime:app_manager", 95 "os_account:libaccountkits", 96 "os_account:os_account_innerkits", 97 ] 98 sources += [ 99 "./src/add_os_account_plugin_test.cpp", 100 "./src/disallow_add_local_account_plugin_test.cpp", 101 "./src/disallow_add_os_account_by_user_plugin_test.cpp", 102 "./src/operate_device_plugin_test.cpp", 103 ] 104 defines += [ "OS_ACCOUNT_EDM_ENABLE" ] 105 } 106 107 if (ability_runtime_edm_enable) { 108 sources += [ 109 "./src/disallowed_running_bundles_plugin_test.cpp", 110 "./src/manage_auto_start_apps_plugin_test.cpp", 111 ] 112 } 113 114 if (screenlock_mgr_edm_enable) { 115 external_deps += [ "screenlock_mgr:screenlock_client" ] 116 } 117 118 if (os_account_edm_enable && screenlock_mgr_edm_enable) { 119 sources += [ "./src/lock_screen_plugin_test.cpp" ] 120 } 121 122 if (power_manager_edm_enable && screenlock_mgr_edm_enable) { 123 external_deps += [ "power_manager:powermgr_client" ] 124 sources += [ 125 "./src/reboot_plugin_test.cpp", 126 "./src/shutdown_plugin_test.cpp", 127 ] 128 } 129 130 if (wifi_edm_enable) { 131 external_deps += [ "wifi:wifi_sdk" ] 132 sources += [ 133 "./src/is_wifi_active_plugin_test.cpp", 134 "./src/message_parcel_utils_test.cpp", 135 "./src/set_wifi_disabled_plugin_test.cpp", 136 "./src/set_wifi_profile_plugin_test.cpp", 137 ] 138 defines += [ "WIFI_EDM_ENABLE" ] 139 } 140 141 if (netmanager_base_edm_enable && netmanager_ext_edm_enable) { 142 external_deps += [ "netmanager_base:net_conn_manager_if" ] 143 sources += [ 144 "./src/domain_filter_rule_plugin_test.cpp", 145 "./src/firewall_rule_plugin_test.cpp", 146 "./src/global_proxy_plugin_test.cpp", 147 "./src/iptables_rule_plugin_test.cpp", 148 "./src/network/executer/domain_executer_test.cpp", 149 "./src/network/executer/executer_factory_test.cpp", 150 "./src/network/executer/executer_utils_test.cpp", 151 "./src/network/executer/firewall_executer_test.cpp", 152 "./src/network/executer/iexecuter_test.cpp", 153 "./src/network/iptables_manager_test.cpp", 154 "./src/network/rule/chain_rule_test.cpp", 155 "./src/network/rule/domain_chain_rule_test.cpp", 156 "./src/network/rule/firewall_chain_rule_test.cpp", 157 "./src/network_manager_plugin_test.cpp", 158 ] 159 } 160 161 if (certificate_manager_edm_enable) { 162 external_deps += [ "certificate_manager:cert_manager_sdk" ] 163 sources += [ "./src/user_cert_plugin_test.cpp" ] 164 } 165 166 if (drivers_interface_usb_edm_enable && usb_manager_edm_enable) { 167 external_deps += [ "usb_manager:usbsrv_client" ] 168 sources += [ 169 "./src/allowed_usb_devices_plugin_test.cpp", 170 "./src/disable_usb_plugin_test.cpp", 171 "./src/disallowed_usb_devices_plugin_test.cpp", 172 "./src/utils/array_usb_device_id_serializer_test.cpp", 173 ] 174 } 175 176 if (drivers_interface_usb_edm_enable && storage_service_edm_enable && 177 usb_manager_edm_enable) { 178 external_deps += [ "storage_service:storage_manager_sa_proxy" ] 179 sources += [ "./src/usb_read_only_plugin_test.cpp" ] 180 } 181 182 if (audio_framework_edm_enable) { 183 external_deps += [ "audio_framework:audio_client" ] 184 sources += [ 185 "./src/disable_hdc_plugin_test.cpp", 186 "./src/disable_microphone_plugin_test.cpp", 187 "./src/disable_printer_plugin_test.cpp", 188 ] 189 } 190 191 if (common_event_service_edm_enable) { 192 external_deps += [ "common_event_service:cesfwk_innerkits" ] 193 sources += [ "./src/set_browser_policies_plugin_test.cpp" ] 194 } 195 196 if (bluetooth_edm_enable) { 197 external_deps += [ "bluetooth:btframework" ] 198 sources += [ 199 "./src/allowed_bluetooth_devices_plugin_test.cpp", 200 "./src/disable_bluetooth_plugin_test.cpp", 201 "./src/get_bluetooth_info_plugin_test.cpp", 202 ] 203 } 204 205 if (location_edm_enable) { 206 sources += [ "./src/location_policy_plugin_test.cpp" ] 207 } 208 209 if (update_service_edm_enable) { 210 external_deps += [ "update_service:updateservicekits" ] 211 } 212 213 if (pasteboard_edm_enable) { 214 sources += [ 215 "./src/clipboard_policy_plugin_test.cpp", 216 "./src/utils/clipboard_policy_serializer_test.cpp", 217 "./src/utils/clipboard_utils_test.cpp", 218 ] 219 } 220 221 if (camera_framework_edm_enable) { 222 sources += [ "./src/disable_camera_plugin_test.cpp" ] 223 } 224 225 sanitize = { 226 boundary_sanitize = true 227 cfi = true 228 cfi_cross_dso = true 229 debug = false 230 integer_overflow = true 231 ubsan = true 232 blocklist = "../../cfi_blocklist.txt" 233 } 234 branch_protector_ret = "pac_ret" 235 subsystem_name = "customization" 236 part_name = "enterprise_device_management" 237} 238 239ohos_unittest("EdmFingerPrintPluginTest") { 240 module_out_path = module_output_path 241 242 include_dirs = [ "../../../../services/edm_plugin/include" ] 243 244 sources = [ "./src/fingerprint_auth_plugin_test.cpp" ] 245 246 configs = [ 247 ":module_private_config", 248 "../../../../common/config:coverage_flags", 249 ] 250 251 deps = [ 252 ":edm_all_plugin_static", 253 "../../../../common/native:edm_commom", 254 "../../../../interfaces/inner_api:edmservice_kits", 255 "../../../../interfaces/inner_api/plugin_kits:plugin_kits", 256 "../../utils:edm_unittest_utils", 257 "//third_party/googletest:gmock_main", 258 ] 259 260 external_deps = [ 261 "access_token:libaccesstoken_sdk", 262 "access_token:libnativetoken", 263 "access_token:libtoken_setproc", 264 "c_utils:utils", 265 "hilog:libhilog", 266 "init:libbegetutil", 267 "ipc:ipc_core", 268 ] 269 270 sanitize = { 271 boundary_sanitize = true 272 cfi = true 273 cfi_cross_dso = true 274 debug = false 275 integer_overflow = true 276 ubsan = true 277 blocklist = "../../cfi_blocklist.txt" 278 } 279 branch_protector_ret = "pac_ret" 280 subsystem_name = "customization" 281 part_name = "enterprise_device_management" 282} 283 284ohos_static_library("edm_all_plugin_static") { 285 visibility = [ ":*" ] 286 testonly = true 287 sources = [ 288 "../../../../services/edm/src/permission_manager.cpp", 289 "../../../../services/edm/src/plugin_manager.cpp", 290 "../../../../services/edm/src/strategy/enhance_execute_strategy.cpp", 291 "../../../../services/edm/src/strategy/replace_execute_strategy.cpp", 292 "../../../../services/edm/src/strategy/single_execute_strategy.cpp", 293 "../../../../services/edm_plugin/src/allowed_install_bundles_plugin.cpp", 294 "../../../../services/edm_plugin/src/bundle_install_plugin.cpp", 295 "../../../../services/edm_plugin/src/disallow_modify_datetime_plugin.cpp", 296 "../../../../services/edm_plugin/src/disallowed_install_bundles_plugin.cpp", 297 "../../../../services/edm_plugin/src/disallowed_uninstall_bundles_plugin.cpp", 298 "../../../../services/edm_plugin/src/get_device_encryption_status_plugin.cpp", 299 "../../../../services/edm_plugin/src/get_device_info_plugin.cpp", 300 "../../../../services/edm_plugin/src/get_display_version_plugin.cpp", 301 "../../../../services/edm_plugin/src/get_security_patch_tag_plugin.cpp", 302 "../../../../services/edm_plugin/src/install_plugin.cpp", 303 "../../../../services/edm_plugin/src/ntp_server_plugin.cpp", 304 "../../../../services/edm_plugin/src/operate_device_plugin.cpp", 305 "../../../../services/edm_plugin/src/password_policy_plugin.cpp", 306 "../../../../services/edm_plugin/src/power_policy_plugin.cpp", 307 "../../../../services/edm_plugin/src/screen_off_time_plugin.cpp", 308 "../../../../services/edm_plugin/src/uninstall_plugin.cpp", 309 "../../../../services/edm_plugin/src/utils/install_param_serializer.cpp", 310 "../../../../services/edm_plugin/src/utils/installer_callback.cpp", 311 "../../../../services/edm_plugin/src/utils/operate_device_param_serializer.cpp", 312 "../../../../services/edm_plugin/src/utils/password_policy_serializer.cpp", 313 "../../../../services/edm_plugin/src/utils/uninstall_param_serializer.cpp", 314 ] 315 316 configs = [ "../../../../common/config:coverage_flags" ] 317 318 include_dirs = [ 319 "../../../../services/edm/include", 320 "../../../../services/edm/include/strategy", 321 "../../../../services/edm_plugin/include", 322 "../../../../services/edm_plugin/include/utils", 323 "../../../../services/edm_plugin/include/network", 324 "../../../../services/edm_plugin/include/network/executer", 325 "../../../../services/edm_plugin/include/network/rule", 326 ] 327 328 deps = [ 329 "../../../../common/external:edm_external_adapters", 330 "../../../../common/native:edm_commom", 331 "../../../../interfaces/inner_api:edmservice_kits", 332 "../../../../interfaces/inner_api/plugin_kits:plugin_kits", 333 ] 334 335 external_deps = [ 336 "ability_base:want", 337 "ability_runtime:app_manager", 338 "access_token:libaccesstoken_sdk", 339 "bounds_checking_function:libsec_shared", 340 "bundle_framework:appexecfwk_base", 341 "bundle_framework:appexecfwk_core", 342 "cJSON:cjson", 343 "c_utils:utils", 344 "hilog:libhilog", 345 "init:libbegetutil", 346 "ipc:ipc_core", 347 "jsoncpp:jsoncpp", 348 "samgr:samgr_proxy", 349 "user_auth_framework:userauth_client", 350 ] 351 defines = [] 352 if (update_service_edm_enable) { 353 external_deps += [ "update_service:updateservicekits" ] 354 sources += 355 [ "../../../../services/edm_plugin/src/reset_factory_plugin.cpp" ] 356 } 357 358 if (os_account_edm_enable) { 359 external_deps += [ 360 "os_account:libaccountkits", 361 "os_account:os_account_innerkits", 362 ] 363 sources += [ 364 "../../../../services/edm_plugin/src/add_os_account_plugin.cpp", 365 "../../../../services/edm_plugin/src/disallow_add_local_account_plugin.cpp", 366 "../../../../services/edm_plugin/src/disallow_add_os_account_by_user_plugin.cpp", 367 ] 368 defines += [ "OS_ACCOUNT_EDM_ENABLE" ] 369 } 370 371 if (screenlock_mgr_edm_enable) { 372 external_deps += [ "screenlock_mgr:screenlock_client" ] 373 sources += [ "../../../../services/edm_plugin/src/lock_screen_plugin.cpp" ] 374 } 375 376 if (power_manager_edm_enable && screenlock_mgr_edm_enable) { 377 external_deps += [ "power_manager:powermgr_client" ] 378 sources += [ 379 "../../../../services/edm_plugin/src/reboot_plugin.cpp", 380 "../../../../services/edm_plugin/src/shutdown_plugin.cpp", 381 ] 382 } 383 384 if (wifi_edm_enable) { 385 external_deps += [ "wifi:wifi_sdk" ] 386 sources += [ 387 "../../../../common/native/src/plugin_utils/message_parcel_utils.cpp", 388 "../../../../services/edm_plugin/src/is_wifi_active_plugin.cpp", 389 "../../../../services/edm_plugin/src/set_wifi_disabled_plugin.cpp", 390 "../../../../services/edm_plugin/src/set_wifi_profile_plugin.cpp", 391 "../../../../services/edm_plugin/src/utils/wifi_device_config_serializer.cpp", 392 ] 393 defines += [ "WIFI_EDM_ENABLE" ] 394 } 395 396 if (netmanager_base_edm_enable && netmanager_ext_edm_enable) { 397 external_deps += [ 398 "netmanager_base:net_conn_manager_if", 399 "netmanager_base:netsys_controller", 400 "netmanager_ext:ethernet_manager_if", 401 ] 402 sources += [ 403 "../../../../services/edm_plugin/src/disabled_network_interface_plugin.cpp", 404 "../../../../services/edm_plugin/src/domain_filter_rule_plugin.cpp", 405 "../../../../services/edm_plugin/src/firewall_rule_plugin.cpp", 406 "../../../../services/edm_plugin/src/get_all_network_interfaces_plugin.cpp", 407 "../../../../services/edm_plugin/src/get_ip_address_plugin.cpp", 408 "../../../../services/edm_plugin/src/get_mac_plugin.cpp", 409 "../../../../services/edm_plugin/src/global_proxy_plugin.cpp", 410 "../../../../services/edm_plugin/src/iptables_rule_plugin.cpp", 411 "../../../../services/edm_plugin/src/network/executer/domain_executer.cpp", 412 "../../../../services/edm_plugin/src/network/executer/executer_factory.cpp", 413 "../../../../services/edm_plugin/src/network/executer/executer_utils.cpp", 414 "../../../../services/edm_plugin/src/network/executer/firewall_executer.cpp", 415 "../../../../services/edm_plugin/src/network/executer/iexecuter.cpp", 416 "../../../../services/edm_plugin/src/network/iptables_manager.cpp", 417 "../../../../services/edm_plugin/src/network/rule/chain_rule.cpp", 418 "../../../../services/edm_plugin/src/network/rule/domain_chain_rule.cpp", 419 "../../../../services/edm_plugin/src/network/rule/firewall_chain_rule.cpp", 420 "../../../../services/edm_plugin/src/network/rule/rule_utils.cpp", 421 "../../../../services/edm_plugin/src/utils/domain_filter_rule_serializer.cpp", 422 "../../../../services/edm_plugin/src/utils/firewall_rule_serializer.cpp", 423 "../../../../services/edm_plugin/src/utils/http_proxy_serializer.cpp", 424 ] 425 } 426 427 if (ability_runtime_edm_enable) { 428 external_deps += [ "ability_runtime:ability_manager" ] 429 sources += [ 430 "../../../../services/edm_plugin/src/disallowed_running_bundles_plugin.cpp", 431 "../../../../services/edm_plugin/src/manage_auto_start_apps_plugin.cpp", 432 ] 433 } 434 435 if (certificate_manager_edm_enable) { 436 external_deps += [ "certificate_manager:cert_manager_sdk" ] 437 sources += [ "../../../../services/edm_plugin/src/user_cert_plugin.cpp" ] 438 } 439 440 if (drivers_interface_usb_edm_enable && usb_manager_edm_enable) { 441 external_deps += [ "usb_manager:usbsrv_client" ] 442 sources += [ 443 "../../../../services/edm_plugin/src/allowed_usb_devices_plugin.cpp", 444 "../../../../services/edm_plugin/src/disable_usb_plugin.cpp", 445 "../../../../services/edm_plugin/src/disallowed_usb_devices_plugin.cpp", 446 "../../../../services/edm_plugin/src/utils/array_usb_device_id_serializer.cpp", 447 "../../../../services/edm_plugin/src/utils/array_usb_device_type_serializer.cpp", 448 "../../../../services/edm_plugin/src/utils/usb_policy_utils.cpp", 449 ] 450 } 451 452 if (drivers_interface_usb_edm_enable && storage_service_edm_enable && 453 usb_manager_edm_enable) { 454 external_deps += [ "storage_service:storage_manager_sa_proxy" ] 455 sources += 456 [ "../../../../services/edm_plugin/src/usb_read_only_plugin.cpp" ] 457 } 458 459 if (audio_framework_edm_enable) { 460 external_deps += [ "audio_framework:audio_client" ] 461 sources += [ 462 "../../../../services/edm_plugin/src/disable_hdc_plugin.cpp", 463 "../../../../services/edm_plugin/src/disable_microphone_plugin.cpp", 464 "../../../../services/edm_plugin/src/disable_printer_plugin.cpp", 465 "../../../../services/edm_plugin/src/fingerprint_auth_plugin.cpp", 466 ] 467 } 468 469 if (common_event_service_edm_enable) { 470 external_deps += [ "common_event_service:cesfwk_innerkits" ] 471 sources += [ 472 "../../../../services/edm_plugin/src/set_browser_policies_plugin.cpp", 473 ] 474 } 475 476 if (bluetooth_edm_enable) { 477 external_deps += [ "bluetooth:btframework" ] 478 sources += [ 479 "../../../../services/edm_plugin/src/allowed_bluetooth_devices_plugin.cpp", 480 "../../../../services/edm_plugin/src/disable_bluetooth_plugin.cpp", 481 "../../../../services/edm_plugin/src/get_bluetooth_info_plugin.cpp", 482 ] 483 } 484 485 if (location_edm_enable) { 486 external_deps += [ "location:locator_sdk" ] 487 sources += 488 [ "../../../../services/edm_plugin/src/location_policy_plugin.cpp" ] 489 } 490 491 if (telephony_core_edm_enable) { 492 external_deps += [ "core_service:tel_core_service_api" ] 493 defines += [ "TELEPHONY_CORE_EDM_ENABLE_TEST" ] 494 } 495 496 if (pasteboard_edm_enable) { 497 external_deps += [ "pasteboard:pasteboard_client" ] 498 sources += [ 499 "../../../../services/edm_plugin/src/clipboard_policy_plugin.cpp", 500 "../../../../services/edm_plugin/src/utils/clipboard_policy_serializer.cpp", 501 "../../../../services/edm_plugin/src/utils/clipboard_utils.cpp", 502 ] 503 } 504 505 if (camera_framework_edm_enable) { 506 external_deps += [ "camera_framework:camera_framework" ] 507 sources += 508 [ "../../../../services/edm_plugin/src/disable_camera_plugin.cpp" ] 509 } 510 511 sanitize = { 512 boundary_sanitize = true 513 cfi = true 514 cfi_cross_dso = true 515 debug = false 516 integer_overflow = true 517 ubsan = true 518 } 519 branch_protector_ret = "pac_ret" 520 subsystem_name = "customization" 521 part_name = "enterprise_device_management" 522} 523 524group("unittest") { 525 testonly = true 526 527 deps = [ 528 # deps file 529 ":EdmFingerPrintPluginTest", 530 ":EdmPluginTest", 531 ] 532} 533