1 /*
2  * Copyright (c) 2021-2023 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 
16 #include "user_auth_hdi_test.h"
17 #include "iam_hat_test.h"
18 
19 using namespace std;
20 using namespace testing::ext;
21 using namespace OHOS::UserIam::Common;
22 using namespace OHOS::HDI::UserAuth;
23 using namespace OHOS::HDI::UserAuth::V2_0;
24 
25 static const uint32_t MAX_FUZZ_STRUCT_LEN = 20;
26 static UserAuthInterfaceService g_service;
27 int32_t Expectedvalue = 0;
28 static OHOS::Parcel parcel;
29 
SetUpTestCase()30 void UserIamUserAuthTest::SetUpTestCase()
31 {
32 }
33 
TearDownTestCase()34 void UserIamUserAuthTest::TearDownTestCase()
35 {
36 }
37 
SetUp()38 void UserIamUserAuthTest::SetUp()
39 {
40 }
41 
TearDown()42 void UserIamUserAuthTest::TearDown()
43 {
44 }
45 
FillAuthTypeVector(Parcel &parcel, vector<int32_t> &vector)46 static void FillAuthTypeVector(Parcel &parcel, vector<int32_t> &vector)
47 {
48     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
49     vector.resize(len);
50     for (uint32_t i = 0; i < len; i++) {
51         vector[i] = parcel.ReadInt32();
52     }
53 }
54 
FillEnrollParam(Parcel &parcel, EnrollParam &enrollParam)55 static void FillEnrollParam(Parcel &parcel, EnrollParam &enrollParam)
56 {
57     enrollParam.authType = static_cast<AuthType>(parcel.ReadInt32());
58     enrollParam.executorSensorHint = parcel.ReadUint32();
59     enrollParam.userId = parcel.ReadInt32();
60 }
61 
FillExecutorRegisterInfo(Parcel &parcel, ExecutorRegisterInfo &executorRegisterInfo)62 static void FillExecutorRegisterInfo(Parcel &parcel, ExecutorRegisterInfo &executorRegisterInfo)
63 {
64     executorRegisterInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
65     executorRegisterInfo.executorRole = static_cast<ExecutorRole>(parcel.ReadInt32());
66     executorRegisterInfo.executorSensorHint = parcel.ReadUint32();
67     executorRegisterInfo.executorMatcher = parcel.ReadUint32();
68     executorRegisterInfo.esl = static_cast<ExecutorSecureLevel>(parcel.ReadInt32());
69     FillTestUint8Vector(parcel, executorRegisterInfo.publicKey);
70 }
71 
FillExecutorIndexInfo(Parcel &parcel, uint64_t &executorIndex)72 static void FillExecutorIndexInfo(Parcel &parcel, uint64_t &executorIndex)
73 {
74     executorIndex = parcel.ReadUint64();
75 }
76 
FillExecutorIndexVector(Parcel &parcel, vector<uint64_t > &vector)77 static void FillExecutorIndexVector(Parcel &parcel, vector<uint64_t > &vector)
78 {
79     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
80     vector.resize(len);
81     for (uint32_t i = 0; i < len; i++) {
82         FillExecutorIndexInfo(parcel, vector[i]);
83     }
84 }
85 
FillScheduleInfo(Parcel &parcel, ScheduleInfo &scheduleInfo)86 static void FillScheduleInfo(Parcel &parcel, ScheduleInfo &scheduleInfo)
87 {
88     scheduleInfo.scheduleId = parcel.ReadUint64();
89     FillTestUint64Vector(parcel, scheduleInfo.templateIds);
90     scheduleInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
91     scheduleInfo.executorMatcher = parcel.ReadUint32();
92     scheduleInfo.scheduleMode = static_cast<ScheduleMode>(parcel.ReadInt32());
93     FillExecutorIndexVector(parcel, scheduleInfo.executorIndexes);
94 }
95 
FillCredentialInfo(Parcel &parcel, CredentialInfo &credentialInfo)96 static void FillCredentialInfo(Parcel &parcel, CredentialInfo &credentialInfo)
97 {
98     credentialInfo.credentialId = parcel.ReadUint64();
99     credentialInfo.executorIndex = parcel.ReadUint64();
100     credentialInfo.templateId = parcel.ReadUint64();
101     credentialInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
102     credentialInfo.executorMatcher = parcel.ReadUint32();
103     credentialInfo.executorSensorHint = parcel.ReadUint32();
104 }
105 
FillEnrolledInfo(Parcel &parcel, EnrolledInfo &enrolledInfo)106 static void FillEnrolledInfo(Parcel &parcel, EnrolledInfo &enrolledInfo)
107 {
108     enrolledInfo.enrolledId = parcel.ReadUint64();
109     enrolledInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
110 }
111 
FillIdentifyResultInfo(Parcel &parcel, IdentifyResultInfo &identifyResultInfo)112 static void FillIdentifyResultInfo(Parcel &parcel, IdentifyResultInfo &identifyResultInfo)
113 {
114     identifyResultInfo.result = parcel.ReadInt32();
115     identifyResultInfo.userId = parcel.ReadInt32();
116     FillTestUint8Vector(parcel, identifyResultInfo.token);
117 }
118 
FillExecutorSendMsg(Parcel &parcel, ExecutorSendMsg &executorSendMsg)119 static void FillExecutorSendMsg(Parcel &parcel, ExecutorSendMsg &executorSendMsg)
120 {
121     executorSendMsg.executorIndex = parcel.ReadUint32();
122     FillTestUint8Vector(parcel, executorSendMsg.msg);
123 }
124 
FillAuthParam(Parcel &parcel, AuthParam &authParam)125 static void FillAuthParam(Parcel &parcel, AuthParam &authParam)
126 {
127     authParam.baseParam.userId = parcel.ReadInt32();
128     authParam.baseParam.authTrustLevel = parcel.ReadUint32();
129     authParam.authType = static_cast<AuthType>(parcel.ReadInt32());
130     authParam.baseParam.executorSensorHint = parcel.ReadUint32();
131     FillTestUint8Vector(parcel, authParam.baseParam.challenge);
132 }
133 
FillScheduleInfoVector(Parcel &parcel, vector<ScheduleInfo> &vector)134 static void FillScheduleInfoVector(Parcel &parcel, vector<ScheduleInfo> &vector)
135 {
136     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
137     vector.resize(len);
138     for (uint32_t i = 0; i < len; i++) {
139         FillScheduleInfo(parcel, vector[i]);
140     }
141 }
142 
FillCredentialInfoVector(Parcel &parcel, vector<CredentialInfo> &vector)143 static void FillCredentialInfoVector(Parcel &parcel, vector<CredentialInfo> &vector)
144 {
145     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
146     vector.resize(len);
147     for (uint32_t i = 0; i < len; i++) {
148         FillCredentialInfo(parcel, vector[i]);
149     }
150 }
151 
FillEnrolledInfoVector(Parcel &parcel, vector<EnrolledInfo> &vector)152 static void FillEnrolledInfoVector(Parcel &parcel, vector<EnrolledInfo> &vector)
153 {
154     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
155     vector.resize(len);
156     for (uint32_t i = 0; i < len; i++) {
157         FillEnrolledInfo(parcel, vector[i]);
158     }
159 }
160 
FillExecutorSendMsgVector(Parcel &parcel, vector<ExecutorSendMsg> &vector)161 static void FillExecutorSendMsgVector(Parcel &parcel, vector<ExecutorSendMsg> &vector)
162 {
163     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
164     vector.resize(len);
165     for (uint32_t i = 0; i < len; i++) {
166         FillExecutorSendMsg(parcel, vector[i]);
167     }
168 }
169 
FillAuthResultInfo(Parcel &parcel, AuthResultInfo &authResultInfo)170 static void FillAuthResultInfo(Parcel &parcel, AuthResultInfo &authResultInfo)
171 {
172     authResultInfo.result = parcel.ReadUint32();
173     authResultInfo.lockoutDuration = parcel.ReadInt32();
174     authResultInfo.remainAttempts = parcel.ReadInt32();
175     FillExecutorSendMsgVector(parcel, authResultInfo.msgs);
176     FillTestUint8Vector(parcel, authResultInfo.token);
177 }
178 
FillTestScheduleInfo(Parcel &parcel, ScheduleInfo &scheduleInfo)179 void FillTestScheduleInfo(Parcel &parcel, ScheduleInfo &scheduleInfo)
180 {
181     scheduleInfo.scheduleId = parcel.ReadUint64();
182     FillTestUint64Vector(parcel, scheduleInfo.templateIds);
183     scheduleInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
184     scheduleInfo.executorMatcher = parcel.ReadUint32();
185     scheduleInfo.scheduleMode = static_cast<ScheduleMode>(parcel.ReadInt32());
186     FillExecutorIndexVector(parcel, scheduleInfo.executorIndexes);
187     std::vector<uint8_t> extraInfo;
188     FillTestUint8Vector(parcel, extraInfo);
189     scheduleInfo.executorMessages.push_back(extraInfo);
190     cout << "success"  << endl;
191 }
192 
FillTestScheduleInfo_Vector(Parcel &parcel, vector<ScheduleInfo> &vector)193 void FillTestScheduleInfo_Vector(Parcel &parcel, vector<ScheduleInfo> &vector)
194 {
195     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
196     vector.resize(len);
197     for (uint32_t i = 0; i < len; i++) {
198         FillTestScheduleInfo(parcel, vector[i]);
199     }
200     cout << "success"  << endl;
201 }
202 
203 /**
204  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0101
205  * @tc.name: Test Init
206  * @tc.size: MediumTest
207  * @tc.type: Function
208  * @tc.level: Level1
209  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0101, Function | MediumTest | Level1)210 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0101, Function | MediumTest | Level1)
211 {
212     cout << "start Init" << endl;
213     const std::string deviceUdid = std::string(64, '0');
214     int32_t ret = g_service.Init(deviceUdid);
215     EXPECT_EQ(ret, 0);
216 }
217 
218 /**
219  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0102
220  * @tc.name: Test AddExecutor
221  * @tc.size: MediumTest
222  * @tc.type: Function
223  * @tc.level: Level1
224  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0102, Function | MediumTest | Level1)225 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0102, Function | MediumTest | Level1)
226 {
227     cout << "start AddExecutor" << endl;
228     ExecutorRegisterInfo info;
229     FillExecutorRegisterInfo(parcel, info);
230     uint64_t index = parcel.ReadUint64();
231     std::vector<uint8_t> publicKey;
232     FillTestUint8Vector(parcel, publicKey);
233     std::vector<uint64_t> templateIds;
234     FillTestUint64Vector(parcel, templateIds);
235     int32_t ret = g_service.AddExecutor(info, index, publicKey, templateIds);
236     cout << "ret is " << ret << endl;
237     ASSERT_EQ(ret != Expectedvalue, true);
238 }
239 
240 /**
241  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0103
242  * @tc.name: Test GetCredential
243  * @tc.size: MediumTest
244  * @tc.type: Function
245  * @tc.level: Level1
246  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0103, Function | MediumTest | Level1)247 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0103, Function | MediumTest | Level1)
248 {
249     cout << "start GetCredential" << endl;
250     int32_t userId = parcel.ReadInt32();
251     int32_t authType = static_cast<int32_t>(parcel.ReadInt32());
252     std::vector<CredentialInfo> infos;
253     FillCredentialInfoVector(parcel, infos);
254     int32_t ret = g_service.GetCredential(userId, authType, infos);
255     cout << "ret is " << ret << endl;
256     EXPECT_EQ(ret, 0);
257 }
258 
259 /**
260  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0104
261  * @tc.name: Test GetUserInfo
262  * @tc.size: MediumTest
263  * @tc.type: Function
264  * @tc.level: Level1
265  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0104, Function | MediumTest | Level1)266 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0104, Function | MediumTest | Level1)
267 {
268     cout << "start GetUserInfo" << endl;
269     int32_t userId = parcel.ReadInt32();
270     uint64_t secureUid = parcel.ReadUint64();
271     int32_t pinSubType = static_cast<int32_t>(parcel.ReadUint32());
272     std::vector<EnrolledInfo> infos;
273     FillEnrolledInfoVector(parcel, infos);
274     int32_t ret = g_service.GetUserInfo(userId, secureUid, pinSubType, infos);
275     cout << "ret is " << ret << endl;
276     ASSERT_EQ(ret != Expectedvalue, true);
277 }
278 
279 /**
280  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0105
281  * @tc.name: Test DeleteUser
282  * @tc.size: MediumTest
283  * @tc.type: Function
284  * @tc.level: Level1
285  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0105, Function | MediumTest | Level1)286 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0105, Function | MediumTest | Level1)
287 {
288     cout << "start DeleteUser" << endl;
289     int32_t userId = parcel.ReadInt32();
290     std::vector<uint8_t> authToken;
291     FillTestUint8Vector(parcel, authToken);
292     std::vector<CredentialInfo> deletedInfos;
293     FillCredentialInfoVector(parcel, deletedInfos);
294     std::vector<uint8_t> rootSecret;
295     FillTestUint8Vector(parcel, rootSecret);
296     int32_t ret = g_service.DeleteUser(userId, authToken, deletedInfos, rootSecret);
297     cout << "ret is " << ret << endl;
298     ASSERT_EQ(ret != Expectedvalue, true);
299 }
300 
301 /**
302  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0106
303  * @tc.name: Test BeginIdentification
304  * @tc.size: MediumTest
305  * @tc.type: Function
306  * @tc.level: Level1
307  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0106, Function | MediumTest | Level1)308 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0106, Function | MediumTest | Level1)
309 {
310     cout << "start BeginIdentification" << endl;
311     uint64_t contextId = parcel.ReadUint64();
312     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
313     std::vector<uint8_t> challenge;
314     FillTestUint8Vector(parcel, challenge);
315     uint32_t executorId = parcel.ReadUint32();
316     ScheduleInfo scheduleInfo;
317     FillScheduleInfo(parcel, scheduleInfo);
318     int32_t ret = g_service.BeginIdentification(contextId, authType, challenge, executorId, scheduleInfo);
319     cout << "ret is " << ret << endl;
320     ASSERT_EQ(ret != Expectedvalue, true);
321 }
322 
323 /**
324  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0107
325  * @tc.name: Test DeleteExecutor
326  * @tc.size: MediumTest
327  * @tc.type: Function
328  * @tc.level: Level1
329  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0107, Function | MediumTest | Level1)330 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0107, Function | MediumTest | Level1)
331 {
332     cout << "start DeleteExecutor" << endl;
333     uint64_t index = parcel.ReadUint64();
334     int32_t ret = g_service.DeleteExecutor(index);
335     cout << "ret is " << ret << endl;
336     ASSERT_EQ(ret != Expectedvalue, true);
337 }
338 
339 /**
340  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0108
341  * @tc.name: Test OpenSession
342  * @tc.size: MediumTest
343  * @tc.type: Function
344  * @tc.level: Level1
345  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0108, Function | MediumTest | Level1)346 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0108, Function | MediumTest | Level1)
347 {
348     cout << "start OpenSession" << endl;
349     int32_t userId = parcel.ReadInt32();
350     std::vector<uint8_t> challenge;
351     FillTestUint8Vector(parcel, challenge);
352     int32_t ret = g_service.OpenSession(userId, challenge);
353     cout << "ret is " << ret << endl;
354     EXPECT_EQ(ret, 0);
355 }
356 
357 /**
358  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0109
359  * @tc.name: Test CloseSession
360  * @tc.size: MediumTest
361  * @tc.type: Function
362  * @tc.level: Level1
363  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0109, Function | MediumTest | Level1)364 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0109, Function | MediumTest | Level1)
365 {
366     cout << "start CloseSession" << endl;
367     int32_t userId = parcel.ReadInt32();
368     int32_t ret = g_service.CloseSession(userId);
369     cout << "ret is " << ret << endl;
370     EXPECT_EQ(ret, 0);
371 }
372 
373 /**
374  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0110
375  * @tc.name: Test BeginEnrollment
376  * @tc.size: MediumTest
377  * @tc.type: Function
378  * @tc.level: Level1
379  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0110, Function | MediumTest | Level1)380 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0110, Function | MediumTest | Level1)
381 {
382     cout << "start BeginEnrollment" << endl;
383     std::vector<uint8_t> authToken;
384     FillTestUint8Vector(parcel, authToken);
385     EnrollParam param;
386     FillEnrollParam(parcel, param);
387     ScheduleInfo info;
388     FillScheduleInfo(parcel, info);
389     int32_t ret = g_service.BeginEnrollment(authToken, param, info);
390     cout << "ret is " << ret << endl;
391     ASSERT_EQ(ret != Expectedvalue, true);
392 }
393 
394 /**
395  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0111
396  * @tc.name: Test UpdateEnrollmentResult
397  * @tc.size: MediumTest
398  * @tc.type: Function
399  * @tc.level: Level1
400  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0111, Function | MediumTest | Level1)401 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0111, Function | MediumTest | Level1)
402 {
403     cout << "start UpdateEnrollmentResult" << endl;
404     int32_t userId = parcel.ReadInt32();
405     std::vector<uint8_t> scheduleResult;
406     FillTestUint8Vector(parcel, scheduleResult);
407     EnrollResultInfo info = {};
408     FillCredentialInfo(parcel, info.oldInfo);
409     info.credentialId = parcel.ReadUint64();
410     FillTestUint8Vector(parcel, info.rootSecret);
411     int32_t ret = g_service.UpdateEnrollmentResult(userId, scheduleResult, info);
412     cout << "ret is " << ret << endl;
413     ASSERT_EQ(ret != Expectedvalue, true);
414 }
415 
416 /**
417  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0112
418  * @tc.name: Test CancelEnrollment
419  * @tc.size: MediumTest
420  * @tc.type: Function
421  * @tc.level: Level1
422  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0112, Function | MediumTest | Level1)423 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0112, Function | MediumTest | Level1)
424 {
425     cout << "start CancelEnrollment" << endl;
426     int32_t userId = parcel.ReadInt32();
427     int32_t ret = g_service.CancelEnrollment(userId);
428     cout << "ret is " << ret << endl;
429     EXPECT_EQ(ret, 0);
430 }
431 
432 /**
433  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0113
434  * @tc.name: Test DeleteCredential
435  * @tc.size: MediumTest
436  * @tc.type: Function
437  * @tc.level: Level1
438  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0113, Function | MediumTest | Level1)439 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0113, Function | MediumTest | Level1)
440 {
441     cout << "start DeleteCredential" << endl;
442     int32_t userId = parcel.ReadInt32();
443     uint64_t credentialId = parcel.ReadUint64();
444     std::vector<uint8_t> authToken;
445     FillTestUint8Vector(parcel, authToken);
446     CredentialInfo info;
447     FillCredentialInfo(parcel, info);
448     int32_t ret = g_service.DeleteCredential(userId, credentialId, authToken, info);
449     cout << "ret is " << ret << endl;
450     ASSERT_EQ(ret != Expectedvalue, true);
451 }
452 
453 /**
454  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0114
455  * @tc.name: Test EnforceDeleteUser
456  * @tc.size: MediumTest
457  * @tc.type: Function
458  * @tc.level: Level1
459  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0114, Function | MediumTest | Level1)460 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0114, Function | MediumTest | Level1)
461 {
462     cout << "start EnforceDeleteUser" << endl;
463     int32_t userId = parcel.ReadInt32();
464     std::vector<CredentialInfo> deletedInfos;
465     FillCredentialInfoVector(parcel, deletedInfos);
466     int32_t ret = g_service.EnforceDeleteUser(userId, deletedInfos);
467     cout << "ret is " << ret << endl;
468     ASSERT_EQ(ret != Expectedvalue, true);
469 }
470 
471 /**
472  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0115
473  * @tc.name: Test BeginAuthentication
474  * @tc.size: MediumTest
475  * @tc.type: Function
476  * @tc.level: Level1
477  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0115, Function | MediumTest | Level1)478 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0115, Function | MediumTest | Level1)
479 {
480     cout << "start BeginAuthentication" << endl;
481     uint64_t contextId = parcel.ReadUint64();
482     AuthParam param;
483     FillAuthParam(parcel, param);
484     std::vector<ScheduleInfo> scheduleInfos;
485     FillScheduleInfoVector(parcel, scheduleInfos);
486     int32_t ret = g_service.BeginAuthentication(contextId, param, scheduleInfos);
487     cout << "ret is " << ret << endl;
488     ASSERT_EQ(ret != Expectedvalue, true);
489 }
490 
491 /**
492  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0116
493  * @tc.name: Test UpdateAuthenticationResult
494  * @tc.size: MediumTest
495  * @tc.type: Function
496  * @tc.level: Level1
497  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0116, Function | MediumTest | Level1)498 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0116, Function | MediumTest | Level1)
499 {
500     cout << "start UpdateAuthenticationResult" << endl;
501     uint64_t contextId = parcel.ReadUint64();
502     std::vector<uint8_t> scheduleResult;
503     FillTestUint8Vector(parcel, scheduleResult);
504     AuthResultInfo info;
505     FillAuthResultInfo(parcel, info);
506     EnrolledState enrolledState;
507     int32_t ret = g_service.UpdateAuthenticationResult(contextId, scheduleResult, info, enrolledState);
508     cout << "ret is " << ret << endl;
509     ASSERT_EQ(ret != Expectedvalue, true);
510 }
511 
512 /**
513  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0117
514  * @tc.name: Test CancelAuthentication
515  * @tc.size: MediumTest
516  * @tc.type: Function
517  * @tc.level: Level1
518  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0117, Function | MediumTest | Level1)519 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0117, Function | MediumTest | Level1)
520 {
521     cout << "start CancelAuthentication" << endl;
522     uint64_t contextId = parcel.ReadUint64();
523     int32_t ret = g_service.CancelAuthentication(contextId);
524     cout << "ret is " << ret << endl;
525     ASSERT_EQ(ret != Expectedvalue, true);
526 }
527 
528 /**
529  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0118
530  * @tc.name: Test UpdateIdentificationResult
531  * @tc.size: MediumTest
532  * @tc.type: Function
533  * @tc.level: Level1
534  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0118, Function | MediumTest | Level1)535 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0118, Function | MediumTest | Level1)
536 {
537     cout << "start UpdateIdentificationResult" << endl;
538     uint64_t contextId = parcel.ReadUint64();
539     std::vector<uint8_t> scheduleResult;
540     FillTestUint8Vector(parcel, scheduleResult);
541     IdentifyResultInfo info;
542     FillIdentifyResultInfo(parcel, info);
543     int32_t ret = g_service.UpdateIdentificationResult(contextId, scheduleResult, info);
544     cout << "ret is " << ret << endl;
545     ASSERT_EQ(ret != Expectedvalue, true);
546 }
547 
548 /**
549  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0119
550  * @tc.name: Test CancelIdentification
551  * @tc.size: MediumTest
552  * @tc.type: Function
553  * @tc.level: Level1
554  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0119, Function | MediumTest | Level1)555 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0119, Function | MediumTest | Level1)
556 {
557     cout << "start CancelIdentification" << endl;
558     uint64_t contextId = parcel.ReadUint64();
559     int32_t ret = g_service.CancelIdentification(contextId);
560     cout << "ret is " << ret << endl;
561     ASSERT_EQ(ret != Expectedvalue, true);
562 }
563 
564 /**
565  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0120
566  * @tc.name: Test GetAvailableStatus
567  * @tc.size: MediumTest
568  * @tc.type: Function
569  * @tc.level: Level1
570  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0120, Function | MediumTest | Level1)571 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0120, Function | MediumTest | Level1)
572 {
573     cout << "start GetAvailableStatus" << endl;
574     int32_t userId = parcel.ReadInt32();
575     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
576     uint32_t authTrustLevel = parcel.ReadUint32();
577     int32_t checkResult = parcel.ReadInt32();
578     int32_t ret = g_service.GetAvailableStatus(userId, authType, authTrustLevel, checkResult);
579     cout << "ret is " << ret << endl;
580     ASSERT_EQ(checkResult != Expectedvalue, true);
581 }
582 
583 /**
584  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0121
585  * @tc.name: Test GetValidSolution
586  * @tc.size: MediumTest
587  * @tc.type: Function
588  * @tc.level: Level1
589  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0121, Function | MediumTest | Level1)590 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0121, Function | MediumTest | Level1)
591 {
592     cout << "start GetValidSolution" << endl;
593     int32_t userId = parcel.ReadInt32();
594     std::vector<int32_t> authTypes;
595     FillAuthTypeVector(parcel, authTypes);
596     uint32_t authTrustLevel = parcel.ReadUint32();
597     std::vector<int32_t> validTypes;
598     FillAuthTypeVector(parcel, validTypes);
599     int32_t ret = g_service.GetValidSolution(userId, authTypes, authTrustLevel, validTypes);
600     cout << "ret is " << ret << endl;
601     ASSERT_EQ(ret != Expectedvalue, true);
602 }
603 
604 /**
605  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0101
606  * @tc.name: Test BeginEnrollmentV1_1
607  * @tc.size: MediumTest
608  * @tc.type: Function
609  * @tc.level: Level1
610  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0101, Function | MediumTest | Level1)611 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0101, Function | MediumTest | Level1)
612 {
613     cout << "start BeginEnrollmentV1_1" << endl;
614     std::vector<uint8_t> authToken;
615     FillTestUint8Vector(parcel, authToken);
616     EnrollParam param;
617     FillEnrollParam(parcel, param);
618     ScheduleInfo info;
619     FillTestScheduleInfo(parcel, info);
620     int32_t ret = g_service.BeginEnrollment(authToken, param, info);
621 
622     ASSERT_EQ(ret != Expectedvalue, true);
623 }
624 
625 /**
626  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0102
627  * @tc.name: Test BeginAuthenticationV1_1
628  * @tc.size: MediumTest
629  * @tc.type: Function
630  * @tc.level: Level1
631  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0102, Function | MediumTest | Level1)632 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0102, Function | MediumTest | Level1)
633 {
634     cout << "start BeginAuthenticationV1_1" << endl;
635     uint64_t contextId = parcel.ReadUint64();
636     AuthParam param;
637     FillAuthParam(parcel, param);
638     std::vector<ScheduleInfo> scheduleInfos;
639     FillTestScheduleInfo_Vector(parcel, scheduleInfos);
640     int32_t ret = g_service.BeginAuthentication(contextId, param, scheduleInfos);
641 
642     ASSERT_EQ(ret != Expectedvalue, true);
643 }
644 
645 /**
646  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0103
647  * @tc.name: Test BeginIdentificationV1_1
648  * @tc.size: MediumTest
649  * @tc.type: Function
650  * @tc.level: Level1
651  */
HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0103, Function | MediumTest | Level1)652 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0103, Function | MediumTest | Level1)
653 {
654     cout << "start BeginIdentificationV1_1" << endl;
655     uint64_t contextId = parcel.ReadUint64();
656     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
657     std::vector<uint8_t> challenge;
658     FillTestUint8Vector(parcel, challenge);
659     uint32_t executorId = parcel.ReadUint32();
660     ScheduleInfo scheduleInfo;
661     FillTestScheduleInfo(parcel, scheduleInfo);
662     int32_t ret = g_service.BeginIdentification(contextId, authType, challenge, executorId, scheduleInfo);
663 
664     ASSERT_EQ(ret != Expectedvalue, true);
665 }