1#
2# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16import("//build/ohos.gni")
17import("//build/test.gni")
18
19if (!defined(global_parts_info) ||
20    defined(global_parts_info.account_os_account)) {
21  has_os_account_part = true
22} else {
23  has_os_account_part = false
24}
25
26module_output_path = "device_auth/deviceauth_test"
27
28hichain_sources = [
29  "../../source/auth_info/auth_info.c",
30  "../../source/auth_info/exchange_auth_info_client.c",
31  "../../source/auth_info/remove_auth_info.c",
32  "../../source/auth_info/remove_auth_info_client.c",
33  "../../source/hichain.c",
34  "../../source/huks_adapter/huks_adapter.c",
35  "../../source/json/commonutil.c",
36  "../../source/json/jsonutil.c",
37  "../../source/key_agreement/key_agreement.c",
38  "../../source/key_agreement/key_agreement_client.c",
39  "../../source/key_agreement/key_agreement_server.c",
40  "../../source/key_agreement/pake_client.c",
41  "../../source/key_agreement/pake_server.c",
42  "../../source/key_agreement/sec_clone_server.c",
43  "../../source/key_agreement/sts_client.c",
44  "../../source/key_agreement/sts_server.c",
45  "../../source/log/log.c",
46  "../../source/os_account_adapter/os_account_adapter.cpp",
47  "../../source/schedule/build_object.c",
48  "../../source/schedule/distribution.c",
49  "../../source/struct/add_auth_info_data.c",
50  "../../source/struct/auth_ack_request.c",
51  "../../source/struct/auth_ack_response.c",
52  "../../source/struct/auth_start_request.c",
53  "../../source/struct/auth_start_response.c",
54  "../../source/struct/exchange_auth_data.c",
55  "../../source/struct/exchange_request.c",
56  "../../source/struct/exchange_response.c",
57  "../../source/struct/inform_message.c",
58  "../../source/struct/key_agreement_version.c",
59  "../../source/struct/pake_client_confirm.c",
60  "../../source/struct/pake_request.c",
61  "../../source/struct/pake_response.c",
62  "../../source/struct/pake_server_confirm.c",
63  "../../source/struct/parsedata.c",
64  "../../source/struct/rmv_auth_info_data.c",
65  "../../source/struct/rmv_auth_info_request.c",
66  "../../source/struct/rmv_auth_info_response.c",
67  "../../source/struct/sec_clone_data.c",
68]
69
70config("standard_config") {
71  visibility = [ ":*" ]
72  include_dirs = [
73    "//base/security/device_auth/interfaces/inner_api/deviceauth_lite",
74    "../unittest",
75    "../../inc/base",
76    "../../inc/huks_adapter",
77    "../../inc/json",
78    "../../inc/key_agreement",
79    "../../inc/log",
80    "../../inc/os_account_adapter",
81    "../../inc/schedule",
82    "../../inc/struct",
83    "../../inc/auth_info",
84  ]
85
86  defines = [ "_CUT_REMOVE_" ]
87  if (has_os_account_part) {
88    defines += [ "HAS_OS_ACCOUNT_PART" ]
89  }
90}
91
92ohos_unittest("DeviceAuthTest") {
93  module_out_path = module_output_path
94  testonly = true
95  configs = [ ":standard_config" ]
96  sources = hichain_sources
97  sources -= [ "../../source/huks_adapter/huks_adapter.c" ]
98  sources += [
99    "./unittest_mock/huks_adapter_mock.c",
100    "deviceauth_test.cpp",
101    "hichain_receivedata_test.cpp",
102  ]
103
104  cflags = [
105    "--coverage",
106    "-Wall",
107    "-fvisibility=hidden",
108  ]
109
110  ldflags = [ "--coverage" ]
111
112  external_deps = [
113    "bounds_checking_function:libsec_shared",
114    "cJSON:cjson",
115    "c_utils:utils",
116    "googletest:gmock_main",
117    "googletest:gtest_main",
118    "hilog:libhilog",
119    "huks:libhukssdk",
120  ]
121  if (has_os_account_part) {
122    external_deps += [ "os_account:os_account_innerkits" ]
123  }
124}
125
126ohos_unittest("HuksAdapterTest") {
127  module_out_path = module_output_path
128  testonly = true
129  configs = [ ":standard_config" ]
130  sources = hichain_sources
131  sources += [ "huks_adapter_test.cpp" ]
132
133  deps = []
134
135  cflags = [
136    "--coverage",
137    "-fvisibility=hidden",
138  ]
139
140  ldflags = [ "--coverage" ]
141
142  external_deps = [
143    "bounds_checking_function:libsec_shared",
144    "cJSON:cjson",
145    "c_utils:utils",
146    "googletest:gmock_main",
147    "googletest:gtest_main",
148    "hilog:libhilog",
149    "huks:libhukssdk",
150  ]
151  if (has_os_account_part) {
152    external_deps += [ "os_account:os_account_innerkits" ]
153  }
154}
155
156ohos_unittest("PakeTest") {
157  module_out_path = module_output_path
158  testonly = true
159  configs = [ ":standard_config" ]
160  sources = hichain_sources
161  sources -= [ "../../source/huks_adapter/huks_adapter.c" ]
162  sources += [
163    "./unittest_mock/huks_adapter_mock_for_pake.c",
164    "hichain_pake_test.cpp",
165  ]
166
167  deps = []
168
169  cflags = [
170    "--coverage",
171    "-fvisibility=hidden",
172  ]
173
174  ldflags = [ "--coverage" ]
175
176  external_deps = [
177    "bounds_checking_function:libsec_shared",
178    "cJSON:cjson",
179    "c_utils:utils",
180    "googletest:gmock_main",
181    "googletest:gtest_main",
182    "hilog:libhilog",
183    "huks:libhukssdk",
184  ]
185
186  if (has_os_account_part) {
187    external_deps += [ "os_account:os_account_innerkits" ]
188  }
189}
190