mirror of
https://gitee.com/openharmony/useriam_user_auth_framework
synced 2024-11-23 07:39:51 +00:00
support msg distribute
Signed-off-by: Tianshi Liu <tianshi.liu@huawei.com> Change-Id: If39383d0ddeeefcce458820a48201123c2e23ec5 Signed-off-by: Tianshi Liu <tianshi.liu@huawei.com>
This commit is contained in:
parent
9ddc8f2f2f
commit
9102da1c6c
@ -34,6 +34,7 @@ public:
|
||||
int32_t OnEndExecute(uint64_t scheduleId, const Attributes &command) override;
|
||||
int32_t OnSetProperty(const Attributes &properties) override;
|
||||
int32_t OnGetProperty(const Attributes &condition, Attributes &values) override;
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ExecutorRegisterCallback> callback_ {nullptr};
|
||||
|
@ -25,9 +25,8 @@ namespace UserAuth {
|
||||
class ExecutorMessengerClient final : public ExecutorMessenger {
|
||||
public:
|
||||
explicit ExecutorMessengerClient(const sptr<ExecutorMessengerInterface> &messenger);
|
||||
int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) override;
|
||||
int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode,
|
||||
int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) override;
|
||||
int32_t Finish(uint64_t scheduleId, int32_t resultCode,
|
||||
const Attributes &finalResult) override;
|
||||
|
||||
private:
|
||||
|
@ -85,6 +85,16 @@ int32_t ExecutorCallbackService::OnGetProperty(const Attributes &condition, Attr
|
||||
}
|
||||
return callback_->OnGetProperty(condition, values);
|
||||
}
|
||||
|
||||
int32_t ExecutorCallbackService::OnSendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
if (callback_ == nullptr) {
|
||||
IAM_LOGE("callback is nullptr");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
return callback_->OnSendData(scheduleId, data);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
@ -29,8 +29,8 @@ ExecutorMessengerClient::ExecutorMessengerClient(const sptr<ExecutorMessengerInt
|
||||
{
|
||||
}
|
||||
|
||||
int32_t ExecutorMessengerClient::SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole,
|
||||
ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg)
|
||||
int32_t ExecutorMessengerClient::SendData(uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
if (messenger_ == nullptr) {
|
||||
@ -44,10 +44,10 @@ int32_t ExecutorMessengerClient::SendData(uint64_t scheduleId, uint64_t transNum
|
||||
} else {
|
||||
buffer = AuthMessageImpl::GetMsgBuffer(msg);
|
||||
}
|
||||
return messenger_->SendData(scheduleId, transNum, srcRole, dstRole, buffer);
|
||||
return messenger_->SendData(scheduleId, dstRole, buffer);
|
||||
}
|
||||
|
||||
int32_t ExecutorMessengerClient::Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode,
|
||||
int32_t ExecutorMessengerClient::Finish(uint64_t scheduleId, int32_t resultCode,
|
||||
const Attributes &finalResult)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
@ -60,7 +60,7 @@ int32_t ExecutorMessengerClient::Finish(uint64_t scheduleId, ExecutorRole srcRol
|
||||
IAM_LOGE("failed to create attributes");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
return messenger_->Finish(scheduleId, srcRole, static_cast<ResultCode>(resultCode), attr);
|
||||
return messenger_->Finish(scheduleId, static_cast<ResultCode>(resultCode), attr);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -34,6 +34,7 @@ ohos_shared_library("userauth_executors") {
|
||||
sources = [
|
||||
"src/async_command/async_command_base.cpp",
|
||||
"src/async_command/auth_command.cpp",
|
||||
"src/async_command/collect_command.cpp",
|
||||
"src/async_command/custom_command.cpp",
|
||||
"src/async_command/enroll_command.cpp",
|
||||
"src/async_command/identify_command.cpp",
|
||||
@ -42,6 +43,7 @@ ohos_shared_library("userauth_executors") {
|
||||
"src/executor.cpp",
|
||||
"src/framework/executor_mgr_wrapper.cpp",
|
||||
"src/framework/framework_executor_callback.cpp",
|
||||
"src/iauth_executor_hdi.cpp",
|
||||
"src/idriver_manager.cpp",
|
||||
"src/listener/auth_executor_mgr_status_listener.cpp",
|
||||
"src/listener/driver_manager_status_listener.cpp",
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
ResultCode StartProcess() override;
|
||||
void OnResult(ResultCode result) override;
|
||||
void OnResult(ResultCode result, const std::vector<uint8_t> &extraInfo) override;
|
||||
void OnMessage(int destRole, const std::vector<uint8_t> &msg) override;
|
||||
void OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &extraInfo) override;
|
||||
int32_t GetAuthType();
|
||||
|
||||
@ -48,11 +49,12 @@ protected:
|
||||
static uint32_t GenerateCommandId();
|
||||
virtual ResultCode SendRequest() = 0;
|
||||
virtual void OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo) = 0;
|
||||
virtual void OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo) = 0;
|
||||
virtual void OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo);
|
||||
virtual void OnMessageInner(int destRole, const std::vector<uint8_t> &msg);
|
||||
std::shared_ptr<IAuthExecutorHdi> GetExecutorHdi();
|
||||
int32_t MessengerSendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcType, ExecutorRole dstType,
|
||||
int32_t MessengerSendData(uint64_t scheduleId, ExecutorRole dstType,
|
||||
std::shared_ptr<AuthMessage> msg);
|
||||
int32_t MessengerFinish(uint64_t scheduleId, ExecutorRole srcType, int32_t resultCode,
|
||||
int32_t MessengerFinish(uint64_t scheduleId, int32_t resultCode,
|
||||
std::shared_ptr<Attributes> finalResult);
|
||||
|
||||
const char *GetDescription();
|
||||
|
@ -32,11 +32,9 @@ public:
|
||||
|
||||
protected:
|
||||
ResultCode SendRequest() override;
|
||||
void OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo) override;
|
||||
void OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo) override;
|
||||
|
||||
private:
|
||||
uint32_t transNum_ = 1;
|
||||
std::shared_ptr<Attributes> attributes_;
|
||||
std::shared_ptr<IamHitraceHelper> iamHitraceHelper_;
|
||||
};
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef COLLECT_COMMAND_H
|
||||
#define COLLECT_COMMAND_H
|
||||
|
||||
#include "iam_hitrace_helper.h"
|
||||
|
||||
#include "async_command_base.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace UserAuth {
|
||||
class CollectCommand : public AsyncCommandBase {
|
||||
public:
|
||||
CollectCommand(std::weak_ptr<Executor> executor, uint64_t scheduleId,
|
||||
const Attributes &commandAttrs,
|
||||
std::shared_ptr<ExecutorMessenger> executorMessenger);
|
||||
~CollectCommand() override = default;
|
||||
|
||||
protected:
|
||||
ResultCode SendRequest() override;
|
||||
void OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Attributes> attributes_;
|
||||
std::shared_ptr<IamHitraceHelper> iamHitraceHelper_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // COLLECT_COMMAND_H
|
@ -33,6 +33,7 @@ protected:
|
||||
ResultCode SendRequest() override;
|
||||
void OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo) override;
|
||||
void OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo) override;
|
||||
void OnMessageInner(int destRole, const std::vector<uint8_t> &msg) override;
|
||||
|
||||
private:
|
||||
void SetResult(ResultCode resultCode);
|
||||
|
@ -31,11 +31,9 @@ public:
|
||||
|
||||
protected:
|
||||
ResultCode SendRequest() override;
|
||||
void OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo) override;
|
||||
void OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo) override;
|
||||
|
||||
private:
|
||||
uint32_t transNum_ = 1;
|
||||
std::shared_ptr<Attributes> attributes_;
|
||||
std::shared_ptr<IamHitraceHelper> iamHitraceHelper_;
|
||||
};
|
||||
|
@ -31,11 +31,9 @@ public:
|
||||
|
||||
protected:
|
||||
ResultCode SendRequest() override;
|
||||
void OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo) override;
|
||||
void OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo) override;
|
||||
|
||||
private:
|
||||
uint32_t transNum_ = 1;
|
||||
std::shared_ptr<Attributes> attributes_;
|
||||
std::shared_ptr<IamHitraceHelper> iamHitraceHelper_;
|
||||
};
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
std::shared_ptr<IAuthExecutorHdi> GetExecutorHdi();
|
||||
const char *GetDescription();
|
||||
int32_t GetAuthType() const;
|
||||
int32_t GetExecutorRole() const;
|
||||
|
||||
private:
|
||||
void RegisterExecutorCallback(ExecutorInfo &executorInfo);
|
||||
@ -57,6 +58,7 @@ private:
|
||||
std::string description_;
|
||||
uint16_t hdiId_;
|
||||
int32_t authType_;
|
||||
int32_t executorRole_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
int32_t OnSetProperty(const Attributes &properties) override;
|
||||
|
||||
int32_t OnGetProperty(const Attributes &conditions, Attributes &results) override;
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override;
|
||||
|
||||
private:
|
||||
static uint32_t GenerateExecutorCallbackId();
|
||||
@ -58,6 +59,7 @@ private:
|
||||
ResultCode ProcessCancelCommand(uint64_t scheduleId);
|
||||
ResultCode ProcessDeleteTemplateCommand(const Attributes &properties);
|
||||
ResultCode ProcessSetCachedTemplates(const Attributes &properties);
|
||||
ResultCode ProcessNotifyExecutorReady(const Attributes &properties);
|
||||
ResultCode ProcessCustomCommand(const Attributes &properties);
|
||||
ResultCode ProcessGetPropertyCommand(std::shared_ptr<Attributes> conditions, std::shared_ptr<Attributes> values);
|
||||
ResultCode FillPropertyToAttribute(const std::vector<Attributes::AttributeKey> &keyList, const Property property,
|
||||
|
@ -98,6 +98,59 @@ void AsyncCommandBase::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t>
|
||||
OnAcquireInfoInner(acquire, extraInfo);
|
||||
}
|
||||
|
||||
void AsyncCommandBase::OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
{
|
||||
IAM_LOGI("%{public}s start", GetDescription());
|
||||
|
||||
Attributes attr;
|
||||
bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAcquireRet);
|
||||
bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet);
|
||||
|
||||
auto data = AuthMessage::As(attr.Serialize());
|
||||
IF_FALSE_LOGE_AND_RETURN(data != nullptr);
|
||||
int32_t ret = MessengerSendData(scheduleId_, SCHEDULER, data);
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s end, acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
|
||||
void AsyncCommandBase::OnMessage(int destRole, const std::vector<uint8_t> &msg)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
if (isFinished_) {
|
||||
IAM_LOGE("command is finished, invocation of OnMessage is invalid");
|
||||
return;
|
||||
}
|
||||
OnMessageInner(destRole, msg);
|
||||
}
|
||||
|
||||
void AsyncCommandBase::OnMessageInner(int destRole, const std::vector<uint8_t> &msg)
|
||||
{
|
||||
IAM_LOGI("%{public}s start", GetDescription());
|
||||
|
||||
std::shared_ptr<Executor> executor = executor_.lock();
|
||||
IF_FALSE_LOGE_AND_RETURN(executor != nullptr);
|
||||
|
||||
Attributes attr;
|
||||
bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_SRC_ROLE, executor->GetExecutorRole());
|
||||
IF_FALSE_LOGE_AND_RETURN(setAcquireRet);
|
||||
bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, msg);
|
||||
IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet);
|
||||
|
||||
auto data = AuthMessage::As(attr.Serialize());
|
||||
IF_FALSE_LOGE_AND_RETURN(data != nullptr);
|
||||
int32_t ret = MessengerSendData(scheduleId_, static_cast<ExecutorRole>(destRole), data);
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s end, msg size %{public}uz", GetDescription(), msg.size());
|
||||
}
|
||||
|
||||
int32_t AsyncCommandBase::GetAuthType()
|
||||
{
|
||||
auto executor = executor_.lock();
|
||||
@ -142,20 +195,20 @@ std::shared_ptr<IAuthExecutorHdi> AsyncCommandBase::GetExecutorHdi()
|
||||
return executor->GetExecutorHdi();
|
||||
}
|
||||
|
||||
int32_t AsyncCommandBase::MessengerSendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcType,
|
||||
int32_t AsyncCommandBase::MessengerSendData(uint64_t scheduleId,
|
||||
ExecutorRole dstType, std::shared_ptr<AuthMessage> msg)
|
||||
{
|
||||
auto messenger = executorMessenger_;
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(messenger != nullptr, USERAUTH_ERROR);
|
||||
return messenger->SendData(scheduleId, transNum, srcType, dstType, msg);
|
||||
return messenger->SendData(scheduleId, dstType, msg);
|
||||
}
|
||||
|
||||
int32_t AsyncCommandBase::MessengerFinish(uint64_t scheduleId, ExecutorRole srcType, int32_t resultCode,
|
||||
int32_t AsyncCommandBase::MessengerFinish(uint64_t scheduleId, int32_t resultCode,
|
||||
std::shared_ptr<Attributes> finalResult)
|
||||
{
|
||||
auto messenger = executorMessenger_;
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(messenger != nullptr, USERAUTH_ERROR);
|
||||
int32_t ret = messenger->Finish(scheduleId, srcType, resultCode, *finalResult);
|
||||
int32_t ret = messenger->Finish(scheduleId, resultCode, *finalResult);
|
||||
executorMessenger_ = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
@ -76,34 +76,13 @@ void AuthCommand::OnResultInner(ResultCode result, const std::vector<uint8_t> &e
|
||||
authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAuthResultRet == true);
|
||||
iamHitraceHelper_ = nullptr;
|
||||
int32_t ret = MessengerFinish(scheduleId_, ALL_IN_ONE, result, authAttributes);
|
||||
int32_t ret = MessengerFinish(scheduleId_, result, authAttributes);
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call finish fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
|
||||
void AuthCommand::OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
{
|
||||
IAM_LOGI("%{public}s on acquire info start", GetDescription());
|
||||
|
||||
Attributes attr;
|
||||
bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAcquireRet);
|
||||
bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet);
|
||||
|
||||
auto msg = AuthMessage::As(attr.Serialize());
|
||||
IF_FALSE_LOGE_AND_RETURN(msg != nullptr);
|
||||
int32_t ret = MessengerSendData(scheduleId_, transNum_, ALL_IN_ONE, SCHEDULER, msg);
|
||||
++transNum_;
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "collect_command.h"
|
||||
|
||||
#include "iam_check.h"
|
||||
#include "iam_common_defines.h"
|
||||
#include "iam_executor_framework_types.h"
|
||||
#include "iam_logger.h"
|
||||
#include "iam_para2str.h"
|
||||
#include "iam_ptr.h"
|
||||
|
||||
#define LOG_TAG "USER_COLLECT_EXECUTOR"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace UserAuth {
|
||||
CollectCommand::CollectCommand(std::weak_ptr<Executor> executor, uint64_t scheduleId,
|
||||
const Attributes &attributes, std::shared_ptr<ExecutorMessenger> executorMessenger)
|
||||
: AsyncCommandBase("COLLECT", scheduleId, executor, executorMessenger),
|
||||
attributes_(Common::MakeShared<Attributes>(attributes.Serialize())),
|
||||
iamHitraceHelper_(Common::MakeShared<IamHitraceHelper>("CollectCommand"))
|
||||
{
|
||||
}
|
||||
|
||||
ResultCode CollectCommand::SendRequest()
|
||||
{
|
||||
IAM_LOGI("%{public}s send request start", GetDescription());
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(attributes_ != nullptr, ResultCode::GENERAL_ERROR);
|
||||
|
||||
auto hdi = GetExecutorHdi();
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, ResultCode::GENERAL_ERROR);
|
||||
|
||||
std::vector<uint8_t> extraInfo;
|
||||
bool getExtraInfoRet = attributes_->GetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(getExtraInfoRet == true, ResultCode::GENERAL_ERROR);
|
||||
|
||||
IamHitraceHelper traceHelper("hdi collect");
|
||||
ResultCode ret = hdi->Collect(scheduleId_, (CollectParam) { extraInfo }, shared_from_this());
|
||||
IAM_LOGI("%{public}s collect result %{public}d", GetDescription(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CollectCommand::OnResultInner(ResultCode result, const std::vector<uint8_t> &extraInfo)
|
||||
{
|
||||
IAM_LOGI("%{public}s on result start", GetDescription());
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
auto authAttributes = Common::MakeShared<Attributes>();
|
||||
IF_FALSE_LOGE_AND_RETURN(authAttributes != nullptr);
|
||||
bool setResultCodeRet = authAttributes->SetUint32Value(Attributes::ATTR_RESULT_CODE, result);
|
||||
IF_FALSE_LOGE_AND_RETURN(setResultCodeRet == true);
|
||||
bool setCollectResultRet =
|
||||
authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setCollectResultRet == true);
|
||||
iamHitraceHelper_ = nullptr;
|
||||
int32_t ret = MessengerFinish(scheduleId_, result, authAttributes);
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call finish fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
@ -78,6 +78,11 @@ void CustomCommand::OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_
|
||||
IAM_LOGE("%{public}s not support", GetDescription());
|
||||
}
|
||||
|
||||
void CustomCommand::OnMessageInner(int destRole, const std::vector<uint8_t> &msg)
|
||||
{
|
||||
IAM_LOGE("%{public}s not support", GetDescription());
|
||||
}
|
||||
|
||||
ResultCode CustomCommand::GetResult()
|
||||
{
|
||||
if (!future_.valid()) {
|
||||
|
@ -77,34 +77,13 @@ void EnrollCommand::OnResultInner(ResultCode result, const std::vector<uint8_t>
|
||||
authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAuthResultRet == true);
|
||||
iamHitraceHelper_ = nullptr;
|
||||
int32_t ret = MessengerFinish(scheduleId_, ALL_IN_ONE, result, authAttributes);
|
||||
int32_t ret = MessengerFinish(scheduleId_, result, authAttributes);
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call finish fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
|
||||
void EnrollCommand::OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
{
|
||||
IAM_LOGI("%{public}s on acquire info start", GetDescription());
|
||||
|
||||
Attributes attr;
|
||||
bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAcquireRet);
|
||||
bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet);
|
||||
|
||||
auto msg = AuthMessage::As(attr.Serialize());
|
||||
IF_FALSE_LOGE_AND_RETURN(msg != nullptr);
|
||||
int32_t ret = MessengerSendData(scheduleId_, transNum_, ALL_IN_ONE, SCHEDULER, msg);
|
||||
++transNum_;
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
|
@ -68,34 +68,13 @@ void IdentifyCommand::OnResultInner(ResultCode result, const std::vector<uint8_t
|
||||
authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAuthResultRet == true);
|
||||
iamHitraceHelper_ = nullptr;
|
||||
int32_t ret = MessengerFinish(scheduleId_, ALL_IN_ONE, result, authAttributes);
|
||||
int32_t ret = MessengerFinish(scheduleId_, result, authAttributes);
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call finish fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
|
||||
void IdentifyCommand::OnAcquireInfoInner(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
{
|
||||
IAM_LOGI("%{public}s on acquire info start", GetDescription());
|
||||
|
||||
Attributes attr;
|
||||
bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire);
|
||||
IF_FALSE_LOGE_AND_RETURN(setAcquireRet);
|
||||
bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet);
|
||||
|
||||
auto msg = AuthMessage::As(attr.Serialize());
|
||||
IF_FALSE_LOGE_AND_RETURN(msg != nullptr);
|
||||
int32_t ret = MessengerSendData(scheduleId_, transNum_, ALL_IN_ONE, SCHEDULER, msg);
|
||||
++transNum_;
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
|
@ -41,6 +41,7 @@ Executor::Executor(std::shared_ptr<ExecutorMgrWrapper> executorMgrWrapper,
|
||||
ExecutorInfo executorInfo = {};
|
||||
IF_FALSE_LOGE_AND_RETURN(hdi->GetExecutorInfo(executorInfo) == ResultCode::SUCCESS);
|
||||
authType_ = executorInfo.authType;
|
||||
executorRole_ = executorInfo.executorRole;
|
||||
std::ostringstream ss;
|
||||
uint32_t combineExecutorId =
|
||||
Common::CombineUint16ToUint32(hdiId_, static_cast<uint16_t>(executorInfo.executorSensorHint));
|
||||
@ -151,6 +152,11 @@ int32_t Executor::GetAuthType() const
|
||||
{
|
||||
return authType_;
|
||||
}
|
||||
|
||||
int32_t Executor::GetExecutorRole() const
|
||||
{
|
||||
return executorRole_;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
|
@ -127,6 +127,8 @@ ResultCode FrameworkExecutorCallback::OnSetPropertyInner(const Attributes &prope
|
||||
ret = ProcessDeleteTemplateCommand(properties);
|
||||
} else if (commandId == PROPERTY_MODE_SET_CACHED_TEMPLATES) {
|
||||
ret = ProcessSetCachedTemplates(properties);
|
||||
} else if (commandId == PROPERTY_MODE_NOTIFY_COLLECTOR_READY) {
|
||||
ret = ProcessNotifyExecutorReady(properties);
|
||||
} else {
|
||||
ret = ProcessCustomCommand(properties);
|
||||
}
|
||||
@ -145,6 +147,25 @@ int32_t FrameworkExecutorCallback::OnGetProperty(const Attributes &conditions, A
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t FrameworkExecutorCallback::OnSendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
int32_t srcRole = 0;
|
||||
bool getDestRoleRet = data.GetInt32Value(Attributes::ATTR_SRC_ROLE, srcRole);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(getDestRoleRet == true, ResultCode::GENERAL_ERROR);
|
||||
std::vector<uint8_t> extraInfo;
|
||||
bool getExtraInfoRet = data.GetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(getExtraInfoRet == true, ResultCode::GENERAL_ERROR);
|
||||
|
||||
auto executor = executor_.lock();
|
||||
if (executor == nullptr) {
|
||||
IAM_LOGE("executor has been released, process failed");
|
||||
return ResultCode::GENERAL_ERROR;
|
||||
}
|
||||
auto hdi = executor->GetExecutorHdi();
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, ResultCode::GENERAL_ERROR);
|
||||
return hdi->SendMessage(scheduleId, srcRole, extraInfo);
|
||||
}
|
||||
|
||||
ResultCode FrameworkExecutorCallback::OnGetPropertyInner(std::shared_ptr<Attributes> conditions,
|
||||
std::shared_ptr<Attributes> values)
|
||||
{
|
||||
@ -246,6 +267,25 @@ ResultCode FrameworkExecutorCallback::ProcessSetCachedTemplates(const Attributes
|
||||
return hdi->SetCachedTemplates(templateIdList);
|
||||
}
|
||||
|
||||
ResultCode FrameworkExecutorCallback::ProcessNotifyExecutorReady(const Attributes &properties)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
auto executor = executor_.lock();
|
||||
if (executor == nullptr) {
|
||||
IAM_LOGE("executor has been released, process failed");
|
||||
return ResultCode::GENERAL_ERROR;
|
||||
}
|
||||
|
||||
auto hdi = executor->GetExecutorHdi();
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, ResultCode::GENERAL_ERROR);
|
||||
|
||||
uint64_t scheduleId;
|
||||
bool getScheduleIdRet = properties.GetUint64Value(Attributes::ATTR_SCHEDULE_ID, scheduleId);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(getScheduleIdRet == true, ResultCode::GENERAL_ERROR);
|
||||
|
||||
return hdi->NotifyCollectorReady(scheduleId);
|
||||
}
|
||||
|
||||
ResultCode FrameworkExecutorCallback::ProcessCustomCommand(const Attributes &properties)
|
||||
{
|
||||
auto command = Common::MakeShared<CustomCommand>(executor_, properties);
|
||||
|
86
frameworks/native/executors/src/iauth_executor_hdi.cpp
Normal file
86
frameworks/native/executors/src/iauth_executor_hdi.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "iam_executor_iauth_executor_hdi.h"
|
||||
|
||||
#include "iam_logger.h"
|
||||
|
||||
#define LOG_TAG "USER_AUTH_EXECUTOR"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace UserAuth {
|
||||
ResultCode IAuthExecutorHdi::Enroll(uint64_t scheduleId, const EnrollParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::Authenticate(uint64_t scheduleId, const AuthenticateParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::Collect(uint64_t scheduleId, const CollectParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::Identify(uint64_t scheduleId, const IdentifyParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::Delete(const std::vector<uint64_t> &templateIdList)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::SendCommand(PropertyMode commandId, const std::vector<uint8_t> &extraInfo,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::GetProperty(const std::vector<uint64_t> &templateIdList,
|
||||
const std::vector<Attributes::AttributeKey> &keys, Property &property)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::SetCachedTemplates(const std::vector<uint64_t> &templateIdList)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ResultCode IAuthExecutorHdi::NotifyCollectorReady(uint64_t scheduleId)
|
||||
{
|
||||
IAM_LOGE("method not implemented");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
@ -15,6 +15,7 @@
|
||||
global:
|
||||
extern "C++" {
|
||||
OHOS::UserIam::UserAuth::IDriverManager::Start*;
|
||||
OHOS::UserIam::UserAuth::IAuthExecutorHdi::*;
|
||||
};
|
||||
local:
|
||||
*;
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
uint32_t executorSensorHint; // for multiple sensors index
|
||||
uint32_t executorMatcher; // for executors matcher
|
||||
ExecutorSecureLevel esl;
|
||||
uint32_t maxTemplateAcl {0};
|
||||
std::vector<uint8_t> publicKey;
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
virtual int32_t OnEndExecute(uint64_t scheduleId, const Attributes &command) = 0;
|
||||
virtual int32_t OnSetProperty(const Attributes &properties) = 0;
|
||||
virtual int32_t OnGetProperty(const Attributes &condition, Attributes &values) = 0;
|
||||
virtual int32_t OnSendData(uint64_t scheduleId, const Attributes &data) = 0;
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIam.AuthResPool.ExecutorCallback");
|
||||
};
|
||||
} // namespace UserAuth
|
||||
|
@ -26,6 +26,7 @@ enum ExecutorCallbackInterfaceCode : uint32_t {
|
||||
ON_END_EXECUTE,
|
||||
ON_SET_PROPERTY,
|
||||
ON_GET_PROPERTY,
|
||||
ON_SEND_DATA,
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -27,9 +27,9 @@ namespace UserIam {
|
||||
namespace UserAuth {
|
||||
class ExecutorMessengerInterface : public IRemoteBroker {
|
||||
public:
|
||||
virtual int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
virtual int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::vector<uint8_t> &msg) = 0;
|
||||
virtual int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
virtual int32_t Finish(uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult) = 0;
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIam.AuthResPool.IExecutor_Messenger");
|
||||
};
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
int32_t OnEndExecute(uint64_t scheduleId, const Attributes &command) override;
|
||||
int32_t OnSetProperty(const Attributes &properties) override;
|
||||
int32_t OnGetProperty(const Attributes &condition, Attributes &values) override;
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<ExecutorCallbackProxy> delegator_;
|
||||
|
@ -34,6 +34,7 @@ private:
|
||||
int32_t OnEndExecuteStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnSetPropertyStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetPropertyStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnSendDataStub(MessageParcel &data, MessageParcel &reply);
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -28,9 +28,9 @@ class ExecutorMessengerProxy : public IRemoteProxy<ExecutorMessengerInterface>,
|
||||
public:
|
||||
explicit ExecutorMessengerProxy(const sptr<IRemoteObject> &impl);
|
||||
~ExecutorMessengerProxy() override = default;
|
||||
int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::vector<uint8_t> &msg) override;
|
||||
int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
int32_t Finish(uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult) override;
|
||||
|
||||
private:
|
||||
|
@ -51,6 +51,10 @@ int32_t CoAuthProxy::WriteExecutorInfo(const ExecutorRegisterInfo &info, Message
|
||||
IAM_LOGE("failed to write esl");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteUint32(info.maxTemplateAcl)) {
|
||||
IAM_LOGE("failed to write esl");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteUInt8Vector(info.publicKey)) {
|
||||
IAM_LOGE("failed to write publicKey");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
|
@ -83,6 +83,7 @@ int32_t CoAuthStub::ReadExecutorRegisterInfo(ExecutorRegisterInfo &executorInfo,
|
||||
uint32_t executorSensorHint;
|
||||
uint32_t executorMatcher;
|
||||
int32_t esl;
|
||||
uint32_t maxTemplateAcl;
|
||||
|
||||
if (!data.ReadInt32(authType)) {
|
||||
IAM_LOGE("failed to read authType");
|
||||
@ -104,6 +105,10 @@ int32_t CoAuthStub::ReadExecutorRegisterInfo(ExecutorRegisterInfo &executorInfo,
|
||||
IAM_LOGE("failed to read esl");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadUint32(maxTemplateAcl)) {
|
||||
IAM_LOGE("failed to read esl");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadUInt8Vector(&executorInfo.publicKey)) {
|
||||
IAM_LOGE("failed to read publicKey");
|
||||
return READ_PARCEL_ERROR;
|
||||
@ -113,6 +118,7 @@ int32_t CoAuthStub::ReadExecutorRegisterInfo(ExecutorRegisterInfo &executorInfo,
|
||||
executorInfo.executorRole = static_cast<ExecutorRole>(executorRole);
|
||||
executorInfo.executorSensorHint = executorSensorHint;
|
||||
executorInfo.executorMatcher = executorMatcher;
|
||||
executorInfo.maxTemplateAcl = maxTemplateAcl;
|
||||
executorInfo.esl = static_cast<ExecutorSecureLevel>(esl);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -190,6 +190,38 @@ int32_t ExecutorCallbackProxy::OnGetProperty(const Attributes &condition, Attrib
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t ExecutorCallbackProxy::OnSendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel reply;
|
||||
|
||||
if (!dataParcel.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) {
|
||||
IAM_LOGE("write descriptor failed");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
if (!dataParcel.WriteUint64(scheduleId)) {
|
||||
IAM_LOGE("write scheduleId failed");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
auto attr = data.Serialize();
|
||||
if (!dataParcel.WriteUInt8Vector(attr)) {
|
||||
IAM_LOGE("write data failed");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
bool ret = SendRequest(ExecutorCallbackInterfaceCode::ON_SEND_DATA, dataParcel, reply);
|
||||
if (!ret) {
|
||||
IAM_LOGE("send request failed");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
int32_t result = GENERAL_ERROR;
|
||||
if (!reply.ReadInt32(result)) {
|
||||
IAM_LOGE("read request result failed");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ExecutorCallbackProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
IAM_LOGI("code = %{public}u", code);
|
||||
|
@ -43,6 +43,8 @@ int32_t ExecutorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data
|
||||
return OnSetPropertyStub(data, reply);
|
||||
case ExecutorCallbackInterfaceCode::ON_GET_PROPERTY:
|
||||
return OnGetPropertyStub(data, reply);
|
||||
case ExecutorCallbackInterfaceCode::ON_SEND_DATA:
|
||||
return OnSendDataStub(data, reply);
|
||||
default:
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
@ -168,6 +170,29 @@ int32_t ExecutorCallbackStub::OnGetPropertyStub(MessageParcel &data, MessageParc
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ExecutorCallbackStub::OnSendDataStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint64_t scheduleId;
|
||||
std::vector<uint8_t> buffer;
|
||||
|
||||
if (!data.ReadUint64(scheduleId)) {
|
||||
IAM_LOGE("failed to read scheduleId");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadUInt8Vector(&buffer)) {
|
||||
IAM_LOGE("failed to read data");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
Attributes dataAttr(buffer);
|
||||
|
||||
int32_t result = OnSendData(scheduleId, dataAttr);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
IAM_LOGE("failed to write OnSendData result");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
@ -27,7 +27,7 @@ ExecutorMessengerProxy::ExecutorMessengerProxy(const sptr<IRemoteObject> &impl)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole,
|
||||
int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId,
|
||||
ExecutorRole dstRole, const std::vector<uint8_t> &msg)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -41,14 +41,6 @@ int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum,
|
||||
IAM_LOGE("failed to write scheduleId");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteUint64(transNum)) {
|
||||
IAM_LOGE("failed to write transNum");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(srcRole)) {
|
||||
IAM_LOGE("failed to write srcRole");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(dstRole)) {
|
||||
IAM_LOGE("failed to write dstRole");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
@ -71,7 +63,7 @@ int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum,
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult)
|
||||
{
|
||||
if (finalResult == nullptr) {
|
||||
@ -89,10 +81,6 @@ int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, ExecutorRole srcRole
|
||||
IAM_LOGE("failed to write scheduleId");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(srcRole)) {
|
||||
IAM_LOGE("failed to write srcRole");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(resultCode)) {
|
||||
IAM_LOGE("failed to write resultCode");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
|
@ -52,8 +52,6 @@ int32_t ExecutorMessengerStub::OnRemoteRequest(uint32_t code, MessageParcel &dat
|
||||
int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint64_t scheduleId;
|
||||
uint64_t transNum;
|
||||
int32_t srcRole;
|
||||
int32_t dstRole;
|
||||
std::vector<uint8_t> msg;
|
||||
|
||||
@ -61,14 +59,6 @@ int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel &
|
||||
IAM_LOGE("read scheduleId failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadUint64(transNum)) {
|
||||
IAM_LOGE("read transNum failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadInt32(srcRole)) {
|
||||
IAM_LOGE("read srcRole failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadInt32(dstRole)) {
|
||||
IAM_LOGE("read dstRole failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
@ -78,8 +68,7 @@ int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel &
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
int32_t result =
|
||||
SendData(scheduleId, transNum, static_cast<ExecutorRole>(srcRole), static_cast<ExecutorRole>(dstRole), msg);
|
||||
int32_t result = SendData(scheduleId, static_cast<ExecutorRole>(dstRole), msg);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
IAM_LOGE("write SendData result failed");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
@ -90,7 +79,6 @@ int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel &
|
||||
int32_t ExecutorMessengerStub::FinishStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint64_t scheduleId;
|
||||
int32_t srcRole;
|
||||
int32_t resultCode;
|
||||
std::vector<uint8_t> attributes;
|
||||
|
||||
@ -98,10 +86,6 @@ int32_t ExecutorMessengerStub::FinishStub(MessageParcel &data, MessageParcel &re
|
||||
IAM_LOGE("read scheduleId failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadInt32(srcRole)) {
|
||||
IAM_LOGE("read srcRole failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadInt32(resultCode)) {
|
||||
IAM_LOGE("read resultCode failed");
|
||||
return READ_PARCEL_ERROR;
|
||||
@ -113,7 +97,7 @@ int32_t ExecutorMessengerStub::FinishStub(MessageParcel &data, MessageParcel &re
|
||||
auto finalResult = Common::MakeShared<Attributes>(attributes);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(finalResult != nullptr, WRITE_PARCEL_ERROR);
|
||||
int32_t result =
|
||||
Finish(scheduleId, static_cast<ExecutorRole>(srcRole), static_cast<ResultCode>(resultCode), finalResult);
|
||||
Finish(scheduleId, static_cast<ResultCode>(resultCode), finalResult);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
IAM_LOGE("write Finish result failed");
|
||||
return WRITE_PARCEL_ERROR;
|
||||
|
@ -53,8 +53,10 @@ public:
|
||||
ATTR_ERROR_COUNT = 100008,
|
||||
/** Remain time, the value type is int32_t. */
|
||||
ATTR_REMAIN_TIMES = 100009,
|
||||
ATTR_REMAIN_ATTEMPTS = ATTR_REMAIN_TIMES,
|
||||
/** Freezing time, the value type is int32_t. */
|
||||
ATTR_FREEZING_TIME = 100010,
|
||||
ATTR_LOCKOUT_DURATION = ATTR_FREEZING_TIME,
|
||||
/** Session ID, the value type is uint64_t. */
|
||||
ATTR_SESSION_ID = 100014,
|
||||
/** Schedule version, the value type is uint32_t. */
|
||||
@ -101,6 +103,8 @@ public:
|
||||
ATTR_OLD_ROOT_SECRET = 100040,
|
||||
/** Old credential ID, the value type is uint64_t. */
|
||||
ATTR_OLD_CREDENTIAL_ID = 100041,
|
||||
/** Source role, the value type is int32_t. */
|
||||
ATTR_SRC_ROLE = 100042,
|
||||
/**
|
||||
* Private attrs.
|
||||
* User ID, the value type is int32_t.
|
||||
|
@ -78,6 +78,15 @@ public:
|
||||
* @return Return get property success or not(0:success; other:failed).
|
||||
*/
|
||||
virtual int32_t OnGetProperty(const Attributes &conditions, Attributes &results) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called by coAuth resource pool to send data.
|
||||
*
|
||||
* @param scheduleId Specify the current schedule.
|
||||
* @param results The result of get property.
|
||||
* @return data Data.
|
||||
*/
|
||||
virtual int32_t OnSendData(uint64_t scheduleId, const Attributes &data) = 0;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -46,6 +46,8 @@ struct ExecutorInfo {
|
||||
uint32_t executorMatcher {0};
|
||||
/** Executor secure level. */
|
||||
ExecutorSecureLevel esl {0};
|
||||
/** Max template acl. */
|
||||
uint32_t maxTemplateAcl {0};
|
||||
/** Used to verify the result issued by the authenticator. */
|
||||
std::vector<uint8_t> publicKey {};
|
||||
};
|
||||
@ -67,26 +69,21 @@ public:
|
||||
* @brief Called by the executor, send authentication data to resource pool.
|
||||
*
|
||||
* @param scheduleId Specify the current schedule.
|
||||
* @param transNum Properties of this operation.
|
||||
* @param srcRole Source executor role.
|
||||
* @param dstRole Destination executor role.
|
||||
* @param msg Authentication message.
|
||||
* @return Return send data success or not(0:success; other:failed).
|
||||
*/
|
||||
virtual int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) = 0;
|
||||
virtual int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called by the executor, send finish data to resource pool.
|
||||
*
|
||||
* @param scheduleId Specify the current schedule.
|
||||
* @param srcRole Source executor role.
|
||||
* @param resultcode Authentication result code.
|
||||
* @param resultCode Authentication result code.
|
||||
* @param finalResult Authentication final result.
|
||||
* @return Return finish success or not(0:success; other:failed).
|
||||
*/
|
||||
virtual int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode,
|
||||
const Attributes &finalResult) = 0;
|
||||
virtual int32_t Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) = 0;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -133,6 +133,8 @@ enum PropertyMode : uint32_t {
|
||||
PROPERTY_MODE_UNFREEZE = 6,
|
||||
/** The property mode is set cached templates. */
|
||||
PROPERTY_MODE_SET_CACHED_TEMPLATES = 7,
|
||||
/** The property mode is notify collector ready. */
|
||||
PROPERTY_MODE_NOTIFY_COLLECTOR_READY = 8,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -41,20 +41,6 @@ enum UserAuthResult : int32_t {
|
||||
USERAUTH_ERROR = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines Template infomation.
|
||||
*/
|
||||
struct TemplateInfo {
|
||||
/** Executor type. */
|
||||
uint32_t executorType;
|
||||
/** Freezing time. */
|
||||
int32_t freezingTime;
|
||||
/** Remain time. */
|
||||
int32_t remainTimes;
|
||||
/** Extra Info. */
|
||||
std::vector<uint8_t> extraInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines Enroll parameter.
|
||||
*/
|
||||
@ -79,6 +65,14 @@ struct AuthenticateParam {
|
||||
bool endAfterFirstFail;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines Collect parameter.
|
||||
*/
|
||||
struct CollectParam {
|
||||
/** Extra info. */
|
||||
std::vector<uint8_t> extraInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines Identify parameter.
|
||||
*/
|
||||
|
@ -66,6 +66,24 @@ public:
|
||||
virtual ResultCode OnRegisterFinish(const std::vector<uint64_t> &templateIdList,
|
||||
const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief Cancel the action of executor.
|
||||
*
|
||||
* @param scheduleId Current working schedule ID.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Cancel(uint64_t scheduleId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Cancel the action of executor.
|
||||
*
|
||||
* @param scheduleId Current working schedule ID.
|
||||
* @param srcRole Source role.
|
||||
* @param msg Message.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector<uint8_t> &msg) = 0;
|
||||
|
||||
/**
|
||||
* @brief Begin enroll.
|
||||
*
|
||||
@ -75,7 +93,7 @@ public:
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Enroll(uint64_t scheduleId, const EnrollParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) = 0;
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj);
|
||||
|
||||
/**
|
||||
* @brief Begin authenticate.
|
||||
@ -86,7 +104,18 @@ public:
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Authenticate(uint64_t scheduleId, const AuthenticateParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) = 0;
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj);
|
||||
|
||||
/**
|
||||
* @brief Begin collect.
|
||||
*
|
||||
* @param scheduleId Current collect schedule ID.
|
||||
* @param param Collect param.
|
||||
* @param callbackObj Callback of authenticate result.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Collect(uint64_t scheduleId, const CollectParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj);
|
||||
|
||||
/**
|
||||
* @brief Begin identify.
|
||||
@ -97,7 +126,7 @@ public:
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Identify(uint64_t scheduleId, const IdentifyParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) = 0;
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj);
|
||||
|
||||
/**
|
||||
* @brief Delete.
|
||||
@ -105,15 +134,7 @@ public:
|
||||
* @param templateIdList Template ID list.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Delete(const std::vector<uint64_t> &templateIdList) = 0;
|
||||
|
||||
/**
|
||||
* @brief Cancel the action of executor.
|
||||
*
|
||||
* @param scheduleId Current working schedule ID.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode Cancel(uint64_t scheduleId) = 0;
|
||||
virtual ResultCode Delete(const std::vector<uint64_t> &templateIdList);
|
||||
|
||||
/**
|
||||
* @brief Send command.
|
||||
@ -124,7 +145,7 @@ public:
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode SendCommand(PropertyMode commandId, const std::vector<uint8_t> &extraInfo,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) = 0;
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj);
|
||||
|
||||
/**
|
||||
* @brief Get property.
|
||||
@ -135,7 +156,7 @@ public:
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode GetProperty(const std::vector<uint64_t> &templateIdList,
|
||||
const std::vector<Attributes::AttributeKey> &keys, Property &property) = 0;
|
||||
const std::vector<Attributes::AttributeKey> &keys, Property &property);
|
||||
|
||||
/**
|
||||
* @brief Set cached templates.
|
||||
@ -143,7 +164,15 @@ public:
|
||||
* @param templateIdList Template id list.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode SetCachedTemplates(const std::vector<uint64_t> &templateIdList) = 0;
|
||||
virtual ResultCode SetCachedTemplates(const std::vector<uint64_t> &templateIdList);
|
||||
|
||||
/**
|
||||
* @brief Notify collector ready.
|
||||
*
|
||||
* @param scheduleId Current collect schedule ID.
|
||||
* @return Return the result success or error code{@link ResultCode}.
|
||||
*/
|
||||
virtual ResultCode NotifyCollectorReady(uint64_t scheduleId);
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -68,6 +68,14 @@ public:
|
||||
* @param extraInfo Other related information about execute.
|
||||
*/
|
||||
virtual void OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &extraInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief The callback send message information.
|
||||
*
|
||||
* @param destRole Destination role.
|
||||
* @param msg Message.
|
||||
*/
|
||||
virtual void OnMessage(int destRole, const std::vector<uint8_t> &msg) = 0;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define USER_AUTH_HDI
|
||||
|
||||
#include "v2_0/iuser_auth_interface.h"
|
||||
#include "v2_0/message_callback_stub.h"
|
||||
#include "v2_0/user_auth_types.h"
|
||||
#include "v2_0/user_auth_interface_service.h"
|
||||
|
||||
|
@ -54,6 +54,7 @@ ohos_source_set("userauth_service_core") {
|
||||
"src/credential_info_impl.cpp",
|
||||
"src/enrolled_info_impl.cpp",
|
||||
"src/enrollment_impl.cpp",
|
||||
"src/hdi_message_callback_service.cpp",
|
||||
"src/identification_impl.cpp",
|
||||
"src/resource_node_impl.cpp",
|
||||
"src/resource_node_pool_impl.cpp",
|
||||
@ -81,6 +82,7 @@ ohos_source_set("userauth_service_core") {
|
||||
"ability_runtime:app_manager",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
|
36
services/core/inc/hdi_message_callback_service.h
Normal file
36
services/core/inc/hdi_message_callback_service.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HDI_MESSAGE_CALLBACK_IMPL_H
|
||||
#define HDI_MESSAGE_CALLBACK_IMPL_H
|
||||
|
||||
#include "user_auth_hdi.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace UserAuth {
|
||||
class HdiMessageCallbackService : public HdiIMessageCallback {
|
||||
public:
|
||||
static sptr<HdiMessageCallbackService> GetInstance();
|
||||
void OnHdiConnect();
|
||||
|
||||
int32_t OnMessage(uint64_t scheduleId, int32_t destRole, const std::vector<uint8_t>& msg) override;
|
||||
private:
|
||||
~HdiMessageCallbackService() override = default;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
#endif // HDI_MESSAGE_CALLBACK_IMPL_H
|
@ -45,6 +45,7 @@ public:
|
||||
virtual int32_t EndExecute(uint64_t scheduleId, const Attributes &command) = 0;
|
||||
virtual int32_t SetProperty(const Attributes &properties) = 0;
|
||||
virtual int32_t GetProperty(const Attributes &condition, Attributes &values) = 0;
|
||||
virtual int32_t SendData(uint64_t scheduleId, const Attributes &data) = 0;
|
||||
virtual void Detach() = 0;
|
||||
|
||||
static std::shared_ptr<ResourceNode> MakeNewResource(const ExecutorRegisterInfo &info,
|
||||
|
@ -70,8 +70,7 @@ public:
|
||||
virtual void ClearScheduleCallback() = 0;
|
||||
virtual bool StartSchedule() = 0;
|
||||
virtual bool StopSchedule() = 0;
|
||||
virtual bool ContinueSchedule(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum,
|
||||
const std::vector<uint8_t> &msg) = 0;
|
||||
virtual bool SendMessage(ExecutorRole dstRole, const std::vector<uint8_t> &msg) = 0;
|
||||
virtual bool ContinueSchedule(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult) = 0;
|
||||
};
|
||||
|
||||
|
66
services/core/src/hdi_message_callback_service.cpp
Normal file
66
services/core/src/hdi_message_callback_service.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hdi_message_callback_service.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "context_pool.h"
|
||||
#include "attributes.h"
|
||||
#include "iam_logger.h"
|
||||
#include "iam_check.h"
|
||||
#include "hdi_wrapper.h"
|
||||
|
||||
#define LOG_TAG "USER_AUTH_SA"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace UserAuth {
|
||||
sptr<HdiMessageCallbackService> HdiMessageCallbackService::GetInstance()
|
||||
{
|
||||
static sptr<HdiMessageCallbackService> instance = new HdiMessageCallbackService();
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(instance != nullptr, nullptr);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void HdiMessageCallbackService::OnHdiConnect()
|
||||
{
|
||||
auto hdi = HdiWrapper::GetHdiInstance();
|
||||
IF_FALSE_LOGE_AND_RETURN(hdi != nullptr);
|
||||
|
||||
int32_t ret = hdi->RegisterMessageCallback(GetInstance());
|
||||
IF_FALSE_LOGE_AND_RETURN(ret == HDF_SUCCESS);
|
||||
IAM_LOGI("success");
|
||||
}
|
||||
|
||||
int32_t HdiMessageCallbackService::OnMessage(uint64_t scheduleId, int32_t destRole, const std::vector<uint8_t>& msg)
|
||||
{
|
||||
std::shared_ptr<ScheduleNode> scheduleNode = ContextPool::Instance().SelectScheduleNodeByScheduleId(scheduleId);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(scheduleNode != nullptr, HDF_FAILURE);
|
||||
|
||||
Attributes attr;
|
||||
bool roleRet = attr.SetInt32Value(Attributes::ATTR_SRC_ROLE, SCHEDULER);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(roleRet, HDF_FAILURE);
|
||||
bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, msg);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(setExtraInfoRet, HDF_FAILURE);
|
||||
|
||||
bool ret = scheduleNode->SendMessage(static_cast<ExecutorRole>(destRole), attr.Serialize());
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, HDF_FAILURE);
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
@ -49,6 +49,7 @@ public:
|
||||
int32_t EndExecute(uint64_t scheduleId, const Attributes &command) override;
|
||||
int32_t SetProperty(const Attributes &properties) override;
|
||||
int32_t GetProperty(const Attributes &condition, Attributes &values) override;
|
||||
int32_t SendData(uint64_t scheduleId, const Attributes &data) override;
|
||||
void Detach() override;
|
||||
friend ResourceNode;
|
||||
|
||||
@ -168,6 +169,16 @@ int32_t ResourceNodeImpl::GetProperty(const Attributes &condition, Attributes &v
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
int32_t ResourceNodeImpl::SendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
|
||||
if (callback_ != nullptr) {
|
||||
return callback_->OnSendData(scheduleId, data);
|
||||
}
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
|
||||
void ResourceNodeImpl::Detach()
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "nocopyable.h"
|
||||
|
||||
#include "hdi_wrapper.h"
|
||||
#include "iam_check.h"
|
||||
#include "iam_logger.h"
|
||||
#include "iam_ptr.h"
|
||||
#include "iam_para2str.h"
|
||||
@ -152,19 +154,40 @@ bool ScheduleNodeImpl::StopSchedule()
|
||||
return TryKickMachine(E_STOP_AUTH);
|
||||
}
|
||||
|
||||
bool ScheduleNodeImpl::ContinueSchedule(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum,
|
||||
const std::vector<uint8_t> &msg)
|
||||
bool ScheduleNodeImpl::SendMessage(ExecutorRole dstRole, const std::vector<uint8_t> &msg)
|
||||
{
|
||||
if (dstRole != SCHEDULER) {
|
||||
IAM_LOGE("not supported yet");
|
||||
return false;
|
||||
Attributes attr(msg);
|
||||
if (dstRole == SCHEDULER) {
|
||||
int32_t tip;
|
||||
if (attr.GetInt32Value(Attributes::ATTR_TIP_INFO, tip)) {
|
||||
std::shared_ptr<ScheduleNodeCallback> callback = GetScheduleCallback();
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(callback != nullptr, false);
|
||||
callback->OnScheduleProcessed(dstRole, GetAuthType(), msg);
|
||||
return true;
|
||||
} else {
|
||||
int srcRole;
|
||||
std::vector<uint8_t> msg;
|
||||
bool getAcquireRet = attr.GetInt32Value(Attributes::ATTR_SRC_ROLE, srcRole);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(getAcquireRet, false);
|
||||
bool getExtraInfoRet = attr.GetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, msg);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(getExtraInfoRet, false);
|
||||
auto hdi = HdiWrapper::GetHdiInstance();
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, false);
|
||||
int sendMsgRet = hdi->SendMessage(GetScheduleId(), srcRole, msg);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(sendMsgRet == HDF_SUCCESS, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<ScheduleNodeCallback> callback = GetScheduleCallback();
|
||||
if (callback) {
|
||||
callback->OnScheduleProcessed(srcRole, GetAuthType(), msg);
|
||||
std::shared_ptr<ResourceNode> node = nullptr;
|
||||
if (dstRole == ALL_IN_ONE || dstRole == VERIFIER) {
|
||||
node = info_.verifier.lock();
|
||||
} else if (dstRole == COLLECTOR) {
|
||||
node = info_.collector.lock();
|
||||
}
|
||||
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(node != nullptr, false);
|
||||
node->SendData(GetScheduleId(), attr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,7 @@ public:
|
||||
void ClearScheduleCallback() override;
|
||||
bool StartSchedule() override;
|
||||
bool StopSchedule() override;
|
||||
bool ContinueSchedule(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum,
|
||||
const std::vector<uint8_t> &msg) override;
|
||||
bool SendMessage(ExecutorRole dstRole, const std::vector<uint8_t> &msg) override;
|
||||
bool ContinueSchedule(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult) override;
|
||||
|
||||
private:
|
||||
|
@ -25,13 +25,13 @@ namespace UserAuth {
|
||||
class ExecutorMessengerService : public ExecutorMessengerStub {
|
||||
public:
|
||||
static sptr<ExecutorMessengerService> GetInstance();
|
||||
int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::vector<uint8_t> &msg) override;
|
||||
int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
int32_t Finish(uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult) override;
|
||||
|
||||
private:
|
||||
ExecutorMessengerService();
|
||||
explicit ExecutorMessengerService();
|
||||
~ExecutorMessengerService() override = default;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
|
@ -22,12 +22,14 @@
|
||||
#include "string_ex.h"
|
||||
|
||||
#include "executor_messenger_service.h"
|
||||
#include "hdi_message_callback_service.h"
|
||||
#include "hdi_wrapper.h"
|
||||
#include "hisysevent_adapter.h"
|
||||
#include "iam_logger.h"
|
||||
#include "iam_ptr.h"
|
||||
#include "iam_para2str.h"
|
||||
#include "ipc_common.h"
|
||||
#include "iam_check.h"
|
||||
#include "iam_time.h"
|
||||
#include "iam_common_defines.h"
|
||||
#include "ipc_skeleton.h"
|
||||
@ -125,6 +127,9 @@ void CoAuthService::Init()
|
||||
IAM_LOGI("delete all executors for hdi dead");
|
||||
UserIam::UserAuth::ReportSystemFault(Common::GetNowTimeString(), "user_auth_hdi host");
|
||||
}));
|
||||
auto callbackService = HdiMessageCallbackService::GetInstance();
|
||||
IF_FALSE_LOGE_AND_RETURN(callbackService != nullptr);
|
||||
callbackService->OnHdiConnect();
|
||||
IAM_LOGI("set fwk ready parameter");
|
||||
SetParameter("bootevent.useriam.fwkready", "false");
|
||||
SetParameter("bootevent.useriam.fwkready", "true");
|
||||
|
@ -39,15 +39,14 @@ sptr<ExecutorMessengerService> ExecutorMessengerService::GetInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
int32_t ExecutorMessengerService::SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole,
|
||||
ExecutorRole dstRole, const std::vector<uint8_t> &msg)
|
||||
int32_t ExecutorMessengerService::SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector<uint8_t> &msg)
|
||||
{
|
||||
auto scheduleNode = ContextPool::Instance().SelectScheduleNodeByScheduleId(scheduleId);
|
||||
if (scheduleNode == nullptr) {
|
||||
IAM_LOGE("selected schedule node is nullptr");
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
bool result = scheduleNode->ContinueSchedule(srcRole, dstRole, transNum, msg);
|
||||
bool result = scheduleNode->SendMessage(dstRole, msg);
|
||||
if (!result) {
|
||||
IAM_LOGE("continue schedule failed");
|
||||
return GENERAL_ERROR;
|
||||
@ -55,7 +54,7 @@ int32_t ExecutorMessengerService::SendData(uint64_t scheduleId, uint64_t transNu
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ExecutorMessengerService::Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
int32_t ExecutorMessengerService::Finish(uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult)
|
||||
{
|
||||
auto scheduleNode = ContextPool::Instance().SelectScheduleNodeByScheduleId(scheduleId);
|
||||
|
@ -73,28 +73,32 @@ public:
|
||||
static_cast<void>(results);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(data);
|
||||
return SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
class DummyExecutorMessengerInterface final : public ExecutorMessengerInterface {
|
||||
public:
|
||||
int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::vector<uint8_t> &msg) override
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(transNum);
|
||||
static_cast<void>(srcRole);
|
||||
static_cast<void>(dstRole);
|
||||
static_cast<void>(msg);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult) override
|
||||
int32_t Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult) override
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(srcRole);
|
||||
static_cast<void>(resultCode);
|
||||
static_cast<void>(finalResult);
|
||||
return SUCCESS;
|
||||
@ -213,14 +217,12 @@ void FuzzExecutorMessengerClientSendData(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
uint64_t scheduleId = parcel.ReadUint64();
|
||||
uint64_t transNum = parcel.ReadUint64();
|
||||
auto srcRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
auto dstRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
std::vector<uint8_t> testMessage;
|
||||
Common::FillFuzzUint8Vector(parcel, testMessage);
|
||||
auto msg = AuthMessage::As(testMessage);
|
||||
if (g_ExecutorMessengerClient != nullptr) {
|
||||
g_ExecutorMessengerClient->SendData(scheduleId, transNum, srcRole, dstRole, msg);
|
||||
g_ExecutorMessengerClient->SendData(scheduleId, dstRole, msg);
|
||||
}
|
||||
IAM_LOGI("end");
|
||||
}
|
||||
@ -229,13 +231,12 @@ void FuzzExecutorMessengerClientFinish(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
uint64_t scheduleId = parcel.ReadUint64();
|
||||
auto srcRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
int32_t resultCode = parcel.ReadInt32();
|
||||
std::vector<uint8_t> attr;
|
||||
Common::FillFuzzUint8Vector(parcel, attr);
|
||||
Attributes finalResult(attr);
|
||||
if (g_ExecutorMessengerClient != nullptr) {
|
||||
g_ExecutorMessengerClient->Finish(scheduleId, srcRole, resultCode, finalResult);
|
||||
g_ExecutorMessengerClient->Finish(scheduleId, resultCode, finalResult);
|
||||
}
|
||||
IAM_LOGI("end");
|
||||
}
|
||||
|
@ -77,6 +77,14 @@ public:
|
||||
static_cast<void>(results);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(data);
|
||||
return SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
auto g_ExecutorCallbackService =
|
||||
|
@ -156,6 +156,7 @@ ohos_source_set("userauth_service_core_fuzzer") {
|
||||
"../../../services/core/src/credential_info_impl.cpp",
|
||||
"../../../services/core/src/enrolled_info_impl.cpp",
|
||||
"../../../services/core/src/enrollment_impl.cpp",
|
||||
"../../../services/core/src/hdi_message_callback_service.cpp",
|
||||
"../../../services/core/src/identification_impl.cpp",
|
||||
"../../../services/core/src/resource_node_impl.cpp",
|
||||
"../../../services/core/src/resource_node_pool_impl.cpp",
|
||||
|
@ -44,6 +44,7 @@ ohos_fuzztest("UserAuthDriverManagerFuzzTest") {
|
||||
"../../../../frameworks/native/executors/src/executor.cpp",
|
||||
"../../../../frameworks/native/executors/src/framework/executor_mgr_wrapper.cpp",
|
||||
"../../../../frameworks/native/executors/src/framework/framework_executor_callback.cpp",
|
||||
"../../../../frameworks/native/executors/src/iauth_executor_hdi.cpp",
|
||||
"../../../../frameworks/native/executors/src/idriver_manager.cpp",
|
||||
"../../../../frameworks/native/executors/src/listener/auth_executor_mgr_status_listener.cpp",
|
||||
"../../../../frameworks/native/executors/src/listener/driver_manager_status_listener.cpp",
|
||||
|
@ -41,6 +41,15 @@ public:
|
||||
DummyAuthExecutorHdi() = default;
|
||||
~DummyAuthExecutorHdi() override = default;
|
||||
|
||||
ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector<uint8_t> &msg) override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (fuzzParcel_ == nullptr) {
|
||||
return ResultCode::GENERAL_ERROR;
|
||||
}
|
||||
return static_cast<ResultCode>(fuzzParcel_->ReadInt32());
|
||||
}
|
||||
|
||||
ResultCode GetExecutorInfo(ExecutorInfo &executorInfo) override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
@ -44,6 +44,7 @@ ohos_fuzztest("UserAuthExecutorFuzzTest") {
|
||||
"../../../../frameworks/native/executors/src/executor.cpp",
|
||||
"../../../../frameworks/native/executors/src/framework/executor_mgr_wrapper.cpp",
|
||||
"../../../../frameworks/native/executors/src/framework/framework_executor_callback.cpp",
|
||||
"../../../../frameworks/native/executors/src/iauth_executor_hdi.cpp",
|
||||
"../../../../frameworks/native/executors/src/idriver_manager.cpp",
|
||||
"../../../../frameworks/native/executors/src/listener/auth_executor_mgr_status_listener.cpp",
|
||||
"../../../../frameworks/native/executors/src/listener/driver_manager_status_listener.cpp",
|
||||
|
@ -46,6 +46,15 @@ public:
|
||||
DummyAuthExecutorHdi() = default;
|
||||
~DummyAuthExecutorHdi() override = default;
|
||||
|
||||
ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector<uint8_t> &msg) override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (fuzzParcel_ == nullptr) {
|
||||
return ResultCode::GENERAL_ERROR;
|
||||
}
|
||||
return static_cast<ResultCode>(fuzzParcel_->ReadInt32());
|
||||
}
|
||||
|
||||
ResultCode GetExecutorInfo(ExecutorInfo &executorInfo) override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
@ -205,22 +214,17 @@ public:
|
||||
class DummyExecutorMessenger : public ExecutorMessenger {
|
||||
public:
|
||||
virtual ~DummyExecutorMessenger() = default;
|
||||
int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) override
|
||||
int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) override
|
||||
{
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(transNum);
|
||||
static_cast<void>(srcRole);
|
||||
static_cast<void>(dstRole);
|
||||
static_cast<void>(msg);
|
||||
return fuzzParcel_->ReadInt32();
|
||||
}
|
||||
|
||||
int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode,
|
||||
const Attributes &finalResult) override
|
||||
int32_t Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) override
|
||||
{
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(srcRole);
|
||||
static_cast<void>(resultCode);
|
||||
static_cast<void>(finalResult);
|
||||
return fuzzParcel_->ReadInt32();
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("CoAuthServiceFuzzTest") {
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -45,11 +45,12 @@ std::u16string cmd[] = {u"-h", u"-lc", u"-ls", u"-c", u"-c [base system]", u"-s"
|
||||
class CoAuthServiceFuzzer : public ExecutorCallbackInterface {
|
||||
public:
|
||||
CoAuthServiceFuzzer(int32_t onBeginExecuteResult, int32_t onEndExecuteResult, int32_t onSetPropertyResult,
|
||||
int32_t onGetPropertyResult)
|
||||
int32_t onGetPropertyResult, int32_t onSendDataResult)
|
||||
: onBeginExecuteResult_(onBeginExecuteResult),
|
||||
onEndExecuteResult_(onEndExecuteResult),
|
||||
onSetPropertyResult_(onSetPropertyResult),
|
||||
onGetPropertyResult_(onGetPropertyResult)
|
||||
onGetPropertyResult_(onGetPropertyResult),
|
||||
onSendDataResult_(onSendDataResult)
|
||||
{
|
||||
}
|
||||
|
||||
@ -87,6 +88,12 @@ public:
|
||||
return onGetPropertyResult_;
|
||||
}
|
||||
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
return onSendDataResult_;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> AsObject() override
|
||||
{
|
||||
sptr<IRemoteObject> tmp(nullptr);
|
||||
@ -98,6 +105,7 @@ private:
|
||||
int32_t onEndExecuteResult_;
|
||||
int32_t onSetPropertyResult_;
|
||||
int32_t onGetPropertyResult_;
|
||||
int32_t onSendDataResult_;
|
||||
};
|
||||
|
||||
void FillFuzzExecutorRegisterInfo(Parcel &parcel, ExecutorRegisterInfo &executorInfo)
|
||||
@ -122,7 +130,8 @@ void FuzzRegister(Parcel &parcel)
|
||||
sptr<ExecutorCallbackInterface> callback(nullptr);
|
||||
if (parcel.ReadBool()) {
|
||||
callback = sptr<ExecutorCallbackInterface>(new (std::nothrow)
|
||||
CoAuthServiceFuzzer(parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32()));
|
||||
CoAuthServiceFuzzer(parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32(),
|
||||
parcel.ReadInt32()));
|
||||
}
|
||||
g_coAuthService.ExecutorRegister(executorInfo, callback);
|
||||
IAM_LOGI("FuzzRegister end");
|
||||
@ -132,14 +141,12 @@ void FuzzSendData(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("FuzzSendData begin");
|
||||
uint64_t scheduleId = parcel.ReadUint64();
|
||||
uint64_t transNum = parcel.ReadUint64();
|
||||
ExecutorRole srcRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
ExecutorRole dstRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
std::vector<uint8_t> msg;
|
||||
Common::FillFuzzUint8Vector(parcel, msg);
|
||||
|
||||
if (executorMessengerService != nullptr) {
|
||||
executorMessengerService->SendData(scheduleId, transNum, srcRole, dstRole, msg);
|
||||
executorMessengerService->SendData(scheduleId, dstRole, msg);
|
||||
}
|
||||
IAM_LOGI("FuzzSendData end");
|
||||
}
|
||||
@ -148,12 +155,11 @@ void FuzzFinish(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("FuzzFinish begin");
|
||||
uint64_t scheduleId = parcel.ReadUint64();
|
||||
ExecutorRole srcRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
ResultCode resultCode = static_cast<ResultCode>(parcel.ReadInt32());
|
||||
auto finalResult = Common::MakeShared<Attributes>();
|
||||
|
||||
if (executorMessengerService != nullptr) {
|
||||
executorMessengerService->Finish(scheduleId, srcRole, resultCode, finalResult);
|
||||
executorMessengerService->Finish(scheduleId, resultCode, finalResult);
|
||||
}
|
||||
IAM_LOGI("FuzzFinish end");
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ ohos_fuzztest("CoAuthStubFuzzTest") {
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -52,7 +52,10 @@ ohos_fuzztest("ServiceCoreFuzzTest") {
|
||||
|
||||
remove_configs = [ "//build/config/compiler:no_exceptions" ]
|
||||
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
external_deps = [
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
subsystem_name = "useriam"
|
||||
part_name = "user_auth_framework"
|
||||
|
@ -116,6 +116,14 @@ public:
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SendData(uint64_t scheduleId, const Attributes &data)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(data);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void Detach()
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
|
@ -70,6 +70,14 @@ public:
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
static_cast<void>(scheduleId);
|
||||
static_cast<void>(data);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> AsObject() override
|
||||
{
|
||||
sptr<IRemoteObject> tmp(nullptr);
|
||||
|
@ -163,22 +163,20 @@ void FuzzScheduleNodeStopSchedule(Parcel &parcel)
|
||||
IAM_LOGI("end");
|
||||
}
|
||||
|
||||
void FuzzScheduleNodeContinueSchedule001(Parcel &parcel)
|
||||
void FuzzScheduleNodeSendMessage(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
auto srcRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
auto dstRole = static_cast<ExecutorRole>(parcel.ReadInt32());
|
||||
uint64_t transNum = parcel.ReadUint64();
|
||||
std::vector<uint8_t> msg;
|
||||
Common::FillFuzzUint8Vector(parcel, msg);
|
||||
auto node = GetScheduleNode(parcel);
|
||||
if (node != nullptr) {
|
||||
node->ContinueSchedule(srcRole, dstRole, transNum, msg);
|
||||
node->SendMessage(dstRole, msg);
|
||||
}
|
||||
IAM_LOGI("end");
|
||||
}
|
||||
|
||||
void FuzzScheduleNodeContinueSchedule002(Parcel &parcel)
|
||||
void FuzzScheduleNodeContinueSchedule(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
auto resultCode = static_cast<ResultCode>(parcel.ReadInt32());
|
||||
@ -205,8 +203,8 @@ ScheduleNodeFuzzFunc *g_ScheduleNodeFuzzFuncs[] = {
|
||||
FuzzScheduleNodeGetCurrentScheduleState,
|
||||
FuzzScheduleNodeStartSchedule,
|
||||
FuzzScheduleNodeStopSchedule,
|
||||
FuzzScheduleNodeContinueSchedule001,
|
||||
FuzzScheduleNodeContinueSchedule002,
|
||||
FuzzScheduleNodeSendMessage,
|
||||
FuzzScheduleNodeContinueSchedule,
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
@ -48,6 +48,7 @@ ohos_fuzztest("UserAuthServiceFuzzTest") {
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -48,6 +48,7 @@ ohos_fuzztest("UserAuthStubFuzzTest") {
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -48,6 +48,7 @@ ohos_fuzztest("UserIdmServiceFuzzTest") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -48,6 +48,7 @@ ohos_fuzztest("UserIdmStubFuzzTest") {
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -38,6 +38,7 @@ ohos_unittest("iam_executors_test") {
|
||||
sources = [
|
||||
"../../../frameworks/native/executors/src/async_command/async_command_base.cpp",
|
||||
"../../../frameworks/native/executors/src/async_command/auth_command.cpp",
|
||||
"../../../frameworks/native/executors/src/async_command/collect_command.cpp",
|
||||
"../../../frameworks/native/executors/src/async_command/custom_command.cpp",
|
||||
"../../../frameworks/native/executors/src/async_command/enroll_command.cpp",
|
||||
"../../../frameworks/native/executors/src/async_command/identify_command.cpp",
|
||||
@ -46,6 +47,7 @@ ohos_unittest("iam_executors_test") {
|
||||
"../../../frameworks/native/executors/src/executor.cpp",
|
||||
"../../../frameworks/native/executors/src/framework/executor_mgr_wrapper.cpp",
|
||||
"../../../frameworks/native/executors/src/framework/framework_executor_callback.cpp",
|
||||
"../../../frameworks/native/executors/src/iauth_executor_hdi.cpp",
|
||||
"../../../frameworks/native/executors/src/idriver_manager.cpp",
|
||||
"../../../frameworks/native/executors/src/listener/auth_executor_mgr_status_listener.cpp",
|
||||
"../../../frameworks/native/executors/src/listener/driver_manager_status_listener.cpp",
|
||||
|
@ -68,11 +68,10 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_001, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
uint32_t attrResultCode;
|
||||
EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true);
|
||||
@ -98,9 +97,9 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_002, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
return USERAUTH_ERROR;
|
||||
});
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
@ -119,11 +118,10 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_003, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
uint32_t attrResultCode;
|
||||
EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true);
|
||||
@ -149,7 +147,7 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_004, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1));
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
Attributes attr;
|
||||
@ -168,13 +166,11 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnAcquireInfoTest_001, TestSize.Level0
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(1));
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(dstRole, SCHEDULER);
|
||||
EXPECT_NE(msg, nullptr);
|
||||
return USERAUTH_SUCCESS;
|
||||
@ -195,9 +191,9 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnAcquireInfoTest_002, TestSize.Level0
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) { return USERAUTH_ERROR; });
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
@ -215,21 +211,15 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnAcquireInfoTest_003, TestSize.Level0
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(3))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(1));
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
return USERAUTH_SUCCESS;
|
||||
})
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(2));
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
return USERAUTH_ERROR;
|
||||
})
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(3));
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
return USERAUTH_SUCCESS;
|
||||
});
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
@ -251,10 +241,10 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_MixTest_003, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(3))
|
||||
.WillRepeatedly([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillRepeatedly([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) { return USERAUTH_SUCCESS; });
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
|
@ -68,11 +68,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_001, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
uint32_t attrResultCode;
|
||||
EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true);
|
||||
@ -98,9 +97,9 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_002, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
// return error
|
||||
return USERAUTH_ERROR;
|
||||
});
|
||||
@ -120,11 +119,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_003, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
uint32_t attrResultCode;
|
||||
EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true);
|
||||
@ -150,7 +148,7 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_004, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1));
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
Attributes attr;
|
||||
@ -169,13 +167,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnAcquireInfoTest_001, TestSize.Le
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(1));
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(dstRole, SCHEDULER);
|
||||
EXPECT_NE(msg, nullptr);
|
||||
std::vector<uint8_t> extraInfo;
|
||||
@ -197,9 +192,9 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnAcquireInfoTest_002, TestSize.Le
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) { return USERAUTH_ERROR; });
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
@ -217,21 +212,15 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnAcquireInfoTest_003, TestSize.Le
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(3))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType,
|
||||
std::shared_ptr<AuthMessage> msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(1));
|
||||
.WillOnce([](uint64_t scheduleId, int32_t dstType, std::shared_ptr<AuthMessage> msg) {
|
||||
return USERAUTH_SUCCESS;
|
||||
})
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType,
|
||||
std::shared_ptr<AuthMessage> msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(2));
|
||||
.WillOnce([](uint64_t scheduleId, int32_t dstType, std::shared_ptr<AuthMessage> msg) {
|
||||
return USERAUTH_ERROR;
|
||||
})
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType,
|
||||
std::shared_ptr<AuthMessage> msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(3));
|
||||
.WillOnce([](uint64_t scheduleId, int32_t dstType, std::shared_ptr<AuthMessage> msg) {
|
||||
return USERAUTH_SUCCESS;
|
||||
});
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
@ -253,10 +242,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_MixTest_003, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(3))
|
||||
.WillRepeatedly([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType,
|
||||
.WillRepeatedly([](uint64_t scheduleId, int32_t dstType,
|
||||
std::shared_ptr<AuthMessage> msg) { return USERAUTH_SUCCESS; });
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
|
@ -367,8 +367,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_CommonErrorTest_001,
|
||||
int32_t ret = GetExecutorAndMockStub(executor, executorCallback, mockExecutorHdi, mockMessenger);
|
||||
ASSERT_EQ(ret, ResultCode::SUCCESS);
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
Attributes attr;
|
||||
@ -387,8 +387,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_CommonErrorTest_002,
|
||||
int32_t ret = GetExecutorAndMockStub(executor, executorCallback, mockExecutorHdi, mockMessenger);
|
||||
ASSERT_EQ(ret, ResultCode::SUCCESS);
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -410,8 +410,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_CommonErrorTest_003,
|
||||
int32_t ret = GetExecutorAndMockStub(executor, executorCallback, mockExecutorHdi, mockMessenger);
|
||||
ASSERT_EQ(ret, ResultCode::SUCCESS);
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -442,13 +442,12 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_ExecutorDisconnectTest_001, TestSize
|
||||
[](uint64_t scheduleId, const EnrollParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) { return ResultCode::SUCCESS; });
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _))
|
||||
.Times(Exactly(2))
|
||||
.WillRepeatedly(
|
||||
[](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
[](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, static_cast<ExecutorRole>(ALL_IN_ONE));
|
||||
EXPECT_EQ(resultCode, ResultCode::GENERAL_ERROR);
|
||||
std::vector<uint8_t> extraInfo;
|
||||
EXPECT_EQ(finalResult.GetUint8ArrayValue(Attributes::ATTR_RESULT, extraInfo), true);
|
||||
@ -497,8 +496,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_EnrollTest_001, TestS
|
||||
return ResultCode::SUCCESS;
|
||||
});
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -524,8 +523,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_EnrollTest_002, TestS
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Enroll(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -550,8 +549,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_EnrollTest_003, TestS
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Enroll(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -594,8 +593,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_001, TestSiz
|
||||
return ResultCode::SUCCESS;
|
||||
});
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -623,8 +622,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_002, TestSiz
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Authenticate(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -649,8 +648,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_003, TestSiz
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Authenticate(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -677,8 +676,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_004, TestSiz
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Authenticate(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -717,8 +716,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_IdentifyTest_001, Tes
|
||||
return ResultCode::SUCCESS;
|
||||
});
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -744,8 +743,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_IdentifyTest_002, Tes
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Identify(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
@ -770,8 +769,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_IdentifyTest_003, Tes
|
||||
|
||||
EXPECT_CALL(*mockExecutorHdi, Identify(_, _, _)).Times(Exactly(0));
|
||||
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0));
|
||||
EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0));
|
||||
|
||||
vector<uint8_t> uselessPublicKey;
|
||||
auto commandAttrs = MakeShared<Attributes>();
|
||||
|
@ -68,11 +68,10 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_001, TestSize.Lev
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
uint32_t attrResultCode;
|
||||
EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true);
|
||||
@ -98,9 +97,9 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_002, TestSize.Lev
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
// return error
|
||||
return USERAUTH_ERROR;
|
||||
});
|
||||
@ -120,11 +119,10 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_003, TestSize.Lev
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) {
|
||||
.WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
uint32_t attrResultCode;
|
||||
EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true);
|
||||
@ -150,7 +148,7 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_004, TestSize.Lev
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1));
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
Attributes attr;
|
||||
@ -169,13 +167,11 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnAcquireInfoTest_001, TestSiz
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(1));
|
||||
EXPECT_EQ(srcRole, ALL_IN_ONE);
|
||||
EXPECT_EQ(dstRole, SCHEDULER);
|
||||
EXPECT_NE(msg, nullptr);
|
||||
return USERAUTH_SUCCESS;
|
||||
@ -196,9 +192,9 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnAcquireInfoTest_002, TestSiz
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(1))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) { return USERAUTH_ERROR; });
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
@ -216,21 +212,15 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnAcquireInfoTest_003, TestSiz
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(3))
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(1));
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
return USERAUTH_SUCCESS;
|
||||
})
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(2));
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
return USERAUTH_ERROR;
|
||||
})
|
||||
.WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) {
|
||||
EXPECT_EQ(transNum, static_cast<uint64_t>(3));
|
||||
.WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) {
|
||||
return USERAUTH_SUCCESS;
|
||||
});
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
@ -252,10 +242,10 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_MixTest_003, TestSize.Level0)
|
||||
|
||||
auto messenger = MakeShared<MockIExecutorMessenger>();
|
||||
ASSERT_NE(messenger, nullptr);
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _, _, _))
|
||||
EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(*messenger, SendData(_, _, _))
|
||||
.Times(Exactly(3))
|
||||
.WillRepeatedly([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
.WillRepeatedly([](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg) { return USERAUTH_SUCCESS; });
|
||||
auto executor = Common::MakeShared<Executor>(nullptr, nullptr, 3);
|
||||
ASSERT_NE(executor, nullptr);
|
||||
|
@ -34,20 +34,25 @@ public:
|
||||
MOCK_METHOD3(
|
||||
OnRegisterFinish, ResultCode(const std::vector<uint64_t> &templateIdList,
|
||||
const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo));
|
||||
MOCK_METHOD1(Cancel, ResultCode(uint64_t scheduleId));
|
||||
MOCK_METHOD3(SendMessage, ResultCode(uint64_t scheduleId, int32_t srcRole, const std::vector<uint8_t> &msg));
|
||||
MOCK_METHOD3(Enroll, ResultCode(uint64_t scheduleId, const EnrollParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj));
|
||||
MOCK_METHOD3(Authenticate,
|
||||
ResultCode(uint64_t scheduleId, const AuthenticateParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj));
|
||||
MOCK_METHOD3(Collect,
|
||||
ResultCode(uint64_t scheduleId, const CollectParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj));
|
||||
MOCK_METHOD3(Identify, ResultCode(uint64_t scheduleId, const IdentifyParam ¶m,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj));
|
||||
MOCK_METHOD1(Delete, ResultCode(const std::vector<uint64_t> &templateIdList));
|
||||
MOCK_METHOD1(Cancel, ResultCode(uint64_t scheduleId));
|
||||
MOCK_METHOD3(SendCommand, ResultCode(PropertyMode commandId, const std::vector<uint8_t> &extraInfo,
|
||||
const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj));
|
||||
MOCK_METHOD3(GetProperty, ResultCode (const std::vector<uint64_t> &templateIdList,
|
||||
const std::vector<Attributes::AttributeKey> &keys, Property &property));
|
||||
MOCK_METHOD1(SetCachedTemplates, ResultCode(const std::vector<uint64_t> &templateIdList));
|
||||
MOCK_METHOD1(NotifyCollectorReady, ResultCode(uint64_t scheduleId));
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -30,10 +30,8 @@ class MockIExecutorMessenger : public ExecutorMessenger {
|
||||
public:
|
||||
virtual ~MockIExecutorMessenger() = default;
|
||||
|
||||
MOCK_METHOD5(SendData, int32_t(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole,
|
||||
const std::shared_ptr<AuthMessage> &msg));
|
||||
MOCK_METHOD4(Finish,
|
||||
int32_t(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult));
|
||||
MOCK_METHOD3(SendData, int32_t(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg));
|
||||
MOCK_METHOD3(Finish, int32_t(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult));
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
MOCK_METHOD2(OnEndExecute, int32_t(uint64_t scheduleId, const Attributes &command));
|
||||
MOCK_METHOD1(OnSetProperty, int32_t(const Attributes &properties));
|
||||
MOCK_METHOD2(OnGetProperty, int32_t(const Attributes &condition, Attributes &values));
|
||||
MOCK_METHOD2(OnSendData, int32_t(uint64_t scheduleId, const Attributes &data));
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -26,9 +26,8 @@ namespace UserIam {
|
||||
namespace UserAuth {
|
||||
class MockExecutorMessengerService final : public ExecutorMessengerStub {
|
||||
public:
|
||||
MOCK_METHOD5(SendData, int32_t(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole,
|
||||
ExecutorRole dstRole, const std::vector<uint8_t> &msg));
|
||||
MOCK_METHOD4(Finish, int32_t(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode,
|
||||
MOCK_METHOD3(SendData, int32_t(uint64_t scheduleId, ExecutorRole dstRole, const std::vector<uint8_t> &msg));
|
||||
MOCK_METHOD3(Finish, int32_t(uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult));
|
||||
};
|
||||
} // namespace UserAuth
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
MOCK_METHOD2(OnEndExecute, int32_t(uint64_t scheduleId, const Attributes &commandAttrs));
|
||||
MOCK_METHOD1(OnSetProperty, int32_t(const Attributes &properties));
|
||||
MOCK_METHOD2(OnGetProperty, int32_t(const Attributes &conditions, Attributes &results));
|
||||
MOCK_METHOD2(OnSendData, int32_t(uint64_t scheduleId, const Attributes &data));
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -44,8 +44,6 @@ void ExecutorMessengerClientTest::TearDown()
|
||||
HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData001, TestSize.Level0)
|
||||
{
|
||||
uint64_t testScheduleId = 6598;
|
||||
uint64_t testTransNum = 8784;
|
||||
ExecutorRole testSrcRole = SCHEDULER;
|
||||
ExecutorRole testDstRole = COLLECTOR;
|
||||
std::vector<uint8_t> message = {1, 2, 4, 6};
|
||||
std::shared_ptr<AuthMessage> testMsg = AuthMessage::As(message);
|
||||
@ -54,15 +52,13 @@ HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData001, Te
|
||||
sptr<ExecutorMessengerInterface> testMessenger(nullptr);
|
||||
auto service = Common::MakeShared<ExecutorMessengerClient>(testMessenger);
|
||||
EXPECT_NE(service, nullptr);
|
||||
int32_t result = service->SendData(testScheduleId, testTransNum, testSrcRole, testDstRole, testMsg);
|
||||
int32_t result = service->SendData(testScheduleId, testDstRole, testMsg);
|
||||
EXPECT_EQ(result, GENERAL_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData002, TestSize.Level0)
|
||||
{
|
||||
uint64_t testScheduleId = 6598;
|
||||
uint64_t testTransNum = 8784;
|
||||
ExecutorRole testSrcRole = SCHEDULER;
|
||||
ExecutorRole testDstRole = COLLECTOR;
|
||||
std::shared_ptr<AuthMessage> testMsg = nullptr;
|
||||
|
||||
@ -70,15 +66,13 @@ HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData002, Te
|
||||
EXPECT_NE(testMessenger, nullptr);
|
||||
auto service = Common::MakeShared<ExecutorMessengerClient>(testMessenger);
|
||||
EXPECT_NE(service, nullptr);
|
||||
int32_t result = service->SendData(testScheduleId, testTransNum, testSrcRole, testDstRole, testMsg);
|
||||
int32_t result = service->SendData(testScheduleId, testDstRole, testMsg);
|
||||
EXPECT_EQ(result, GENERAL_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData003, TestSize.Level0)
|
||||
{
|
||||
uint64_t testScheduleId = 6598;
|
||||
uint64_t testTransNum = 8784;
|
||||
ExecutorRole testSrcRole = SCHEDULER;
|
||||
ExecutorRole testDstRole = COLLECTOR;
|
||||
std::vector<uint8_t> message = {1, 2, 4, 6};
|
||||
std::shared_ptr<AuthMessage> testMsg = AuthMessage::As(message);
|
||||
@ -86,61 +80,55 @@ HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData003, Te
|
||||
|
||||
sptr<MockExecutorMessengerService> testMessenger(new (std::nothrow) MockExecutorMessengerService());
|
||||
EXPECT_NE(testMessenger, nullptr);
|
||||
EXPECT_CALL(*testMessenger, SendData(_, _, _, _, _)).Times(1);
|
||||
EXPECT_CALL(*testMessenger, SendData(_, _, _)).Times(1);
|
||||
ON_CALL(*testMessenger, SendData)
|
||||
.WillByDefault(
|
||||
[&testScheduleId, &testTransNum, &testSrcRole, &testDstRole, &message](uint64_t scheduleId,
|
||||
uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, const std::vector<uint8_t> &msg) {
|
||||
[&testScheduleId, &testDstRole, &message](uint64_t scheduleId, ExecutorRole dstRole,
|
||||
const std::vector<uint8_t> &msg) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(transNum, testTransNum);
|
||||
EXPECT_EQ(srcRole, testSrcRole);
|
||||
EXPECT_EQ(dstRole, testDstRole);
|
||||
EXPECT_THAT(msg, ElementsAreArray(message));
|
||||
return SUCCESS;
|
||||
}
|
||||
);
|
||||
auto service = Common::MakeShared<ExecutorMessengerClient>(testMessenger);
|
||||
EXPECT_NE(service, nullptr);
|
||||
int32_t result = service->SendData(testScheduleId, testTransNum, testSrcRole, testDstRole, testMsg);
|
||||
int32_t result = service->SendData(testScheduleId, testDstRole, testMsg);
|
||||
EXPECT_EQ(result, SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestFinish001, TestSize.Level0)
|
||||
{
|
||||
uint64_t testScheduleId = 6598;
|
||||
ExecutorRole testSrcRole = SCHEDULER;
|
||||
int32_t testResultCode = FAIL;
|
||||
Attributes finalResult;
|
||||
|
||||
sptr<ExecutorMessengerInterface> testMessenger(nullptr);
|
||||
auto service = Common::MakeShared<ExecutorMessengerClient>(testMessenger);
|
||||
EXPECT_NE(service, nullptr);
|
||||
int32_t result = service->Finish(testScheduleId, testSrcRole, testResultCode, finalResult);
|
||||
int32_t result = service->Finish(testScheduleId, testResultCode, finalResult);
|
||||
EXPECT_EQ(result, GENERAL_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestFinish002, TestSize.Level0)
|
||||
{
|
||||
uint64_t testScheduleId = 6598;
|
||||
ExecutorRole testSrcRole = SCHEDULER;
|
||||
int32_t testResultCode = FAIL;
|
||||
Attributes finalResult;
|
||||
|
||||
sptr<MockExecutorMessengerService> testMessenger(new (std::nothrow) MockExecutorMessengerService());
|
||||
EXPECT_NE(testMessenger, nullptr);
|
||||
EXPECT_CALL(*testMessenger, Finish(_, _, _, _)).Times(1);
|
||||
EXPECT_CALL(*testMessenger, Finish(_, _, _)).Times(1);
|
||||
ON_CALL(*testMessenger, Finish)
|
||||
.WillByDefault(
|
||||
[&testScheduleId, &testSrcRole, &testResultCode](uint64_t scheduleId, ExecutorRole srcRole,
|
||||
ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult) {
|
||||
[&testScheduleId, &testResultCode](uint64_t scheduleId, ResultCode resultCode,
|
||||
const std::shared_ptr<Attributes> &finalResult) {
|
||||
EXPECT_EQ(scheduleId, testScheduleId);
|
||||
EXPECT_EQ(srcRole, testSrcRole);
|
||||
EXPECT_EQ(resultCode, testResultCode);
|
||||
return SUCCESS;
|
||||
}
|
||||
);
|
||||
auto service = Common::MakeShared<ExecutorMessengerClient>(testMessenger);
|
||||
int32_t result = service->Finish(testScheduleId, testSrcRole, testResultCode, finalResult);
|
||||
int32_t result = service->Finish(testScheduleId, testResultCode, finalResult);
|
||||
EXPECT_EQ(result, SUCCESS);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
|
@ -55,20 +55,17 @@ HWTEST_F(ExecutorMessengerProxyTest, TestSendData_001, TestSize.Level0)
|
||||
);
|
||||
|
||||
uint64_t scheduleId = 6598;
|
||||
uint64_t transNum = 8784;
|
||||
ExecutorRole srcRole = SCHEDULER;
|
||||
ExecutorRole dstRole = COLLECTOR;
|
||||
std::vector<uint8_t> message = {1, 2, 4, 6};
|
||||
|
||||
auto proxy = Common::MakeShared<ExecutorMessengerProxy>(obj);
|
||||
EXPECT_NE(proxy, nullptr);
|
||||
EXPECT_EQ(proxy->SendData(scheduleId, transNum, srcRole, dstRole, message), SUCCESS);
|
||||
EXPECT_EQ(proxy->SendData(scheduleId, dstRole, message), SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(ExecutorMessengerProxyTest, TestFinish_001, TestSize.Level0)
|
||||
{
|
||||
uint64_t scheduleId = 6598;
|
||||
ExecutorRole srcRole = SCHEDULER;
|
||||
ResultCode resultCode = SUCCESS;
|
||||
std::shared_ptr<Attributes> finalResult = nullptr;
|
||||
|
||||
@ -76,7 +73,7 @@ HWTEST_F(ExecutorMessengerProxyTest, TestFinish_001, TestSize.Level0)
|
||||
EXPECT_NE(obj, nullptr);
|
||||
auto proxy = Common::MakeShared<ExecutorMessengerProxy>(obj);
|
||||
EXPECT_NE(proxy, nullptr);
|
||||
EXPECT_EQ(proxy->Finish(scheduleId, srcRole, resultCode, finalResult), INVALID_PARAMETERS);
|
||||
EXPECT_EQ(proxy->Finish(scheduleId, resultCode, finalResult), INVALID_PARAMETERS);
|
||||
}
|
||||
|
||||
HWTEST_F(ExecutorMessengerProxyTest, TestFinish_002, TestSize.Level0)
|
||||
@ -93,14 +90,13 @@ HWTEST_F(ExecutorMessengerProxyTest, TestFinish_002, TestSize.Level0)
|
||||
);
|
||||
|
||||
uint64_t scheduleId = 6598;
|
||||
ExecutorRole srcRole = SCHEDULER;
|
||||
ResultCode resultCode = SUCCESS;
|
||||
std::shared_ptr<Attributes> finalResult = Common::MakeShared<Attributes>();
|
||||
EXPECT_NE(finalResult, nullptr);
|
||||
|
||||
auto proxy = Common::MakeShared<ExecutorMessengerProxy>(obj);
|
||||
EXPECT_NE(proxy, nullptr);
|
||||
EXPECT_EQ(proxy->Finish(scheduleId, srcRole, resultCode, finalResult), SUCCESS);
|
||||
EXPECT_EQ(proxy->Finish(scheduleId, resultCode, finalResult), SUCCESS);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -45,8 +45,6 @@ void ExecutorMessengerStubTest::TearDown()
|
||||
HWTEST_F(ExecutorMessengerStubTest, TestSendDataStub_001, TestSize.Level0)
|
||||
{
|
||||
uint64_t scheduleId = 6598;
|
||||
uint64_t transNum = 8784;
|
||||
ExecutorRole srcRole = SCHEDULER;
|
||||
ExecutorRole dstRole = COLLECTOR;
|
||||
std::vector<uint8_t> message = {1, 2, 4, 6};
|
||||
|
||||
@ -57,14 +55,12 @@ HWTEST_F(ExecutorMessengerStubTest, TestSendDataStub_001, TestSize.Level0)
|
||||
|
||||
EXPECT_TRUE(data.WriteInterfaceToken(ExecutorMessengerInterface::GetDescriptor()));
|
||||
EXPECT_TRUE(data.WriteUint64(scheduleId));
|
||||
EXPECT_TRUE(data.WriteUint64(transNum));
|
||||
EXPECT_TRUE(data.WriteInt32(srcRole));
|
||||
EXPECT_TRUE(data.WriteInt32(dstRole));
|
||||
EXPECT_TRUE(data.WriteUInt8Vector(message));
|
||||
|
||||
auto service = Common::MakeShared<MockExecutorMessengerService>();
|
||||
EXPECT_NE(service, nullptr);
|
||||
EXPECT_CALL(*service, SendData(_, _, _, _, _)).Times(1);
|
||||
EXPECT_CALL(*service, SendData(_, _, _)).Times(1);
|
||||
|
||||
EXPECT_EQ(service->OnRemoteRequest(code, data, reply, option), SUCCESS);
|
||||
}
|
||||
@ -72,7 +68,6 @@ HWTEST_F(ExecutorMessengerStubTest, TestSendDataStub_001, TestSize.Level0)
|
||||
HWTEST_F(ExecutorMessengerStubTest, TestFinishStub_001, TestSize.Level0)
|
||||
{
|
||||
uint64_t scheduleId = 6598;
|
||||
ExecutorRole srcRole = SCHEDULER;
|
||||
ResultCode resultCode = SUCCESS;
|
||||
std::vector<uint8_t> finalResult = {1, 2, 4, 6};
|
||||
|
||||
@ -83,13 +78,12 @@ HWTEST_F(ExecutorMessengerStubTest, TestFinishStub_001, TestSize.Level0)
|
||||
|
||||
EXPECT_TRUE(data.WriteInterfaceToken(ExecutorMessengerInterface::GetDescriptor()));
|
||||
EXPECT_TRUE(data.WriteUint64(scheduleId));
|
||||
EXPECT_TRUE(data.WriteInt32(srcRole));
|
||||
EXPECT_TRUE(data.WriteInt32(resultCode));
|
||||
EXPECT_TRUE(data.WriteUInt8Vector(finalResult));
|
||||
|
||||
auto service = Common::MakeShared<MockExecutorMessengerService>();
|
||||
EXPECT_NE(service, nullptr);
|
||||
EXPECT_CALL(*service, Finish(_, _, _, _)).Times(1);
|
||||
EXPECT_CALL(*service, Finish(_, _, _)).Times(1);
|
||||
|
||||
EXPECT_EQ(service->OnRemoteRequest(code, data, reply, option), SUCCESS);
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ ohos_unittest("iam_services_test") {
|
||||
"../../../services/core/src/credential_info_impl.cpp",
|
||||
"../../../services/core/src/enrolled_info_impl.cpp",
|
||||
"../../../services/core/src/enrollment_impl.cpp",
|
||||
"../../../services/core/src/hdi_message_callback_service.cpp",
|
||||
"../../../services/core/src/identification_impl.cpp",
|
||||
"../../../services/core/src/resource_node_impl.cpp",
|
||||
"../../../services/core/src/resource_node_pool_impl.cpp",
|
||||
@ -154,6 +155,7 @@ ohos_unittest("iam_services_test") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_user_auth:libuser_auth_proxy_2.0",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbeget_proxy",
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
MOCK_METHOD2(OnEndExecute, int32_t(uint64_t scheduleId, const Attributes &command));
|
||||
MOCK_METHOD1(OnSetProperty, int32_t(const Attributes &properties));
|
||||
MOCK_METHOD2(OnGetProperty, int32_t(const Attributes &condition, Attributes &values));
|
||||
MOCK_METHOD2(OnSendData, int32_t(uint64_t scheduleId, const Attributes &data));
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
MOCK_METHOD2(EndExecute, int32_t(uint64_t scheduleId, const Attributes &command));
|
||||
MOCK_METHOD1(SetProperty, int32_t(const Attributes &properties));
|
||||
MOCK_METHOD2(GetProperty, int32_t(const Attributes &condition, Attributes &values));
|
||||
MOCK_METHOD2(SendData, int32_t(uint64_t scheduleId, const Attributes &data));
|
||||
MOCK_METHOD0(OnRegisterFinish, int32_t());
|
||||
MOCK_METHOD0(Detach, void());
|
||||
|
||||
static std::shared_ptr<ResourceNode> CreateWithExecuteIndex(uint64_t executorId, bool detach = false)
|
||||
|
@ -42,8 +42,7 @@ public:
|
||||
MOCK_METHOD1(SetExpiredTime, bool(uint32_t ms));
|
||||
MOCK_METHOD0(StartSchedule, bool());
|
||||
MOCK_METHOD0(StopSchedule, bool());
|
||||
MOCK_METHOD4(ContinueSchedule,
|
||||
bool(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum, const std::vector<uint8_t> &msg));
|
||||
MOCK_METHOD2(SendMessage, bool(ExecutorRole dstRole, const std::vector<uint8_t> &msg));
|
||||
MOCK_METHOD2(ContinueSchedule, bool(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult));
|
||||
|
||||
static std::shared_ptr<MockScheduleNode> CreateWithScheduleId(uint64_t scheduleId)
|
||||
|
@ -51,6 +51,7 @@ HWTEST_F(CoAuthStubTest, CoAuthStubTestExecutorRegister001, TestSize.Level0)
|
||||
testInfo.executorSensorHint = 0;
|
||||
testInfo.executorMatcher = 0;
|
||||
testInfo.esl = ESL1;
|
||||
testInfo.maxTemplateAcl = 0;
|
||||
testInfo.publicKey = {'a', 'b', 'c', 'd'};
|
||||
|
||||
uint64_t testContextId = 124545;
|
||||
@ -79,6 +80,7 @@ HWTEST_F(CoAuthStubTest, CoAuthStubTestExecutorRegister001, TestSize.Level0)
|
||||
EXPECT_TRUE(data.WriteUint32(testInfo.executorSensorHint));
|
||||
EXPECT_TRUE(data.WriteUint32(testInfo.executorMatcher));
|
||||
EXPECT_TRUE(data.WriteInt32(testInfo.esl));
|
||||
EXPECT_TRUE(data.WriteUint32(testInfo.maxTemplateAcl));
|
||||
EXPECT_TRUE(data.WriteUInt8Vector(testInfo.publicKey));
|
||||
EXPECT_NE(callback->AsObject(), nullptr);
|
||||
EXPECT_TRUE(data.WriteRemoteObject(callback->AsObject()));
|
||||
|
@ -30,7 +30,6 @@ namespace UserAuth {
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
void ContextAppStateObserverTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
@ -56,8 +56,6 @@ HWTEST_F(ExecutorMessengerServiceTest, ExecutorMessengerServiceTest002, TestSize
|
||||
uint64_t testScheduleId1 = 1545;
|
||||
uint64_t testScheduleId2 = 1876;
|
||||
uint64_t testContextId = 78545;
|
||||
uint64_t testTransNum = 8751;
|
||||
ExecutorRole testSrcRole = SCHEDULER;
|
||||
ExecutorRole testDstRole = VERIFIER;
|
||||
ResultCode testResultCode = FAIL;
|
||||
std::shared_ptr<Attributes> testFinalResult = nullptr;
|
||||
@ -66,19 +64,19 @@ HWTEST_F(ExecutorMessengerServiceTest, ExecutorMessengerServiceTest002, TestSize
|
||||
auto service = ExecutorMessengerService::GetInstance();
|
||||
EXPECT_NE(service, nullptr);
|
||||
|
||||
int32_t result1 = service->SendData(testScheduleId1, testTransNum, testSrcRole, testDstRole, testMsg);
|
||||
int32_t result1 = service->SendData(testScheduleId1, testDstRole, testMsg);
|
||||
EXPECT_EQ(result1, GENERAL_ERROR);
|
||||
|
||||
int32_t result2 = service->Finish(testScheduleId1, testSrcRole, testResultCode, testFinalResult);
|
||||
int32_t result2 = service->Finish(testScheduleId1, testResultCode, testFinalResult);
|
||||
EXPECT_EQ(result2, GENERAL_ERROR);
|
||||
|
||||
auto scheduleNode1 = MockScheduleNode::CreateWithScheduleId(testScheduleId1);
|
||||
EXPECT_NE(scheduleNode1, nullptr);
|
||||
EXPECT_CALL(*scheduleNode1, ContinueSchedule(_, _, _, _)).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(*scheduleNode1, SendMessage(_, _)).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(*scheduleNode1, ContinueSchedule(_, _)).WillRepeatedly(Return(false));
|
||||
auto scheduleNode2 = MockScheduleNode::CreateWithScheduleId(testScheduleId2);
|
||||
EXPECT_NE(scheduleNode2, nullptr);
|
||||
EXPECT_CALL(*scheduleNode2, ContinueSchedule(_, _, _, _)).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*scheduleNode2, SendMessage(_, _)).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*scheduleNode2, ContinueSchedule(_, _)).WillRepeatedly(Return(true));
|
||||
std::set<std::shared_ptr<ScheduleNode>> scheduleNodeSet;
|
||||
scheduleNodeSet.insert(scheduleNode1);
|
||||
@ -88,14 +86,14 @@ HWTEST_F(ExecutorMessengerServiceTest, ExecutorMessengerServiceTest002, TestSize
|
||||
EXPECT_NE(context, nullptr);
|
||||
EXPECT_TRUE(ContextPool::Instance().Insert(context));
|
||||
|
||||
result1 = service->SendData(testScheduleId1, testTransNum, testSrcRole, testDstRole, testMsg);
|
||||
result1 = service->SendData(testScheduleId1, testDstRole, testMsg);
|
||||
EXPECT_EQ(result1, GENERAL_ERROR);
|
||||
result1 = service->SendData(testScheduleId2, testTransNum, testSrcRole, testDstRole, testMsg);
|
||||
result1 = service->SendData(testScheduleId2, testDstRole, testMsg);
|
||||
EXPECT_EQ(result1, SUCCESS);
|
||||
|
||||
result2 = service->Finish(testScheduleId1, testSrcRole, testResultCode, testFinalResult);
|
||||
result2 = service->Finish(testScheduleId1, testResultCode, testFinalResult);
|
||||
EXPECT_EQ(result2, GENERAL_ERROR);
|
||||
result2 = service->Finish(testScheduleId2, testSrcRole, testResultCode, testFinalResult);
|
||||
result2 = service->Finish(testScheduleId2, testResultCode, testFinalResult);
|
||||
EXPECT_EQ(result2, SUCCESS);
|
||||
|
||||
EXPECT_TRUE(ContextPool::Instance().Delete(testContextId));
|
||||
|
@ -569,11 +569,8 @@ HWTEST_F(ScheduleNodeTest, ScheduleNodeStartAllInOneUserStopAndEndFailed, TestSi
|
||||
handler->EnsureTask(nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(ScheduleNodeTest, ScheduleNodeTestContinueSchedule, TestSize.Level0)
|
||||
HWTEST_F(ScheduleNodeTest, ScheduleNodeTestSendMessage, TestSize.Level0)
|
||||
{
|
||||
ExecutorRole testSrcRole = COLLECTOR;
|
||||
ExecutorRole testDstRole = COLLECTOR;
|
||||
uint64_t testTransNum = 58786;
|
||||
std::vector<uint8_t> testMsg;
|
||||
|
||||
constexpr uint32_t EXECUTOR_INDEX = 0xAAAAAAA;
|
||||
@ -592,11 +589,15 @@ HWTEST_F(ScheduleNodeTest, ScheduleNodeTestContinueSchedule, TestSize.Level0)
|
||||
auto scheduleNode = builder->Build();
|
||||
EXPECT_NE(scheduleNode, nullptr);
|
||||
|
||||
EXPECT_FALSE(scheduleNode->ContinueSchedule(testSrcRole, testDstRole, testTransNum, testMsg));
|
||||
ExecutorRole testDstRole = COLLECTOR;
|
||||
EXPECT_TRUE(scheduleNode->SendMessage(testDstRole, testMsg));
|
||||
testDstRole = SCHEDULER;
|
||||
scheduleNode = builder->Build();
|
||||
EXPECT_NE(scheduleNode, nullptr);
|
||||
EXPECT_TRUE(scheduleNode->ContinueSchedule(testSrcRole, testDstRole, testTransNum, testMsg));
|
||||
Attributes attr;
|
||||
EXPECT_TRUE(attr.SetInt32Value(Attributes::ATTR_TIP_INFO, 40));
|
||||
testMsg = attr.Serialize();
|
||||
EXPECT_FALSE(scheduleNode->SendMessage(testDstRole, testMsg));
|
||||
callback = Common::MakeShared<MockScheduleNodeCallback>();
|
||||
EXPECT_NE(callback, nullptr);
|
||||
EXPECT_CALL(*callback, OnScheduleProcessed(_, _, _)).Times(1);
|
||||
@ -604,7 +605,7 @@ HWTEST_F(ScheduleNodeTest, ScheduleNodeTestContinueSchedule, TestSize.Level0)
|
||||
builder->SetAuthType(FACE);
|
||||
scheduleNode = builder->Build();
|
||||
EXPECT_NE(scheduleNode, nullptr);
|
||||
EXPECT_TRUE(scheduleNode->ContinueSchedule(testSrcRole, testDstRole, testTransNum, testMsg));
|
||||
EXPECT_TRUE(scheduleNode->SendMessage(testDstRole, testMsg));
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
|
@ -463,7 +463,7 @@ static void MockForAuthResourceNode(std::shared_ptr<MockResourceNode> &resourceN
|
||||
EXPECT_NE(finalResult, nullptr);
|
||||
std::vector<uint8_t> scheduleResult = {1, 2, 3, 4};
|
||||
EXPECT_TRUE(finalResult->SetUint8ArrayValue(Attributes::ATTR_RESULT, scheduleResult));
|
||||
EXPECT_EQ(messenger->Finish(testScheduleId, ALL_IN_ONE, SUCCESS, finalResult), SUCCESS);
|
||||
EXPECT_EQ(messenger->Finish(testScheduleId, SUCCESS, finalResult), SUCCESS);
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ static void MockForIdmResourceNode(std::shared_ptr<MockResourceNode> &resourceNo
|
||||
EXPECT_NE(finalResult, nullptr);
|
||||
std::vector<uint8_t> scheduleResult = {1, 2, 3, 4};
|
||||
EXPECT_TRUE(finalResult->SetUint8ArrayValue(Attributes::ATTR_RESULT, scheduleResult));
|
||||
EXPECT_EQ(messenger->Finish(testScheduleId, ALL_IN_ONE, SUCCESS, finalResult), SUCCESS);
|
||||
EXPECT_EQ(messenger->Finish(testScheduleId, SUCCESS, finalResult), SUCCESS);
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user