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