• 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::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 
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<AuthType> & vector)46 static void FillAuthTypeVector(Parcel &parcel, vector<AuthType> &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] = static_cast<AuthType>(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 }
60 
FillExecutorRegisterInfo(Parcel & parcel,ExecutorRegisterInfo & executorRegisterInfo)61 static void FillExecutorRegisterInfo(Parcel &parcel, ExecutorRegisterInfo &executorRegisterInfo)
62 {
63     executorRegisterInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
64     executorRegisterInfo.executorRole = static_cast<ExecutorRole>(parcel.ReadInt32());
65     executorRegisterInfo.executorSensorHint = parcel.ReadUint32();
66     executorRegisterInfo.executorMatcher = parcel.ReadUint32();
67     executorRegisterInfo.esl = static_cast<ExecutorSecureLevel>(parcel.ReadInt32());
68     FillTestUint8Vector(parcel, executorRegisterInfo.publicKey);
69 }
70 
FillExecutorInfo(Parcel & parcel,ExecutorInfo & executorInfo)71 static void FillExecutorInfo(Parcel &parcel, ExecutorInfo &executorInfo)
72 {
73     executorInfo.executorIndex = parcel.ReadUint64();
74     FillExecutorRegisterInfo(parcel, executorInfo.info);
75 }
76 
FillExecutorInfoVector(Parcel & parcel,vector<ExecutorInfo> & vector)77 static void FillExecutorInfoVector(Parcel &parcel, vector<ExecutorInfo> &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         FillExecutorInfo(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     FillExecutorInfoVector(parcel, scheduleInfo.executors);
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 
FillAuthSolution(Parcel & parcel,AuthSolution & authSolution)125 static void FillAuthSolution(Parcel &parcel, AuthSolution &authSolution)
126 {
127     authSolution.userId = parcel.ReadInt32();
128     authSolution.authTrustLevel = parcel.ReadUint32();
129     authSolution.authType = static_cast<AuthType>(parcel.ReadInt32());
130     authSolution.executorSensorHint = parcel.ReadUint32();
131     FillTestUint8Vector(parcel, authSolution.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 
FillTestScheduleInfoV1_1(Parcel & parcel,ScheduleInfoV1_1 & scheduleInfo)179 void FillTestScheduleInfoV1_1(Parcel &parcel, ScheduleInfoV1_1 &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     FillExecutorInfoVector(parcel, scheduleInfo.executors);
187     FillTestUint8Vector(parcel, scheduleInfo.extraInfo);
188     cout << "success"  << endl;
189 }
190 
FillTestScheduleInfoV1_1Vector(Parcel & parcel,vector<ScheduleInfoV1_1> & vector)191 void FillTestScheduleInfoV1_1Vector(Parcel &parcel, vector<ScheduleInfoV1_1> &vector)
192 {
193     uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
194     vector.resize(len);
195     for (uint32_t i = 0; i < len; i++) {
196         FillTestScheduleInfoV1_1(parcel, vector[i]);
197     }
198     cout << "success"  << endl;
199 }
200 
201 /**
202  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0101
203  * @tc.name: Test Init
204  * @tc.size: MediumTest
205  * @tc.type: Function
206  * @tc.level: Level1
207  */
208 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0101, Function | MediumTest | Level1)
209 {
210     cout << "start Init" << endl;
211     int32_t ret = g_service.Init();
212     EXPECT_EQ(ret, 0);
213 }
214 
215 /**
216  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0102
217  * @tc.name: Test AddExecutor
218  * @tc.size: MediumTest
219  * @tc.type: Function
220  * @tc.level: Level1
221  */
222 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0102, Function | MediumTest | Level1)
223 {
224     cout << "start AddExecutor" << endl;
225     ExecutorRegisterInfo info;
226     FillExecutorRegisterInfo(parcel, info);
227     uint64_t index = parcel.ReadUint64();
228     std::vector<uint8_t> publicKey;
229     FillTestUint8Vector(parcel, publicKey);
230     std::vector<uint64_t> templateIds;
231     FillTestUint64Vector(parcel, templateIds);
232     int32_t ret = g_service.AddExecutor(info, index, publicKey, templateIds);
233     cout << "ret is " << ret << endl;
234     ASSERT_EQ(ret != Expectedvalue, true);
235 }
236 
237 /**
238  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0103
239  * @tc.name: Test GetCredential
240  * @tc.size: MediumTest
241  * @tc.type: Function
242  * @tc.level: Level1
243  */
244 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0103, Function | MediumTest | Level1)
245 {
246     cout << "start GetCredential" << endl;
247     int32_t userId = parcel.ReadInt32();
248     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
249     std::vector<CredentialInfo> infos;
250     FillCredentialInfoVector(parcel, infos);
251     int32_t ret = g_service.GetCredential(userId, authType, infos);
252     cout << "ret is " << ret << endl;
253     EXPECT_EQ(ret, 0);
254 }
255 
256 /**
257  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0104
258  * @tc.name: Test GetUserInfo
259  * @tc.size: MediumTest
260  * @tc.type: Function
261  * @tc.level: Level1
262  */
263 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0104, Function | MediumTest | Level1)
264 {
265     cout << "start GetUserInfo" << endl;
266     int32_t userId = parcel.ReadInt32();
267     uint64_t secureUid = parcel.ReadUint64();
268     PinSubType pinSubType = static_cast<PinSubType>(parcel.ReadUint32());
269     std::vector<EnrolledInfo> infos;
270     FillEnrolledInfoVector(parcel, infos);
271     int32_t ret = g_service.GetUserInfo(userId, secureUid, pinSubType, infos);
272     cout << "ret is " << ret << endl;
273     ASSERT_EQ(ret != Expectedvalue, true);
274 }
275 
276 /**
277  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0105
278  * @tc.name: Test DeleteUser
279  * @tc.size: MediumTest
280  * @tc.type: Function
281  * @tc.level: Level1
282  */
283 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0105, Function | MediumTest | Level1)
284 {
285     cout << "start DeleteUser" << endl;
286     int32_t userId = parcel.ReadInt32();
287     std::vector<uint8_t> authToken;
288     FillTestUint8Vector(parcel, authToken);
289     std::vector<CredentialInfo> deletedInfos;
290     FillCredentialInfoVector(parcel, deletedInfos);
291     int32_t ret = g_service.DeleteUser(userId, authToken, deletedInfos);
292     cout << "ret is " << ret << endl;
293     ASSERT_EQ(ret != Expectedvalue, true);
294 }
295 
296 /**
297  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0106
298  * @tc.name: Test BeginIdentification
299  * @tc.size: MediumTest
300  * @tc.type: Function
301  * @tc.level: Level1
302  */
303 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0106, Function | MediumTest | Level1)
304 {
305     cout << "start BeginIdentification" << endl;
306     uint64_t contextId = parcel.ReadUint64();
307     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
308     std::vector<uint8_t> challenge;
309     FillTestUint8Vector(parcel, challenge);
310     uint32_t executorId = parcel.ReadUint32();
311     ScheduleInfo scheduleInfo;
312     FillScheduleInfo(parcel, scheduleInfo);
313     int32_t ret = g_service.BeginIdentification(contextId, authType, challenge, executorId, scheduleInfo);
314     cout << "ret is " << ret << endl;
315     ASSERT_EQ(ret != Expectedvalue, true);
316 }
317 
318 /**
319  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0107
320  * @tc.name: Test DeleteExecutor
321  * @tc.size: MediumTest
322  * @tc.type: Function
323  * @tc.level: Level1
324  */
325 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0107, Function | MediumTest | Level1)
326 {
327     cout << "start DeleteExecutor" << endl;
328     uint64_t index = parcel.ReadUint64();
329     int32_t ret = g_service.DeleteExecutor(index);
330     cout << "ret is " << ret << endl;
331     ASSERT_EQ(ret != Expectedvalue, true);
332 }
333 
334 /**
335  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0108
336  * @tc.name: Test OpenSession
337  * @tc.size: MediumTest
338  * @tc.type: Function
339  * @tc.level: Level1
340  */
341 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0108, Function | MediumTest | Level1)
342 {
343     cout << "start OpenSession" << endl;
344     int32_t userId = parcel.ReadInt32();
345     std::vector<uint8_t> challenge;
346     FillTestUint8Vector(parcel, challenge);
347     int32_t ret = g_service.OpenSession(userId, challenge);
348     cout << "ret is " << ret << endl;
349     EXPECT_EQ(ret, 0);
350 }
351 
352 /**
353  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0109
354  * @tc.name: Test CloseSession
355  * @tc.size: MediumTest
356  * @tc.type: Function
357  * @tc.level: Level1
358  */
359 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0109, Function | MediumTest | Level1)
360 {
361     cout << "start CloseSession" << endl;
362     int32_t userId = parcel.ReadInt32();
363     int32_t ret = g_service.CloseSession(userId);
364     cout << "ret is " << ret << endl;
365     EXPECT_EQ(ret, 0);
366 }
367 
368 /**
369  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0110
370  * @tc.name: Test BeginEnrollment
371  * @tc.size: MediumTest
372  * @tc.type: Function
373  * @tc.level: Level1
374  */
375 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0110, Function | MediumTest | Level1)
376 {
377     cout << "start BeginEnrollment" << endl;
378     int32_t userId = parcel.ReadInt32();
379     std::vector<uint8_t> authToken;
380     FillTestUint8Vector(parcel, authToken);
381     EnrollParam param;
382     FillEnrollParam(parcel, param);
383     ScheduleInfo info;
384     FillScheduleInfo(parcel, info);
385     int32_t ret = g_service.BeginEnrollment(userId, authToken, param, info);
386     cout << "ret is " << ret << endl;
387     ASSERT_EQ(ret != Expectedvalue, true);
388 }
389 
390 /**
391  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0111
392  * @tc.name: Test UpdateEnrollmentResult
393  * @tc.size: MediumTest
394  * @tc.type: Function
395  * @tc.level: Level1
396  */
397 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0111, Function | MediumTest | Level1)
398 {
399     cout << "start UpdateEnrollmentResult" << endl;
400     int32_t userId = parcel.ReadInt32();
401     std::vector<uint8_t> scheduleResult;
402     FillTestUint8Vector(parcel, scheduleResult);
403     EnrollResultInfo info = {};
404     FillCredentialInfo(parcel, info.oldInfo);
405     info.credentialId = parcel.ReadUint64();
406     FillTestUint8Vector(parcel, info.rootSecret);
407     int32_t ret = g_service.UpdateEnrollmentResult(userId, scheduleResult, info);
408     cout << "ret is " << ret << endl;
409     ASSERT_EQ(ret != Expectedvalue, true);
410 }
411 
412 /**
413  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0112
414  * @tc.name: Test CancelEnrollment
415  * @tc.size: MediumTest
416  * @tc.type: Function
417  * @tc.level: Level1
418  */
419 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0112, Function | MediumTest | Level1)
420 {
421     cout << "start CancelEnrollment" << endl;
422     int32_t userId = parcel.ReadInt32();
423     int32_t ret = g_service.CancelEnrollment(userId);
424     cout << "ret is " << ret << endl;
425     EXPECT_EQ(ret, 0);
426 }
427 
428 /**
429  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0113
430  * @tc.name: Test DeleteCredential
431  * @tc.size: MediumTest
432  * @tc.type: Function
433  * @tc.level: Level1
434  */
435 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0113, Function | MediumTest | Level1)
436 {
437     cout << "start DeleteCredential" << endl;
438     int32_t userId = parcel.ReadInt32();
439     uint64_t credentialId = parcel.ReadUint64();
440     std::vector<uint8_t> authToken;
441     FillTestUint8Vector(parcel, authToken);
442     CredentialInfo info;
443     FillCredentialInfo(parcel, info);
444     int32_t ret = g_service.DeleteCredential(userId, credentialId, authToken, info);
445     cout << "ret is " << ret << endl;
446     ASSERT_EQ(ret != Expectedvalue, true);
447 }
448 
449 /**
450  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0114
451  * @tc.name: Test EnforceDeleteUser
452  * @tc.size: MediumTest
453  * @tc.type: Function
454  * @tc.level: Level1
455  */
456 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0114, Function | MediumTest | Level1)
457 {
458     cout << "start EnforceDeleteUser" << endl;
459     int32_t userId = parcel.ReadInt32();
460     std::vector<CredentialInfo> deletedInfos;
461     FillCredentialInfoVector(parcel, deletedInfos);
462     int32_t ret = g_service.EnforceDeleteUser(userId, deletedInfos);
463     cout << "ret is " << ret << endl;
464     ASSERT_EQ(ret != Expectedvalue, true);
465 }
466 
467 /**
468  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0115
469  * @tc.name: Test BeginAuthentication
470  * @tc.size: MediumTest
471  * @tc.type: Function
472  * @tc.level: Level1
473  */
474 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0115, Function | MediumTest | Level1)
475 {
476     cout << "start BeginAuthentication" << endl;
477     uint64_t contextId = parcel.ReadUint64();
478     AuthSolution param;
479     FillAuthSolution(parcel, param);
480     std::vector<ScheduleInfo> scheduleInfos;
481     FillScheduleInfoVector(parcel, scheduleInfos);
482     int32_t ret = g_service.BeginAuthentication(contextId, param, scheduleInfos);
483     cout << "ret is " << ret << endl;
484     ASSERT_EQ(ret != Expectedvalue, true);
485 }
486 
487 /**
488  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0116
489  * @tc.name: Test UpdateAuthenticationResult
490  * @tc.size: MediumTest
491  * @tc.type: Function
492  * @tc.level: Level1
493  */
494 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0116, Function | MediumTest | Level1)
495 {
496     cout << "start UpdateAuthenticationResult" << endl;
497     uint64_t contextId = parcel.ReadUint64();
498     std::vector<uint8_t> scheduleResult;
499     FillTestUint8Vector(parcel, scheduleResult);
500     AuthResultInfo info;
501     FillAuthResultInfo(parcel, info);
502     int32_t ret = g_service.UpdateAuthenticationResult(contextId, scheduleResult, info);
503     cout << "ret is " << ret << endl;
504     ASSERT_EQ(ret != Expectedvalue, true);
505 }
506 
507 /**
508  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0117
509  * @tc.name: Test CancelAuthentication
510  * @tc.size: MediumTest
511  * @tc.type: Function
512  * @tc.level: Level1
513  */
514 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0117, Function | MediumTest | Level1)
515 {
516     cout << "start CancelAuthentication" << endl;
517     uint64_t contextId = parcel.ReadUint64();
518     int32_t ret = g_service.CancelAuthentication(contextId);
519     cout << "ret is " << ret << endl;
520     ASSERT_EQ(ret != Expectedvalue, true);
521 }
522 
523 /**
524  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0118
525  * @tc.name: Test UpdateIdentificationResult
526  * @tc.size: MediumTest
527  * @tc.type: Function
528  * @tc.level: Level1
529  */
530 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0118, Function | MediumTest | Level1)
531 {
532     cout << "start UpdateIdentificationResult" << endl;
533     uint64_t contextId = parcel.ReadUint64();
534     std::vector<uint8_t> scheduleResult;
535     FillTestUint8Vector(parcel, scheduleResult);
536     IdentifyResultInfo info;
537     FillIdentifyResultInfo(parcel, info);
538     int32_t ret = g_service.UpdateIdentificationResult(contextId, scheduleResult, info);
539     cout << "ret is " << ret << endl;
540     ASSERT_EQ(ret != Expectedvalue, true);
541 }
542 
543 /**
544  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0119
545  * @tc.name: Test CancelIdentification
546  * @tc.size: MediumTest
547  * @tc.type: Function
548  * @tc.level: Level1
549  */
550 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0119, Function | MediumTest | Level1)
551 {
552     cout << "start CancelIdentification" << endl;
553     uint64_t contextId = parcel.ReadUint64();
554     int32_t ret = g_service.CancelIdentification(contextId);
555     cout << "ret is " << ret << endl;
556     ASSERT_EQ(ret != Expectedvalue, true);
557 }
558 
559 /**
560  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0120
561  * @tc.name: Test GetAuthTrustLevel
562  * @tc.size: MediumTest
563  * @tc.type: Function
564  * @tc.level: Level1
565  */
566 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0120, Function | MediumTest | Level1)
567 {
568     cout << "start GetAuthTrustLevel" << endl;
569     int32_t userId = parcel.ReadInt32();
570     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
571     uint32_t authTrustLevel = parcel.ReadUint32();
572     int32_t ret = g_service.GetAuthTrustLevel(userId, authType, authTrustLevel);
573     cout << "ret is " << ret << endl;
574     ASSERT_EQ(ret != Expectedvalue, true);
575 }
576 
577 /**
578  * @tc.number: Security_IAM_UserAuth_HDI_FUNC_0121
579  * @tc.name: Test GetValidSolution
580  * @tc.size: MediumTest
581  * @tc.type: Function
582  * @tc.level: Level1
583  */
584 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_FUNC_0121, Function | MediumTest | Level1)
585 {
586     cout << "start GetValidSolution" << endl;
587     int32_t userId = parcel.ReadInt32();
588     std::vector<AuthType> authTypes;
589     FillAuthTypeVector(parcel, authTypes);
590     uint32_t authTrustLevel = parcel.ReadUint32();
591     std::vector<AuthType> validTypes;
592     FillAuthTypeVector(parcel, validTypes);
593     int32_t ret = g_service.GetValidSolution(userId, authTypes, authTrustLevel, validTypes);
594     cout << "ret is " << ret << endl;
595     ASSERT_EQ(ret != Expectedvalue, true);
596 }
597 
598 /**
599  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0101
600  * @tc.name: Test BeginEnrollmentV1_1
601  * @tc.size: MediumTest
602  * @tc.type: Function
603  * @tc.level: Level1
604  */
605 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0101, Function | MediumTest | Level1)
606 {
607     cout << "start BeginEnrollmentV1_1" << endl;
608     int32_t userId = parcel.ReadInt32();
609     std::vector<uint8_t> authToken;
610     FillTestUint8Vector(parcel, authToken);
611     EnrollParam param;
612     FillEnrollParam(parcel, param);
613     ScheduleInfoV1_1 info;
614     FillTestScheduleInfoV1_1(parcel, info);
615     int32_t ret = g_service.BeginEnrollmentV1_1(userId, authToken, param, info);
616 
617     ASSERT_EQ(ret != Expectedvalue, true);
618 }
619 
620 /**
621  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0102
622  * @tc.name: Test BeginAuthenticationV1_1
623  * @tc.size: MediumTest
624  * @tc.type: Function
625  * @tc.level: Level1
626  */
627 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0102, Function | MediumTest | Level1)
628 {
629     cout << "start BeginAuthenticationV1_1" << endl;
630     uint64_t contextId = parcel.ReadUint64();
631     AuthSolution param;
632     FillAuthSolution(parcel, param);
633     std::vector<ScheduleInfoV1_1> scheduleInfos;
634     FillTestScheduleInfoV1_1Vector(parcel, scheduleInfos);
635     int32_t ret = g_service.BeginAuthenticationV1_1(contextId, param, scheduleInfos);
636 
637     ASSERT_EQ(ret != Expectedvalue, true);
638 }
639 
640 /**
641  * @tc.number: Security_IAM_UserAuth_HDI_NEW_FUNC_0103
642  * @tc.name: Test BeginIdentificationV1_1
643  * @tc.size: MediumTest
644  * @tc.type: Function
645  * @tc.level: Level1
646  */
647 HWTEST_F(UserIamUserAuthTest, Security_IAM_UserAuth_HDI_NEW_FUNC_0103, Function | MediumTest | Level1)
648 {
649     cout << "start BeginIdentificationV1_1" << endl;
650     uint64_t contextId = parcel.ReadUint64();
651     AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
652     std::vector<uint8_t> challenge;
653     FillTestUint8Vector(parcel, challenge);
654     uint32_t executorId = parcel.ReadUint32();
655     ScheduleInfoV1_1 scheduleInfo;
656     FillTestScheduleInfoV1_1(parcel, scheduleInfo);
657     int32_t ret = g_service.BeginIdentificationV1_1(contextId, authType, challenge, executorId, scheduleInfo);
658 
659     ASSERT_EQ(ret != Expectedvalue, true);
660 }