osaccount fuzz params replenish

Signed-off-by: wuliushuan <wuliushuan.30044128@huawei.com>
Change-Id: I9d847a7ee028fb03be4f93ae9658ae7dadefbf8b
This commit is contained in:
wuliushuan 2023-05-30 11:41:00 +00:00
parent dbd826df17
commit 098ebeb68f
31 changed files with 70 additions and 29 deletions

View File

@ -23,6 +23,7 @@
"OHOS::AccountSA::OsAccount::ActivateOsAccount(int)";
"OHOS::AccountSA::OsAccount::StopOsAccount(int)";
"VTT for OHOS::AccountSA::OsAccountInfo";
"OHOS::AccountSA::OsAccountEventListener::OsAccountEventListener(std::__h::shared_ptr<OHOS::AccountSA::OsAccountSubscriber> const&)";
};
local:
*;

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool ActivateOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool CheckOsAccountConstraintEnabledStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -18,6 +18,7 @@
#include <thread>
#include <vector>
#include "domain_account_callback_service.h"
#include "ios_account.h"
#include "os_account_manager_service.h"
@ -29,7 +30,7 @@ const int CONSTANTS_NUMBER_FIVE = 5;
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool CreateOsAccountForDomainStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}
@ -48,6 +49,11 @@ bool CreateOsAccountForDomainStubFuzzTest(const uint8_t *data, size_t size)
return false;
}
sptr<DomainAccountCallbackService> callbackService = new (std::nothrow) DomainAccountCallbackService(nullptr);
if ((callbackService == nullptr) || (!datas.WriteRemoteObject(callbackService->AsObject()))) {
return false;
}
uint32_t code = static_cast<uint32_t>(IOsAccount::Message::CREATE_OS_ACCOUNT_FOR_DOMAIN);
MessageParcel reply;

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool DumpStateStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool GetOsAccountAllConstraintsStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool GetOsAccountLocalIdBySerialNumberStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool GetOsAccountLocalIdFromDomainStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool GetOsAccountProfilePhotoStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool GetSerialNumberByOsAccountLocalIdStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool IsOsAccountActivedStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool IsOsAccountCompletedStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool IsOsAccountConstraintEnableStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool IsOsAccountExistsStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool IsOsAccountVerifiedStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool ProcCreateOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -27,7 +27,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool QueryOsAccountByIdStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool QueryOsAccountConstraintSourceTypesStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool RemoveOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetCurrentOsAccountIsVerifiedStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetDefaultActivatedOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -31,7 +31,7 @@ const int CONSTANTS_NUMBER_THREE = 3;
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetGlobalOsAccountConstraintsStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -30,7 +30,7 @@ const int CONSTANTS_NUMBER_THREE = 3;
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetOsAccountConstraintsStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -29,7 +29,7 @@ const int TEST_IS_VERIFIED_NUM = 2;
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetOsAccountIsVerifiedStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetOsAccountProfilePhotoStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -32,7 +32,7 @@ const int CONSTANTS_NUMBER_THREE = 3;
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SetSpecificOsAccountConstraintsStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -28,7 +28,7 @@ namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool StopOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}

View File

@ -46,6 +46,7 @@ ohos_fuzztest("SubscribeOsAccountStubFuzzTest") {
deps = [
"${os_account_path}/frameworks/common:libaccount_common",
"${os_account_path}/frameworks/osaccount/core:os_account_core",
"${os_account_path}/frameworks/osaccount/native:os_account_innerkits",
"${os_account_path}/services/accountmgr:accountmgr",
]

View File

@ -24,16 +24,20 @@
using namespace std;
using namespace OHOS::AccountSA;
class TestOsAccountSubscriber : public OsAccountSubscriber {
public:
void OnAccountsChanged(const int& id) {}
};
namespace OHOS {
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool SubscribeOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}
MessageParcel datas;
datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR);
OsAccountSubscribeInfo subscribeInfo;
@ -42,6 +46,18 @@ bool SubscribeOsAccountStubFuzzTest(const uint8_t *data, size_t size)
return false;
}
std::shared_ptr<OsAccountSubscriber> subscriber = make_shared<TestOsAccountSubscriber>();
sptr<OsAccountEventListener> listener = new (std::nothrow) OsAccountEventListener(subscriber);
if (listener == nullptr) {
return false;
}
sptr<IRemoteObject> osAccountEventListener = listener->AsObject();
if (!datas.WriteRemoteObject(osAccountEventListener)) {
return false;
}
uint32_t code = static_cast<uint32_t>(IOsAccount::Message::SUBSCRIBE_ACCOUNT);
MessageParcel reply;

View File

@ -46,6 +46,7 @@ ohos_fuzztest("UnSubscribeOsAccountStubFuzzTest") {
deps = [
"${os_account_path}/frameworks/common:libaccount_common",
"${os_account_path}/frameworks/osaccount/core:os_account_core",
"${os_account_path}/frameworks/osaccount/native:os_account_innerkits",
"${os_account_path}/services/accountmgr:accountmgr",
]

View File

@ -25,10 +25,14 @@ using namespace std;
using namespace OHOS::AccountSA;
namespace OHOS {
class TestOsAccountSubscriber : public OsAccountSubscriber {
public:
void OnAccountsChanged(const int& id) {}
};
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
bool UnSubscribeOsAccountStubFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}
@ -36,6 +40,18 @@ bool UnSubscribeOsAccountStubFuzzTest(const uint8_t *data, size_t size)
datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR);
std::shared_ptr<OsAccountSubscriber> subscriber = make_shared<TestOsAccountSubscriber>();
sptr<OsAccountEventListener> listener = new (std::nothrow) OsAccountEventListener(subscriber);
if (listener == nullptr) {
return false;
}
sptr<IRemoteObject> osAccountEventListener = listener->AsObject();
if (!datas.WriteRemoteObject(osAccountEventListener)) {
return false;
}
uint32_t code = static_cast<uint32_t>(IOsAccount::Message::UNSUBSCRIBE_ACCOUNT);
MessageParcel reply;