• 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 "iam_hat_test.h"
17 #include "user_auth_hdi_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::V1_2;
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 
30 struct HdiBeginEnrollmentV1_1List {
31     int32_t userId[4] = {12345, 1234, 12345, 12345};
32     int32_t authType[4] = {1, 0, 2, 4};
33     uint32_t executorSensorHint[4] = {0, 65535, 1, 0};
34 };
35 struct HdiBeginAuthenticationV1_1List {
36     uint32_t authType[4] = {0, 1, 2, 4};
37     uint32_t userId[4] = {356581, 1};
38 };
39 struct HdiBeginIdentificationV1_1List {
40     uint32_t addExecutor[2] = {0, 1};
41     uint32_t authType[4] = {0, 1, 2, 4};
42 };
43 
SetUpTestCase()44 void UserIamUserAuthTestAdditional::SetUpTestCase() {}
45 
TearDownTestCase()46 void UserIamUserAuthTestAdditional::TearDownTestCase() {}
47 
SetUp()48 void UserIamUserAuthTestAdditional::SetUp() { EXPECT_EQ(g_service.Init(), 0); }
49 
TearDown()50 void UserIamUserAuthTestAdditional::TearDown() {}
51 
FillEnrollParam(Parcel & parcel,EnrollParam & enrollParam)52 static void FillEnrollParam(Parcel &parcel, EnrollParam &enrollParam)
53 {
54     enrollParam.authType = static_cast<AuthType>(parcel.ReadInt32());
55     enrollParam.executorSensorHint = parcel.ReadUint32();
56 }
57 
FillExecutorRegisterInfo(Parcel & parcel,ExecutorRegisterInfo & executorRegisterInfo)58 static void FillExecutorRegisterInfo(Parcel &parcel, ExecutorRegisterInfo &executorRegisterInfo)
59 {
60     executorRegisterInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
61     executorRegisterInfo.executorRole = static_cast<ExecutorRole>(parcel.ReadInt32());
62     executorRegisterInfo.executorSensorHint = parcel.ReadUint32();
63     executorRegisterInfo.executorMatcher = parcel.ReadUint32();
64     executorRegisterInfo.esl = static_cast<ExecutorSecureLevel>(parcel.ReadInt32());
65     FillTestUint8Vector(parcel, executorRegisterInfo.publicKey);
66 }
67 
FillExecutorInfo(Parcel & parcel,ExecutorInfo & executorInfo)68 static void FillExecutorInfo(Parcel &parcel, ExecutorInfo &executorInfo)
69 {
70     executorInfo.executorIndex = parcel.ReadUint64();
71     FillExecutorRegisterInfo(parcel, executorInfo.info);
72 }
73 
FillExecutorInfoVector(Parcel & parcel,vector<ExecutorInfo> & vector)74 static void FillExecutorInfoVector(Parcel &parcel, vector<ExecutorInfo> &vector)
75 {
76     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
77     vector.resize(len);
78     for (uint32_t i = 0; i < len; i++) {
79         FillExecutorInfo(parcel, vector[i]);
80     }
81 }
82 
FillScheduleInfo(Parcel & parcel,ScheduleInfo & scheduleInfo)83 static void FillScheduleInfo(Parcel &parcel, ScheduleInfo &scheduleInfo)
84 {
85     scheduleInfo.scheduleId = parcel.ReadUint64();
86     FillTestUint64Vector(parcel, scheduleInfo.templateIds);
87     scheduleInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
88     scheduleInfo.executorMatcher = parcel.ReadUint32();
89     scheduleInfo.scheduleMode = static_cast<ScheduleMode>(parcel.ReadInt32());
90     FillExecutorInfoVector(parcel, scheduleInfo.executors);
91 }
92 
FillCredentialInfo(Parcel & parcel,CredentialInfo & credentialInfo)93 static void FillCredentialInfo(Parcel &parcel, CredentialInfo &credentialInfo)
94 {
95     credentialInfo.credentialId = parcel.ReadUint64();
96     credentialInfo.executorIndex = parcel.ReadUint64();
97     credentialInfo.templateId = parcel.ReadUint64();
98     credentialInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
99     credentialInfo.executorMatcher = parcel.ReadUint32();
100     credentialInfo.executorSensorHint = parcel.ReadUint32();
101 }
102 
FillEnrolledInfo(Parcel & parcel,EnrolledInfo & enrolledInfo)103 static void FillEnrolledInfo(Parcel &parcel, EnrolledInfo &enrolledInfo)
104 {
105     enrolledInfo.enrolledId = parcel.ReadUint64();
106     enrolledInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
107 }
108 
FillCredentialInfoVector(Parcel & parcel,vector<CredentialInfo> & vector)109 static void FillCredentialInfoVector(Parcel &parcel, vector<CredentialInfo> &vector)
110 {
111     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
112     vector.resize(len);
113     for (uint32_t i = 0; i < len; i++) {
114         FillCredentialInfo(parcel, vector[i]);
115     }
116 }
117 
FillEnrolledInfoVector(Parcel & parcel,vector<EnrolledInfo> & vector)118 static void FillEnrolledInfoVector(Parcel &parcel, vector<EnrolledInfo> &vector)
119 {
120     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
121     vector.resize(len);
122     for (uint32_t i = 0; i < len; i++) {
123         FillEnrolledInfo(parcel, vector[i]);
124     }
125 }
126 
127 /**
128  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0200
129  * @tc.name  : testAddExecutor001
130  * @tc.desc  : First input parameter being the ExecutorRegisterInfo structure ->authType value being
131  * ALL/PIN/FACE/FINGERPRINT
132  */
133 HWTEST_F(UserIamUserAuthTestAdditional, testAddExecutor001, Function | MediumTest | Level1)
134 {
135     uint32_t i = 0;
136     uint32_t authType[4] = {0, 1, 2, 4};
137     ExecutorRegisterInfo info = {};
138     uint64_t index = 0;
139     std::vector<uint8_t> publicKey;
140     std::vector<uint64_t> templateIds;
141 
142     for (i = 0; i < 4; i++) {
143         info.authType = static_cast<AuthType>(authType[i]);
144         info.publicKey.resize(32);
145         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
146         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
147     }
148 }
149 /**
150  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1800
151  * @tc.name  : testDeleteExecutor001
152  * @tc.desc  : Delete call without adding an authentication executor
153  */
154 HWTEST_F(UserIamUserAuthTestAdditional, testDeleteExecutor001, Function | MediumTest | Level2)
155 {
156     cout << "start DeleteExecutor" << endl;
157     uint64_t index = -1;
158     auto ret = g_service.DeleteExecutor(index);
159     cout << "ret is " << ret << endl;
160     ASSERT_EQ(ret != Expectedvalue, true);
161 }
162 /**
163  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1900
164  * @tc.name  : testDeleteExecutor002
165  * @tc.desc  : First call the AddExecutor function to add an authentication executor,
166  *              and then call the DeleteExecutor function to delete it
167  */
168 HWTEST_F(UserIamUserAuthTestAdditional, testDeleteExecutor002, Function | MediumTest | Level1)
169 {
170     cout << "start DeleteExecutor" << endl;
171     ExecutorRegisterInfo info = {};
172     info.authType = AuthType::ALL;
173     info.publicKey.resize(32);
174     uint64_t index = 0;
175     std::vector<uint8_t> publicKey;
176     std::vector<uint64_t> templateIds;
177     EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
178 
179     auto ret = g_service.DeleteExecutor(index);
180     cout << "ret is " << ret << endl;
181     EXPECT_EQ(ret, 0);
182 }
183 /**
184  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2000
185  * @tc.name  : testDeleteExecutor003
186  * @tc.desc  : Call the AddExecutor function to add an authentication executor,
187  *              and then call the DeleteExecutor function to pass in different parameters for deletion
188  */
189 HWTEST_F(UserIamUserAuthTestAdditional, testDeleteExecutor003, Function | MediumTest | Level2)
190 {
191     cout << "start DeleteExecutor" << endl;
192     ExecutorRegisterInfo info = {};
193     info.authType = AuthType::ALL;
194     info.publicKey.resize(32);
195     uint64_t index = 0;
196     std::vector<uint8_t> publicKey;
197     std::vector<uint64_t> templateIds;
198     EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
199     EXPECT_NE(index, 0);
200     index = 0;
201     auto ret = g_service.DeleteExecutor(index);
202     cout << "ret is " << ret << endl;
203     EXPECT_NE(ret, 0);
204 }
205 /**
206  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2200
207  * @tc.name  : testOpenSession002
208  * @tc.desc  : Call the OpenSession function with the parameter userId = -1/0/1
209  */
210 HWTEST_F(UserIamUserAuthTestAdditional, testOpenSession002, Function | MediumTest | Level1)
211 {
212     cout << "start OpenSession" << endl;
213     uint32_t i = 0;
214     int32_t userId[3] = {-1, 0, 1};
215     std::vector<uint8_t> challenge;
216     for (i = 0; i < 3; i++) {
217         FillTestUint8Vector(parcel, challenge);
218         EXPECT_EQ(g_service.OpenSession(userId[i], challenge), 0);
219         EXPECT_EQ(g_service.CloseSession(userId[i]), 0);
220     }
221 }
222 /**
223  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2500
224  * @tc.name  : testCloseSession002
225  * @tc.desc  : Close unopened authentication credential management sessions
226  */
227 HWTEST_F(UserIamUserAuthTestAdditional, testCloseSession002, Function | MediumTest | Level2)
228 {
229     cout << "start CloseSession" << endl;
230     uint32_t i = 0;
231     uint32_t ret = 0;
232     int32_t userId[2] = {-1, 1000};
233     for (i = 0; i < 2; i++) {
234         EXPECT_NE(g_service.CloseSession(userId[i]), 0);
235     }
236     cout << "ret is " << ret << endl;
237 }
238 /**
239  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2600
240  * @tc.name  : testCloseSession003
241  * @tc.desc  : Close unopened authentication credential management sessions
242  */
243 HWTEST_F(UserIamUserAuthTestAdditional, testCloseSession003, Function | MediumTest | Level2)
244 {
245     cout << "start CloseSession" << endl;
246     int32_t userId = 1000;
247     int32_t i = 0;
248     while (i < 50) {
249         EXPECT_NE(g_service.CloseSession(userId), 0);
250         i++;
251     }
252 }
253 /**
254  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2700
255  * @tc.name  : testBeginEnrollment001
256  * @tc.desc  : Directly call the BeginEnrollment function without preprocessing
257  */
258 HWTEST_F(UserIamUserAuthTestAdditional, testBeginEnrollment001, Function | MediumTest | Level2)
259 {
260     cout << "start BeginEnrollment" << endl;
261     int32_t userId = -1;
262     std::vector<uint8_t> authToken;
263     FillTestUint8Vector(parcel, authToken);
264     EnrollParam param;
265     FillEnrollParam(parcel, param);
266     ScheduleInfo info;
267     FillScheduleInfo(parcel, info);
268     auto ret = g_service.BeginEnrollment(userId, authToken, param, info);
269     cout << "ret is " << ret << endl;
270     EXPECT_NE(ret, 0);
271 }
272 /**
273  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2800
274  * @tc.name  : testBeginEnrollment002
275  * @tc.desc  : Call the OpenSession function and AddExecutor function, then call the BeginEnrollment function
276  * and test different authTypes
277  */
278 HWTEST_F(UserIamUserAuthTestAdditional, testBeginEnrollment002, Function | MediumTest | Level1)
279 {
280     int32_t userId = 12345;
281     uint32_t i = 0;
282     uint64_t index = 0;
283     std::vector<uint8_t> challenge;
284     std::vector<uint8_t> authToken;
285     std::vector<uint8_t> publicKey;
286     std::vector<uint64_t> templateIds;
287     ScheduleInfo scheduleInfo = {};
288     ExecutorRegisterInfo info = {};
289     EnrollParam param = {};
290     uint32_t authType[4] = {0, 1, 2, 4};
291 
292     for (i = 0; i < 4; i++) {
293         EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
294         info.executorRole = ExecutorRole::ALL_IN_ONE;
295         info.esl = ExecutorSecureLevel::ESL0;
296         info.publicKey.resize(32);
297         info.authType = static_cast<AuthType>(authType[i]);
298         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
299         param.authType = static_cast<AuthType>(authType[i]);
300 
301         if (i == 1) {
302             EXPECT_EQ(g_service.BeginEnrollment(userId, authToken, param, scheduleInfo), 0);
303 
304             EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
305         } else {
306             EXPECT_NE(g_service.BeginEnrollment(userId, authToken, param, scheduleInfo), 0);
307         }
308         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
309         EXPECT_EQ(g_service.CloseSession(userId), 0);
310     }
311 }
312 /**
313  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3200
314  * @tc.name  : testCancelEnrollment001
315  * @tc.desc  : Call the CancelEnrollment function with userId=-123 as the input parameter
316  */
317 HWTEST_F(UserIamUserAuthTestAdditional, testCancelEnrollment001, Function | MediumTest | Level1)
318 {
319     cout << "start CancelEnrollment" << endl;
320     int32_t userId = -123;
321     auto ret = g_service.CancelEnrollment(userId);
322     cout << "ret is " << ret << endl;
323     EXPECT_EQ(ret, 0);
324 }
325 /**
326  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3300
327  * @tc.name  : testCancelEnrollment002
328  * @tc.desc  : The BeginEnrollment function is invoked to register the authentication credentials,
329  *              and then the CancelEnrollment function is invoked to cancel the registration
330  */
331 HWTEST_F(UserIamUserAuthTestAdditional, testCancelEnrollment002, Function | MediumTest | Level1)
332 {
333     uint32_t i = 0;
334     int32_t userId[3] = {-12345, 0, 1};
335     std::vector<uint8_t> challenge;
336     ExecutorRegisterInfo info = {};
337     uint64_t index = 0;
338     std::vector<uint8_t> publicKey;
339     std::vector<uint64_t> templateIds;
340     std::vector<uint8_t> authToken;
341     EnrollParam param = {};
342     ScheduleInfo scheduleInfo = {};
343 
344     for (i = 0; i < 3; i++) {
345         EXPECT_EQ(g_service.OpenSession(userId[i], challenge), 0);
346 
347         info.authType = AuthType::PIN;
348         info.executorRole = ExecutorRole::ALL_IN_ONE;
349         info.esl = ExecutorSecureLevel::ESL0;
350         info.publicKey.resize(32);
351         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
352 
353         param.authType = AuthType::PIN;
354         EXPECT_EQ(g_service.BeginEnrollment(userId[i], authToken, param, scheduleInfo), 0);
355 
356         EXPECT_EQ(g_service.CancelEnrollment(userId[i]), 0);
357         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
358         EXPECT_EQ(g_service.CloseSession(userId[i]), 0);
359     }
360 }
361 /**
362  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3700
363  * @tc.name  : testCancelEnrollment006
364  * @tc.desc  : Call the BeginEnrollment function to register the authentication credentials,
365  *              then call the CancelEnrollment function to cancel, and then continue to cancel 50 times
366  */
367 HWTEST_F(UserIamUserAuthTestAdditional, testCancelEnrollment006, Function | MediumTest | Level1)
368 {
369     int32_t userId = 1;
370     int32_t i = 0;
371     std::vector<uint8_t> challenge;
372     EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
373 
374     ExecutorRegisterInfo info = {};
375     info.authType = AuthType::PIN;
376     info.executorRole = ExecutorRole::ALL_IN_ONE;
377     info.esl = ExecutorSecureLevel::ESL0;
378     info.publicKey.resize(32);
379     uint64_t index = 0;
380     std::vector<uint8_t> publicKey;
381     std::vector<uint64_t> templateIds;
382     EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
383 
384     std::vector<uint8_t> authToken;
385     EnrollParam param = {};
386     param.authType = AuthType::PIN;
387     ScheduleInfo scheduleInfo = {};
388     EXPECT_EQ(g_service.BeginEnrollment(userId, authToken, param, scheduleInfo), 0);
389 
390     EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
391     while (i < 50) {
392         EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
393         i++;
394     }
395     EXPECT_EQ(g_service.DeleteExecutor(index), 0);
396     EXPECT_EQ(g_service.CloseSession(userId), 0);
397 }
398 /**
399  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3800
400  * @tc.name  : testGetCredential001
401  * @tc.desc  : Call the GetCredential function, with the first input parameter being userId=-1、0、1
402  */
403 HWTEST_F(UserIamUserAuthTestAdditional, testGetCredential001, Function | MediumTest | Level1)
404 {
405     cout << "start GetCredential" << endl;
406     uint32_t i = 0;
407     uint32_t userId[3] = {-1, 0, 1};
408     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
409     std::vector<CredentialInfo> infos;
410 
411     for (i = 0; i < 3; i++) {
412         FillCredentialInfoVector(parcel, infos);
413         EXPECT_EQ(g_service.GetCredential(userId[i], authType, infos), 0);
414     }
415 }
416 /**
417  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3900
418  * @tc.name  : testGetCredential002
419  * @tc.desc  : Pass the authType authentication type to all types and determine the result of the function
420  */
421 HWTEST_F(UserIamUserAuthTestAdditional, testGetCredential002, Function | MediumTest | Level1)
422 {
423     cout << "start GetCredential" << endl;
424     uint32_t i = 0;
425     int32_t userId = parcel.ReadInt32();
426     uint32_t authType[4] = {0, 1, 2, 4};
427     std::vector<CredentialInfo> infos;
428 
429     for (i = 0; i < 4; i++) {
430         FillCredentialInfoVector(parcel, infos);
431         EXPECT_EQ(g_service.GetCredential(userId, static_cast<AuthType>(authType[i]), infos), 0);
432     }
433 }
434 /**
435  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_4500
436  * @tc.name  : testGetUserInfo001
437  * @tc.desc  : Pass the wrong userId to the function to determine the result of the function
438  */
439 HWTEST_F(UserIamUserAuthTestAdditional, testGetUserInfo001, Function | MediumTest | Level2)
440 {
441     cout << "start GetUserInfo" << endl;
442     uint32_t i = 0;
443     int userId[2] = {6789, -6789};
444     uint64_t secureUid = parcel.ReadUint64();
445     PinSubType pinSubType = static_cast<PinSubType>(parcel.ReadUint32());
446     std::vector<EnrolledInfo> infos;
447 
448     for (i = 0; i < 2; i++) {
449         FillEnrolledInfoVector(parcel, infos);
450         EXPECT_NE(g_service.GetUserInfo(userId[i], secureUid, pinSubType, infos), 0);
451     }
452 }
453 /**
454  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_4700
455  * @tc.name  : testDeleteUser001
456  * @tc.desc  : Call the DeleteUser function, with the first input parameter
457  *              being userId=-1 and the second parameter being empty
458  */
459 HWTEST_F(UserIamUserAuthTestAdditional, testDeleteUser001, Function | MediumTest | Level2)
460 {
461     cout << "start DeleteUser" << endl;
462 
463     int32_t userId = -1;
464     std::vector<uint8_t> challenge;
465     EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
466 
467     ExecutorRegisterInfo info = {};
468     info.authType = AuthType::PIN;
469     info.executorRole = ExecutorRole::ALL_IN_ONE;
470     info.esl = ExecutorSecureLevel::ESL0;
471     info.publicKey.resize(32);
472 
473     std::vector<uint8_t> publicKey;
474     std::vector<uint64_t> templateIds;
475     uint64_t index = 0;
476     EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
477 
478     std::vector<uint8_t> authToken;
479     std::vector<CredentialInfo> deletedInfos;
480     auto ret = g_service.DeleteUser(userId, authToken, deletedInfos);
481     cout << "ret is " << ret << endl;
482     EXPECT_NE(ret, 0);
483 }
484 /**
485  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_4800
486  * @tc.name  : testDeleteUser002
487  * @tc.desc  : Call the DeleteUser function, with the second input parameter being authToken=-1、0
488  */
489 HWTEST_F(UserIamUserAuthTestAdditional, testDeleteUser002, Function | MediumTest | Level2)
490 {
491     cout << "start DeleteUser" << endl;
492     uint32_t i = 0;
493     uint32_t num[2] = {-1, 0};
494     std::vector<CredentialInfo> deletedInfos;
495     int32_t userId = parcel.ReadInt32();
496     std::vector<uint8_t> authToken(1);
497     FillTestUint8Vector(parcel, authToken);
498 
499     for (i = 0; i < 2; i++) {
500         authToken[0] = num[i];
501         EXPECT_NE(g_service.DeleteUser(userId, authToken, deletedInfos), 0);
502     }
503 }
504 /**
505  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_5000
506  * @tc.name  : testEnforceDeleteUser001
507  * @tc.desc  : Directly call the EnforceDeleteUser function, with the first input parameter being userId=-1,65535
508  */
509 HWTEST_F(UserIamUserAuthTestAdditional, testEnforceDeleteUser001, Function | MediumTest | Level2)
510 {
511     cout << "start EnforceDeleteUser" << endl;
512     uint32_t i = 0;
513     int32_t userId[2] = {-1, 65535};
514     std::vector<CredentialInfo> deletedInfos;
515 
516     for (i = 0; i < 2; i++) {
517         EXPECT_NE(g_service.EnforceDeleteUser(userId[i], deletedInfos), 0);
518     }
519 }
520 /**
521  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_5200
522  * @tc.name  : testBeginAuthentication001
523  * @tc.desc  : When the registration results are not updated and the registration is completed,
524  *              The first entry is contextId = 1/0/-1, the second entry is the AuthSolution structure ->userId = 365861,
525  *              authTrustLevel = 10000,authType = PIN,executorSensorHint = 1
526  */
527 HWTEST_F(UserIamUserAuthTestAdditional, testBeginAuthentication001, Function | MediumTest | Level2)
528 {
529     uint32_t i = 0;
530     int32_t userId = 365861;
531     uint64_t contextId[3] = {1, 0, -1};
532     AuthType authType = AuthType::PIN;
533     std::vector<uint8_t> challenge;
534     ExecutorRegisterInfo info = {};
535     std::vector<uint8_t> publicKey;
536     std::vector<uint64_t> templateIds;
537     uint64_t index = 0;
538     ScheduleInfo scheduleInfo = {};
539     std::vector<uint8_t> authToken;
540     EnrollParam enrollParam = {};
541     AuthSolution authParam = {};
542     std::vector<ScheduleInfo> scheduleInfos;
543 
544     for (i = 0; i < 3; i++) {
545         EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
546 
547         info.authType = authType;
548         info.executorRole = ExecutorRole::ALL_IN_ONE;
549         info.esl = ExecutorSecureLevel::ESL0;
550         info.publicKey.resize(32);
551         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
552 
553         enrollParam.authType = authType;
554         EXPECT_EQ(g_service.BeginEnrollment(userId, authToken, enrollParam, scheduleInfo), 0);
555 
556         authParam.userId = userId;
557         authParam.authTrustLevel = 10000;
558         authParam.authType = authType;
559         authParam.executorSensorHint = 1;
560         authParam.challenge = challenge;
561         EXPECT_NE(g_service.BeginAuthentication(contextId[i], authParam, scheduleInfos), 0);
562 
563         EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
564         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
565         EXPECT_EQ(g_service.CloseSession(userId), 0);
566     }
567 }
568 /**
569  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_5500
570  * @tc.name  : testBeginAuthentication004
571  * @tc.desc  : The first input parameter is contextId=1, the second input parameter is the
572  *              AuthSolution structure->userId=0, authTrustLevel=-1、0、1000, authType=PIN, executorSensorHint=1
573  */
574 HWTEST_F(UserIamUserAuthTestAdditional, testBeginAuthentication004, Function | MediumTest | Level2)
575 {
576     uint32_t i = 0;
577     int32_t userId = 0;
578     uint64_t index = 0;
579     uint64_t contextId = 1;
580     uint32_t authTrustLevel[3] = {-1, 0, 1000};
581     AuthSolution authParam = {};
582     ExecutorRegisterInfo info = {};
583     AuthType authType = AuthType::PIN;
584     std::vector<uint8_t> challenge;
585     std::vector<uint8_t> publicKey;
586     std::vector<uint64_t> templateIds;
587     std::vector<ScheduleInfo> scheduleInfos;
588 
589     for (i = 0; i < 3; i++) {
590         EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
591 
592         info.authType = authType;
593         info.executorRole = ExecutorRole::ALL_IN_ONE;
594         info.esl = ExecutorSecureLevel::ESL0;
595         info.publicKey.resize(32);
596         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
597 
598         authParam.userId = userId;
599         authParam.authTrustLevel = authTrustLevel[i];
600         authParam.authType = authType;
601         authParam.executorSensorHint = 1;
602         authParam.challenge = challenge;
603         EXPECT_NE(g_service.BeginAuthentication(contextId, authParam, scheduleInfos), 0);
604 
605         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
606         EXPECT_EQ(g_service.CloseSession(userId), 0);
607     }
608 }
609 /**
610  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_6200
611  * @tc.name  : testUpdateAuthenticationResult001
612  * @tc.desc  : The first input parameter is contextId=-1、0、1234567, and the second input parameter
613  *              is scheduleResult is empty
614  */
615 HWTEST_F(UserIamUserAuthTestAdditional, testUpdateAuthenticationResult001, Function | MediumTest | Level2)
616 {
617     uint32_t i = 0;
618     uint64_t contextId[3] = {-1, 0, 1234567};
619     std::vector<uint8_t> scheduleResult;
620     AuthResultInfo authResultInfo = {};
621 
622     for (i = 0; i < 3; i++) {
623         EXPECT_NE(g_service.UpdateAuthenticationResult(contextId[i], scheduleResult, authResultInfo), 0);
624     }
625 }
626 /**
627  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_6500
628  * @tc.name  : testUpdateAuthenticationResult004
629  * @tc.desc  : The first input is contextId = 1, the second input is scheduleResult The size is 100,
630  *              and all inputs are initialized to 1 and 0
631  */
632 HWTEST_F(UserIamUserAuthTestAdditional, testUpdateAuthenticationResult004, Function | MediumTest | Level2)
633 {
634     uint32_t i = 0;
635     uint64_t contextId = 1;
636     uint64_t num[2] = {1, 0};
637     std::vector<uint8_t> scheduleResult(100);
638     AuthResultInfo authResultInfo = {};
639 
640     for (i = 0; i < 2; i++) {
641         scheduleResult.insert(scheduleResult.begin(), 100, num[i]);
642         EXPECT_NE(g_service.UpdateAuthenticationResult(contextId, scheduleResult, authResultInfo), 0);
643     }
644 }
645 /**
646  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_6700
647  * @tc.name  : testCancelAuthentication001
648  * @tc.desc  : Verify the CancelAuthentication function with the first input being contextId = 0、-1、1000
649  */
650 HWTEST_F(UserIamUserAuthTestAdditional, testCancelAuthentication001, Function | MediumTest | Level2)
651 {
652     cout << "start CancelAuthentication" << endl;
653     uint32_t i = 0;
654     uint64_t contextId[3] = {0, -1, 1000};
655 
656     for (i = 0; i < 3; i++) {
657         EXPECT_NE(g_service.CancelAuthentication(contextId[i]), 0);
658     }
659 }
660 /**
661  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_7000
662  * @tc.name  : testBeginIdentification001
663  * @tc.desc  : The AddExecutor function is called first to add the authentication actuator,
664  *              and then the BeginIdentification function is called to start the identification
665  */
666 HWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification001, Function | MediumTest | Level1)
667 {
668     uint32_t i = 0;
669     uint64_t index = 0;
670     uint64_t contextId = 123456;
671     uint32_t authType[3] = {0, 2, 4};
672     ExecutorRegisterInfo info = {};
673     std::vector<uint8_t> challenge;
674     uint32_t executorSensorHint = 0;
675     ScheduleInfo scheduleInfo = {};
676     std::vector<uint8_t> publicKey;
677     std::vector<uint64_t> templateIds;
678 
679     for (i = 0; i < 3; i++) {
680         info.authType = static_cast<AuthType>(authType[i]);
681         info.executorRole = ExecutorRole::ALL_IN_ONE;
682         info.esl = ExecutorSecureLevel::ESL0;
683         info.publicKey.resize(32);
684 
685         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
686         EXPECT_EQ(g_service.BeginIdentification(contextId, static_cast<AuthType>(authType[i]), challenge,
687                                                 executorSensorHint, scheduleInfo),
688                   0);
689         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
690         EXPECT_EQ(g_service.Init(), 0);
691     }
692 }
693 /**
694  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8000
695  * @tc.name  : testBeginIdentification011
696  * @tc.desc  : The AddExecutor function is called first to add the authentication actuator,
697  *              and then the BeginIdentification function is called to start the identification
698  */
699 HWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification011, Function | MediumTest | Level2)
700 {
701     uint32_t i = 0;
702     ExecutorRegisterInfo info = {};
703     uint64_t index = 0;
704     std::vector<uint8_t> publicKey;
705     std::vector<uint64_t> templateIds;
706     uint64_t contextId = 123456;
707     AuthType authType = AuthType::FACE;
708     std::vector<uint8_t> challenge;
709     uint32_t executorSensorHint[2] = {-1234, 1234};
710     ScheduleInfo scheduleInfo = {};
711 
712     for (i = 0; i < 2; i++) {
713         info.authType = AuthType::FACE;
714         info.executorRole = ExecutorRole::ALL_IN_ONE;
715         info.esl = ExecutorSecureLevel::ESL0;
716         info.publicKey.resize(32);
717         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
718         EXPECT_NE(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint[i], scheduleInfo),
719                   0);
720         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
721     }
722 }
723 /**
724  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8200
725  * @tc.name  : testBeginIdentification013
726  * @tc.desc  : The AddExecutor function is called to add the authentication actuator,
727  *              and then the BeginIdentification function is called 50 times to start the identification
728  */
729 HWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification013, Function | MediumTest | Level2)
730 {
731     int i = 0;
732     ExecutorRegisterInfo info = {};
733     info.authType = AuthType::FACE;
734     info.executorRole = ExecutorRole::ALL_IN_ONE;
735     info.esl = ExecutorSecureLevel::ESL0;
736     info.publicKey.resize(32);
737     uint64_t index = 0;
738     std::vector<uint8_t> publicKey;
739     std::vector<uint64_t> templateIds;
740     EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
741 
742     uint64_t contextId = 123456;
743     AuthType authType = AuthType::FACE;
744     std::vector<uint8_t> challenge;
745     uint32_t executorSensorHint = 0;
746     ScheduleInfo scheduleInfo = {};
747     EXPECT_EQ(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
748     while (i < 50) {
749         EXPECT_NE(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
750         cout << "i = " << i << endl;
751         i++;
752     }
753     EXPECT_EQ(g_service.DeleteExecutor(index), 0);
754 }
755 /**
756  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8300
757  * @tc.name  : testUpdateIdentificationResult001
758  * @tc.desc  : Call the BeginIdentification function to start recognition,
759  *              and then call the UpdateIdenticationResult function to update the recognition result
760  */
761 HWTEST_F(UserIamUserAuthTestAdditional, testUpdateIdentificationResult001, Function | MediumTest | Level2)
762 {
763     int size[2] = {0, 32};
764     uint32_t i = 0;
765     ExecutorRegisterInfo info = {};
766     uint64_t index = 0;
767     std::vector<uint8_t> publicKey;
768     std::vector<uint64_t> templateIds;
769     uint64_t contextId = 123456;
770     std::vector<uint8_t> scheduleResult;
771     std::vector<uint8_t> challenge;
772     uint32_t executorSensorHint = 0;
773     ScheduleInfo scheduleInfo = {};
774     AuthType authType = AuthType::FACE;
775     IdentifyResultInfo identityResultInfo = {};
776 
777     for (i = 0; i < 2; i++) {
778         info.authType = AuthType::FACE;
779         info.executorRole = ExecutorRole::ALL_IN_ONE;
780         info.esl = ExecutorSecureLevel::ESL0;
781         info.publicKey.resize(32);
782         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
783         EXPECT_EQ(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
784 
785         scheduleResult.resize(size[i]);
786         EXPECT_NE(g_service.UpdateIdentificationResult(contextId, scheduleResult, identityResultInfo), 0);
787         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
788         EXPECT_EQ(g_service.Init(), 0);
789     }
790 }
791 /**
792  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8800
793  * @tc.name  : testCancelIdentification003
794  * @tc.desc  : Cancel by calling the CancelIdentification function directly
795  */
796 HWTEST_F(UserIamUserAuthTestAdditional, testCancelIdentification003, Function | MediumTest | Level2)
797 {
798     uint64_t contextId = 1000;
799     EXPECT_NE(g_service.CancelIdentification(contextId), 0);
800 }
801 /**
802  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8900
803  * @tc.name  : testCancelIdentification004
804  * @tc.desc  : Cancel by calling the CancelIdentification function directly
805  */
806 HWTEST_F(UserIamUserAuthTestAdditional, testCancelIdentification004, Function | MediumTest | Level2)
807 {
808     uint64_t contextId = 123456;
809     AuthType authType = AuthType::FACE;
810     std::vector<uint8_t> challenge;
811     uint32_t executorSensorHint = 0;
812     ScheduleInfo scheduleInfo = {};
813     EXPECT_NE(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
814     EXPECT_NE(g_service.CancelIdentification(contextId), 0);
815 }
816 /**
817  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_9000
818  * @tc.name  : testGetAuthTrustLevel001
819  * @tc.desc  : Directly call the GetAuthTrustLevel function, with the first input parameter
820  *              being userId=1000 and the second input parameter being all authType
821  */
822 HWTEST_F(UserIamUserAuthTestAdditional, testGetAuthTrustLevel001, Function | MediumTest | Level2)
823 {
824     uint32_t i = 0;
825     int32_t userId = 1000;
826     uint32_t authType[] = {0, 1, 2, 4};
827     uint32_t authTrustLevel = 0;
828     for (i = 0; i < 4; i++) {
829         EXPECT_NE(g_service.GetAuthTrustLevel(userId, static_cast<AuthType>(authType[i]), authTrustLevel), 0);
830     }
831 }
832 /**
833  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_9400
834  * @tc.name  : testGetAuthTrustLevel005
835  * @tc.desc  : Call the BeginEnrollment function without calling the UpdateEnrollmentResult function to update and
836  *              enroll the result, and then call the GetAuthTrustLevel function,
837  *              with the first entry being userId = 12345. The second entry is authType = PIN
838  */
839 HWTEST_F(UserIamUserAuthTestAdditional, testGetAuthTrustLevel005, Function | MediumTest | Level2)
840 {
841     int32_t userId = 12345;
842     std::vector<uint8_t> challenge;
843     EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
844 
845     ExecutorRegisterInfo info = {};
846     info.authType = AuthType::PIN;
847     info.executorRole = ExecutorRole::ALL_IN_ONE;
848     info.esl = ExecutorSecureLevel::ESL0;
849     info.publicKey.resize(32);
850     uint64_t index = 0;
851     std::vector<uint8_t> publicKey;
852     std::vector<uint64_t> templateIds;
853     EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
854 
855     std::vector<uint8_t> authToken;
856     EnrollParam param = {};
857     param.authType = AuthType::PIN;
858     ScheduleInfo scheduleInfo = {};
859     EXPECT_EQ(g_service.BeginEnrollment(userId, authToken, param, scheduleInfo), 0);
860 
861     AuthType authType = AuthType::PIN;
862     uint32_t authTrustLevel = 0;
863     EXPECT_NE(g_service.GetAuthTrustLevel(userId, authType, authTrustLevel), 0);
864     EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
865     EXPECT_EQ(g_service.DeleteExecutor(index), 0);
866     EXPECT_EQ(g_service.CloseSession(userId), 0);
867 }
868 /**
869  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_9500
870  * @tc.name  : testBeginEnrollmentV1_1_001
871  * @tc.desc  : Call the HDI-encapsulated BeginEnrollmentV1_1 function, and use a loop to assign the parameters
872  *              in the HdiBeginEnrollmentV1_1List struct to the BeginEnrollmentV1_1 function
873  */
874 HWTEST_F(UserIamUserAuthTestAdditional, testBeginEnrollmentV1_1_001, Function | MediumTest | Level2)
875 {
876     uint32_t i = 0;
877     HdiBeginEnrollmentV1_1List g_hdiBeginEnrollmentV1_1List;
878     uint32_t userId = g_hdiBeginEnrollmentV1_1List.userId[i];
879     std::vector<uint8_t> challenge;
880     EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
881 
882     ExecutorRegisterInfo info = {};
883     info.executorRole = ExecutorRole::ALL_IN_ONE;
884     info.esl = ExecutorSecureLevel::ESL0;
885     info.publicKey.resize(32);
886     uint64_t index = 0;
887     std::vector<uint8_t> publicKey;
888     std::vector<uint64_t> templateIds;
889 
890     std::vector<uint8_t> authToken;
891     EnrollParam param = {};
892     ScheduleInfoV1_1 scheduleInfo = {};
893 
894     for (i = 0; i < 4; i++) {
895         info.authType = static_cast<AuthType>(g_hdiBeginEnrollmentV1_1List.authType[i]);
896         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
897 
898         param.authType = static_cast<AuthType>(g_hdiBeginEnrollmentV1_1List.authType[i]);
899         param.executorSensorHint = g_hdiBeginEnrollmentV1_1List.executorSensorHint[i];
900         userId = g_hdiBeginEnrollmentV1_1List.userId[i];
901         if (i == 0) {
902             EXPECT_EQ(g_service.BeginEnrollmentV1_1(userId, authToken, param, scheduleInfo), 0);
903         } else {
904             EXPECT_NE(g_service.BeginEnrollmentV1_1(userId, authToken, param, scheduleInfo), 0);
905         }
906 
907         EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
908         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
909     }
910     EXPECT_EQ(g_service.CloseSession(userId), 0);
911 }
912 /**
913  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0250
914  * @tc.name  : testBeginAuthenticationV1_1_001
915  * @tc.desc  : Call the HDI-encapsulated BeginAuthenticationV1_1 function, and use a loop to assign the parameters
916  *              in the HdiBeginAuthenticationV1_1List structure to the BeginAuthenticationV1_1 function
917  */
918 HWTEST_F(UserIamUserAuthTestAdditional, testBeginAuthenticationV1_1_001, Function | MediumTest | Level2)
919 {
920     uint32_t i = 0;
921     uint32_t j;
922     HdiBeginAuthenticationV1_1List g_hdiBeginAuthenticationV1_1List;
923     uint32_t userId = g_hdiBeginAuthenticationV1_1List.userId[i];
924     std::vector<uint8_t> challenge;
925     EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
926 
927     ExecutorRegisterInfo info = {};
928     info.esl = ExecutorSecureLevel::ESL0;
929     info.publicKey.resize(32);
930     std::vector<uint8_t> publicKey;
931     std::vector<uint64_t> templateIds;
932     uint64_t index = 0;
933 
934     uint64_t contextId = 1;
935     AuthSolution authParam = {};
936     authParam.authTrustLevel = 0;
937     authParam.executorSensorHint = 0;
938     authParam.challenge = challenge;
939     std::vector<ScheduleInfoV1_1> scheduleInfos;
940 
941     for (i = 0; i < 4; i++) {
942         info.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[i]);
943         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
944         for (j = 4; j > 0; j--) {
945             authParam.userId = g_hdiBeginAuthenticationV1_1List.userId[0];
946             authParam.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[j - 1]);
947             EXPECT_NE(g_service.BeginAuthenticationV1_1(contextId, authParam, scheduleInfos), 0);
948         }
949         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
950     }
951 
952     for (i = 1; i < 2; i++) {
953         info.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[i]);
954         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
955 
956         authParam.userId = g_hdiBeginAuthenticationV1_1List.userId[i];
957         authParam.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[i]);
958         EXPECT_NE(g_service.BeginAuthenticationV1_1(contextId, authParam, scheduleInfos), 0);
959     }
960     EXPECT_EQ(g_service.CloseSession(userId), 0);
961 }
962 /**
963  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0550
964  * @tc.name  : testBeginIdentificationV1_1_001
965  * @tc.desc  : The AddExecutor function is called first to add the authentication actuator,
966  *              and then the BeginIdentificationV1_1 function is called to start the identification
967  */
968 HWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentificationV1_1_001, Function | MediumTest | Level2)
969 {
970     uint32_t i = 0;
971     uint32_t j = 0;
972     HdiBeginIdentificationV1_1List g_hdiBeginIdentificationV1_1List;
973 
974     ExecutorRegisterInfo info = {};
975     info.authType = AuthType::FACE;
976     info.executorRole = ExecutorRole::ALL_IN_ONE;
977     info.esl = ExecutorSecureLevel::ESL0;
978     info.publicKey.resize(32);
979     uint64_t index = 0;
980     std::vector<uint8_t> publicKey;
981     std::vector<uint64_t> templateIds;
982 
983     uint64_t contextId = 123456;
984     AuthType authType = AuthType::FACE;
985     std::vector<uint8_t> challenge;
986     uint32_t executorSensorHint = 0;
987     ScheduleInfoV1_1 scheduleInfo = {};
988 
989     for (i = 0; i < 2; i++) {
990         for (j = 0; j < 4; j++) {
991             authType = static_cast<AuthType>(g_hdiBeginIdentificationV1_1List.authType[j]);
992             if (i == 1 && authType == AuthType::FACE) {
993                 EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
994                 EXPECT_EQ(
995                     g_service.BeginIdentificationV1_1(contextId, authType, challenge, executorSensorHint, scheduleInfo),
996                     0);
997             } else {
998                 EXPECT_NE(
999                     g_service.BeginIdentificationV1_1(contextId, authType, challenge, executorSensorHint, scheduleInfo),
1000                     0);
1001             }
1002         }
1003     }
1004 }
1005 /**
1006  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0890
1007  * @tc.name  : testGetAllUserInfo001
1008  * @tc.desc  : Call the GetAllUserInfo function to get the information
1009  */
1010 HWTEST_F(UserIamUserAuthTestAdditional, testGetAllUserInfo001, Function | MediumTest | Level1)
1011 {
1012     std::vector<UserInfo> userInfos;
1013     EXPECT_EQ(g_service.GetAllUserInfo(userInfos), 0);
1014 }
1015 /**
1016  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0910
1017  * @tc.name  : testInit001
1018  * @tc.desc  : Call the Init function for initialization
1019  */
1020 HWTEST_F(UserIamUserAuthTestAdditional, testInit001, Function | MediumTest | Level1)
1021 {
1022     cout << "start Init" << endl;
1023     EXPECT_EQ(g_service.Init(), 0);
1024 }
1025 /**
1026  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0920
1027  * @tc.name  : testBeginIdentification014
1028  * @tc.desc  : Verify that the function BeginIdentification returns a failure when the first entry structure of the
1029  *              function AddExecutor is ExecutorRegisterInfo->executorRole = COLLECTOR/VERIFIER/ALL_IN_ONE
1030  */
1031 HWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification014, Function | MediumTest | Level2)
1032 {
1033     uint32_t i = 0;
1034     uint64_t index = 0;
1035     std::vector<uint8_t> publicKey;
1036     std::vector<uint64_t> templateIds;
1037     uint32_t executorRole[3] = {1, 2, 3};
1038     ExecutorRegisterInfo info = {};
1039     uint64_t contextId = 123456;
1040     std::vector<uint8_t> challenge;
1041     uint32_t executorSensorHint = 0;
1042     ScheduleInfo scheduleInfo = {};
1043 
1044     for (i = 0; i < 3; i++) {
1045         info.authType = AuthType::FACE;
1046         info.executorRole = static_cast<ExecutorRole>(executorRole[i]);
1047         info.esl = ExecutorSecureLevel::ESL0;
1048         info.publicKey.resize(32);
1049         if (executorRole[i] == ExecutorRole::ALL_IN_ONE) {
1050             EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
1051             EXPECT_EQ(
1052                 g_service.BeginIdentification(contextId, AuthType::FACE, challenge, executorSensorHint, scheduleInfo),
1053                 0);
1054             EXPECT_EQ(g_service.DeleteExecutor(index), 0);
1055         } else {
1056             EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
1057             EXPECT_NE(
1058                 g_service.BeginIdentification(contextId, AuthType::FACE, challenge, executorSensorHint, scheduleInfo),
1059                 0);
1060             EXPECT_EQ(g_service.DeleteExecutor(index), 0);
1061         }
1062     }
1063 }
1064 /**
1065  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0940
1066  * @tc.name  : testBeginIdentification016
1067  * @tc.desc  : Verify that the function BeginIdentification returns a success when the first entry structure of the
1068  *              function AddExecutor is ExecutorRegisterInfo->esl = ESL0\ESL1\ESL2\ESL3
1069  */
1070 HWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification016, Function | MediumTest | Level1)
1071 {
1072     uint32_t i = 0;
1073     uint64_t index = 0;
1074     std::vector<uint8_t> publicKey;
1075     std::vector<uint64_t> templateIds;
1076     uint32_t esl[4] = {0, 1, 2, 3};
1077     ExecutorRegisterInfo info = {};
1078     uint64_t contextId = 123456;
1079     std::vector<uint8_t> challenge;
1080     uint32_t executorSensorHint = 0;
1081     ScheduleInfo scheduleInfo = {};
1082 
1083     for (i = 0; i < 4; i++) {
1084         info.authType = AuthType::FACE;
1085         info.executorRole = ExecutorRole::ALL_IN_ONE;
1086         info.esl = static_cast<ExecutorSecureLevel>(esl[i]);
1087         info.publicKey.resize(32);
1088 
1089         EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
1090         EXPECT_EQ(g_service.BeginIdentification(contextId, AuthType::FACE, challenge, executorSensorHint, scheduleInfo),
1091                   0);
1092         EXPECT_EQ(g_service.DeleteExecutor(index), 0);
1093         EXPECT_EQ(g_service.Init(), 0);
1094     }
1095 }
1096 /**
1097  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1110
1098  * @tc.name  : testGetValidSolution001
1099  * @tc.desc  : Call the GetValidSolution function to get the the authentication information
1100  */
1101 HWTEST_F(UserIamUserAuthTestAdditional, testGetValidSolution001, Function | MediumTest | Level2)
1102 {
1103     int32_t userId = parcel.ReadInt32();
1104     std::vector<AuthType> authTypes = {AuthType::ALL, AuthType::PIN, AuthType::FACE, AuthType::FINGERPRINT};
1105     uint32_t authTrustLevel = 0;
1106     std::vector<AuthType> validTypes;
1107     EXPECT_NE(g_service.GetValidSolution(userId, authTypes, authTrustLevel, validTypes), 0);
1108 }
1109 /**
1110  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1120
1111  * @tc.name  : testDeleteCredential001
1112  * @tc.desc  : Call the DeleteCredential function to deletes credential information
1113  */
1114 HWTEST_F(UserIamUserAuthTestAdditional, testDeleteCredential001, Function | MediumTest | Level2)
1115 {
1116     int32_t userId = parcel.ReadInt32();
1117     uint64_t credentialId = parcel.ReadUint64();
1118     std::vector<uint8_t> authToken;
1119     CredentialInfo info;
1120     EXPECT_NE(g_service.DeleteCredential(userId, credentialId, authToken, info), 0);
1121 }
1122 /**
1123  * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1130
1124  * @tc.name  : testUpdateEnrollmentResult001
1125  * @tc.desc  : Call the UpdateEnrollmentResult function directly to update and enroll the result
1126  */
1127 HWTEST_F(UserIamUserAuthTestAdditional, testUpdateEnrollmentResult001, Function | MediumTest | Level2)
1128 {
1129     int32_t userId = 12345;
1130     std::vector<uint8_t> challenge;
1131     EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
1132 
1133     std::vector<uint8_t> scheduleResult(1);
1134     scheduleResult[0] = 1;
1135     EnrollResultInfo enrolledResultInfo = {};
1136     EXPECT_NE(g_service.UpdateEnrollmentResult(userId, scheduleResult, enrolledResultInfo), 0);
1137 
1138     EXPECT_EQ(g_service.CloseSession(userId), 0);
1139 }