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 += [ 168 "drivers_interface_usb:libusb_proxy_1.0", 169 "usb_manager:usbsrv_client", 170 ] 171 sources += [ 172 "./src/allowed_usb_devices_plugin_test.cpp", 173 "./src/disable_usb_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 sanitize = { 224 boundary_sanitize = true 225 cfi = true 226 cfi_cross_dso = true 227 debug = false 228 integer_overflow = true 229 ubsan = true 230 blocklist = "../../cfi_blocklist.txt" 231 } 232 branch_protector_ret = "pac_ret" 233 subsystem_name = "customization" 234 part_name = "enterprise_device_management" 235} 236 237ohos_unittest("EdmFingerPrintPluginTest") { 238 module_out_path = module_output_path 239 240 include_dirs = [ "../../../../services/edm_plugin/include" ] 241 242 sources = [ "./src/fingerprint_auth_plugin_test.cpp" ] 243 244 configs = [ 245 ":module_private_config", 246 "../../../../common/config:coverage_flags", 247 ] 248 249 deps = [ 250 ":edm_all_plugin_static", 251 "../../../../common/native:edm_commom", 252 "../../../../interfaces/inner_api:edmservice_kits", 253 "../../../../interfaces/inner_api/plugin_kits:plugin_kits", 254 "../../utils:edm_unittest_utils", 255 "//third_party/googletest:gmock_main", 256 ] 257 258 external_deps = [ 259 "access_token:libaccesstoken_sdk", 260 "access_token:libnativetoken", 261 "access_token:libtoken_setproc", 262 "c_utils:utils", 263 "hilog:libhilog", 264 "init:libbegetutil", 265 "ipc:ipc_core", 266 ] 267 268 sanitize = { 269 boundary_sanitize = true 270 cfi = true 271 cfi_cross_dso = true 272 debug = false 273 integer_overflow = true 274 ubsan = true 275 blocklist = "../../cfi_blocklist.txt" 276 } 277 branch_protector_ret = "pac_ret" 278 subsystem_name = "customization" 279 part_name = "enterprise_device_management" 280} 281 282ohos_static_library("edm_all_plugin_static") { 283 visibility = [ ":*" ] 284 testonly = true 285 sources = [ 286 "../../../../services/edm/src/permission_manager.cpp", 287 "../../../../services/edm/src/plugin_manager.cpp", 288 "../../../../services/edm/src/strategy/enhance_execute_strategy.cpp", 289 "../../../../services/edm/src/strategy/replace_execute_strategy.cpp", 290 "../../../../services/edm/src/strategy/single_execute_strategy.cpp", 291 "../../../../services/edm_plugin/src/allowed_install_bundles_plugin.cpp", 292 "../../../../services/edm_plugin/src/bundle_install_plugin.cpp", 293 "../../../../services/edm_plugin/src/disallow_modify_datetime_plugin.cpp", 294 "../../../../services/edm_plugin/src/disallowed_install_bundles_plugin.cpp", 295 "../../../../services/edm_plugin/src/disallowed_uninstall_bundles_plugin.cpp", 296 "../../../../services/edm_plugin/src/get_device_encryption_status_plugin.cpp", 297 "../../../../services/edm_plugin/src/get_device_info_plugin.cpp", 298 "../../../../services/edm_plugin/src/get_display_version_plugin.cpp", 299 "../../../../services/edm_plugin/src/get_security_patch_tag_plugin.cpp", 300 "../../../../services/edm_plugin/src/install_plugin.cpp", 301 "../../../../services/edm_plugin/src/ntp_server_plugin.cpp", 302 "../../../../services/edm_plugin/src/operate_device_plugin.cpp", 303 "../../../../services/edm_plugin/src/password_policy_plugin.cpp", 304 "../../../../services/edm_plugin/src/power_policy_plugin.cpp", 305 "../../../../services/edm_plugin/src/screen_off_time_plugin.cpp", 306 "../../../../services/edm_plugin/src/uninstall_plugin.cpp", 307 "../../../../services/edm_plugin/src/utils/install_param_serializer.cpp", 308 "../../../../services/edm_plugin/src/utils/installer_callback.cpp", 309 "../../../../services/edm_plugin/src/utils/operate_device_param_serializer.cpp", 310 "../../../../services/edm_plugin/src/utils/password_policy_serializer.cpp", 311 "../../../../services/edm_plugin/src/utils/uninstall_param_serializer.cpp", 312 ] 313 314 configs = [ "../../../../common/config:coverage_flags" ] 315 316 include_dirs = [ 317 "../../../../services/edm/include", 318 "../../../../services/edm/include/strategy", 319 "../../../../services/edm_plugin/include", 320 "../../../../services/edm_plugin/include/utils", 321 "../../../../services/edm_plugin/include/network", 322 "../../../../services/edm_plugin/include/network/executer", 323 "../../../../services/edm_plugin/include/network/rule", 324 ] 325 326 deps = [ 327 "../../../../common/external:edm_external_adapters", 328 "../../../../common/native:edm_commom", 329 "../../../../interfaces/inner_api:edmservice_kits", 330 "../../../../interfaces/inner_api/plugin_kits:plugin_kits", 331 ] 332 333 external_deps = [ 334 "ability_base:want", 335 "bounds_checking_function:libsec_shared", 336 "bundle_framework:appexecfwk_base", 337 "bundle_framework:appexecfwk_core", 338 "cJSON:cjson", 339 "c_utils:utils", 340 "hilog:libhilog", 341 "init:libbegetutil", 342 "ipc:ipc_core", 343 "jsoncpp:jsoncpp", 344 "samgr:samgr_proxy", 345 "user_auth_framework:userauth_client", 346 ] 347 defines = [] 348 if (update_service_edm_enable) { 349 external_deps += [ "update_service:updateservicekits" ] 350 sources += 351 [ "../../../../services/edm_plugin/src/reset_factory_plugin.cpp" ] 352 } 353 354 if (os_account_edm_enable) { 355 external_deps += [ 356 "os_account:libaccountkits", 357 "os_account:os_account_innerkits", 358 ] 359 sources += [ 360 "../../../../services/edm_plugin/src/add_os_account_plugin.cpp", 361 "../../../../services/edm_plugin/src/disallow_add_local_account_plugin.cpp", 362 "../../../../services/edm_plugin/src/disallow_add_os_account_by_user_plugin.cpp", 363 ] 364 defines += [ "OS_ACCOUNT_EDM_ENABLE" ] 365 } 366 367 if (screenlock_mgr_edm_enable) { 368 external_deps += [ "screenlock_mgr:screenlock_client" ] 369 sources += [ "../../../../services/edm_plugin/src/lock_screen_plugin.cpp" ] 370 } 371 372 if (power_manager_edm_enable && screenlock_mgr_edm_enable) { 373 external_deps += [ "power_manager:powermgr_client" ] 374 sources += [ 375 "../../../../services/edm_plugin/src/reboot_plugin.cpp", 376 "../../../../services/edm_plugin/src/shutdown_plugin.cpp", 377 ] 378 } 379 380 if (wifi_edm_enable) { 381 external_deps += [ "wifi:wifi_sdk" ] 382 sources += [ 383 "../../../../common/native/src/plugin_utils/message_parcel_utils.cpp", 384 "../../../../services/edm_plugin/src/is_wifi_active_plugin.cpp", 385 "../../../../services/edm_plugin/src/set_wifi_disabled_plugin.cpp", 386 "../../../../services/edm_plugin/src/set_wifi_profile_plugin.cpp", 387 "../../../../services/edm_plugin/src/utils/wifi_device_config_serializer.cpp", 388 ] 389 defines += [ "WIFI_EDM_ENABLE" ] 390 } 391 392 if (netmanager_base_edm_enable && netmanager_ext_edm_enable) { 393 external_deps += [ 394 "netmanager_base:net_conn_manager_if", 395 "netmanager_base:netsys_controller", 396 "netmanager_ext:ethernet_manager_if", 397 ] 398 sources += [ 399 "../../../../services/edm_plugin/src/disabled_network_interface_plugin.cpp", 400 "../../../../services/edm_plugin/src/domain_filter_rule_plugin.cpp", 401 "../../../../services/edm_plugin/src/firewall_rule_plugin.cpp", 402 "../../../../services/edm_plugin/src/get_all_network_interfaces_plugin.cpp", 403 "../../../../services/edm_plugin/src/get_ip_address_plugin.cpp", 404 "../../../../services/edm_plugin/src/get_mac_plugin.cpp", 405 "../../../../services/edm_plugin/src/global_proxy_plugin.cpp", 406 "../../../../services/edm_plugin/src/iptables_rule_plugin.cpp", 407 "../../../../services/edm_plugin/src/network/executer/domain_executer.cpp", 408 "../../../../services/edm_plugin/src/network/executer/executer_factory.cpp", 409 "../../../../services/edm_plugin/src/network/executer/executer_utils.cpp", 410 "../../../../services/edm_plugin/src/network/executer/firewall_executer.cpp", 411 "../../../../services/edm_plugin/src/network/executer/iexecuter.cpp", 412 "../../../../services/edm_plugin/src/network/iptables_manager.cpp", 413 "../../../../services/edm_plugin/src/network/rule/chain_rule.cpp", 414 "../../../../services/edm_plugin/src/network/rule/domain_chain_rule.cpp", 415 "../../../../services/edm_plugin/src/network/rule/firewall_chain_rule.cpp", 416 "../../../../services/edm_plugin/src/network/rule/rule_utils.cpp", 417 "../../../../services/edm_plugin/src/utils/domain_filter_rule_serializer.cpp", 418 "../../../../services/edm_plugin/src/utils/firewall_rule_serializer.cpp", 419 "../../../../services/edm_plugin/src/utils/http_proxy_serializer.cpp", 420 ] 421 } 422 423 if (ability_runtime_edm_enable) { 424 external_deps += [ "ability_runtime:ability_manager" ] 425 sources += [ 426 "../../../../services/edm_plugin/src/disallowed_running_bundles_plugin.cpp", 427 "../../../../services/edm_plugin/src/manage_auto_start_apps_plugin.cpp", 428 ] 429 } 430 431 if (certificate_manager_edm_enable) { 432 external_deps += [ "certificate_manager:cert_manager_sdk" ] 433 sources += [ "../../../../services/edm_plugin/src/user_cert_plugin.cpp" ] 434 } 435 436 if (drivers_interface_usb_edm_enable && usb_manager_edm_enable) { 437 external_deps += [ 438 "drivers_interface_usb:libusb_proxy_1.0", 439 "usb_manager:usbsrv_client", 440 ] 441 sources += [ 442 "../../../../services/edm_plugin/src/allowed_usb_devices_plugin.cpp", 443 "../../../../services/edm_plugin/src/disable_usb_plugin.cpp", 444 "../../../../services/edm_plugin/src/utils/array_usb_device_id_serializer.cpp", 445 "../../../../services/edm_plugin/src/utils/usb_policy_utils.cpp", 446 ] 447 } 448 449 if (drivers_interface_usb_edm_enable && storage_service_edm_enable && 450 usb_manager_edm_enable) { 451 external_deps += [ "storage_service:storage_manager_sa_proxy" ] 452 sources += 453 [ "../../../../services/edm_plugin/src/usb_read_only_plugin.cpp" ] 454 } 455 456 if (audio_framework_edm_enable) { 457 external_deps += [ "audio_framework:audio_client" ] 458 sources += [ 459 "../../../../services/edm_plugin/src/disable_hdc_plugin.cpp", 460 "../../../../services/edm_plugin/src/disable_microphone_plugin.cpp", 461 "../../../../services/edm_plugin/src/disable_printer_plugin.cpp", 462 "../../../../services/edm_plugin/src/fingerprint_auth_plugin.cpp", 463 ] 464 } 465 466 if (common_event_service_edm_enable) { 467 external_deps += [ "common_event_service:cesfwk_innerkits" ] 468 sources += [ 469 "../../../../services/edm_plugin/src/set_browser_policies_plugin.cpp", 470 ] 471 } 472 473 if (bluetooth_edm_enable) { 474 external_deps += [ "bluetooth:btframework" ] 475 sources += [ 476 "../../../../services/edm_plugin/src/allowed_bluetooth_devices_plugin.cpp", 477 "../../../../services/edm_plugin/src/disable_bluetooth_plugin.cpp", 478 "../../../../services/edm_plugin/src/get_bluetooth_info_plugin.cpp", 479 ] 480 } 481 482 if (location_edm_enable) { 483 external_deps += [ "location:locator_sdk" ] 484 sources += 485 [ "../../../../services/edm_plugin/src/location_policy_plugin.cpp" ] 486 } 487 488 if (telephony_core_edm_enable) { 489 external_deps += [ "core_service:tel_core_service_api" ] 490 defines += [ "TELEPHONY_CORE_EDM_ENABLE_TEST" ] 491 } 492 493 if (pasteboard_edm_enable) { 494 external_deps += [ "pasteboard:pasteboard_client" ] 495 sources += [ 496 "../../../../services/edm_plugin/src/clipboard_policy_plugin.cpp", 497 "../../../../services/edm_plugin/src/utils/clipboard_policy_serializer.cpp", 498 "../../../../services/edm_plugin/src/utils/clipboard_utils.cpp", 499 ] 500 } 501 502 sanitize = { 503 boundary_sanitize = true 504 cfi = true 505 cfi_cross_dso = true 506 debug = false 507 integer_overflow = true 508 ubsan = true 509 } 510 branch_protector_ret = "pac_ret" 511 subsystem_name = "customization" 512 part_name = "enterprise_device_management" 513} 514 515group("unittest") { 516 testonly = true 517 518 deps = [ 519 # deps file 520 ":EdmFingerPrintPluginTest", 521 ":EdmPluginTest", 522 ] 523} 524