fix : update pin_auth user_auth idl to 2_0

Signed-off-by: hejiaogirl <hejiao@huawei.com>
Change-Id: I6cd19c61ed26bc4ef72844dbd609265aa12ca8c8
This commit is contained in:
hejiaogirl 2024-03-25 14:18:30 +08:00
parent f975a7f61e
commit 48149be997
30 changed files with 190 additions and 230 deletions

View File

@ -17,7 +17,7 @@
<oatconfig>
<filefilterlist>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filename" name="*.png" desc="The framework image"/>
<filteritem type="filename" name="*.png" desc="The framework image"/>
</filefilter>
</filefilterlist>
</oatconfig>

View File

@ -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
```

View File

@ -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",

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -133,15 +133,15 @@ int32_t AuthWidgetHelper::CheckValidSolution(int32_t userId,
IAM_LOGE("hdi interface is nullptr");
return GENERAL_ERROR;
}
std::vector<HdiAuthType> inputAuthType;
std::vector<HdiAuthType> validTypes;
std::vector<int32_t> inputAuthType;
std::vector<int32_t> 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<HdiAuthType>(type));
inputAuthType.emplace_back(static_cast<int32_t>(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<uint8_t> 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<int32_t>(reuseResult.authType));
static_cast<int32_t>(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<HdiAuthType>(type));
unlockParam.authTypes.emplace_back(static_cast<HdiAuthType>(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<uint8_t> 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

View File

@ -85,18 +85,18 @@ bool AuthenticationImpl::Start(std::vector<std::shared_ptr<ScheduleNode>> &sched
IAM_LOGE("bad hdi");
return false;
}
HdiAuthSolution solution = {
.userId = authPara_.userId,
.authTrustLevel = authPara_.atl,
.authType = static_cast<HdiAuthType>(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<int32_t>(authPara_.authType),
};
std::vector<HdiScheduleInfo> 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<uint8_t> &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);
}

View File

@ -102,9 +102,10 @@ bool EnrollmentImpl::Start(std::vector<std::shared_ptr<ScheduleNode>> &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);

View File

@ -78,7 +78,7 @@ bool IdentificationImpl::Start(std::vector<std::shared_ptr<ScheduleNode>> &sched
HdiScheduleInfo info;
IamHitraceHelper traceHelper("hdi BeginIdentification");
auto result =
hdi->BeginIdentificationV1_1(contextId_, static_cast<HdiAuthType>(authType_), challenge_, executorIndex_, info);
hdi->BeginIdentification(contextId_, static_cast<HdiAuthType>(authType_), challenge_, executorIndex_, info);
if (result != HDF_SUCCESS) {
IAM_LOGE("hdi BeginAuthentication failed, err is %{public}d", result);
SetLatestError(result);

View File

@ -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<AuthType>(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");

View File

@ -40,7 +40,7 @@ std::shared_ptr<SecureUserInfoInterface> UserIdmDatabaseImpl::GetSecUserInfo(int
std::vector<HdiEnrolledInfo> 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<uint8_
}
std::vector<HdiCredentialInfo> hdiInfos;
std::vector<uint8_t> 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;

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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<uint8_t> 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<uint8_t> testChallenge = {4, 5, 6, 7, 3, 4, 1, 2};
AuthType testAuthType = FACE;

View File

@ -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",

View File

@ -38,54 +38,44 @@ public:
MOCK_METHOD1(DeleteExecutor, int32_t(uint64_t index));
MOCK_METHOD2(OpenSession, int32_t(int32_t userId, std::vector<uint8_t> &challenge));
MOCK_METHOD1(CloseSession, int32_t(int32_t userId));
MOCK_METHOD4(BeginEnrollment,
int32_t(int32_t userId, const std::vector<uint8_t> &authToken, const HdiEnrollParamV1_0 &param,
HdiScheduleInfoV1_0 &info));
MOCK_METHOD3(UpdateEnrollmentResult, int32_t(int32_t userId, const std::vector<uint8_t> &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<uint8_t> &authToken, HdiCredentialInfo &info));
MOCK_METHOD3(GetCredential, int32_t(int32_t userId, HdiAuthType authType, std::vector<HdiCredentialInfo> &infos));
MOCK_METHOD3(GetCredential, int32_t(int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &infos));
MOCK_METHOD4(GetUserInfo,
int32_t(int32_t userId, uint64_t &secureUid, HdiPinSubType &pinSubType, std::vector<HdiEnrolledInfo> &infos));
MOCK_METHOD3(DeleteUser,
int32_t(int32_t userId, const std::vector<uint8_t> &authToken, std::vector<HdiCredentialInfo> &deletedInfos));
int32_t(int32_t userId, uint64_t &secureUid, int32_t &pinSubType, std::vector<HdiEnrolledInfo> &infos));
MOCK_METHOD4(DeleteUser,
int32_t(int32_t userId, const std::vector<uint8_t> &authToken, std::vector<HdiCredentialInfo> &deletedInfos,
std::vector<uint8_t> &rootSecret));
MOCK_METHOD2(EnforceDeleteUser, int32_t(int32_t userId, std::vector<HdiCredentialInfo> &deletedInfos));
MOCK_METHOD3(BeginAuthentication,
int32_t(uint64_t contextId, const HdiAuthSolutionV1_0 &param, std::vector<HdiScheduleInfoV1_0> &scheduleInfos));
MOCK_METHOD3(UpdateAuthenticationResult,
int32_t(uint64_t contextId, const std::vector<uint8_t> &scheduleResult, HdiAuthResultInfo &info));
MOCK_METHOD1(CancelAuthentication, int32_t(uint64_t contextId));
MOCK_METHOD5(BeginIdentification,
int32_t(uint64_t contextId, HdiAuthType authType, const std::vector<uint8_t> &challenge, uint32_t executorId,
HdiScheduleInfoV1_0 &scheduleInfo));
MOCK_METHOD3(UpdateIdentificationResult,
int32_t(uint64_t contextId, const std::vector<uint8_t> &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<HdiAuthType> &authTypes,
uint32_t authTrustLevel, std::vector<HdiAuthType> &validTypes));
MOCK_METHOD4(BeginEnrollmentV1_1,
int32_t(int32_t userId, const std::vector<uint8_t> &authToken, const HdiEnrollParamV1_0 &param,
HdiScheduleInfo &info));
MOCK_METHOD3(BeginAuthenticationV1_1,
int32_t(uint64_t contextId, const HdiAuthSolutionV1_0 &param, std::vector<HdiScheduleInfo> &scheduleInfos));
MOCK_METHOD5(BeginIdentificationV1_1,
int32_t(uint64_t contextId, HdiAuthType authType, const std::vector<uint8_t> &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<int32_t>& authTypes,
uint32_t authTrustLevel, std::vector<int32_t>& validTypes));
MOCK_METHOD5(BeginIdentification,
int32_t(uint64_t contextId, int32_t authType, const std::vector<uint8_t> &challenge, uint32_t executorId,
HdiScheduleInfo &scheduleInfo));
MOCK_METHOD1(GetAllUserInfo, int32_t(std::vector<UserInfo> &userInfos));
MOCK_METHOD1(GetAllExtUserInfo, int32_t(std::vector<ExtUserInfo> &userInfos));
MOCK_METHOD4(BeginEnrollmentV1_2,
int32_t(int32_t userId, const std::vector<uint8_t> &authToken, const HdiEnrollParam &param,
HdiScheduleInfo &info));
MOCK_METHOD3(BeginAuthenticationV1_2,
int32_t(uint64_t contextId, const HdiAuthSolution &param, std::vector<HdiScheduleInfo> &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<uint8_t> &authToken, const HdiEnrollParam &param, HdiScheduleInfo &info));
MOCK_METHOD3(BeginAuthentication,
int32_t(uint64_t contextId, const HdiAuthParam &param, std::vector<HdiScheduleInfo> &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<uint8_t> &scheduleResult, HdiAuthResultInfo &info, HdiEnrolledState &enrolledState));
MOCK_METHOD2(CheckReuseUnlockResult, int32_t(const HdiReuseUnlockInfo &info, std::vector<uint8_t> &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<uint8_t>& msg));
MOCK_METHOD1(RegisterMessageCallback, int32_t(const sptr<HdiIMessageCallback>& messageCallback));
MOCK_METHOD3(GetLocalScheduleFromMessage, int32_t(const std::vector<uint8_t>& remoteDeviceId,
const std::vector<uint8_t>& message, HdiScheduleInfo& scheduleInfo));
MOCK_METHOD4(GetSignedExecutorInfo, int32_t(const std::vector<int32_t>& authTypes, int32_t executorRole,
const std::vector<uint8_t>& remoteDeviceId, std::vector<uint8_t>& signedExecutorInfo));
};
class MockIUserAuthInterface::Holder : public Singleton<MockIUserAuthInterface::Holder> {

View File

@ -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<uint8_t> &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<uint8_t> &reuseResult) {
return HDF_SUCCESS;
}
);
EXPECT_EQ(AuthWidgetHelper::CheckReuseUnlockResult(para, authParam, extraInfo), GENERAL_ERROR);
ON_CALL(*mockHdi, CheckReuseUnlockResult)
.WillByDefault(
[](const HdiReuseUnlockInfo &info, std::vector<uint8_t> &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<uint8_t> 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

View File

@ -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<AuthenticationImpl>(contextId, para);
std::vector<std::shared_ptr<ScheduleNode>> 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<AuthenticationImpl>(contextId, para);
std::vector<std::shared_ptr<ScheduleNode>> 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<AuthenticationImpl>(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<uint8_t> &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<uint8_t> &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 &param, std::vector<HdiScheduleInfo> &scheduleInfos) {
[](uint64_t contextId, const HdiAuthParam &param, std::vector<HdiScheduleInfo> &scheduleInfos) {
HdiScheduleInfo scheduleInfo = {};
scheduleInfo.authType = HdiAuthType::FACE;
scheduleInfo.executorMatcher = 10;

View File

@ -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<EnrollmentImpl>(para);
std::vector<std::shared_ptr<ScheduleNode>> 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<EnrollmentImpl>(para);
std::vector<std::shared_ptr<ScheduleNode>> 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<uint8_t> &authToken, const HdiEnrollParam &param,
[](const std::vector<uint8_t> &authToken, const HdiEnrollParam &param,
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<HdiEnrolledInfo> &infos) {
secureUid = 1;
pinSubType = static_cast<HdiPinSubType>(10000);

View File

@ -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<IdentificationImpl>(contextId, FACE);
std::vector<std::shared_ptr<ScheduleNode>> 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<IdentificationImpl>(contextId, FACE);
std::vector<std::shared_ptr<ScheduleNode>> 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<uint8_t> &challenge, uint32_t executorId,
[](uint64_t contextId, int32_t authType, const std::vector<uint8_t> &challenge, uint32_t executorId,
HdiScheduleInfo &scheduleInfo) {
scheduleInfo.authType = HdiAuthType::FACE;
scheduleInfo.executorMatcher = 10;

View File

@ -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<AuthTrustLevel>(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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<UserAuthCallbackInterface> 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> &context, std::promise<v
const uint32_t testExecutorIndex = 60;
auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get();
EXPECT_NE(mockHdi, nullptr);
EXPECT_CALL(*mockHdi, BeginAuthenticationV1_2(_, _, _))
.WillRepeatedly([&context](uint64_t contextId, const HdiAuthSolution &param,
EXPECT_CALL(*mockHdi, BeginAuthentication(_, _, _))
.WillRepeatedly([&context](uint64_t contextId, const HdiAuthParam &param,
std::vector<HdiScheduleInfo> &scheduleInfos) {
HdiScheduleInfo scheduleInfo = {};
scheduleInfo.authType = HdiAuthType::FACE;
@ -438,7 +438,7 @@ static void MockForUserAuthHdi(std::shared_ptr<Context> &context, std::promise<v
return HDF_SUCCESS;
});
EXPECT_CALL(*mockHdi, UpdateAuthenticationResultWithEnrolledState(_, _, _, _)).WillOnce(Return(HDF_SUCCESS));
EXPECT_CALL(*mockHdi, UpdateAuthenticationResult(_, _, _, _)).WillOnce(Return(HDF_SUCCESS));
EXPECT_CALL(*mockHdi, CancelAuthentication(_))
.WillOnce([&promise](uint64_t contextId) {
promise.set_value();
@ -519,7 +519,7 @@ HWTEST_F(UserAuthServiceTest, UserAuthServiceAuthUser001, TestSize.Level0)
auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get();
EXPECT_NE(mockHdi, nullptr);
EXPECT_CALL(*testCallback, OnResult(_, _)).Times(1);
EXPECT_CALL(*mockHdi, BeginAuthenticationV1_2(_, _, _)).Times(1);
EXPECT_CALL(*mockHdi, BeginAuthentication(_, _, _)).Times(1);
IpcCommon::AddPermission(ACCESS_USER_AUTH_INTERNAL_PERMISSION);
sptr<UserAuthCallbackInterface> 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<UserAuthCallbackInterface> callbackInterface = testCallback;
uint64_t contextId = service.Identify(testChallenge, testAuthType, callbackInterface);
@ -646,8 +646,8 @@ static void MockForIdentifyHdi(std::shared_ptr<Context> &context, std::promise<v
const uint32_t testscheduleId = 20;
auto mockHdi = MockIUserAuthInterface::Holder::GetInstance().Get();
EXPECT_NE(mockHdi, nullptr);
EXPECT_CALL(*mockHdi, BeginIdentificationV1_1(_, _, _, _, _))
.WillRepeatedly([&context](uint64_t contextId, HdiAuthType authType, const std::vector<uint8_t> &challenge,
EXPECT_CALL(*mockHdi, BeginIdentification(_, _, _, _, _))
.WillRepeatedly([&context](uint64_t contextId, int32_t authType, const std::vector<uint8_t> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<uint8_t> &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;
}
);

View File

@ -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<uint8_t> &authToken, std::vector<HdiCredentialInfo> &deletedInfos) {
[](int32_t userId, const std::vector<uint8_t> &authToken, std::vector<HdiCredentialInfo> &deletedInfos,
std::vector<uint8_t> &rootSecret) {
HdiCredentialInfo info = {};
info.authType = static_cast<HdiAuthType>(1);
info.credentialId = 10;

View File

@ -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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiEnrolledInfo> &infos) {
[](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector<HdiEnrolledInfo> &infos) {
HdiEnrolledInfo info = {
.enrolledId = 0,
.authType = static_cast<HdiAuthType>(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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiEnrolledInfo> &infos) {
[](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector<HdiEnrolledInfo> &infos) {
HdiEnrolledInfo info = {
.enrolledId = 0,
.authType = static_cast<HdiAuthType>(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> &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<uint8_t> &authToken, const HdiEnrollParam &param,
EXPECT_CALL(*mockHdi, BeginEnrollment(_, _, _))
.WillOnce([&context](const std::vector<uint8_t> &authToken, const HdiEnrollParam &param,
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<HdiCredentialInfo> &infos) {
[](int32_t userId, int32_t authType, std::vector<HdiCredentialInfo> &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<HdiEnrolledInfo> &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<uint8_t> &authToken, std::vector<HdiCredentialInfo> &deletedInfos) {
[](int32_t userId, const std::vector<uint8_t> &authToken, std::vector<HdiCredentialInfo> &deletedInfos,
std::vector<uint8_t> &rootSecret) {
HdiCredentialInfo info = {};
info.authType = static_cast<HdiAuthType>(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<HdiEnrolledInfo> &infos) {
[](int32_t userId, uint64_t &secureUid, int32_t& pinSubType, std::vector<HdiEnrolledInfo> &infos) {
HdiEnrolledInfo info = {
.enrolledId = 0,
.authType = static_cast<HdiAuthType>(1),

View File

@ -56,7 +56,7 @@ HWTEST_F(UserInfoTest, GetPinSubType, TestSize.Level0)
constexpr uint64_t secUserId = 200;
UserInfo info = {
.secureUid = secUserId,
.pinSubType = static_cast<OHOS::HDI::UserAuth::V1_3::PinSubType>(pinSubType),
.pinSubType = static_cast<OHOS::HDI::UserAuth::V2_0::PinSubType>(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<OHOS::HDI::UserAuth::V1_3::PinSubType>(pinSubType),
.pinSubType = static_cast<OHOS::HDI::UserAuth::V2_0::PinSubType>(pinSubType),
};
UserInfoImpl UserInfoImpl(userId, info);
uint64_t ret = UserInfoImpl.GetSecUserId();