19762338dSopenharmony_ci/*
29762338dSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
39762338dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
49762338dSopenharmony_ci * you may not use this file except in compliance with the License.
59762338dSopenharmony_ci * You may obtain a copy of the License at
69762338dSopenharmony_ci *
79762338dSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
89762338dSopenharmony_ci *
99762338dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
109762338dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
119762338dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129762338dSopenharmony_ci * See the License for the specific language governing permissions and
139762338dSopenharmony_ci * limitations under the License.
149762338dSopenharmony_ci */
159762338dSopenharmony_ci
169762338dSopenharmony_ci#include "iam_hat_test.h"
179762338dSopenharmony_ci#include "user_auth_hdi_test.h"
189762338dSopenharmony_ci
199762338dSopenharmony_ciusing namespace std;
209762338dSopenharmony_ciusing namespace testing::ext;
219762338dSopenharmony_ciusing namespace OHOS::UserIam::Common;
229762338dSopenharmony_ciusing namespace OHOS::HDI::UserAuth;
239762338dSopenharmony_ciusing namespace OHOS::HDI::UserAuth::V2_0;
249762338dSopenharmony_ci
259762338dSopenharmony_cistatic const uint32_t MAX_FUZZ_STRUCT_LEN = 20;
269762338dSopenharmony_cistatic UserAuthInterfaceService g_service;
279762338dSopenharmony_ciint32_t Expectedvalue = 0;
289762338dSopenharmony_cistatic OHOS::Parcel parcel;
299762338dSopenharmony_ci
309762338dSopenharmony_cistruct HdiBeginEnrollmentList {
319762338dSopenharmony_ci    int32_t userId[4] = {12345, 1234, 12345, 12345};
329762338dSopenharmony_ci    int32_t authType[4] = {1, 0, 2, 4};
339762338dSopenharmony_ci    uint32_t executorSensorHint[4] = {0, 65535, 1, 0};
349762338dSopenharmony_ci};
359762338dSopenharmony_cistruct HdiBeginAuthenticationList {
369762338dSopenharmony_ci    uint32_t authType[4] = {0, 1, 2, 4};
379762338dSopenharmony_ci    uint32_t userId[4] = {356581, 1};
389762338dSopenharmony_ci};
399762338dSopenharmony_cistruct HdiBeginIdentificationList {
409762338dSopenharmony_ci    uint32_t addExecutor[2] = {0, 1};
419762338dSopenharmony_ci    uint32_t authType[4] = {0, 1, 2, 4};
429762338dSopenharmony_ci};
439762338dSopenharmony_ci
449762338dSopenharmony_civoid UserIamUserAuthTestAdditional::SetUpTestCase() {}
459762338dSopenharmony_ci
469762338dSopenharmony_civoid UserIamUserAuthTestAdditional::TearDownTestCase() {}
479762338dSopenharmony_ci
489762338dSopenharmony_civoid UserIamUserAuthTestAdditional::SetUp()
499762338dSopenharmony_ci{
509762338dSopenharmony_ci    const std::string deviceUdid = std::string(64, '0');
519762338dSopenharmony_ci    EXPECT_EQ(g_service.Init(deviceUdid), 0);
529762338dSopenharmony_ci}
539762338dSopenharmony_ci
549762338dSopenharmony_civoid UserIamUserAuthTestAdditional::TearDown() {}
559762338dSopenharmony_ci
569762338dSopenharmony_cistatic void FillEnrollParam(Parcel &parcel, EnrollParam &enrollParam)
579762338dSopenharmony_ci{
589762338dSopenharmony_ci    enrollParam.authType = static_cast<AuthType>(parcel.ReadInt32());
599762338dSopenharmony_ci    enrollParam.executorSensorHint = parcel.ReadUint32();
609762338dSopenharmony_ci    enrollParam.userId = parcel.ReadInt32();
619762338dSopenharmony_ci}
629762338dSopenharmony_ci
639762338dSopenharmony_cistatic void FillExecutorIndexInfo(Parcel &parcel, uint64_t &executorIndex)
649762338dSopenharmony_ci{
659762338dSopenharmony_ci    executorIndex = parcel.ReadUint64();
669762338dSopenharmony_ci}
679762338dSopenharmony_ci
689762338dSopenharmony_cistatic void FillExecutorIndexVector(Parcel &parcel, vector<uint64_t > &vector)
699762338dSopenharmony_ci{
709762338dSopenharmony_ci    uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
719762338dSopenharmony_ci    vector.resize(len);
729762338dSopenharmony_ci    for (uint32_t i = 0; i < len; i++) {
739762338dSopenharmony_ci        FillExecutorIndexInfo(parcel, vector[i]);
749762338dSopenharmony_ci    }
759762338dSopenharmony_ci}
769762338dSopenharmony_ci
779762338dSopenharmony_cistatic void FillScheduleInfo(Parcel &parcel, ScheduleInfo &scheduleInfo)
789762338dSopenharmony_ci{
799762338dSopenharmony_ci    scheduleInfo.scheduleId = parcel.ReadUint64();
809762338dSopenharmony_ci    FillTestUint64Vector(parcel, scheduleInfo.templateIds);
819762338dSopenharmony_ci    scheduleInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
829762338dSopenharmony_ci    scheduleInfo.executorMatcher = parcel.ReadUint32();
839762338dSopenharmony_ci    scheduleInfo.scheduleMode = static_cast<ScheduleMode>(parcel.ReadInt32());
849762338dSopenharmony_ci    FillExecutorIndexVector(parcel, scheduleInfo.executorIndexes);
859762338dSopenharmony_ci}
869762338dSopenharmony_ci
879762338dSopenharmony_cistatic void FillCredentialInfo(Parcel &parcel, CredentialInfo &credentialInfo)
889762338dSopenharmony_ci{
899762338dSopenharmony_ci    credentialInfo.credentialId = parcel.ReadUint64();
909762338dSopenharmony_ci    credentialInfo.executorIndex = parcel.ReadUint64();
919762338dSopenharmony_ci    credentialInfo.templateId = parcel.ReadUint64();
929762338dSopenharmony_ci    credentialInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
939762338dSopenharmony_ci    credentialInfo.executorMatcher = parcel.ReadUint32();
949762338dSopenharmony_ci    credentialInfo.executorSensorHint = parcel.ReadUint32();
959762338dSopenharmony_ci}
969762338dSopenharmony_ci
979762338dSopenharmony_cistatic void FillEnrolledInfo(Parcel &parcel, EnrolledInfo &enrolledInfo)
989762338dSopenharmony_ci{
999762338dSopenharmony_ci    enrolledInfo.enrolledId = parcel.ReadUint64();
1009762338dSopenharmony_ci    enrolledInfo.authType = static_cast<AuthType>(parcel.ReadInt32());
1019762338dSopenharmony_ci}
1029762338dSopenharmony_ci
1039762338dSopenharmony_cistatic void FillCredentialInfoVector(Parcel &parcel, vector<CredentialInfo> &vector)
1049762338dSopenharmony_ci{
1059762338dSopenharmony_ci    uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
1069762338dSopenharmony_ci    vector.resize(len);
1079762338dSopenharmony_ci    for (uint32_t i = 0; i < len; i++) {
1089762338dSopenharmony_ci        FillCredentialInfo(parcel, vector[i]);
1099762338dSopenharmony_ci    }
1109762338dSopenharmony_ci}
1119762338dSopenharmony_ci
1129762338dSopenharmony_cistatic void FillEnrolledInfoVector(Parcel &parcel, vector<EnrolledInfo> &vector)
1139762338dSopenharmony_ci{
1149762338dSopenharmony_ci    uint32_t len = parcel.ReadInt32() % MAX_FUZZ_STRUCT_LEN;
1159762338dSopenharmony_ci    vector.resize(len);
1169762338dSopenharmony_ci    for (uint32_t i = 0; i < len; i++) {
1179762338dSopenharmony_ci        FillEnrolledInfo(parcel, vector[i]);
1189762338dSopenharmony_ci    }
1199762338dSopenharmony_ci}
1209762338dSopenharmony_ci
1219762338dSopenharmony_ci/**
1229762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0200
1239762338dSopenharmony_ci * @tc.name  : testAddExecutor001
1249762338dSopenharmony_ci * @tc.desc  : First input parameter being the ExecutorRegisterInfo structure ->authType value being
1259762338dSopenharmony_ci * ALL/PIN/FACE/FINGERPRINT
1269762338dSopenharmony_ci */
1279762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testAddExecutor001, Function | MediumTest | Level1)
1289762338dSopenharmony_ci{
1299762338dSopenharmony_ci    uint32_t i = 0;
1309762338dSopenharmony_ci    uint32_t authType[4] = {0, 1, 2, 4};
1319762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
1329762338dSopenharmony_ci    uint64_t index = 0;
1339762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
1349762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
1359762338dSopenharmony_ci
1369762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
1379762338dSopenharmony_ci        info.authType = static_cast<AuthType>(authType[i]);
1389762338dSopenharmony_ci        info.publicKey.resize(32);
1399762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
1409762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
1419762338dSopenharmony_ci    }
1429762338dSopenharmony_ci}
1439762338dSopenharmony_ci/**
1449762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1800
1459762338dSopenharmony_ci * @tc.name  : testDeleteExecutor001
1469762338dSopenharmony_ci * @tc.desc  : Delete call without adding an authentication executor
1479762338dSopenharmony_ci */
1489762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testDeleteExecutor001, Function | MediumTest | Level2)
1499762338dSopenharmony_ci{
1509762338dSopenharmony_ci    cout << "start DeleteExecutor" << endl;
1519762338dSopenharmony_ci    uint64_t index = -1;
1529762338dSopenharmony_ci    auto ret = g_service.DeleteExecutor(index);
1539762338dSopenharmony_ci    cout << "ret is " << ret << endl;
1549762338dSopenharmony_ci    ASSERT_EQ(ret != Expectedvalue, true);
1559762338dSopenharmony_ci}
1569762338dSopenharmony_ci/**
1579762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1900
1589762338dSopenharmony_ci * @tc.name  : testDeleteExecutor002
1599762338dSopenharmony_ci * @tc.desc  : First call the AddExecutor function to add an authentication executor,
1609762338dSopenharmony_ci *              and then call the DeleteExecutor function to delete it
1619762338dSopenharmony_ci */
1629762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testDeleteExecutor002, Function | MediumTest | Level1)
1639762338dSopenharmony_ci{
1649762338dSopenharmony_ci    cout << "start DeleteExecutor" << endl;
1659762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
1669762338dSopenharmony_ci    info.authType = AuthType::ALL;
1679762338dSopenharmony_ci    info.publicKey.resize(32);
1689762338dSopenharmony_ci    uint64_t index = 0;
1699762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
1709762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
1719762338dSopenharmony_ci    EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
1729762338dSopenharmony_ci
1739762338dSopenharmony_ci    auto ret = g_service.DeleteExecutor(index);
1749762338dSopenharmony_ci    cout << "ret is " << ret << endl;
1759762338dSopenharmony_ci    EXPECT_EQ(ret, 0);
1769762338dSopenharmony_ci}
1779762338dSopenharmony_ci/**
1789762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2000
1799762338dSopenharmony_ci * @tc.name  : testDeleteExecutor003
1809762338dSopenharmony_ci * @tc.desc  : Call the AddExecutor function to add an authentication executor,
1819762338dSopenharmony_ci *              and then call the DeleteExecutor function to pass in different parameters for deletion
1829762338dSopenharmony_ci */
1839762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testDeleteExecutor003, Function | MediumTest | Level2)
1849762338dSopenharmony_ci{
1859762338dSopenharmony_ci    cout << "start DeleteExecutor" << endl;
1869762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
1879762338dSopenharmony_ci    info.authType = AuthType::ALL;
1889762338dSopenharmony_ci    info.publicKey.resize(32);
1899762338dSopenharmony_ci    uint64_t index = 0;
1909762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
1919762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
1929762338dSopenharmony_ci    EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
1939762338dSopenharmony_ci    EXPECT_NE(index, 0);
1949762338dSopenharmony_ci    index = 0;
1959762338dSopenharmony_ci    auto ret = g_service.DeleteExecutor(index);
1969762338dSopenharmony_ci    cout << "ret is " << ret << endl;
1979762338dSopenharmony_ci    EXPECT_NE(ret, 0);
1989762338dSopenharmony_ci}
1999762338dSopenharmony_ci/**
2009762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2200
2019762338dSopenharmony_ci * @tc.name  : testOpenSession002
2029762338dSopenharmony_ci * @tc.desc  : Call the OpenSession function with the parameter userId = -1/0/1
2039762338dSopenharmony_ci */
2049762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testOpenSession002, Function | MediumTest | Level1)
2059762338dSopenharmony_ci{
2069762338dSopenharmony_ci    cout << "start OpenSession" << endl;
2079762338dSopenharmony_ci    uint32_t i = 0;
2089762338dSopenharmony_ci    int32_t userId[3] = {-1, 0, 1};
2099762338dSopenharmony_ci    std::vector<uint8_t> challenge;
2109762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
2119762338dSopenharmony_ci        FillTestUint8Vector(parcel, challenge);
2129762338dSopenharmony_ci        EXPECT_EQ(g_service.OpenSession(userId[i], challenge), 0);
2139762338dSopenharmony_ci        EXPECT_EQ(g_service.CloseSession(userId[i]), 0);
2149762338dSopenharmony_ci    }
2159762338dSopenharmony_ci}
2169762338dSopenharmony_ci/**
2179762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2500
2189762338dSopenharmony_ci * @tc.name  : testCloseSession002
2199762338dSopenharmony_ci * @tc.desc  : Close unopened authentication credential management sessions
2209762338dSopenharmony_ci */
2219762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCloseSession002, Function | MediumTest | Level2)
2229762338dSopenharmony_ci{
2239762338dSopenharmony_ci    cout << "start CloseSession" << endl;
2249762338dSopenharmony_ci    uint32_t i = 0;
2259762338dSopenharmony_ci    uint32_t ret = 0;
2269762338dSopenharmony_ci    int32_t userId[2] = {-1, 1000};
2279762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
2289762338dSopenharmony_ci        EXPECT_NE(g_service.CloseSession(userId[i]), 0);
2299762338dSopenharmony_ci    }
2309762338dSopenharmony_ci    cout << "ret is " << ret << endl;
2319762338dSopenharmony_ci}
2329762338dSopenharmony_ci/**
2339762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2600
2349762338dSopenharmony_ci * @tc.name  : testCloseSession003
2359762338dSopenharmony_ci * @tc.desc  : Close unopened authentication credential management sessions
2369762338dSopenharmony_ci */
2379762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCloseSession003, Function | MediumTest | Level2)
2389762338dSopenharmony_ci{
2399762338dSopenharmony_ci    cout << "start CloseSession" << endl;
2409762338dSopenharmony_ci    int32_t userId = 1000;
2419762338dSopenharmony_ci    int32_t i = 0;
2429762338dSopenharmony_ci    while (i < 50) {
2439762338dSopenharmony_ci        EXPECT_NE(g_service.CloseSession(userId), 0);
2449762338dSopenharmony_ci        i++;
2459762338dSopenharmony_ci    }
2469762338dSopenharmony_ci}
2479762338dSopenharmony_ci/**
2489762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2700
2499762338dSopenharmony_ci * @tc.name  : testBeginEnrollment001
2509762338dSopenharmony_ci * @tc.desc  : Directly call the BeginEnrollment function without preprocessing
2519762338dSopenharmony_ci */
2529762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginEnrollment001, Function | MediumTest | Level2)
2539762338dSopenharmony_ci{
2549762338dSopenharmony_ci    cout << "start BeginEnrollment" << endl;
2559762338dSopenharmony_ci    std::vector<uint8_t> authToken;
2569762338dSopenharmony_ci    FillTestUint8Vector(parcel, authToken);
2579762338dSopenharmony_ci    EnrollParam param;
2589762338dSopenharmony_ci    FillEnrollParam(parcel, param);
2599762338dSopenharmony_ci    ScheduleInfo info;
2609762338dSopenharmony_ci    FillScheduleInfo(parcel, info);
2619762338dSopenharmony_ci    auto ret = g_service.BeginEnrollment(authToken, param, info);
2629762338dSopenharmony_ci    cout << "ret is " << ret << endl;
2639762338dSopenharmony_ci    EXPECT_NE(ret, 0);
2649762338dSopenharmony_ci}
2659762338dSopenharmony_ci/**
2669762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_2800
2679762338dSopenharmony_ci * @tc.name  : testBeginEnrollment002
2689762338dSopenharmony_ci * @tc.desc  : Call the OpenSession function and AddExecutor function, then call the BeginEnrollment function
2699762338dSopenharmony_ci * and test different authTypes
2709762338dSopenharmony_ci */
2719762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginEnrollment002, Function | MediumTest | Level1)
2729762338dSopenharmony_ci{
2739762338dSopenharmony_ci    uint32_t i = 0;
2749762338dSopenharmony_ci    uint64_t index = 0;
2759762338dSopenharmony_ci    std::vector<uint8_t> challenge;
2769762338dSopenharmony_ci    std::vector<uint8_t> authToken;
2779762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
2789762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
2799762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
2809762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
2819762338dSopenharmony_ci    EnrollParam param = {};
2829762338dSopenharmony_ci    param.userId = 12345;
2839762338dSopenharmony_ci    uint32_t authType[4] = {0, 1, 2, 4};
2849762338dSopenharmony_ci
2859762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
2869762338dSopenharmony_ci        EXPECT_EQ(g_service.OpenSession(param.userId, challenge), 0);
2879762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
2889762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
2899762338dSopenharmony_ci        info.publicKey.resize(32);
2909762338dSopenharmony_ci        info.authType = static_cast<AuthType>(authType[i]);
2919762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
2929762338dSopenharmony_ci        param.authType = static_cast<AuthType>(authType[i]);
2939762338dSopenharmony_ci
2949762338dSopenharmony_ci        if (i == 1) {
2959762338dSopenharmony_ci            EXPECT_EQ(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
2969762338dSopenharmony_ci
2979762338dSopenharmony_ci            EXPECT_EQ(g_service.CancelEnrollment(param.userId), 0);
2989762338dSopenharmony_ci        } else {
2999762338dSopenharmony_ci            EXPECT_NE(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
3009762338dSopenharmony_ci        }
3019762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
3029762338dSopenharmony_ci        EXPECT_EQ(g_service.CloseSession(param.userId), 0);
3039762338dSopenharmony_ci    }
3049762338dSopenharmony_ci}
3059762338dSopenharmony_ci/**
3069762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3200
3079762338dSopenharmony_ci * @tc.name  : testCancelEnrollment001
3089762338dSopenharmony_ci * @tc.desc  : Call the CancelEnrollment function with userId=-123 as the input parameter
3099762338dSopenharmony_ci */
3109762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCancelEnrollment001, Function | MediumTest | Level1)
3119762338dSopenharmony_ci{
3129762338dSopenharmony_ci    cout << "start CancelEnrollment" << endl;
3139762338dSopenharmony_ci    int32_t userId = -123;
3149762338dSopenharmony_ci    auto ret = g_service.CancelEnrollment(userId);
3159762338dSopenharmony_ci    cout << "ret is " << ret << endl;
3169762338dSopenharmony_ci    EXPECT_EQ(ret, 0);
3179762338dSopenharmony_ci}
3189762338dSopenharmony_ci/**
3199762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3300
3209762338dSopenharmony_ci * @tc.name  : testCancelEnrollment002
3219762338dSopenharmony_ci * @tc.desc  : The BeginEnrollment function is invoked to register the authentication credentials,
3229762338dSopenharmony_ci *              and then the CancelEnrollment function is invoked to cancel the registration
3239762338dSopenharmony_ci */
3249762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCancelEnrollment002, Function | MediumTest | Level1)
3259762338dSopenharmony_ci{
3269762338dSopenharmony_ci    uint32_t i = 0;
3279762338dSopenharmony_ci    int32_t userId[3] = {-12345, 0, 1};
3289762338dSopenharmony_ci    std::vector<uint8_t> challenge;
3299762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
3309762338dSopenharmony_ci    uint64_t index = 0;
3319762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
3329762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
3339762338dSopenharmony_ci    std::vector<uint8_t> authToken;
3349762338dSopenharmony_ci    EnrollParam param = {};
3359762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
3369762338dSopenharmony_ci
3379762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
3389762338dSopenharmony_ci        EXPECT_EQ(g_service.OpenSession(userId[i], challenge), 0);
3399762338dSopenharmony_ci
3409762338dSopenharmony_ci        info.authType = AuthType::PIN;
3419762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
3429762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
3439762338dSopenharmony_ci        info.publicKey.resize(32);
3449762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
3459762338dSopenharmony_ci
3469762338dSopenharmony_ci        param.authType = AuthType::PIN;
3479762338dSopenharmony_ci        param.userId = userId[i];
3489762338dSopenharmony_ci        EXPECT_EQ(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
3499762338dSopenharmony_ci
3509762338dSopenharmony_ci        EXPECT_EQ(g_service.CancelEnrollment(userId[i]), 0);
3519762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
3529762338dSopenharmony_ci        EXPECT_EQ(g_service.CloseSession(userId[i]), 0);
3539762338dSopenharmony_ci    }
3549762338dSopenharmony_ci}
3559762338dSopenharmony_ci/**
3569762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3700
3579762338dSopenharmony_ci * @tc.name  : testCancelEnrollment006
3589762338dSopenharmony_ci * @tc.desc  : Call the BeginEnrollment function to register the authentication credentials,
3599762338dSopenharmony_ci *              then call the CancelEnrollment function to cancel, and then continue to cancel 50 times
3609762338dSopenharmony_ci */
3619762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCancelEnrollment006, Function | MediumTest | Level1)
3629762338dSopenharmony_ci{
3639762338dSopenharmony_ci    int32_t userId = 1;
3649762338dSopenharmony_ci    int32_t i = 0;
3659762338dSopenharmony_ci    std::vector<uint8_t> challenge;
3669762338dSopenharmony_ci    EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
3679762338dSopenharmony_ci
3689762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
3699762338dSopenharmony_ci    info.authType = AuthType::PIN;
3709762338dSopenharmony_ci    info.executorRole = ExecutorRole::ALL_IN_ONE;
3719762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
3729762338dSopenharmony_ci    info.publicKey.resize(32);
3739762338dSopenharmony_ci    uint64_t index = 0;
3749762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
3759762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
3769762338dSopenharmony_ci    EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
3779762338dSopenharmony_ci
3789762338dSopenharmony_ci    std::vector<uint8_t> authToken;
3799762338dSopenharmony_ci    EnrollParam param = {};
3809762338dSopenharmony_ci    param.userId = userId;
3819762338dSopenharmony_ci    param.authType = AuthType::PIN;
3829762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
3839762338dSopenharmony_ci    EXPECT_EQ(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
3849762338dSopenharmony_ci
3859762338dSopenharmony_ci    EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
3869762338dSopenharmony_ci    while (i < 50) {
3879762338dSopenharmony_ci        EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
3889762338dSopenharmony_ci        i++;
3899762338dSopenharmony_ci    }
3909762338dSopenharmony_ci    EXPECT_EQ(g_service.DeleteExecutor(index), 0);
3919762338dSopenharmony_ci    EXPECT_EQ(g_service.CloseSession(userId), 0);
3929762338dSopenharmony_ci}
3939762338dSopenharmony_ci/**
3949762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3800
3959762338dSopenharmony_ci * @tc.name  : testGetCredential001
3969762338dSopenharmony_ci * @tc.desc  : Call the GetCredential function, with the first input parameter being userId=-1、0、1
3979762338dSopenharmony_ci */
3989762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetCredential001, Function | MediumTest | Level1)
3999762338dSopenharmony_ci{
4009762338dSopenharmony_ci    cout << "start GetCredential" << endl;
4019762338dSopenharmony_ci    uint32_t i = 0;
4029762338dSopenharmony_ci    uint32_t userId[3] = {-1, 0, 1};
4039762338dSopenharmony_ci    AuthType authType = static_cast<AuthType>(parcel.ReadInt32());
4049762338dSopenharmony_ci    std::vector<CredentialInfo> infos;
4059762338dSopenharmony_ci
4069762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
4079762338dSopenharmony_ci        FillCredentialInfoVector(parcel, infos);
4089762338dSopenharmony_ci        EXPECT_EQ(g_service.GetCredential(userId[i], authType, infos), 0);
4099762338dSopenharmony_ci    }
4109762338dSopenharmony_ci}
4119762338dSopenharmony_ci/**
4129762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_3900
4139762338dSopenharmony_ci * @tc.name  : testGetCredential002
4149762338dSopenharmony_ci * @tc.desc  : Pass the authType authentication type to all types and determine the result of the function
4159762338dSopenharmony_ci */
4169762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetCredential002, Function | MediumTest | Level1)
4179762338dSopenharmony_ci{
4189762338dSopenharmony_ci    cout << "start GetCredential" << endl;
4199762338dSopenharmony_ci    uint32_t i = 0;
4209762338dSopenharmony_ci    int32_t userId = parcel.ReadInt32();
4219762338dSopenharmony_ci    uint32_t authType[4] = {0, 1, 2, 4};
4229762338dSopenharmony_ci    std::vector<CredentialInfo> infos;
4239762338dSopenharmony_ci
4249762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
4259762338dSopenharmony_ci        FillCredentialInfoVector(parcel, infos);
4269762338dSopenharmony_ci        EXPECT_EQ(g_service.GetCredential(userId, static_cast<AuthType>(authType[i]), infos), 0);
4279762338dSopenharmony_ci    }
4289762338dSopenharmony_ci}
4299762338dSopenharmony_ci/**
4309762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_4500
4319762338dSopenharmony_ci * @tc.name  : testGetUserInfo001
4329762338dSopenharmony_ci * @tc.desc  : Pass the wrong userId to the function to determine the result of the function
4339762338dSopenharmony_ci */
4349762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetUserInfo001, Function | MediumTest | Level2)
4359762338dSopenharmony_ci{
4369762338dSopenharmony_ci    cout << "start GetUserInfo" << endl;
4379762338dSopenharmony_ci    uint32_t i = 0;
4389762338dSopenharmony_ci    int userId[2] = {6789, -6789};
4399762338dSopenharmony_ci    uint64_t secureUid = parcel.ReadUint64();
4409762338dSopenharmony_ci    int32_t pinSubType = parcel.ReadInt32();
4419762338dSopenharmony_ci    std::vector<EnrolledInfo> infos;
4429762338dSopenharmony_ci
4439762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
4449762338dSopenharmony_ci        FillEnrolledInfoVector(parcel, infos);
4459762338dSopenharmony_ci        EXPECT_NE(g_service.GetUserInfo(userId[i], secureUid, pinSubType, infos), 0);
4469762338dSopenharmony_ci    }
4479762338dSopenharmony_ci}
4489762338dSopenharmony_ci/**
4499762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_4700
4509762338dSopenharmony_ci * @tc.name  : testDeleteUser001
4519762338dSopenharmony_ci * @tc.desc  : Call the DeleteUser function, with the first input parameter
4529762338dSopenharmony_ci *              being userId=-1 and the second parameter being empty
4539762338dSopenharmony_ci */
4549762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testDeleteUser001, Function | MediumTest | Level2)
4559762338dSopenharmony_ci{
4569762338dSopenharmony_ci    cout << "start DeleteUser" << endl;
4579762338dSopenharmony_ci
4589762338dSopenharmony_ci    int32_t userId = -1;
4599762338dSopenharmony_ci    std::vector<uint8_t> challenge;
4609762338dSopenharmony_ci    EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
4619762338dSopenharmony_ci
4629762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
4639762338dSopenharmony_ci    info.authType = AuthType::PIN;
4649762338dSopenharmony_ci    info.executorRole = ExecutorRole::ALL_IN_ONE;
4659762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
4669762338dSopenharmony_ci    info.publicKey.resize(32);
4679762338dSopenharmony_ci
4689762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
4699762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
4709762338dSopenharmony_ci    uint64_t index = 0;
4719762338dSopenharmony_ci    EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
4729762338dSopenharmony_ci
4739762338dSopenharmony_ci    std::vector<uint8_t> authToken;
4749762338dSopenharmony_ci    std::vector<CredentialInfo> deletedInfos;
4759762338dSopenharmony_ci    std::vector<uint8_t> rootSecret;
4769762338dSopenharmony_ci    auto ret = g_service.DeleteUser(userId, authToken, deletedInfos, rootSecret);
4779762338dSopenharmony_ci    cout << "ret is " << ret << endl;
4789762338dSopenharmony_ci    EXPECT_NE(ret, 0);
4799762338dSopenharmony_ci}
4809762338dSopenharmony_ci/**
4819762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_4800
4829762338dSopenharmony_ci * @tc.name  : testDeleteUser002
4839762338dSopenharmony_ci * @tc.desc  : Call the DeleteUser function, with the second input parameter being authToken=-1、0
4849762338dSopenharmony_ci */
4859762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testDeleteUser002, Function | MediumTest | Level2)
4869762338dSopenharmony_ci{
4879762338dSopenharmony_ci    cout << "start DeleteUser" << endl;
4889762338dSopenharmony_ci    uint32_t i = 0;
4899762338dSopenharmony_ci    uint32_t num[2] = {-1, 0};
4909762338dSopenharmony_ci    std::vector<CredentialInfo> deletedInfos;
4919762338dSopenharmony_ci    int32_t userId = parcel.ReadInt32();
4929762338dSopenharmony_ci    std::vector<uint8_t> authToken(1);
4939762338dSopenharmony_ci    FillTestUint8Vector(parcel, authToken);
4949762338dSopenharmony_ci    std::vector<uint8_t> rootSecret(1);
4959762338dSopenharmony_ci    FillTestUint8Vector(parcel, rootSecret);
4969762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
4979762338dSopenharmony_ci        authToken[0] = num[i];
4989762338dSopenharmony_ci        EXPECT_NE(g_service.DeleteUser(userId, authToken, deletedInfos, rootSecret), 0);
4999762338dSopenharmony_ci    }
5009762338dSopenharmony_ci}
5019762338dSopenharmony_ci/**
5029762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_5000
5039762338dSopenharmony_ci * @tc.name  : testEnforceDeleteUser001
5049762338dSopenharmony_ci * @tc.desc  : Directly call the EnforceDeleteUser function, with the first input parameter being userId=-1,65535
5059762338dSopenharmony_ci */
5069762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testEnforceDeleteUser001, Function | MediumTest | Level2)
5079762338dSopenharmony_ci{
5089762338dSopenharmony_ci    cout << "start EnforceDeleteUser" << endl;
5099762338dSopenharmony_ci    uint32_t i = 0;
5109762338dSopenharmony_ci    int32_t userId[2] = {-1, 65535};
5119762338dSopenharmony_ci    std::vector<CredentialInfo> deletedInfos;
5129762338dSopenharmony_ci
5139762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
5149762338dSopenharmony_ci        EXPECT_NE(g_service.EnforceDeleteUser(userId[i], deletedInfos), 0);
5159762338dSopenharmony_ci    }
5169762338dSopenharmony_ci}
5179762338dSopenharmony_ci/**
5189762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_5200
5199762338dSopenharmony_ci * @tc.name  : testBeginAuthentication001
5209762338dSopenharmony_ci * @tc.desc  : When the registration results are not updated and the registration is completed,
5219762338dSopenharmony_ci *              The first entry is contextId = 1/0/-1, the second entry is the AuthSolution structure ->userId = 365861,
5229762338dSopenharmony_ci *              authTrustLevel = 10000,authType = PIN,executorSensorHint = 1
5239762338dSopenharmony_ci */
5249762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginAuthentication001, Function | MediumTest | Level2)
5259762338dSopenharmony_ci{
5269762338dSopenharmony_ci    uint32_t i = 0;
5279762338dSopenharmony_ci    uint64_t contextId[3] = {1, 0, -1};
5289762338dSopenharmony_ci    AuthType authType = AuthType::PIN;
5299762338dSopenharmony_ci    std::vector<uint8_t> challenge;
5309762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
5319762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
5329762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
5339762338dSopenharmony_ci    uint64_t index = 0;
5349762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
5359762338dSopenharmony_ci    std::vector<uint8_t> authToken;
5369762338dSopenharmony_ci    EnrollParam enrollParam = {};
5379762338dSopenharmony_ci    enrollParam.userId = 365861;
5389762338dSopenharmony_ci    AuthParam authParam = {};
5399762338dSopenharmony_ci    std::vector<ScheduleInfo> scheduleInfos;
5409762338dSopenharmony_ci
5419762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
5429762338dSopenharmony_ci        EXPECT_EQ(g_service.OpenSession(enrollParam.userId, challenge), 0);
5439762338dSopenharmony_ci
5449762338dSopenharmony_ci        info.authType = authType;
5459762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
5469762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
5479762338dSopenharmony_ci        info.publicKey.resize(32);
5489762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
5499762338dSopenharmony_ci
5509762338dSopenharmony_ci        enrollParam.authType = authType;
5519762338dSopenharmony_ci        EXPECT_EQ(g_service.BeginEnrollment(authToken, enrollParam, scheduleInfo), 0);
5529762338dSopenharmony_ci
5539762338dSopenharmony_ci        authParam.baseParam.userId = enrollParam.userId;
5549762338dSopenharmony_ci        authParam.baseParam.authTrustLevel = 10000;
5559762338dSopenharmony_ci        authParam.authType = authType;
5569762338dSopenharmony_ci        authParam.baseParam.executorSensorHint = 1;
5579762338dSopenharmony_ci        authParam.baseParam.challenge = challenge;
5589762338dSopenharmony_ci        EXPECT_NE(g_service.BeginAuthentication(contextId[i], authParam, scheduleInfos), 0);
5599762338dSopenharmony_ci
5609762338dSopenharmony_ci        EXPECT_EQ(g_service.CancelEnrollment(enrollParam.userId), 0);
5619762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
5629762338dSopenharmony_ci        EXPECT_EQ(g_service.CloseSession(enrollParam.userId), 0);
5639762338dSopenharmony_ci    }
5649762338dSopenharmony_ci}
5659762338dSopenharmony_ci/**
5669762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_5500
5679762338dSopenharmony_ci * @tc.name  : testBeginAuthentication004
5689762338dSopenharmony_ci * @tc.desc  : The first input parameter is contextId=1, the second input parameter is the
5699762338dSopenharmony_ci *              AuthSolution structure->userId=0, authTrustLevel=-1、0、1000, authType=PIN, executorSensorHint=1
5709762338dSopenharmony_ci */
5719762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginAuthentication004, Function | MediumTest | Level2)
5729762338dSopenharmony_ci{
5739762338dSopenharmony_ci    uint32_t i = 0;
5749762338dSopenharmony_ci    int32_t userId = 0;
5759762338dSopenharmony_ci    uint64_t index = 0;
5769762338dSopenharmony_ci    uint64_t contextId = 1;
5779762338dSopenharmony_ci    uint32_t authTrustLevel[3] = {-1, 0, 1000};
5789762338dSopenharmony_ci    AuthParam authParam = {};
5799762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
5809762338dSopenharmony_ci    AuthType authType = AuthType::PIN;
5819762338dSopenharmony_ci    std::vector<uint8_t> challenge;
5829762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
5839762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
5849762338dSopenharmony_ci    std::vector<ScheduleInfo> scheduleInfos;
5859762338dSopenharmony_ci
5869762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
5879762338dSopenharmony_ci        EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
5889762338dSopenharmony_ci
5899762338dSopenharmony_ci        info.authType = authType;
5909762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
5919762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
5929762338dSopenharmony_ci        info.publicKey.resize(32);
5939762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
5949762338dSopenharmony_ci
5959762338dSopenharmony_ci        authParam.baseParam.userId = userId;
5969762338dSopenharmony_ci        authParam.baseParam.authTrustLevel = authTrustLevel[i];
5979762338dSopenharmony_ci        authParam.authType = authType;
5989762338dSopenharmony_ci        authParam.baseParam.executorSensorHint = 1;
5999762338dSopenharmony_ci        authParam.baseParam.challenge = challenge;
6009762338dSopenharmony_ci        EXPECT_NE(g_service.BeginAuthentication(contextId, authParam, scheduleInfos), 0);
6019762338dSopenharmony_ci
6029762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
6039762338dSopenharmony_ci        EXPECT_EQ(g_service.CloseSession(userId), 0);
6049762338dSopenharmony_ci    }
6059762338dSopenharmony_ci}
6069762338dSopenharmony_ci/**
6079762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_6200
6089762338dSopenharmony_ci * @tc.name  : testUpdateAuthenticationResult001
6099762338dSopenharmony_ci * @tc.desc  : The first input parameter is contextId=-1、0、1234567, and the second input parameter
6109762338dSopenharmony_ci *              is scheduleResult is empty
6119762338dSopenharmony_ci */
6129762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testUpdateAuthenticationResult001, Function | MediumTest | Level2)
6139762338dSopenharmony_ci{
6149762338dSopenharmony_ci    uint32_t i = 0;
6159762338dSopenharmony_ci    uint64_t contextId[3] = {-1, 0, 1234567};
6169762338dSopenharmony_ci    std::vector<uint8_t> scheduleResult;
6179762338dSopenharmony_ci    AuthResultInfo authResultInfo = {};
6189762338dSopenharmony_ci    EnrolledState enrollState = {};
6199762338dSopenharmony_ci
6209762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
6219762338dSopenharmony_ci        EXPECT_NE(g_service.UpdateAuthenticationResult(contextId[i], scheduleResult, authResultInfo, enrollState), 0);
6229762338dSopenharmony_ci    }
6239762338dSopenharmony_ci}
6249762338dSopenharmony_ci/**
6259762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_6500
6269762338dSopenharmony_ci * @tc.name  : testUpdateAuthenticationResult004
6279762338dSopenharmony_ci * @tc.desc  : The first input is contextId = 1, the second input is scheduleResult The size is 100,
6289762338dSopenharmony_ci *              and all inputs are initialized to 1 and 0
6299762338dSopenharmony_ci */
6309762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testUpdateAuthenticationResult004, Function | MediumTest | Level2)
6319762338dSopenharmony_ci{
6329762338dSopenharmony_ci    uint32_t i = 0;
6339762338dSopenharmony_ci    uint64_t contextId = 1;
6349762338dSopenharmony_ci    uint64_t num[2] = {1, 0};
6359762338dSopenharmony_ci    std::vector<uint8_t> scheduleResult(100);
6369762338dSopenharmony_ci    AuthResultInfo authResultInfo = {};
6379762338dSopenharmony_ci    EnrolledState enrollState = {};
6389762338dSopenharmony_ci
6399762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
6409762338dSopenharmony_ci        scheduleResult.insert(scheduleResult.begin(), 100, num[i]);
6419762338dSopenharmony_ci        EXPECT_NE(g_service.UpdateAuthenticationResult(contextId, scheduleResult, authResultInfo, enrollState), 0);
6429762338dSopenharmony_ci    }
6439762338dSopenharmony_ci}
6449762338dSopenharmony_ci/**
6459762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_6700
6469762338dSopenharmony_ci * @tc.name  : testCancelAuthentication001
6479762338dSopenharmony_ci * @tc.desc  : Verify the CancelAuthentication function with the first input being contextId = 0、-1、1000
6489762338dSopenharmony_ci */
6499762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCancelAuthentication001, Function | MediumTest | Level2)
6509762338dSopenharmony_ci{
6519762338dSopenharmony_ci    cout << "start CancelAuthentication" << endl;
6529762338dSopenharmony_ci    uint32_t i = 0;
6539762338dSopenharmony_ci    uint64_t contextId[3] = {0, -1, 1000};
6549762338dSopenharmony_ci
6559762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
6569762338dSopenharmony_ci        EXPECT_NE(g_service.CancelAuthentication(contextId[i]), 0);
6579762338dSopenharmony_ci    }
6589762338dSopenharmony_ci}
6599762338dSopenharmony_ci/**
6609762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_7000
6619762338dSopenharmony_ci * @tc.name  : testBeginIdentification001
6629762338dSopenharmony_ci * @tc.desc  : The AddExecutor function is called first to add the authentication actuator,
6639762338dSopenharmony_ci *              and then the BeginIdentification function is called to start the identification
6649762338dSopenharmony_ci */
6659762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification001, Function | MediumTest | Level1)
6669762338dSopenharmony_ci{
6679762338dSopenharmony_ci    uint32_t i = 0;
6689762338dSopenharmony_ci    uint64_t index = 0;
6699762338dSopenharmony_ci    uint64_t contextId = 123456;
6709762338dSopenharmony_ci    uint32_t authType[3] = {0, 2, 4};
6719762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
6729762338dSopenharmony_ci    std::vector<uint8_t> challenge;
6739762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
6749762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
6759762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
6769762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
6779762338dSopenharmony_ci    const std::string deviceUdid = std::string(64, '0');
6789762338dSopenharmony_ci
6799762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
6809762338dSopenharmony_ci        info.authType = static_cast<AuthType>(authType[i]);
6819762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
6829762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
6839762338dSopenharmony_ci        info.publicKey.resize(32);
6849762338dSopenharmony_ci
6859762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
6869762338dSopenharmony_ci        EXPECT_EQ(g_service.BeginIdentification(contextId, static_cast<AuthType>(authType[i]), challenge,
6879762338dSopenharmony_ci                                                executorSensorHint, scheduleInfo),
6889762338dSopenharmony_ci                  0);
6899762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
6909762338dSopenharmony_ci        EXPECT_EQ(g_service.Init(deviceUdid), 0);
6919762338dSopenharmony_ci    }
6929762338dSopenharmony_ci}
6939762338dSopenharmony_ci/**
6949762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8000
6959762338dSopenharmony_ci * @tc.name  : testBeginIdentification011
6969762338dSopenharmony_ci * @tc.desc  : The AddExecutor function is called first to add the authentication actuator,
6979762338dSopenharmony_ci *              and then the BeginIdentification function is called to start the identification
6989762338dSopenharmony_ci */
6999762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification011, Function | MediumTest | Level2)
7009762338dSopenharmony_ci{
7019762338dSopenharmony_ci    uint32_t i = 0;
7029762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
7039762338dSopenharmony_ci    uint64_t index = 0;
7049762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
7059762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
7069762338dSopenharmony_ci    uint64_t contextId = 123456;
7079762338dSopenharmony_ci    AuthType authType = AuthType::FACE;
7089762338dSopenharmony_ci    std::vector<uint8_t> challenge;
7099762338dSopenharmony_ci    uint32_t executorSensorHint[2] = {-1234, 1234};
7109762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
7119762338dSopenharmony_ci
7129762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
7139762338dSopenharmony_ci        info.authType = AuthType::FACE;
7149762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
7159762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
7169762338dSopenharmony_ci        info.publicKey.resize(32);
7179762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
7189762338dSopenharmony_ci        EXPECT_NE(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint[i], scheduleInfo),
7199762338dSopenharmony_ci                  0);
7209762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
7219762338dSopenharmony_ci    }
7229762338dSopenharmony_ci}
7239762338dSopenharmony_ci/**
7249762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8200
7259762338dSopenharmony_ci * @tc.name  : testBeginIdentification013
7269762338dSopenharmony_ci * @tc.desc  : The AddExecutor function is called to add the authentication actuator,
7279762338dSopenharmony_ci *              and then the BeginIdentification function is called 50 times to start the identification
7289762338dSopenharmony_ci */
7299762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification013, Function | MediumTest | Level2)
7309762338dSopenharmony_ci{
7319762338dSopenharmony_ci    int i = 0;
7329762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
7339762338dSopenharmony_ci    info.authType = AuthType::FACE;
7349762338dSopenharmony_ci    info.executorRole = ExecutorRole::ALL_IN_ONE;
7359762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
7369762338dSopenharmony_ci    info.publicKey.resize(32);
7379762338dSopenharmony_ci    uint64_t index = 0;
7389762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
7399762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
7409762338dSopenharmony_ci    EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
7419762338dSopenharmony_ci
7429762338dSopenharmony_ci    uint64_t contextId = 123456;
7439762338dSopenharmony_ci    AuthType authType = AuthType::FACE;
7449762338dSopenharmony_ci    std::vector<uint8_t> challenge;
7459762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
7469762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
7479762338dSopenharmony_ci    EXPECT_EQ(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
7489762338dSopenharmony_ci    while (i < 50) {
7499762338dSopenharmony_ci        EXPECT_NE(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
7509762338dSopenharmony_ci        cout << "i = " << i << endl;
7519762338dSopenharmony_ci        i++;
7529762338dSopenharmony_ci    }
7539762338dSopenharmony_ci    EXPECT_EQ(g_service.DeleteExecutor(index), 0);
7549762338dSopenharmony_ci}
7559762338dSopenharmony_ci/**
7569762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8300
7579762338dSopenharmony_ci * @tc.name  : testUpdateIdentificationResult001
7589762338dSopenharmony_ci * @tc.desc  : Call the BeginIdentification function to start recognition,
7599762338dSopenharmony_ci *              and then call the UpdateIdenticationResult function to update the recognition result
7609762338dSopenharmony_ci */
7619762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testUpdateIdentificationResult001, Function | MediumTest | Level2)
7629762338dSopenharmony_ci{
7639762338dSopenharmony_ci    int size[2] = {0, 32};
7649762338dSopenharmony_ci    uint32_t i = 0;
7659762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
7669762338dSopenharmony_ci    uint64_t index = 0;
7679762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
7689762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
7699762338dSopenharmony_ci    uint64_t contextId = 123456;
7709762338dSopenharmony_ci    std::vector<uint8_t> scheduleResult;
7719762338dSopenharmony_ci    std::vector<uint8_t> challenge;
7729762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
7739762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
7749762338dSopenharmony_ci    AuthType authType = AuthType::FACE;
7759762338dSopenharmony_ci    IdentifyResultInfo identityResultInfo = {};
7769762338dSopenharmony_ci    const std::string deviceUdid = std::string(64, '0');
7779762338dSopenharmony_ci
7789762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
7799762338dSopenharmony_ci        info.authType = AuthType::FACE;
7809762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
7819762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
7829762338dSopenharmony_ci        info.publicKey.resize(32);
7839762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
7849762338dSopenharmony_ci        EXPECT_EQ(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
7859762338dSopenharmony_ci
7869762338dSopenharmony_ci        scheduleResult.resize(size[i]);
7879762338dSopenharmony_ci        EXPECT_NE(g_service.UpdateIdentificationResult(contextId, scheduleResult, identityResultInfo), 0);
7889762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
7899762338dSopenharmony_ci        EXPECT_EQ(g_service.Init(deviceUdid), 0);
7909762338dSopenharmony_ci    }
7919762338dSopenharmony_ci}
7929762338dSopenharmony_ci/**
7939762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8800
7949762338dSopenharmony_ci * @tc.name  : testCancelIdentification003
7959762338dSopenharmony_ci * @tc.desc  : Cancel by calling the CancelIdentification function directly
7969762338dSopenharmony_ci */
7979762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCancelIdentification003, Function | MediumTest | Level2)
7989762338dSopenharmony_ci{
7999762338dSopenharmony_ci    uint64_t contextId = 1000;
8009762338dSopenharmony_ci    EXPECT_NE(g_service.CancelIdentification(contextId), 0);
8019762338dSopenharmony_ci}
8029762338dSopenharmony_ci/**
8039762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_8900
8049762338dSopenharmony_ci * @tc.name  : testCancelIdentification004
8059762338dSopenharmony_ci * @tc.desc  : Cancel by calling the CancelIdentification function directly
8069762338dSopenharmony_ci */
8079762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testCancelIdentification004, Function | MediumTest | Level2)
8089762338dSopenharmony_ci{
8099762338dSopenharmony_ci    uint64_t contextId = 123456;
8109762338dSopenharmony_ci    AuthType authType = AuthType::FACE;
8119762338dSopenharmony_ci    std::vector<uint8_t> challenge;
8129762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
8139762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
8149762338dSopenharmony_ci    EXPECT_NE(g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo), 0);
8159762338dSopenharmony_ci    EXPECT_NE(g_service.CancelIdentification(contextId), 0);
8169762338dSopenharmony_ci}
8179762338dSopenharmony_ci/**
8189762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_9000
8199762338dSopenharmony_ci * @tc.name  : testGetAvailableStatus001
8209762338dSopenharmony_ci * @tc.desc  : Directly call the GetAvailableStatus  function, with the first input parameter
8219762338dSopenharmony_ci *              being userId=1000 and the second input parameter being all authType
8229762338dSopenharmony_ci */
8239762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetAvailableStatus001, Function | MediumTest | Level2)
8249762338dSopenharmony_ci{
8259762338dSopenharmony_ci    uint32_t i = 0;
8269762338dSopenharmony_ci    int32_t userId = 1000;
8279762338dSopenharmony_ci    uint32_t authType[] = {0, 1, 2, 4};
8289762338dSopenharmony_ci    uint32_t authTrustLevel = 0;
8299762338dSopenharmony_ci    int32_t checkResult = 0;
8309762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
8319762338dSopenharmony_ci        g_service.GetAvailableStatus(userId, static_cast<AuthType>(authType[i]), authTrustLevel,
8329762338dSopenharmony_ci            checkResult);
8339762338dSopenharmony_ci        EXPECT_NE(checkResult, 0);
8349762338dSopenharmony_ci    }
8359762338dSopenharmony_ci}
8369762338dSopenharmony_ci/**
8379762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_9400
8389762338dSopenharmony_ci * @tc.name  : testGetAvailableStatus005
8399762338dSopenharmony_ci * @tc.desc  : Call the BeginEnrollment function without calling the UpdateEnrollmentResult function to update and
8409762338dSopenharmony_ci *              enroll the result, and then call the GetAvailableStatus  function,
8419762338dSopenharmony_ci *              with the first entry being userId = 12345. The second entry is authType = PIN
8429762338dSopenharmony_ci */
8439762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetAvailableStatus005, Function | MediumTest | Level2)
8449762338dSopenharmony_ci{
8459762338dSopenharmony_ci    int32_t userId = 12345;
8469762338dSopenharmony_ci    std::vector<uint8_t> challenge;
8479762338dSopenharmony_ci    EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
8489762338dSopenharmony_ci
8499762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
8509762338dSopenharmony_ci    info.authType = AuthType::PIN;
8519762338dSopenharmony_ci    info.executorRole = ExecutorRole::ALL_IN_ONE;
8529762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
8539762338dSopenharmony_ci    info.publicKey.resize(32);
8549762338dSopenharmony_ci    uint64_t index = 0;
8559762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
8569762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
8579762338dSopenharmony_ci    EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
8589762338dSopenharmony_ci
8599762338dSopenharmony_ci    std::vector<uint8_t> authToken;
8609762338dSopenharmony_ci    EnrollParam param = {};
8619762338dSopenharmony_ci    param.userId = userId;
8629762338dSopenharmony_ci    param.authType = AuthType::PIN;
8639762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
8649762338dSopenharmony_ci    EXPECT_EQ(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
8659762338dSopenharmony_ci
8669762338dSopenharmony_ci    AuthType authType = AuthType::PIN;
8679762338dSopenharmony_ci    uint32_t authTrustLevel = 0;
8689762338dSopenharmony_ci    int32_t checkResult = 0;
8699762338dSopenharmony_ci    g_service.GetAvailableStatus(userId, authType, authTrustLevel, checkResult);
8709762338dSopenharmony_ci    EXPECT_NE(checkResult, 0);
8719762338dSopenharmony_ci    EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
8729762338dSopenharmony_ci    EXPECT_EQ(g_service.DeleteExecutor(index), 0);
8739762338dSopenharmony_ci    EXPECT_EQ(g_service.CloseSession(userId), 0);
8749762338dSopenharmony_ci}
8759762338dSopenharmony_ci/**
8769762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_9500
8779762338dSopenharmony_ci * @tc.name  : testBeginEnrollmentV1_1_001
8789762338dSopenharmony_ci * @tc.desc  : Call the HDI-encapsulated BeginEnrollmentV1_1 function, and use a loop to assign the parameters
8799762338dSopenharmony_ci *              in the HdiBeginEnrollmentV1_1List struct to the BeginEnrollmentV1_1 function
8809762338dSopenharmony_ci */
8819762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginEnrollmentV1_1_001, Function | MediumTest | Level2)
8829762338dSopenharmony_ci{
8839762338dSopenharmony_ci    uint32_t i = 0;
8849762338dSopenharmony_ci    HdiBeginEnrollmentList g_hdiBeginEnrollmentV1_1List;
8859762338dSopenharmony_ci    uint32_t userId = g_hdiBeginEnrollmentV1_1List.userId[i];
8869762338dSopenharmony_ci    std::vector<uint8_t> challenge;
8879762338dSopenharmony_ci    EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
8889762338dSopenharmony_ci
8899762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
8909762338dSopenharmony_ci    info.executorRole = ExecutorRole::ALL_IN_ONE;
8919762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
8929762338dSopenharmony_ci    info.publicKey.resize(32);
8939762338dSopenharmony_ci    uint64_t index = 0;
8949762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
8959762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
8969762338dSopenharmony_ci
8979762338dSopenharmony_ci    std::vector<uint8_t> authToken;
8989762338dSopenharmony_ci    EnrollParam param = {};
8999762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
9009762338dSopenharmony_ci
9019762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
9029762338dSopenharmony_ci        info.authType = static_cast<AuthType>(g_hdiBeginEnrollmentV1_1List.authType[i]);
9039762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
9049762338dSopenharmony_ci
9059762338dSopenharmony_ci        param.authType = static_cast<AuthType>(g_hdiBeginEnrollmentV1_1List.authType[i]);
9069762338dSopenharmony_ci        param.executorSensorHint = g_hdiBeginEnrollmentV1_1List.executorSensorHint[i];
9079762338dSopenharmony_ci        param.userId = g_hdiBeginEnrollmentV1_1List.userId[i];
9089762338dSopenharmony_ci        if (i == 0) {
9099762338dSopenharmony_ci            EXPECT_EQ(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
9109762338dSopenharmony_ci        } else {
9119762338dSopenharmony_ci            EXPECT_NE(g_service.BeginEnrollment(authToken, param, scheduleInfo), 0);
9129762338dSopenharmony_ci        }
9139762338dSopenharmony_ci
9149762338dSopenharmony_ci        EXPECT_EQ(g_service.CancelEnrollment(userId), 0);
9159762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
9169762338dSopenharmony_ci    }
9179762338dSopenharmony_ci    EXPECT_EQ(g_service.CloseSession(userId), 0);
9189762338dSopenharmony_ci}
9199762338dSopenharmony_ci/**
9209762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0250
9219762338dSopenharmony_ci * @tc.name  : testBeginAuthenticationV1_1_001
9229762338dSopenharmony_ci * @tc.desc  : Call the HDI-encapsulated BeginAuthenticationV1_1 function, and use a loop to assign the parameters
9239762338dSopenharmony_ci *              in the HdiBeginAuthenticationV1_1List structure to the BeginAuthenticationV1_1 function
9249762338dSopenharmony_ci */
9259762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginAuthenticationV1_1_001, Function | MediumTest | Level2)
9269762338dSopenharmony_ci{
9279762338dSopenharmony_ci    uint32_t i = 0;
9289762338dSopenharmony_ci    uint32_t j;
9299762338dSopenharmony_ci    HdiBeginAuthenticationList g_hdiBeginAuthenticationV1_1List;
9309762338dSopenharmony_ci    uint32_t userId = g_hdiBeginAuthenticationV1_1List.userId[i];
9319762338dSopenharmony_ci    std::vector<uint8_t> challenge;
9329762338dSopenharmony_ci    EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
9339762338dSopenharmony_ci
9349762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
9359762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
9369762338dSopenharmony_ci    info.publicKey.resize(32);
9379762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
9389762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
9399762338dSopenharmony_ci    uint64_t index = 0;
9409762338dSopenharmony_ci
9419762338dSopenharmony_ci    uint64_t contextId = 1;
9429762338dSopenharmony_ci    AuthParam authParam = {};
9439762338dSopenharmony_ci    authParam.baseParam.authTrustLevel = 0;
9449762338dSopenharmony_ci    authParam.baseParam.executorSensorHint = 0;
9459762338dSopenharmony_ci    authParam.baseParam.challenge = challenge;
9469762338dSopenharmony_ci    std::vector<ScheduleInfo> scheduleInfos;
9479762338dSopenharmony_ci
9489762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
9499762338dSopenharmony_ci        info.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[i]);
9509762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
9519762338dSopenharmony_ci        for (j = 4; j > 0; j--) {
9529762338dSopenharmony_ci            authParam.baseParam.userId = g_hdiBeginAuthenticationV1_1List.userId[0];
9539762338dSopenharmony_ci            authParam.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[j - 1]);
9549762338dSopenharmony_ci            EXPECT_NE(g_service.BeginAuthentication(contextId, authParam, scheduleInfos), 0);
9559762338dSopenharmony_ci        }
9569762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
9579762338dSopenharmony_ci    }
9589762338dSopenharmony_ci
9599762338dSopenharmony_ci    for (i = 1; i < 2; i++) {
9609762338dSopenharmony_ci        info.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[i]);
9619762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
9629762338dSopenharmony_ci
9639762338dSopenharmony_ci        authParam.baseParam.userId = g_hdiBeginAuthenticationV1_1List.userId[i];
9649762338dSopenharmony_ci        authParam.authType = static_cast<AuthType>(g_hdiBeginAuthenticationV1_1List.authType[i]);
9659762338dSopenharmony_ci        EXPECT_NE(g_service.BeginAuthentication(contextId, authParam, scheduleInfos), 0);
9669762338dSopenharmony_ci    }
9679762338dSopenharmony_ci    EXPECT_EQ(g_service.CloseSession(userId), 0);
9689762338dSopenharmony_ci}
9699762338dSopenharmony_ci/**
9709762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0550
9719762338dSopenharmony_ci * @tc.name  : testBeginIdentificationV1_1_001
9729762338dSopenharmony_ci * @tc.desc  : The AddExecutor function is called first to add the authentication actuator,
9739762338dSopenharmony_ci *              and then the BeginIdentificationV1_1 function is called to start the identification
9749762338dSopenharmony_ci */
9759762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentificationV1_1_001, Function | MediumTest | Level2)
9769762338dSopenharmony_ci{
9779762338dSopenharmony_ci    uint32_t i = 0;
9789762338dSopenharmony_ci    uint32_t j = 0;
9799762338dSopenharmony_ci    HdiBeginIdentificationList g_hdiBeginIdentificationV1_1List;
9809762338dSopenharmony_ci
9819762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
9829762338dSopenharmony_ci    info.authType = AuthType::FACE;
9839762338dSopenharmony_ci    info.executorRole = ExecutorRole::ALL_IN_ONE;
9849762338dSopenharmony_ci    info.esl = ExecutorSecureLevel::ESL0;
9859762338dSopenharmony_ci    info.publicKey.resize(32);
9869762338dSopenharmony_ci    uint64_t index = 0;
9879762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
9889762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
9899762338dSopenharmony_ci
9909762338dSopenharmony_ci    uint64_t contextId = 123456;
9919762338dSopenharmony_ci    AuthType authType = AuthType::FACE;
9929762338dSopenharmony_ci    std::vector<uint8_t> challenge;
9939762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
9949762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
9959762338dSopenharmony_ci
9969762338dSopenharmony_ci    for (i = 0; i < 2; i++) {
9979762338dSopenharmony_ci        for (j = 0; j < 4; j++) {
9989762338dSopenharmony_ci            authType = static_cast<AuthType>(g_hdiBeginIdentificationV1_1List.authType[j]);
9999762338dSopenharmony_ci            if (i == 1 && authType == AuthType::FACE) {
10009762338dSopenharmony_ci                EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
10019762338dSopenharmony_ci                EXPECT_EQ(
10029762338dSopenharmony_ci                    g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo),
10039762338dSopenharmony_ci                    0);
10049762338dSopenharmony_ci            } else {
10059762338dSopenharmony_ci                EXPECT_NE(
10069762338dSopenharmony_ci                    g_service.BeginIdentification(contextId, authType, challenge, executorSensorHint, scheduleInfo),
10079762338dSopenharmony_ci                    0);
10089762338dSopenharmony_ci            }
10099762338dSopenharmony_ci        }
10109762338dSopenharmony_ci    }
10119762338dSopenharmony_ci}
10129762338dSopenharmony_ci/**
10139762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0890
10149762338dSopenharmony_ci * @tc.name  : testGetAllUserInfo001
10159762338dSopenharmony_ci * @tc.desc  : Call the GetAllUserInfo function to get the information
10169762338dSopenharmony_ci */
10179762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetAllUserInfo001, Function | MediumTest | Level1)
10189762338dSopenharmony_ci{
10199762338dSopenharmony_ci    std::vector<UserInfo> userInfos;
10209762338dSopenharmony_ci    EXPECT_EQ(g_service.GetAllUserInfo(userInfos), 0);
10219762338dSopenharmony_ci}
10229762338dSopenharmony_ci/**
10239762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0910
10249762338dSopenharmony_ci * @tc.name  : testInit001
10259762338dSopenharmony_ci * @tc.desc  : Call the Init function for initialization
10269762338dSopenharmony_ci */
10279762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testInit001, Function | MediumTest | Level1)
10289762338dSopenharmony_ci{
10299762338dSopenharmony_ci    cout << "start Init" << endl;
10309762338dSopenharmony_ci    const std::string deviceUdid = std::string(64, '0');
10319762338dSopenharmony_ci    EXPECT_EQ(g_service.Init(deviceUdid), 0);
10329762338dSopenharmony_ci}
10339762338dSopenharmony_ci/**
10349762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0920
10359762338dSopenharmony_ci * @tc.name  : testBeginIdentification014
10369762338dSopenharmony_ci * @tc.desc  : Verify that the function BeginIdentification returns a failure when the first entry structure of the
10379762338dSopenharmony_ci *              function AddExecutor is ExecutorRegisterInfo->executorRole = COLLECTOR/VERIFIER/ALL_IN_ONE
10389762338dSopenharmony_ci */
10399762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification014, Function | MediumTest | Level2)
10409762338dSopenharmony_ci{
10419762338dSopenharmony_ci    uint32_t i = 0;
10429762338dSopenharmony_ci    uint64_t index = 0;
10439762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
10449762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
10459762338dSopenharmony_ci    uint32_t executorRole[3] = {1, 2, 3};
10469762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
10479762338dSopenharmony_ci    uint64_t contextId = 123456;
10489762338dSopenharmony_ci    std::vector<uint8_t> challenge;
10499762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
10509762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
10519762338dSopenharmony_ci
10529762338dSopenharmony_ci    for (i = 0; i < 3; i++) {
10539762338dSopenharmony_ci        info.authType = AuthType::FACE;
10549762338dSopenharmony_ci        info.executorRole = static_cast<ExecutorRole>(executorRole[i]);
10559762338dSopenharmony_ci        info.esl = ExecutorSecureLevel::ESL0;
10569762338dSopenharmony_ci        info.publicKey.resize(32);
10579762338dSopenharmony_ci        if (executorRole[i] == ExecutorRole::ALL_IN_ONE) {
10589762338dSopenharmony_ci            EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
10599762338dSopenharmony_ci            EXPECT_EQ(
10609762338dSopenharmony_ci                g_service.BeginIdentification(contextId, AuthType::FACE, challenge, executorSensorHint, scheduleInfo),
10619762338dSopenharmony_ci                0);
10629762338dSopenharmony_ci            EXPECT_EQ(g_service.DeleteExecutor(index), 0);
10639762338dSopenharmony_ci        } else {
10649762338dSopenharmony_ci            EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
10659762338dSopenharmony_ci            EXPECT_NE(
10669762338dSopenharmony_ci                g_service.BeginIdentification(contextId, AuthType::FACE, challenge, executorSensorHint, scheduleInfo),
10679762338dSopenharmony_ci                0);
10689762338dSopenharmony_ci            EXPECT_EQ(g_service.DeleteExecutor(index), 0);
10699762338dSopenharmony_ci        }
10709762338dSopenharmony_ci    }
10719762338dSopenharmony_ci}
10729762338dSopenharmony_ci/**
10739762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_0940
10749762338dSopenharmony_ci * @tc.name  : testBeginIdentification016
10759762338dSopenharmony_ci * @tc.desc  : Verify that the function BeginIdentification returns a success when the first entry structure of the
10769762338dSopenharmony_ci *              function AddExecutor is ExecutorRegisterInfo->esl = ESL0\ESL1\ESL2\ESL3
10779762338dSopenharmony_ci */
10789762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testBeginIdentification016, Function | MediumTest | Level1)
10799762338dSopenharmony_ci{
10809762338dSopenharmony_ci    uint32_t i = 0;
10819762338dSopenharmony_ci    uint64_t index = 0;
10829762338dSopenharmony_ci    std::vector<uint8_t> publicKey;
10839762338dSopenharmony_ci    std::vector<uint64_t> templateIds;
10849762338dSopenharmony_ci    uint32_t esl[4] = {0, 1, 2, 3};
10859762338dSopenharmony_ci    ExecutorRegisterInfo info = {};
10869762338dSopenharmony_ci    uint64_t contextId = 123456;
10879762338dSopenharmony_ci    std::vector<uint8_t> challenge;
10889762338dSopenharmony_ci    uint32_t executorSensorHint = 0;
10899762338dSopenharmony_ci    ScheduleInfo scheduleInfo = {};
10909762338dSopenharmony_ci    const std::string deviceUdid = std::string(64, '0');
10919762338dSopenharmony_ci
10929762338dSopenharmony_ci    for (i = 0; i < 4; i++) {
10939762338dSopenharmony_ci        info.authType = AuthType::FACE;
10949762338dSopenharmony_ci        info.executorRole = ExecutorRole::ALL_IN_ONE;
10959762338dSopenharmony_ci        info.esl = static_cast<ExecutorSecureLevel>(esl[i]);
10969762338dSopenharmony_ci        info.publicKey.resize(32);
10979762338dSopenharmony_ci
10989762338dSopenharmony_ci        EXPECT_EQ(g_service.AddExecutor(info, index, publicKey, templateIds), 0);
10999762338dSopenharmony_ci        EXPECT_EQ(g_service.BeginIdentification(contextId, AuthType::FACE, challenge, executorSensorHint, scheduleInfo),
11009762338dSopenharmony_ci                  0);
11019762338dSopenharmony_ci        EXPECT_EQ(g_service.DeleteExecutor(index), 0);
11029762338dSopenharmony_ci        EXPECT_EQ(g_service.Init(deviceUdid), 0);
11039762338dSopenharmony_ci    }
11049762338dSopenharmony_ci}
11059762338dSopenharmony_ci/**
11069762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1110
11079762338dSopenharmony_ci * @tc.name  : testGetValidSolution001
11089762338dSopenharmony_ci * @tc.desc  : Call the GetValidSolution function to get the the authentication information
11099762338dSopenharmony_ci */
11109762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testGetValidSolution001, Function | MediumTest | Level2)
11119762338dSopenharmony_ci{
11129762338dSopenharmony_ci    int32_t userId = parcel.ReadInt32();
11139762338dSopenharmony_ci    std::vector<int32_t> authTypes = {AuthType::ALL, AuthType::PIN, AuthType::FACE, AuthType::FINGERPRINT};
11149762338dSopenharmony_ci    uint32_t authTrustLevel = 0;
11159762338dSopenharmony_ci    std::vector<int32_t> validTypes;
11169762338dSopenharmony_ci    EXPECT_NE(g_service.GetValidSolution(userId, authTypes, authTrustLevel, validTypes), 0);
11179762338dSopenharmony_ci}
11189762338dSopenharmony_ci/**
11199762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1120
11209762338dSopenharmony_ci * @tc.name  : testDeleteCredential001
11219762338dSopenharmony_ci * @tc.desc  : Call the DeleteCredential function to deletes credential information
11229762338dSopenharmony_ci */
11239762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testDeleteCredential001, Function | MediumTest | Level2)
11249762338dSopenharmony_ci{
11259762338dSopenharmony_ci    int32_t userId = parcel.ReadInt32();
11269762338dSopenharmony_ci    uint64_t credentialId = parcel.ReadUint64();
11279762338dSopenharmony_ci    std::vector<uint8_t> authToken;
11289762338dSopenharmony_ci    CredentialInfo info;
11299762338dSopenharmony_ci    EXPECT_NE(g_service.DeleteCredential(userId, credentialId, authToken, info), 0);
11309762338dSopenharmony_ci}
11319762338dSopenharmony_ci/**
11329762338dSopenharmony_ci * @tc.number: SUB_Security_IAM_UserAuth_HDI_FUNC_1130
11339762338dSopenharmony_ci * @tc.name  : testUpdateEnrollmentResult001
11349762338dSopenharmony_ci * @tc.desc  : Call the UpdateEnrollmentResult function directly to update and enroll the result
11359762338dSopenharmony_ci */
11369762338dSopenharmony_ciHWTEST_F(UserIamUserAuthTestAdditional, testUpdateEnrollmentResult001, Function | MediumTest | Level2)
11379762338dSopenharmony_ci{
11389762338dSopenharmony_ci    int32_t userId = 12345;
11399762338dSopenharmony_ci    std::vector<uint8_t> challenge;
11409762338dSopenharmony_ci    EXPECT_EQ(g_service.OpenSession(userId, challenge), 0);
11419762338dSopenharmony_ci
11429762338dSopenharmony_ci    std::vector<uint8_t> scheduleResult(1);
11439762338dSopenharmony_ci    scheduleResult[0] = 1;
11449762338dSopenharmony_ci    EnrollResultInfo enrolledResultInfo = {};
11459762338dSopenharmony_ci    EXPECT_NE(g_service.UpdateEnrollmentResult(userId, scheduleResult, enrolledResultInfo), 0);
11469762338dSopenharmony_ci
11479762338dSopenharmony_ci    EXPECT_EQ(g_service.CloseSession(userId), 0);
11489762338dSopenharmony_ci}