• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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::V4_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  */
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  */
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  */
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  */
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     EXPECT_EQ(ret, 0);
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  */
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  */
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  */
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  */
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  */
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  */
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  */
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  */
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  */
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     CredentialOperateResult info;
447     int32_t ret = g_service.DeleteCredential(userId, credentialId, authToken, info);
448     cout << "ret is " << ret << endl;
449     ASSERT_EQ(ret != Expectedvalue, true);
450 }
451 
452 /**
453  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0114
454  * @tc.name: Test EnforceDeleteUser
455  * @tc.size: MediumTest
456  * @tc.type: Function
457  * @tc.level: Level1
458  */
459 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0114, Function | MediumTest | Level1)
460 {
461     cout << "start EnforceDeleteUser" << endl;
462     int32_t userId = parcel.ReadInt32();
463     std::vector<CredentialInfo> deletedInfos;
464     FillCredentialInfoVector(parcel, deletedInfos);
465     int32_t ret = g_service.EnforceDeleteUser(userId, deletedInfos);
466     cout << "ret is " << ret << endl;
467     ASSERT_EQ(ret != Expectedvalue, true);
468 }
469 
470 /**
471  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0115
472  * @tc.name: Test BeginAuthentication
473  * @tc.size: MediumTest
474  * @tc.type: Function
475  * @tc.level: Level1
476  */
477 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0115, Function | MediumTest | Level1)
478 {
479     cout << "start BeginAuthentication" << endl;
480     uint64_t contextId = parcel.ReadUint64();
481     AuthParam param;
482     FillAuthParam(parcel, param);
483     std::vector<ScheduleInfo> scheduleInfos;
484     FillScheduleInfoVector(parcel, scheduleInfos);
485     int32_t ret = g_service.BeginAuthentication(contextId, param, scheduleInfos);
486     cout << "ret is " << ret << endl;
487     ASSERT_EQ(ret != Expectedvalue, true);
488 }
489 
490 /**
491  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0116
492  * @tc.name: Test UpdateAuthenticationResult
493  * @tc.size: MediumTest
494  * @tc.type: Function
495  * @tc.level: Level1
496  */
497 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0116, Function | MediumTest | Level1)
498 {
499     cout << "start UpdateAuthenticationResult" << endl;
500     uint64_t contextId = parcel.ReadUint64();
501     std::vector<uint8_t> scheduleResult;
502     FillTestUint8Vector(parcel, scheduleResult);
503     AuthResultInfo info;
504     FillAuthResultInfo(parcel, info);
505     EnrolledState enrolledState;
506     int32_t ret = g_service.UpdateAuthenticationResult(contextId, scheduleResult, info, enrolledState);
507     cout << "ret is " << ret << endl;
508     ASSERT_EQ(ret != Expectedvalue, true);
509 }
510 
511 /**
512  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0117
513  * @tc.name: Test CancelAuthentication
514  * @tc.size: MediumTest
515  * @tc.type: Function
516  * @tc.level: Level1
517  */
518 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0117, Function | MediumTest | Level1)
519 {
520     cout << "start CancelAuthentication" << endl;
521     uint64_t contextId = parcel.ReadUint64();
522     int32_t ret = g_service.CancelAuthentication(contextId);
523     cout << "ret is " << ret << endl;
524     ASSERT_EQ(ret != Expectedvalue, true);
525 }
526 
527 /**
528  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0118
529  * @tc.name: Test UpdateIdentificationResult
530  * @tc.size: MediumTest
531  * @tc.type: Function
532  * @tc.level: Level1
533  */
534 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0118, Function | MediumTest | Level1)
535 {
536     cout << "start UpdateIdentificationResult" << endl;
537     uint64_t contextId = parcel.ReadUint64();
538     std::vector<uint8_t> scheduleResult;
539     FillTestUint8Vector(parcel, scheduleResult);
540     IdentifyResultInfo info;
541     FillIdentifyResultInfo(parcel, info);
542     int32_t ret = g_service.UpdateIdentificationResult(contextId, scheduleResult, info);
543     cout << "ret is " << ret << endl;
544     ASSERT_EQ(ret != Expectedvalue, true);
545 }
546 
547 /**
548  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0119
549  * @tc.name: Test CancelIdentification
550  * @tc.size: MediumTest
551  * @tc.type: Function
552  * @tc.level: Level1
553  */
554 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0119, Function | MediumTest | Level1)
555 {
556     cout << "start CancelIdentification" << endl;
557     uint64_t contextId = parcel.ReadUint64();
558     int32_t ret = g_service.CancelIdentification(contextId);
559     cout << "ret is " << ret << endl;
560     ASSERT_EQ(ret != Expectedvalue, true);
561 }
562 
563 /**
564  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0120
565  * @tc.name: Test GetAvailableStatus
566  * @tc.size: MediumTest
567  * @tc.type: Function
568  * @tc.level: Level1
569  */
570 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0120, Function | MediumTest | Level1)
571 {
572     cout << "start GetAvailableStatus" << endl;
573     int32_t userId = parcel.ReadInt32();
574     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
575     uint32_t authTrustLevel = parcel.ReadUint32();
576     int32_t checkResult = parcel.ReadInt32();
577     int32_t ret = g_service.GetAvailableStatus(userId, authType, authTrustLevel, checkResult);
578     cout << "ret is " << ret << endl;
579     ASSERT_EQ(checkResult != Expectedvalue, true);
580 }
581 
582 /**
583  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0121
584  * @tc.name: Test GetValidSolution
585  * @tc.size: MediumTest
586  * @tc.type: Function
587  * @tc.level: Level1
588  */
589 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0121, Function | MediumTest | Level1)
590 {
591     cout << "start GetValidSolution" << endl;
592     int32_t userId = parcel.ReadInt32();
593     std::vector<int32_t> authTypes;
594     FillAuthTypeVector(parcel, authTypes);
595     uint32_t authTrustLevel = parcel.ReadUint32();
596     std::vector<int32_t> validTypes;
597     FillAuthTypeVector(parcel, validTypes);
598     int32_t ret = g_service.GetValidSolution(userId, authTypes, authTrustLevel, validTypes);
599     cout << "ret is " << ret << endl;
600     ASSERT_EQ(ret != Expectedvalue, true);
601 }
602 
603 /**
604  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0101
605  * @tc.name: Test BeginEnrollmentV1_1
606  * @tc.size: MediumTest
607  * @tc.type: Function
608  * @tc.level: Level1
609  */
610 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0101, Function | MediumTest | Level1)
611 {
612     cout << "start BeginEnrollmentV1_1" << endl;
613     std::vector<uint8_t> authToken;
614     FillTestUint8Vector(parcel, authToken);
615     EnrollParam param;
616     FillEnrollParam(parcel, param);
617     ScheduleInfo info;
618     FillTestScheduleInfo(parcel, info);
619     int32_t ret = g_service.BeginEnrollment(authToken, param, info);
620 
621     ASSERT_EQ(ret != Expectedvalue, true);
622 }
623 
624 /**
625  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0102
626  * @tc.name: Test BeginAuthenticationV1_1
627  * @tc.size: MediumTest
628  * @tc.type: Function
629  * @tc.level: Level1
630  */
631 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0102, Function | MediumTest | Level1)
632 {
633     cout << "start BeginAuthenticationV1_1" << endl;
634     uint64_t contextId = parcel.ReadUint64();
635     AuthParam param;
636     FillAuthParam(parcel, param);
637     std::vector<ScheduleInfo> scheduleInfos;
638     FillTestScheduleInfo_Vector(parcel, scheduleInfos);
639     int32_t ret = g_service.BeginAuthentication(contextId, param, scheduleInfos);
640 
641     ASSERT_EQ(ret != Expectedvalue, true);
642 }
643 
644 /**
645  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0103
646  * @tc.name: Test BeginIdentificationV1_1
647  * @tc.size: MediumTest
648  * @tc.type: Function
649  * @tc.level: Level1
650  */
651 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0103, Function | MediumTest | Level1)
652 {
653     cout << "start BeginIdentificationV1_1" << endl;
654     uint64_t contextId = parcel.ReadUint64();
655     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
656     std::vector<uint8_t> challenge;
657     FillTestUint8Vector(parcel, challenge);
658     uint32_t executorId = parcel.ReadUint32();
659     ScheduleInfo scheduleInfo;
660     FillTestScheduleInfo(parcel, scheduleInfo);
661     int32_t ret = g_service.BeginIdentification(contextId, authType, challenge, executorId, scheduleInfo);
662 
663     ASSERT_EQ(ret != Expectedvalue, true);
664 }