mirror of
https://gitee.com/openharmony/useriam_user_auth_framework
synced 2024-11-23 15:49:52 +00:00
commit
f25bbad701
@ -78,6 +78,7 @@ struct SetPropertyRequest {
|
||||
|
||||
struct AuthResult {
|
||||
std::vector<uint8_t> token {};
|
||||
std::vector<uint8_t> rootSecret {};
|
||||
uint32_t remainTimes {0};
|
||||
uint32_t freezingTime {0};
|
||||
};
|
||||
|
@ -49,6 +49,7 @@ struct AddCredInfo {
|
||||
|
||||
struct RequestResult {
|
||||
uint64_t credentialId;
|
||||
std::vector<uint8_t> rootSecret;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
|
@ -114,6 +114,7 @@ struct AddCredInfo {
|
||||
|
||||
struct RequestResult {
|
||||
uint64_t credentialId {0};
|
||||
std::vector<uint8_t> rootSecret;
|
||||
};
|
||||
} // namespace UserIDM
|
||||
} // namespace UserIAM
|
||||
|
@ -97,7 +97,7 @@ bool EnrollmentImpl::Start(std::vector<std::shared_ptr<ScheduleNode>> &scheduleL
|
||||
bool EnrollmentImpl::Update(const std::vector<uint8_t> &scheduleResult, uint64_t &credentialId,
|
||||
std::shared_ptr<CredentialInfo> &info)
|
||||
{
|
||||
using HdiCredentialInfo = OHOS::HDI::UserAuth::V1_0::CredentialInfo;
|
||||
using HdiEnrollResultInfo = OHOS::HDI::UserAuth::V1_0::EnrollResultInfo;
|
||||
|
||||
auto hdi = HdiWrapper::GetHdiInstance();
|
||||
if (!hdi) {
|
||||
@ -105,18 +105,19 @@ bool EnrollmentImpl::Update(const std::vector<uint8_t> &scheduleResult, uint64_t
|
||||
return false;
|
||||
}
|
||||
|
||||
HdiCredentialInfo oldInfo = {};
|
||||
auto result = hdi->UpdateEnrollmentResult(userId_, scheduleResult, credentialId, oldInfo);
|
||||
HdiEnrollResultInfo resultInfo = {};
|
||||
auto result = hdi->UpdateEnrollmentResult(userId_, scheduleResult, resultInfo);
|
||||
if (result != HDF_SUCCESS) {
|
||||
IAM_LOGE("hdi UpdateEnrollmentResult failed, err is %{public}d, userId is %{public}d", result, userId_);
|
||||
return false;
|
||||
}
|
||||
IAM_LOGI("hdi UpdateEnrollmentResult success, userId is %{public}d", userId_);
|
||||
auto infoRet = MakeShared<CredentialInfoImpl>(userId_, oldInfo);
|
||||
auto infoRet = MakeShared<CredentialInfoImpl>(userId_, resultInfo.oldInfo);
|
||||
if (infoRet == nullptr) {
|
||||
IAM_LOGE("bad alloc");
|
||||
return false;
|
||||
}
|
||||
credentialId = resultInfo.credentialId;
|
||||
info = infoRet;
|
||||
|
||||
return true;
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
using AuthSolution = OHOS::HDI::UserAuth::V1_0::AuthSolution;
|
||||
using AuthResultInfo = OHOS::HDI::UserAuth::V1_0::AuthResultInfo;
|
||||
using IdentifyResultInfo = OHOS::HDI::UserAuth::V1_0::IdentifyResultInfo;
|
||||
using EnrollResultInfo = OHOS::HDI::UserAuth::V1_0::EnrollResultInfo;
|
||||
|
||||
class Holder;
|
||||
MOCK_METHOD0(Init, int32_t());
|
||||
@ -51,8 +52,8 @@ public:
|
||||
MOCK_METHOD1(CloseSession, int32_t(int32_t userId));
|
||||
MOCK_METHOD4(BeginEnrollment,
|
||||
int32_t(int32_t userId, const std::vector<uint8_t> &authToken, const EnrollParam ¶m, ScheduleInfo &info));
|
||||
MOCK_METHOD4(UpdateEnrollmentResult, int32_t(int32_t userId, const std::vector<uint8_t> &scheduleResult,
|
||||
uint64_t &credentialId, CredentialInfo &oldInfo));
|
||||
MOCK_METHOD3(UpdateEnrollmentResult, int32_t(int32_t userId, const std::vector<uint8_t> &scheduleResult,
|
||||
EnrollResultInfo &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, CredentialInfo &info));
|
||||
|
@ -80,7 +80,7 @@ HWTEST_F(EnrollmentImplTest, EnrollmentUpdateHdiError, TestSize.Level1)
|
||||
constexpr int32_t userId = 0x11;
|
||||
|
||||
auto mock = MockIUserAuthInterface::Holder::GetInstance().Get();
|
||||
EXPECT_CALL(*mock, UpdateEnrollmentResult(userId, _, _, _)).WillRepeatedly(Return(1));
|
||||
EXPECT_CALL(*mock, UpdateEnrollmentResult(userId, _, _)).WillRepeatedly(Return(1));
|
||||
|
||||
auto authentication = std::make_shared<EnrollmentImpl>(userId, FACE);
|
||||
std::vector<uint8_t> scheduleResult = {1, 2, 3};
|
||||
@ -92,13 +92,14 @@ HWTEST_F(EnrollmentImplTest, EnrollmentUpdateHdiError, TestSize.Level1)
|
||||
HWTEST_F(EnrollmentImplTest, EnrollmentUpdateHdiSuccessful, TestSize.Level1)
|
||||
{
|
||||
using HdiCredentialInfo = OHOS::HDI::UserAuth::V1_0::CredentialInfo;
|
||||
using HdiEnrollResultInfo = OHOS::HDI::UserAuth::V1_0::EnrollResultInfo;
|
||||
constexpr int32_t userId = 0x11;
|
||||
constexpr uint64_t credentialIdRet = 0x12;
|
||||
std::vector<uint8_t> scheduleResult = {1, 2, 3};
|
||||
|
||||
auto mock = MockIUserAuthInterface::Holder::GetInstance().Get();
|
||||
auto fillUpInfos = [](HdiCredentialInfo &infoRet) {
|
||||
HdiCredentialInfo info = {
|
||||
auto fillUpInfos = [](HdiEnrollResultInfo &infoRet) {
|
||||
HdiCredentialInfo oldInfo = {
|
||||
.credentialId = 1,
|
||||
.executorIndex = 2,
|
||||
.templateId = 3,
|
||||
@ -106,10 +107,13 @@ HWTEST_F(EnrollmentImplTest, EnrollmentUpdateHdiSuccessful, TestSize.Level1)
|
||||
.executorMatcher = 5,
|
||||
.executorSensorHint = 6,
|
||||
};
|
||||
HdiEnrollResultInfo info = {
|
||||
.oldInfo = oldInfo,
|
||||
.credentialId = credentialIdRet,
|
||||
};
|
||||
infoRet = info;
|
||||
};
|
||||
EXPECT_CALL(*mock, UpdateEnrollmentResult(userId, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgReferee<2>(credentialIdRet), WithArg<3>(fillUpInfos), Return(0)));
|
||||
EXPECT_CALL(*mock, UpdateEnrollmentResult(userId, _, _)).WillRepeatedly(DoAll(WithArg<2>(fillUpInfos), Return(0)));
|
||||
|
||||
auto authentication = std::make_shared<EnrollmentImpl>(userId, FACE);
|
||||
HdiCredentialInfo oldInfo = {};
|
||||
|
Loading…
Reference in New Issue
Block a user