From 48149be99742baea7b6113c339c112a6fac4b18a Mon Sep 17 00:00:00 2001 From: hejiaogirl Date: Mon, 25 Mar 2024 14:18:30 +0800 Subject: [PATCH] fix : update pin_auth user_auth idl to 2_0 Signed-off-by: hejiaogirl Change-Id: I6cd19c61ed26bc4ef72844dbd609265aa12ca8c8 --- OAT.xml | 2 +- README.md | 18 +++--- services/base/BUILD.gn | 2 +- services/base/inc/user_auth_hdi.h | 56 +++++++++---------- services/core/BUILD.gn | 2 +- services/core/inc/auth_widget_helper.h | 8 +-- services/core/src/auth_widget_helper.cpp | 55 +++++++----------- services/core/src/authentication_impl.cpp | 22 ++++---- services/core/src/enrollment_impl.cpp | 3 +- services/core/src/identification_impl.cpp | 2 +- services/core/src/schedule_node_helper.cpp | 6 +- services/core/src/user_idm_database_impl.cpp | 5 +- services/ipc/BUILD.gn | 2 +- test/fuzztest/common_fuzzer/BUILD.gn | 6 +- .../services/coauthservice_fuzzer/BUILD.gn | 2 +- .../services/coauthstub_fuzzer/BUILD.gn | 2 +- .../services/userauthservice_fuzzer/BUILD.gn | 2 +- .../services/userauthstub_fuzzer/BUILD.gn | 2 +- .../services/useridmstub_fuzzer/BUILD.gn | 2 +- .../inner_api/src/user_auth_client_test.cpp | 4 +- test/unittest/services/BUILD.gn | 2 +- .../mocks/mock_iuser_auth_interface.h | 56 ++++++++----------- .../services/src/auth_widget_helper_test.cpp | 28 +++------- .../services/src/authentication_impl_test.cpp | 18 +++--- .../services/src/enrollment_impl_test.cpp | 12 ++-- .../services/src/identification_impl_test.cpp | 8 +-- .../services/src/user_auth_service_test.cpp | 53 ++++++++---------- .../services/src/user_idm_database_test.cpp | 7 ++- .../services/src/user_idm_service_test.cpp | 29 +++++----- test/unittest/services/src/user_info_test.cpp | 4 +- 30 files changed, 190 insertions(+), 230 deletions(-) diff --git a/OAT.xml b/OAT.xml index c143b9328..ffe412068 100644 --- a/OAT.xml +++ b/OAT.xml @@ -17,7 +17,7 @@ - + diff --git a/README.md b/README.md index 7c7988522..69174a1c9 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,15 @@ The userauth APIs support user authentication of the target Authentication Trust ```undefined //base/useriam/user_auth_framework -├── frameworks # Framework code -├── interfaces # Directory for storing external interfaces -│ └── innerkits # Header files exposed to the internal subsystems -├── sa_profile # Profile of the Service ability -├── services # Implementation of the Service ability -├── test # Directory for storing test code -├── utils # Directory for storing utility code -├── bundle.json # Component description file -└── userauth.gni # Build configuration +├── frameworks # Framework code +├── interfaces # Directory for storing external interfaces +│ └── innerkits # Header files exposed to the internal subsystems +├── sa_profile # Profile of the Service ability +├── services # Implementation of the Service ability +├── test # Directory for storing test code +├── utils # Directory for storing utility code +├── bundle.json # Component description file +└── userauth.gni # Build configuration ``` diff --git a/services/base/BUILD.gn b/services/base/BUILD.gn index aff2366b6..3404046a3 100644 --- a/services/base/BUILD.gn +++ b/services/base/BUILD.gn @@ -42,7 +42,7 @@ ohos_source_set("userauth_service_base") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", diff --git a/services/base/inc/user_auth_hdi.h b/services/base/inc/user_auth_hdi.h index d7fd0c3b3..25ac697e9 100644 --- a/services/base/inc/user_auth_hdi.h +++ b/services/base/inc/user_auth_hdi.h @@ -16,40 +16,36 @@ #ifndef USER_AUTH_HDI #define USER_AUTH_HDI -#include "v1_3/iuser_auth_interface.h" -#include "v1_3/user_auth_types.h" -#include "v1_3/user_auth_interface_service.h" +#include "v2_0/iuser_auth_interface.h" +#include "v2_0/user_auth_types.h" +#include "v2_0/user_auth_interface_service.h" namespace OHOS { namespace UserIam { namespace UserAuth { -using IUserAuthInterface = OHOS::HDI::UserAuth::V1_3::IUserAuthInterface; - -using HdiAuthType = OHOS::HDI::UserAuth::V1_3::AuthType; -using HdiExecutorRole = OHOS::HDI::UserAuth::V1_3::ExecutorRole; -using HdiExecutorSecureLevel = OHOS::HDI::UserAuth::V1_3::ExecutorSecureLevel; -using HdiPinSubType = OHOS::HDI::UserAuth::V1_3::PinSubType; -using HdiScheduleMode = OHOS::HDI::UserAuth::V1_3::ScheduleMode; -using HdiExecutorRegisterInfo = OHOS::HDI::UserAuth::V1_3::ExecutorRegisterInfo; -using HdiExecutorInfo = OHOS::HDI::UserAuth::V1_3::ExecutorInfo; -using HdiScheduleInfoV1_0 = OHOS::HDI::UserAuth::V1_3::ScheduleInfo; -using HdiScheduleInfo = OHOS::HDI::UserAuth::V1_3::ScheduleInfoV1_1; -using HdiAuthSolutionV1_0 = OHOS::HDI::UserAuth::V1_3::AuthSolution; -using HdiAuthSolution = OHOS::HDI::UserAuth::V1_3::AuthSolutionV1_2; -using HdiExecutorSendMsg = OHOS::HDI::UserAuth::V1_3::ExecutorSendMsg; -using HdiAuthResultInfo = OHOS::HDI::UserAuth::V1_3::AuthResultInfo; -using HdiIdentifyResultInfo = OHOS::HDI::UserAuth::V1_3::IdentifyResultInfo; -using HdiEnrollParamV1_0 = OHOS::HDI::UserAuth::V1_3::EnrollParam; -using HdiEnrollParam = OHOS::HDI::UserAuth::V1_3::EnrollParamV1_2; -using HdiCredentialInfo = OHOS::HDI::UserAuth::V1_3::CredentialInfo; -using HdiEnrolledInfo = OHOS::HDI::UserAuth::V1_3::EnrolledInfo; -using HdiEnrollResultInfo = OHOS::HDI::UserAuth::V1_3::EnrollResultInfo; -using HdiEnrolledState = OHOS::HDI::UserAuth::V1_3::EnrolledState; -using HdiReuseUnlockInfo = OHOS::HDI::UserAuth::V1_3::ReuseUnlockInfo; - -using ScheduleInfoV1_1 = OHOS::HDI::UserAuth::V1_3::ScheduleInfoV1_1; -using UserInfo = OHOS::HDI::UserAuth::V1_3::UserInfo; -using ExtUserInfo = OHOS::HDI::UserAuth::V1_3::ExtUserInfo; +using IUserAuthInterface = OHOS::HDI::UserAuth::V2_0::IUserAuthInterface; +using HdiAuthType = OHOS::HDI::UserAuth::V2_0::AuthType; +using HdiExecutorRole = OHOS::HDI::UserAuth::V2_0::ExecutorRole; +using HdiExecutorSecureLevel = OHOS::HDI::UserAuth::V2_0::ExecutorSecureLevel; +using HdiPinSubType = OHOS::HDI::UserAuth::V2_0::PinSubType; +using HdiScheduleMode = OHOS::HDI::UserAuth::V2_0::ScheduleMode; +using HdiExecutorRegisterInfo = OHOS::HDI::UserAuth::V2_0::ExecutorRegisterInfo; +using HdiExecutorInfo = OHOS::HDI::UserAuth::V2_0::ExecutorInfo; +using HdiScheduleInfo = OHOS::HDI::UserAuth::V2_0::ScheduleInfo; +using HdiAuthParam = OHOS::HDI::UserAuth::V2_0::AuthParam; +using HdiExecutorSendMsg = OHOS::HDI::UserAuth::V2_0::ExecutorSendMsg; +using HdiAuthResultInfo = OHOS::HDI::UserAuth::V2_0::AuthResultInfo; +using HdiIdentifyResultInfo = OHOS::HDI::UserAuth::V2_0::IdentifyResultInfo; +using HdiEnrollParam = OHOS::HDI::UserAuth::V2_0::EnrollParam; +using HdiCredentialInfo = OHOS::HDI::UserAuth::V2_0::CredentialInfo; +using HdiEnrolledInfo = OHOS::HDI::UserAuth::V2_0::EnrolledInfo; +using HdiEnrollResultInfo = OHOS::HDI::UserAuth::V2_0::EnrollResultInfo; +using HdiEnrolledState = OHOS::HDI::UserAuth::V2_0::EnrolledState; +using HdiReuseUnlockInfo = OHOS::HDI::UserAuth::V2_0::ReuseUnlockInfo; +using HdiReuseUnlockParam = OHOS::HDI::UserAuth::V2_0::ReuseUnlockParam; +using HdiIMessageCallback = OHOS::HDI::UserAuth::V2_0::IMessageCallback; +using UserInfo = OHOS::HDI::UserAuth::V2_0::UserInfo; +using ExtUserInfo = OHOS::HDI::UserAuth::V2_0::ExtUserInfo; } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 5cb4345a8..8d2aefe64 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -79,7 +79,7 @@ ohos_source_set("userauth_service_core") { external_deps = [ "ability_runtime:app_manager", "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbegetutil", diff --git a/services/core/inc/auth_widget_helper.h b/services/core/inc/auth_widget_helper.h index 4e0cee386..1797c0a39 100644 --- a/services/core/inc/auth_widget_helper.h +++ b/services/core/inc/auth_widget_helper.h @@ -18,6 +18,7 @@ #include "context_factory.h" #include "user_auth_common_defines.h" +#include "user_auth_hdi.h" namespace OHOS { namespace UserIam { @@ -33,17 +34,12 @@ public: private: static const uint32_t USER_AUTH_TOKEN_LEN = 148; - typedef struct { - uint32_t authType; - uint8_t authToken[USER_AUTH_TOKEN_LEN]; - EnrolledState enrolledState; - } ReuseUnlockResult; static bool GetUserAuthProfile(int32_t userId, const AuthType &authType, ContextFactory::AuthWidgetContextPara::AuthProfile &profile); static bool ParseAttributes(const Attributes &values, const AuthType &authType, ContextFactory::AuthWidgetContextPara::AuthProfile &profile); - static int32_t SetReuseUnlockResult(int32_t apiVersion, const ReuseUnlockResult &reuseResult, + static int32_t SetReuseUnlockResult(int32_t apiVersion, const HdiReuseUnlockInfo &info, Attributes &extraInfo); }; } // namespace UserAuth diff --git a/services/core/src/auth_widget_helper.cpp b/services/core/src/auth_widget_helper.cpp index 4e62a5157..2e8780b0c 100644 --- a/services/core/src/auth_widget_helper.cpp +++ b/services/core/src/auth_widget_helper.cpp @@ -133,15 +133,15 @@ int32_t AuthWidgetHelper::CheckValidSolution(int32_t userId, IAM_LOGE("hdi interface is nullptr"); return GENERAL_ERROR; } - std::vector inputAuthType; - std::vector validTypes; + std::vector inputAuthType; + std::vector validTypes; uint32_t inputAtl = atl; for (auto &type : authTypeList) { if (!SystemParamManager::GetInstance().IsAuthTypeEnable(type)) { IAM_LOGE("authType:%{public}d not enable", type); continue; } - inputAuthType.emplace_back(static_cast(type)); + inputAuthType.emplace_back(static_cast(type)); } int32_t result = hdi->GetValidSolution(userId, inputAuthType, inputAtl, validTypes); if (result != SUCCESS) { @@ -156,23 +156,22 @@ int32_t AuthWidgetHelper::CheckValidSolution(int32_t userId, return result; } -int32_t AuthWidgetHelper::SetReuseUnlockResult(int32_t apiVersion, const ReuseUnlockResult &reuseResult, +int32_t AuthWidgetHelper::SetReuseUnlockResult(int32_t apiVersion, const HdiReuseUnlockInfo &info, Attributes &extraInfo) { - std::vector authToken(reuseResult.authToken, reuseResult.authToken + USER_AUTH_TOKEN_LEN); - bool setSignatureResult = extraInfo.SetUint8ArrayValue(Attributes::ATTR_SIGNATURE, authToken); + bool setSignatureResult = extraInfo.SetUint8ArrayValue(Attributes::ATTR_SIGNATURE, info.token); IF_FALSE_LOGE_AND_RETURN_VAL(setSignatureResult == true, GENERAL_ERROR); bool setAuthTypeResult = extraInfo.SetInt32Value(Attributes::ATTR_AUTH_TYPE, - static_cast(reuseResult.authType)); + static_cast(info.authType)); IF_FALSE_LOGE_AND_RETURN_VAL(setAuthTypeResult == true, GENERAL_ERROR); bool setResultCodeRet = extraInfo.SetInt32Value(Attributes::ATTR_RESULT_CODE, SUCCESS); IF_FALSE_LOGE_AND_RETURN_VAL(setResultCodeRet == true, GENERAL_ERROR); if (apiVersion < INNER_API_VERSION_10000) { bool setCredentialDigestRet = extraInfo.SetUint16Value(Attributes::ATTR_CREDENTIAL_DIGEST, - reuseResult.enrolledState.credentialDigest & UINT16_MAX); + info.enrolledState.credentialDigest & UINT16_MAX); IF_FALSE_LOGE_AND_RETURN_VAL(setCredentialDigestRet == true, GENERAL_ERROR); bool setCredentialCountRet = extraInfo.SetUint16Value(Attributes::ATTR_CREDENTIAL_COUNT, - reuseResult.enrolledState.credentialCount); + info.enrolledState.credentialCount); IF_FALSE_LOGE_AND_RETURN_VAL(setCredentialCountRet == true, GENERAL_ERROR); } return SUCCESS; @@ -196,38 +195,26 @@ int32_t AuthWidgetHelper::CheckReuseUnlockResult(const ContextFactory::AuthWidge return GENERAL_ERROR; } - HdiReuseUnlockInfo unlockInfo = {}; - unlockInfo.userId = para.userId; - unlockInfo.authTrustLevel = authParam.authTrustLevel; + HdiReuseUnlockParam unlockParam = {}; + unlockParam.baseParam.userId = para.userId; + unlockParam.baseParam.authTrustLevel = authParam.authTrustLevel; for (auto &type : authParam.authType) { - unlockInfo.authTypes.emplace_back(static_cast(type)); + unlockParam.authTypes.emplace_back(static_cast(type)); } - unlockInfo.challenge = authParam.challenge; - unlockInfo.callerName = para.callerName; - unlockInfo.apiVersion = para.sdkVersion; - unlockInfo.reuseUnlockResultMode = authParam.reuseUnlockResult.reuseMode; - unlockInfo.reuseUnlockResultDuration = authParam.reuseUnlockResult.reuseDuration; + unlockParam.baseParam.challenge = authParam.challenge; + unlockParam.baseParam.callerName = para.callerName; + unlockParam.baseParam.apiVersion = para.sdkVersion; + unlockParam.reuseUnlockResultMode = authParam.reuseUnlockResult.reuseMode; + unlockParam.reuseUnlockResultDuration = authParam.reuseUnlockResult.reuseDuration; - std::vector reuseResultHdi; - int32_t result = hdi->CheckReuseUnlockResult(unlockInfo, reuseResultHdi); + HdiReuseUnlockInfo reuseResultInfo = {}; + int32_t result = hdi->CheckReuseUnlockResult(unlockParam, reuseResultInfo); if (result != SUCCESS) { IAM_LOGE("CheckReuseUnlockResult failed result:%{public}d userId:%{public}d", result, para.userId); return result; } - if (reuseResultHdi.size() != sizeof(ReuseUnlockResult)) { - IAM_LOGE("bad reuse unlock result"); - return GENERAL_ERROR; - } - ReuseUnlockResult reuseResult; - if (memcpy_s(&reuseResult, sizeof(ReuseUnlockResult), reuseResultHdi.data(), - sizeof(ReuseUnlockResult)) != SUCCESS) { - IAM_LOGE("copy reuse result failed"); - reuseResultHdi.clear(); - (void)memset_s(&reuseResult, sizeof(ReuseUnlockResult), 0, sizeof(ReuseUnlockResult)); - return GENERAL_ERROR; - } - reuseResultHdi.clear(); - return SetReuseUnlockResult(para.sdkVersion, reuseResult, extraInfo); + + return SetReuseUnlockResult(para.sdkVersion, reuseResultInfo, extraInfo); } } // namespace UserAuth } // namespace UserIam diff --git a/services/core/src/authentication_impl.cpp b/services/core/src/authentication_impl.cpp index 68909cf41..631a80e3e 100644 --- a/services/core/src/authentication_impl.cpp +++ b/services/core/src/authentication_impl.cpp @@ -85,18 +85,18 @@ bool AuthenticationImpl::Start(std::vector> &sched IAM_LOGE("bad hdi"); return false; } - HdiAuthSolution solution = { - .userId = authPara_.userId, - .authTrustLevel = authPara_.atl, - .authType = static_cast(authPara_.authType), - .executorSensorHint = executorSensorHint, - .challenge = challenge_, - .callerName = authPara_.callerName, - .apiVersion = authPara_.sdkVersion, + HdiAuthParam param = { + .baseParam.userId = authPara_.userId, + .baseParam.authTrustLevel = authPara_.atl, + .baseParam.executorSensorHint = executorSensorHint, + .baseParam.challenge = challenge_, + .baseParam.callerName = authPara_.callerName, + .baseParam.apiVersion = authPara_.sdkVersion, + .authType = static_cast(authPara_.authType), }; std::vector infos; IamHitraceHelper traceHelper("hdi BeginAuthentication"); - auto result = hdi->BeginAuthenticationV1_2(contextId_, solution, infos); + auto result = hdi->BeginAuthentication(contextId_, param, infos); if (result != HDF_SUCCESS) { IAM_LOGE("hdi BeginAuthentication failed, err is %{public}d", result); SetLatestError(result); @@ -130,9 +130,9 @@ bool AuthenticationImpl::Update(const std::vector &scheduleResult, Auth HdiAuthResultInfo info; HdiEnrolledState enrolledState; - auto result = hdi->UpdateAuthenticationResultWithEnrolledState(contextId_, scheduleResult, info, enrolledState); + auto result = hdi->UpdateAuthenticationResult(contextId_, scheduleResult, info, enrolledState); if (result != HDF_SUCCESS) { - IAM_LOGE("hdi UpdateAuthenticationResultWithEnrolledState failed, err is %{public}d", result); + IAM_LOGE("hdi UpdateAuthenticationResult failed, err is %{public}d", result); SetLatestError(result); } diff --git a/services/core/src/enrollment_impl.cpp b/services/core/src/enrollment_impl.cpp index 288ee0279..3de91d697 100644 --- a/services/core/src/enrollment_impl.cpp +++ b/services/core/src/enrollment_impl.cpp @@ -102,9 +102,10 @@ bool EnrollmentImpl::Start(std::vector> &scheduleL .executorSensorHint = executorSensorHint_, .callerName = enrollPara_.callerName, .apiVersion = enrollPara_.sdkVersion, + .userId = enrollPara_.userId, }; IamHitraceHelper traceHelper("hdi BeginEnrollment"); - auto result = hdi->BeginEnrollmentV1_2(enrollPara_.userId, authToken_, param, info); + auto result = hdi->BeginEnrollment(authToken_, param, info); if (result != HDF_SUCCESS) { IAM_LOGE("hdi BeginEnrollment failed, err is %{public}d", result); SetLatestError(result); diff --git a/services/core/src/identification_impl.cpp b/services/core/src/identification_impl.cpp index 1c94bc38d..72095b651 100644 --- a/services/core/src/identification_impl.cpp +++ b/services/core/src/identification_impl.cpp @@ -78,7 +78,7 @@ bool IdentificationImpl::Start(std::vector> &sched HdiScheduleInfo info; IamHitraceHelper traceHelper("hdi BeginIdentification"); auto result = - hdi->BeginIdentificationV1_1(contextId_, static_cast(authType_), challenge_, executorIndex_, info); + hdi->BeginIdentification(contextId_, static_cast(authType_), challenge_, executorIndex_, info); if (result != HDF_SUCCESS) { IAM_LOGE("hdi BeginAuthentication failed, err is %{public}d", result); SetLatestError(result); diff --git a/services/core/src/schedule_node_helper.cpp b/services/core/src/schedule_node_helper.cpp index e185776c4..9b32acb26 100644 --- a/services/core/src/schedule_node_helper.cpp +++ b/services/core/src/schedule_node_helper.cpp @@ -72,6 +72,11 @@ bool ScheduleNodeHelper::ScheduleInfoToScheduleNode(const HdiScheduleInfo &info, if (para.tokenId.has_value()) { builder->SetAccessTokenId(para.tokenId.value()); } + + if (!info.executorMessages.empty()) { + builder->SetExtraInfo(info.executorMessages[0]); + } + node = builder->SetAuthType(static_cast(info.authType)) ->SetExecutorMatcher(info.executorMatcher) ->SetScheduleId(info.scheduleId) @@ -81,7 +86,6 @@ bool ScheduleNodeHelper::ScheduleInfoToScheduleNode(const HdiScheduleInfo &info, ->SetPinSubType(para.pinSubType.value_or(PinSubType::PIN_MAX)) ->SetScheduleCallback(callback) ->SetEndAfterFirstFail(para.endAfterFirstFail.value_or(false)) - ->SetExtraInfo(info.extraInfo) ->Build(); if (node == nullptr) { IAM_LOGE("builder failed"); diff --git a/services/core/src/user_idm_database_impl.cpp b/services/core/src/user_idm_database_impl.cpp index 4ed80cb72..20d33dc74 100644 --- a/services/core/src/user_idm_database_impl.cpp +++ b/services/core/src/user_idm_database_impl.cpp @@ -40,7 +40,7 @@ std::shared_ptr UserIdmDatabaseImpl::GetSecUserInfo(int std::vector enrolledInfoVector; uint64_t secureUid = 0; - HdiPinSubType pinSubType; + int32_t pinSubType; int32_t ret = hdi->GetUserInfo(userId, secureUid, pinSubType, enrolledInfoVector); if (ret != HDF_SUCCESS) { IAM_LOGE("GetSecureInfo failed, error code : %{public}d", ret); @@ -132,8 +132,9 @@ int32_t UserIdmDatabaseImpl::DeleteUser(int32_t userId, const std::vector hdiInfos; + std::vector rootSecret; IamHitraceHelper traceHelper("hdi DeleteUser"); - int32_t ret = hdi->DeleteUser(userId, authToken, hdiInfos); + int32_t ret = hdi->DeleteUser(userId, authToken, hdiInfos, rootSecret); if (ret != HDF_SUCCESS) { IAM_LOGE("failed to delete user, error code : %{public}d", ret); return ret; diff --git a/services/ipc/BUILD.gn b/services/ipc/BUILD.gn index f88c22bed..ef06b0856 100644 --- a/services/ipc/BUILD.gn +++ b/services/ipc/BUILD.gn @@ -66,7 +66,7 @@ ohos_source_set("userauth_services_ipc") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbeget_proxy", diff --git a/test/fuzztest/common_fuzzer/BUILD.gn b/test/fuzztest/common_fuzzer/BUILD.gn index b66b00943..a7ce17395 100644 --- a/test/fuzztest/common_fuzzer/BUILD.gn +++ b/test/fuzztest/common_fuzzer/BUILD.gn @@ -122,7 +122,7 @@ ohos_source_set("userauth_service_base_fuzzer") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", @@ -180,7 +180,7 @@ ohos_source_set("userauth_service_core_fuzzer") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbeget_proxy", @@ -340,7 +340,7 @@ ohos_source_set("userauth_services_ipc_fuzzer") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbegetutil", diff --git a/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn b/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn index 19680dd17..583d3a4a5 100644 --- a/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn +++ b/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn @@ -50,7 +50,7 @@ ohos_fuzztest("CoAuthServiceFuzzTest") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_single", diff --git a/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn b/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn index 5e5e51ad1..19e335e4b 100644 --- a/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn @@ -46,7 +46,7 @@ ohos_fuzztest("CoAuthStubFuzzTest") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_single", diff --git a/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn b/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn index 9eb7ad4c6..f3c6934bb 100644 --- a/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn +++ b/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn @@ -46,7 +46,7 @@ ohos_fuzztest("UserAuthServiceFuzzTest") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_single", diff --git a/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn b/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn index 582bc22e3..ea6976208 100644 --- a/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn @@ -46,7 +46,7 @@ ohos_fuzztest("UserAuthStubFuzzTest") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_single", diff --git a/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn b/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn index a9b6a518a..311d3b82a 100644 --- a/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn @@ -46,7 +46,7 @@ ohos_fuzztest("UserIdmStubFuzzTest") { external_deps = [ "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_single", diff --git a/test/unittest/inner_api/src/user_auth_client_test.cpp b/test/unittest/inner_api/src/user_auth_client_test.cpp index 5c4f864da..5fe6a49a4 100644 --- a/test/unittest/inner_api/src/user_auth_client_test.cpp +++ b/test/unittest/inner_api/src/user_auth_client_test.cpp @@ -389,7 +389,7 @@ HWTEST_F(UserAuthClientTest, UserAuthClientCancelAuthentication002, TestSize.Lev IpcClientUtils::ResetObj(); } -HWTEST_F(UserAuthClientTest, UserAuthClientBeginIdentificationV1_1001, TestSize.Level0) +HWTEST_F(UserAuthClientTest, UserAuthClientBeginIdentification_1001, TestSize.Level0) { std::vector testChallenge = {4, 5, 6, 7, 3, 4, 1, 2}; AuthType testAuthType = FACE; @@ -405,7 +405,7 @@ HWTEST_F(UserAuthClientTest, UserAuthClientBeginIdentificationV1_1001, TestSize. EXPECT_EQ(contextId, 0); } -HWTEST_F(UserAuthClientTest, UserAuthClientBeginIdentificationV1_1002, TestSize.Level0) +HWTEST_F(UserAuthClientTest, UserAuthClientBeginIdentification_1002, TestSize.Level0) { std::vector testChallenge = {4, 5, 6, 7, 3, 4, 1, 2}; AuthType testAuthType = FACE; diff --git a/test/unittest/services/BUILD.gn b/test/unittest/services/BUILD.gn index 666e6e6c0..f5b1ea46f 100644 --- a/test/unittest/services/BUILD.gn +++ b/test/unittest/services/BUILD.gn @@ -150,7 +150,7 @@ ohos_unittest("iam_services_test") { "access_token:libtoken_setproc", "access_token:libtokenid_sdk", "c_utils:utils", - "drivers_interface_user_auth:libuser_auth_proxy_1.3", + "drivers_interface_user_auth:libuser_auth_proxy_2.0", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbeget_proxy", diff --git a/test/unittest/services/mocks/mock_iuser_auth_interface.h b/test/unittest/services/mocks/mock_iuser_auth_interface.h index e39c7ff34..c7e9d2fc9 100644 --- a/test/unittest/services/mocks/mock_iuser_auth_interface.h +++ b/test/unittest/services/mocks/mock_iuser_auth_interface.h @@ -38,54 +38,44 @@ public: MOCK_METHOD1(DeleteExecutor, int32_t(uint64_t index)); MOCK_METHOD2(OpenSession, int32_t(int32_t userId, std::vector &challenge)); MOCK_METHOD1(CloseSession, int32_t(int32_t userId)); - MOCK_METHOD4(BeginEnrollment, - int32_t(int32_t userId, const std::vector &authToken, const HdiEnrollParamV1_0 ¶m, - HdiScheduleInfoV1_0 &info)); MOCK_METHOD3(UpdateEnrollmentResult, int32_t(int32_t userId, const std::vector &scheduleResult, HdiEnrollResultInfo &info)); MOCK_METHOD1(CancelEnrollment, int32_t(int32_t userId)); MOCK_METHOD4(DeleteCredential, int32_t(int32_t userId, uint64_t credentialId, const std::vector &authToken, HdiCredentialInfo &info)); - MOCK_METHOD3(GetCredential, int32_t(int32_t userId, HdiAuthType authType, std::vector &infos)); - + MOCK_METHOD3(GetCredential, int32_t(int32_t userId, int32_t authType, std::vector &infos)); MOCK_METHOD4(GetUserInfo, - int32_t(int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, std::vector &infos)); - MOCK_METHOD3(DeleteUser, - int32_t(int32_t userId, const std::vector &authToken, std::vector &deletedInfos)); + int32_t(int32_t userId, uint64_t &secureUid, int32_t &pinSubType, std::vector &infos)); + MOCK_METHOD4(DeleteUser, + int32_t(int32_t userId, const std::vector &authToken, std::vector &deletedInfos, + std::vector &rootSecret)); MOCK_METHOD2(EnforceDeleteUser, int32_t(int32_t userId, std::vector &deletedInfos)); - MOCK_METHOD3(BeginAuthentication, - int32_t(uint64_t contextId, const HdiAuthSolutionV1_0 ¶m, std::vector &scheduleInfos)); - MOCK_METHOD3(UpdateAuthenticationResult, - int32_t(uint64_t contextId, const std::vector &scheduleResult, HdiAuthResultInfo &info)); MOCK_METHOD1(CancelAuthentication, int32_t(uint64_t contextId)); - MOCK_METHOD5(BeginIdentification, - int32_t(uint64_t contextId, HdiAuthType authType, const std::vector &challenge, uint32_t executorId, - HdiScheduleInfoV1_0 &scheduleInfo)); MOCK_METHOD3(UpdateIdentificationResult, int32_t(uint64_t contextId, const std::vector &scheduleResult, HdiIdentifyResultInfo &info)); MOCK_METHOD1(CancelIdentification, int32_t(uint64_t contextId)); - MOCK_METHOD3(GetAuthTrustLevel, int32_t(int32_t userId, HdiAuthType authType, uint32_t &authTrustLevel)); - MOCK_METHOD4(GetValidSolution, int32_t(int32_t userId, const std::vector &authTypes, - uint32_t authTrustLevel, std::vector &validTypes)); - MOCK_METHOD4(BeginEnrollmentV1_1, - int32_t(int32_t userId, const std::vector &authToken, const HdiEnrollParamV1_0 ¶m, - HdiScheduleInfo &info)); - MOCK_METHOD3(BeginAuthenticationV1_1, - int32_t(uint64_t contextId, const HdiAuthSolutionV1_0 ¶m, std::vector &scheduleInfos)); - MOCK_METHOD5(BeginIdentificationV1_1, - int32_t(uint64_t contextId, HdiAuthType authType, const std::vector &challenge, uint32_t executorId, + MOCK_METHOD3(GetAuthTrustLevel, int32_t(int32_t userId, int32_t authType, uint32_t& authTrustLevel)); + MOCK_METHOD4(GetValidSolution, int32_t(int32_t userId, const std::vector& authTypes, + uint32_t authTrustLevel, std::vector& validTypes)); + MOCK_METHOD5(BeginIdentification, + int32_t(uint64_t contextId, int32_t authType, const std::vector &challenge, uint32_t executorId, HdiScheduleInfo &scheduleInfo)); MOCK_METHOD1(GetAllUserInfo, int32_t(std::vector &userInfos)); MOCK_METHOD1(GetAllExtUserInfo, int32_t(std::vector &userInfos)); - MOCK_METHOD4(BeginEnrollmentV1_2, - int32_t(int32_t userId, const std::vector &authToken, const HdiEnrollParam ¶m, - HdiScheduleInfo &info)); - MOCK_METHOD3(BeginAuthenticationV1_2, - int32_t(uint64_t contextId, const HdiAuthSolution ¶m, std::vector &scheduleInfos)); - MOCK_METHOD3(GetEnrolledState, int32_t(int32_t userId, HdiAuthType authType, HdiEnrolledState &hdiEnrolledState)); - MOCK_METHOD4(UpdateAuthenticationResultWithEnrolledState, int32_t(uint64_t contextId, + MOCK_METHOD3(BeginEnrollment, + int32_t(const std::vector &authToken, const HdiEnrollParam ¶m, HdiScheduleInfo &info)); + MOCK_METHOD3(BeginAuthentication, + int32_t(uint64_t contextId, const HdiAuthParam ¶m, std::vector &scheduleInfos)); + MOCK_METHOD3(GetEnrolledState, int32_t(int32_t userId, int32_t authType, HdiEnrolledState &hdiEnrolledState)); + MOCK_METHOD4(UpdateAuthenticationResult, int32_t(uint64_t contextId, const std::vector &scheduleResult, HdiAuthResultInfo &info, HdiEnrolledState &enrolledState)); - MOCK_METHOD2(CheckReuseUnlockResult, int32_t(const HdiReuseUnlockInfo &info, std::vector &token)); + MOCK_METHOD2(CheckReuseUnlockResult, int32_t(const HdiReuseUnlockParam& reuseParam, HdiReuseUnlockInfo& reuseInfo)); + MOCK_METHOD3(SendMessage, int32_t(uint64_t scheduleId, int32_t srcRole, const std::vector& msg)); + MOCK_METHOD1(RegisterMessageCallback, int32_t(const sptr& messageCallback)); + MOCK_METHOD3(GetLocalScheduleFromMessage, int32_t(const std::vector& remoteDeviceId, + const std::vector& message, HdiScheduleInfo& scheduleInfo)); + MOCK_METHOD4(GetSignedExecutorInfo, int32_t(const std::vector& authTypes, int32_t executorRole, + const std::vector& remoteDeviceId, std::vector& signedExecutorInfo)); }; class MockIUserAuthInterface::Holder : public Singleton { diff --git a/test/unittest/services/src/auth_widget_helper_test.cpp b/test/unittest/services/src/auth_widget_helper_test.cpp index e89e8d740..32342c0c1 100644 --- a/test/unittest/services/src/auth_widget_helper_test.cpp +++ b/test/unittest/services/src/auth_widget_helper_test.cpp @@ -133,33 +133,21 @@ HWTEST_F(AuthWidgetHelperTest, AuthWidgetHelperTestCheckReuseUnlockResult002, Te EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*mockHdi, CheckReuseUnlockResult(_, _)).Times(3); ON_CALL(*mockHdi, CheckReuseUnlockResult) - .WillByDefault( - [](const HdiReuseUnlockInfo &info, std::vector &reuseResult) { - return HDF_FAILURE; - } - ); + .WillByDefault(Return(HDF_FAILURE)); EXPECT_EQ(AuthWidgetHelper::CheckReuseUnlockResult(para, authParam, extraInfo), HDF_FAILURE); ON_CALL(*mockHdi, CheckReuseUnlockResult) .WillByDefault( - [](const HdiReuseUnlockInfo &info, std::vector &reuseResult) { - return HDF_SUCCESS; - } - ); - EXPECT_EQ(AuthWidgetHelper::CheckReuseUnlockResult(para, authParam, extraInfo), GENERAL_ERROR); - ON_CALL(*mockHdi, CheckReuseUnlockResult) - .WillByDefault( - [](const HdiReuseUnlockInfo &info, std::vector &reuseResult) { - static const uint32_t USER_AUTH_TOKEN_LEN = 148; - struct ReuseUnlockResultHdi { - uint32_t authType; - uint8_t authToken[USER_AUTH_TOKEN_LEN]; - EnrolledState enrolledState; - }; - reuseResult.resize(sizeof(ReuseUnlockResultHdi)); + [](const HdiReuseUnlockParam &info, HdiReuseUnlockInfo &reuseInfo) { + std::vector token; + token.push_back(1); return HDF_SUCCESS; } ); EXPECT_EQ(AuthWidgetHelper::CheckReuseUnlockResult(para, authParam, extraInfo), HDF_SUCCESS); + ON_CALL(*mockHdi, CheckReuseUnlockResult) + .WillByDefault(Return(HDF_SUCCESS)); + EXPECT_EQ(AuthWidgetHelper::CheckReuseUnlockResult(para, authParam, extraInfo), GENERAL_ERROR); + MockIUserAuthInterface::Holder::GetInstance().Reset(); } } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/services/src/authentication_impl_test.cpp b/test/unittest/services/src/authentication_impl_test.cpp index 050891146..bbeb36210 100644 --- a/test/unittest/services/src/authentication_impl_test.cpp +++ b/test/unittest/services/src/authentication_impl_test.cpp @@ -69,7 +69,7 @@ HWTEST_F(AuthenticationImplTest, AuthenticationHdiError, TestSize.Level0) para.authType = FACE; para.atl = ATL3; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginAuthenticationV1_2(contextId, _, _)).WillRepeatedly(Return(1)); + EXPECT_CALL(*mock, BeginAuthentication(contextId, _, _)).WillRepeatedly(Return(1)); auto authentication = std::make_shared(contextId, para); std::vector> scheduleList; @@ -87,7 +87,7 @@ HWTEST_F(AuthenticationImplTest, AuthenticationHdiEmpty, TestSize.Level0) para.atl = ATL3; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginAuthenticationV1_2(contextId, _, _)).WillRepeatedly(Return(0)); + EXPECT_CALL(*mock, BeginAuthentication(contextId, _, _)).WillRepeatedly(Return(0)); auto authentication = std::make_shared(contextId, para); std::vector> scheduleList; @@ -126,7 +126,7 @@ HWTEST_F(AuthenticationImplTest, AuthenticationInvalidExecutor, TestSize.Level0) }; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginAuthenticationV1_2(contextId, _, _)).WillRepeatedly(DoAll(WithArg<2>(fillInfoList), + EXPECT_CALL(*mock, BeginAuthentication(contextId, _, _)).WillRepeatedly(DoAll(WithArg<2>(fillInfoList), Return(0))); auto authentication = std::make_shared(contextId, para); @@ -146,8 +146,8 @@ HWTEST_F(AuthenticationImplTest, AuthenticationImplTestUpdate001, TestSize.Level auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, UpdateAuthenticationResultWithEnrolledState(_, _, _, _)).Times(1); - ON_CALL(*mockHdi, UpdateAuthenticationResultWithEnrolledState) + EXPECT_CALL(*mockHdi, UpdateAuthenticationResult(_, _, _, _)).Times(1); + ON_CALL(*mockHdi, UpdateAuthenticationResult) .WillByDefault( [](uint64_t contextId, const std::vector &scheduleResult, HdiAuthResultInfo &info, HdiEnrolledState &enrolledState) { @@ -175,8 +175,8 @@ HWTEST_F(AuthenticationImplTest, AuthenticationImplTestUpdate002, TestSize.Level auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, UpdateAuthenticationResultWithEnrolledState(_, _, _, _)).Times(1); - ON_CALL(*mockHdi, UpdateAuthenticationResultWithEnrolledState) + EXPECT_CALL(*mockHdi, UpdateAuthenticationResult(_, _, _, _)).Times(1); + ON_CALL(*mockHdi, UpdateAuthenticationResult) .WillByDefault( [](uint64_t contextId, const std::vector &scheduleResult, HdiAuthResultInfo &info, HdiEnrolledState &enrolledState) { @@ -259,9 +259,9 @@ HWTEST_F(AuthenticationImplTest, AuthenticationImplTestStart, TestSize.Level0) EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*mockHdi, CancelAuthentication(_)).Times(2) .WillOnce(Return(HDF_SUCCESS)).WillOnce(Return(HDF_FAILURE)); - EXPECT_CALL(*mockHdi, BeginAuthenticationV1_2(_, _, _)) + EXPECT_CALL(*mockHdi, BeginAuthentication(_, _, _)) .WillRepeatedly( - [](uint64_t contextId, const HdiAuthSolution ¶m, std::vector &scheduleInfos) { + [](uint64_t contextId, const HdiAuthParam ¶m, std::vector &scheduleInfos) { HdiScheduleInfo scheduleInfo = {}; scheduleInfo.authType = HdiAuthType::FACE; scheduleInfo.executorMatcher = 10; diff --git a/test/unittest/services/src/enrollment_impl_test.cpp b/test/unittest/services/src/enrollment_impl_test.cpp index 443d6aed4..f4fc2eb0e 100644 --- a/test/unittest/services/src/enrollment_impl_test.cpp +++ b/test/unittest/services/src/enrollment_impl_test.cpp @@ -64,7 +64,7 @@ HWTEST_F(EnrollmentImplTest, EnrollmentHdiError, TestSize.Level0) para.sdkVersion = 11; para.authType = FACE; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginEnrollmentV1_2(para.userId, _, _, _)).WillRepeatedly(Return(1)); + EXPECT_CALL(*mock, BeginEnrollment(_, _, _)).WillRepeatedly(Return(1)); auto enrollment = std::make_shared(para); std::vector> scheduleList; @@ -80,7 +80,7 @@ HWTEST_F(EnrollmentImplTest, EnrollmentHdiEmpty, TestSize.Level0) para.authType = FACE; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginEnrollmentV1_2(para.userId, _, _, _)).WillRepeatedly(Return(0)); + EXPECT_CALL(*mock, BeginEnrollment(_, _, _)).WillRepeatedly(Return(0)); auto enroll = std::make_shared(para); std::vector> scheduleList; @@ -219,9 +219,9 @@ HWTEST_F(EnrollmentImplTest, EnrollmentImplTestStart_001, TestSize.Level0) .Times(2) .WillOnce(Return(HDF_SUCCESS)) .WillOnce(Return(HDF_FAILURE)); - EXPECT_CALL(*mockHdi, BeginEnrollmentV1_2(_, _, _, _)) + EXPECT_CALL(*mockHdi, BeginEnrollment(_, _, _)) .WillRepeatedly( - [](int32_t userId, const std::vector &authToken, const HdiEnrollParam ¶m, + [](const std::vector &authToken, const HdiEnrollParam ¶m, HdiScheduleInfo &info) { info.authType = HdiAuthType::FACE; info.executorMatcher = 10; @@ -265,11 +265,11 @@ HWTEST_F(EnrollmentImplTest, EnrollmentImplTestStart_002, TestSize.Level0) para.sdkVersion = 11; para.authType = PIN; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginEnrollmentV1_2(_, _, _, _)).WillRepeatedly(Return(1)); + EXPECT_CALL(*mock, BeginEnrollment(_, _, _)).WillRepeatedly(Return(1)); EXPECT_CALL(*mock, GetUserInfo(_, _, _, _)) .WillOnce(Return(1)) .WillRepeatedly( - [](int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, + [](int32_t userId, uint64_t &secureUid, int32_t &pinSubType, std::vector &infos) { secureUid = 1; pinSubType = static_cast(10000); diff --git a/test/unittest/services/src/identification_impl_test.cpp b/test/unittest/services/src/identification_impl_test.cpp index ababdc35c..3260a4cd2 100644 --- a/test/unittest/services/src/identification_impl_test.cpp +++ b/test/unittest/services/src/identification_impl_test.cpp @@ -60,7 +60,7 @@ HWTEST_F(IdentificationImplTest, IdentificationHdiError, TestSize.Level0) { constexpr uint64_t contextId = 0x1234567; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginIdentificationV1_1(contextId, _, _, _, _)).WillRepeatedly(Return(1)); + EXPECT_CALL(*mock, BeginIdentification(contextId, _, _, _, _)).WillRepeatedly(Return(1)); auto identification = std::make_shared(contextId, FACE); std::vector> scheduleList; @@ -71,7 +71,7 @@ HWTEST_F(IdentificationImplTest, IdentificationHdiEmpty, TestSize.Level0) { constexpr uint64_t contextId = 0x1234567; auto mock = MockIUserAuthInterface::Holder::GetInstance().Get(); - EXPECT_CALL(*mock, BeginIdentificationV1_1(contextId, _, _, _, _)).WillRepeatedly(Return(0)); + EXPECT_CALL(*mock, BeginIdentification(contextId, _, _, _, _)).WillRepeatedly(Return(0)); auto enrollment = std::make_shared(contextId, FACE); std::vector> scheduleList; @@ -128,9 +128,9 @@ HWTEST_F(IdentificationImplTest, IdentificationTestStart, TestSize.Level0) .Times(2) .WillOnce(Return(HDF_SUCCESS)) .WillOnce(Return(HDF_FAILURE)); - EXPECT_CALL(*mockHdi, BeginIdentificationV1_1(_, _, _, _, _)) + EXPECT_CALL(*mockHdi, BeginIdentification(_, _, _, _, _)) .WillRepeatedly( - [](uint64_t contextId, HdiAuthType authType, const std::vector &challenge, uint32_t executorId, + [](uint64_t contextId, int32_t authType, const std::vector &challenge, uint32_t executorId, HdiScheduleInfo &scheduleInfo) { scheduleInfo.authType = HdiAuthType::FACE; scheduleInfo.executorMatcher = 10; diff --git a/test/unittest/services/src/user_auth_service_test.cpp b/test/unittest/services/src/user_auth_service_test.cpp index b5612080c..17494a929 100644 --- a/test/unittest/services/src/user_auth_service_test.cpp +++ b/test/unittest/services/src/user_auth_service_test.cpp @@ -68,7 +68,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceGetEnrolledState001, TestSize.Level EXPECT_CALL(*mockHdi, GetEnrolledState(_, _, _)) .Times(1) .WillOnce( - [expectCredentialDigest, expectCredentialCount](int32_t userId, HdiAuthType authType, + [expectCredentialDigest, expectCredentialCount](int32_t userId, int32_t authType, HdiEnrolledState &hdiEnrolledState) { hdiEnrolledState.credentialDigest = expectCredentialDigest; hdiEnrolledState.credentialCount = expectCredentialCount; @@ -139,7 +139,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceGetAvailableStatus001, TestSize.Lev EXPECT_CALL(*mockHdi, GetAuthTrustLevel(_, _, _)) .Times(1) .WillOnce( - [](int32_t userId, HdiAuthType authType, uint32_t &authTrustLevel) { + [](int32_t userId, int32_t authType, uint32_t &authTrustLevel) { authTrustLevel = ATL1; return HDF_SUCCESS; } @@ -165,7 +165,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceGetAvailableStatus002, TestSize.Lev EXPECT_CALL(*mockHdi, GetAuthTrustLevel(_, _, _)).Times(1); ON_CALL(*mockHdi, GetAuthTrustLevel) .WillByDefault( - [](int32_t userId, HdiAuthType authType, uint32_t &authTrustLevel) { + [](int32_t userId, int32_t authType, uint32_t &authTrustLevel) { authTrustLevel = static_cast(0); return SUCCESS; } @@ -250,7 +250,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceGetProperty002, TestSize.Level0) EXPECT_CALL(*mockHdi, GetCredential(_, _, _)).Times(2); ON_CALL(*mockHdi, GetCredential) .WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 2, @@ -345,7 +345,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuth001, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, BeginAuthenticationV1_2(_, _, _)).WillOnce(Return(HDF_FAILURE)); + EXPECT_CALL(*mockHdi, BeginAuthentication(_, _, _)).WillOnce(Return(HDF_FAILURE)); IpcCommon::AddPermission(ACCESS_BIOMETRIC_PERMISSION); sptr callbackInterface = testCallback; @@ -407,7 +407,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuth003, TestSize.Level0) IpcCommon::AddPermission(ACCESS_BIOMETRIC_PERMISSION); auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, BeginAuthenticationV1_2(_, _, _)).Times(2).WillRepeatedly(Return(NOT_ENROLLED)); + EXPECT_CALL(*mockHdi, BeginAuthentication(_, _, _)).Times(2).WillRepeatedly(Return(NOT_ENROLLED)); contextId = service.Auth(testApiVersion, testChallenge, testAuthType, testAuthTrustLevel, callbackInterface); EXPECT_EQ(contextId, 0); @@ -424,8 +424,8 @@ static void MockForUserAuthHdi(std::shared_ptr &context, std::promise &scheduleInfos) { HdiScheduleInfo scheduleInfo = {}; scheduleInfo.authType = HdiAuthType::FACE; @@ -438,7 +438,7 @@ static void MockForUserAuthHdi(std::shared_ptr &context, std::promise callbackInterface = testCallback; uint64_t contextId = service.AuthUser(testUserId, testChallenge, testAuthType, @@ -611,7 +611,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceIdentify001, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*testCallback, OnResult(_, _)).Times(1); - EXPECT_CALL(*mockHdi, BeginIdentificationV1_1(_, _, _, _, _)).Times(1); + EXPECT_CALL(*mockHdi, BeginIdentification(_, _, _, _, _)).Times(1); IpcCommon::AddPermission(ACCESS_USER_AUTH_INTERNAL_PERMISSION); sptr callbackInterface = testCallback; uint64_t contextId = service.Identify(testChallenge, testAuthType, callbackInterface); @@ -646,8 +646,8 @@ static void MockForIdentifyHdi(std::shared_ptr &context, std::promise &challenge, + EXPECT_CALL(*mockHdi, BeginIdentification(_, _, _, _, _)) + .WillRepeatedly([&context](uint64_t contextId, int32_t authType, const std::vector &challenge, uint32_t executorId, HdiScheduleInfo &scheduleInfo) { scheduleInfo.authType = HdiAuthType::FACE; scheduleInfo.scheduleId = testscheduleId; @@ -1154,7 +1154,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_015, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1196,7 +1196,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_016, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1246,7 +1246,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_0017, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1297,7 +1297,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_0018, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1347,7 +1347,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_0019, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1395,7 +1395,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_0020, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1444,7 +1444,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_0021, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1493,7 +1493,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_022, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); ON_CALL(*mockHdi, GetCredential).WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 0, @@ -1544,18 +1544,13 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthWidget_023, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*mockHdi, GetAuthTrustLevel(_, _, _)).Times(0); - EXPECT_CALL(*mockHdi, BeginAuthenticationV1_2(_, _, _)).Times(0); + EXPECT_CALL(*mockHdi, BeginAuthentication(_, _, _)).Times(0); EXPECT_CALL(*mockHdi, CheckReuseUnlockResult(_, _)).Times(1); ON_CALL(*mockHdi, CheckReuseUnlockResult) .WillByDefault( - [](const HdiReuseUnlockInfo &info, std::vector &reuseResult) { + [](const HdiReuseUnlockParam &info, HdiReuseUnlockInfo &reuseInfo) { static const uint32_t USER_AUTH_TOKEN_LEN = 148; - struct ReuseUnlockResultHdi { - uint32_t authType; - uint8_t authToken[USER_AUTH_TOKEN_LEN]; - EnrolledState enrolledState; - }; - reuseResult.resize(sizeof(ReuseUnlockResultHdi)); + reuseInfo.token.resize(USER_AUTH_TOKEN_LEN); return HDF_SUCCESS; } ); diff --git a/test/unittest/services/src/user_idm_database_test.cpp b/test/unittest/services/src/user_idm_database_test.cpp index 63cb92da1..4ed75283f 100644 --- a/test/unittest/services/src/user_idm_database_test.cpp +++ b/test/unittest/services/src/user_idm_database_test.cpp @@ -252,7 +252,7 @@ HWTEST_F(UserIdmDatabaseTest, DeleteUser001, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, DeleteUser(_, _, _)).WillRepeatedly(Return(1)); + EXPECT_CALL(*mockHdi, DeleteUser(_, _, _, _)).WillRepeatedly(Return(1)); int32_t result = UserIdmDatabase::Instance().DeleteUser(testUserId, testAuthToken, testCredInfos); EXPECT_EQ(result, 1); } @@ -265,10 +265,11 @@ HWTEST_F(UserIdmDatabaseTest, DeleteUser002, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, DeleteUser(_, _, _)).Times(1); + EXPECT_CALL(*mockHdi, DeleteUser(_, _, _, _)).Times(1); ON_CALL(*mockHdi, DeleteUser) .WillByDefault( - [](int32_t userId, const std::vector &authToken, std::vector &deletedInfos) { + [](int32_t userId, const std::vector &authToken, std::vector &deletedInfos, + std::vector &rootSecret) { HdiCredentialInfo info = {}; info.authType = static_cast(1); info.credentialId = 10; diff --git a/test/unittest/services/src/user_idm_service_test.cpp b/test/unittest/services/src/user_idm_service_test.cpp index 2aedc2ae2..2c053f9df 100644 --- a/test/unittest/services/src/user_idm_service_test.cpp +++ b/test/unittest/services/src/user_idm_service_test.cpp @@ -172,7 +172,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceGetCredentialInfo003, TestSize.Level0 EXPECT_CALL(*mockHdi, GetCredential(_, _, _)).Times(2); ON_CALL(*mockHdi, GetCredential) .WillByDefault( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 2, @@ -189,7 +189,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceGetCredentialInfo003, TestSize.Level0 .Times(2) .WillOnce(Return(HDF_FAILURE)) .WillOnce( - [](int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, std::vector &infos) { + [](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector &infos) { HdiEnrolledInfo info = { .enrolledId = 0, .authType = static_cast(1), @@ -222,7 +222,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceGetCredentialInfo004, TestSize.Level0 EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*mockHdi, GetCredential(_, _, _)) .WillOnce( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 2, @@ -278,7 +278,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceGetSecInfo002, TestSize.Level0) .Times(2) .WillOnce(Return(HDF_FAILURE)) .WillOnce( - [](int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, std::vector &infos) { + [](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector &infos) { HdiEnrolledInfo info = { .enrolledId = 0, .authType = static_cast(1), @@ -336,7 +336,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceAddCredential002, TestSize.Level0) ); auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, BeginEnrollmentV1_2(_, _, _, _)).WillRepeatedly(Return(HDF_FAILURE)); + EXPECT_CALL(*mockHdi, BeginEnrollment(_, _, _)).WillRepeatedly(Return(HDF_FAILURE)); service.AddCredential(testUserId, testCredPara, testCallback, false); IpcCommon::AddPermission(MANAGE_USER_IDM_PERMISSION); @@ -350,8 +350,8 @@ static void MockForAddCredentialHdi(std::shared_ptr &context, std::prom const uint32_t testscheduleId = 20; auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, BeginEnrollmentV1_2(_, _, _, _)) - .WillOnce([&context](int32_t userId, const std::vector &authToken, const HdiEnrollParam ¶m, + EXPECT_CALL(*mockHdi, BeginEnrollment(_, _, _)) + .WillOnce([&context](const std::vector &authToken, const HdiEnrollParam ¶m, HdiScheduleInfo &info) { HdiExecutorInfo executorInfo = {}; executorInfo.executorIndex = testExecutorIndex; @@ -482,7 +482,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceUpdateCredential002, TestSize.Level0) EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*mockHdi, GetCredential(_, _, _)) .WillOnce( - [](int32_t userId, HdiAuthType authType, std::vector &infos) { + [](int32_t userId, int32_t authType, std::vector &infos) { HdiCredentialInfo tempInfo = { .credentialId = 1, .executorIndex = 2, @@ -496,7 +496,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceUpdateCredential002, TestSize.Level0) } ); - EXPECT_CALL(*mockHdi, BeginEnrollmentV1_2(_, _, _, _)).WillOnce(Return(HDF_FAILURE)); + EXPECT_CALL(*mockHdi, BeginEnrollment(_, _, _)).WillOnce(Return(HDF_FAILURE)); testCredPara.token = {1, 2, 3, 4}; service.UpdateCredential(testUserId, testCredPara, testCallback); @@ -611,7 +611,7 @@ static void MockForDelUserHdi() auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); EXPECT_CALL(*mockHdi, GetUserInfo(_, _, _, _)) - .WillRepeatedly([](int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, + .WillRepeatedly([](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector &infos) { HdiEnrolledInfo info = { .enrolledId = 0, @@ -689,7 +689,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceDelUser001, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, DeleteUser(_, _, _)).WillOnce(Return(HDF_FAILURE)); + EXPECT_CALL(*mockHdi, DeleteUser(_, _, _, _)).WillOnce(Return(HDF_FAILURE)); service.DelUser(testUserId, testAuthToken, testCallback); IpcCommon::AddPermission(MANAGE_USER_IDM_PERMISSION); @@ -741,9 +741,10 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceDelUser004, TestSize.Level0) auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get(); EXPECT_NE(mockHdi, nullptr); - EXPECT_CALL(*mockHdi, DeleteUser(_, _, _)) + EXPECT_CALL(*mockHdi, DeleteUser(_, _, _, _)) .WillOnce( - [](int32_t userId, const std::vector &authToken, std::vector &deletedInfos) { + [](int32_t userId, const std::vector &authToken, std::vector &deletedInfos, + std::vector &rootSecret) { HdiCredentialInfo info = {}; info.authType = static_cast(1); info.credentialId = 10; @@ -853,7 +854,7 @@ HWTEST_F(UserIdmServiceTest, UserIdmServiceTestDump, TestSize.Level0) .Times(2) .WillOnce(Return(HDF_FAILURE)) .WillOnce( - [](int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, std::vector &infos) { + [](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector &infos) { HdiEnrolledInfo info = { .enrolledId = 0, .authType = static_cast(1), diff --git a/test/unittest/services/src/user_info_test.cpp b/test/unittest/services/src/user_info_test.cpp index 3750c667b..246c92883 100644 --- a/test/unittest/services/src/user_info_test.cpp +++ b/test/unittest/services/src/user_info_test.cpp @@ -56,7 +56,7 @@ HWTEST_F(UserInfoTest, GetPinSubType, TestSize.Level0) constexpr uint64_t secUserId = 200; UserInfo info = { .secureUid = secUserId, - .pinSubType = static_cast(pinSubType), + .pinSubType = static_cast(pinSubType), }; UserInfoImpl UserInfoImpl(userId, info); EXPECT_EQ(UserInfoImpl.GetPinSubType(), pinSubType); @@ -69,7 +69,7 @@ HWTEST_F(UserInfoTest, GetSecUserId, TestSize.Level0) constexpr uint64_t secUserId = 200; UserInfo info = { .secureUid = secUserId, - .pinSubType = static_cast(pinSubType), + .pinSubType = static_cast(pinSubType), }; UserInfoImpl UserInfoImpl(userId, info); uint64_t ret = UserInfoImpl.GetSecUserId();