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