mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-26 19:50:37 +00:00
!2109 删除多余代码
Merge pull request !2109 from cc_ggboy/OpenHarmony-5.0-Release
This commit is contained in:
commit
f1918f889e
@ -17,7 +17,6 @@
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include "accesstoken_kit.h"
|
||||
@ -53,7 +52,6 @@
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
@ -67,7 +65,6 @@ const int32_t EDM_UID = 3057;
|
||||
static constexpr int32_t DEFAULT_API_VERSION = 8;
|
||||
const std::vector<uint8_t> DEFAULT_TOKEN = {49, 50, 51, 52, 53};
|
||||
static uint64_t g_selfTokenID;
|
||||
const std::string STRING_TEST_NAME = "name";
|
||||
#ifdef ENABLE_MULTIPLE_OS_ACCOUNTS
|
||||
const int32_t WAIT_TIME = 2;
|
||||
const std::string STRING_SHORT_NAME_OUT_OF_RANGE(256, '1');
|
||||
@ -798,74 +795,4 @@ HWTEST_F(DomainAccountClientMockPluginSoModuleTest, DomainAccountClientModuleTes
|
||||
setuid(ROOT_UID);
|
||||
UnloadPluginMethods();
|
||||
ASSERT_TRUE(RecoveryPermission(tokenID));
|
||||
}
|
||||
|
||||
/*** multithread */
|
||||
|
||||
/**
|
||||
* @tc.name: DomainAccountClientModuleTest_IsAuthenticationExpired_MultiThread_001
|
||||
* @tc.desc: MultiThread IsAuthenticationExpired success expired time not set..
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(DomainAccountClientMockPluginSoModuleTest,
|
||||
DomainAccountClientModuleTest_IsAuthenticationExpired_MultiThread_001, TestSize.Level0)
|
||||
{
|
||||
DomainAccountInfo domainInfo;
|
||||
domainInfo.accountName_ = "testaccount";
|
||||
domainInfo.domain_ = "test.example.com";
|
||||
domainInfo.accountId_ = "testid";
|
||||
|
||||
LoadPluginMethods();
|
||||
auto callback = std::make_shared<MockPluginSoDomainCreateDomainAccountCallback>();
|
||||
ASSERT_NE(callback, nullptr);
|
||||
auto testCallback = std::make_shared<TestPluginSoCreateDomainAccountCallback>(callback);
|
||||
EXPECT_CALL(*callback, OnResult(ERR_OK, "testaccount", "test.example.com", _)).Times(Exactly(1));
|
||||
ASSERT_NE(testCallback, nullptr);
|
||||
ErrCode errCode = OsAccountManager::CreateOsAccountForDomain(OsAccountType::NORMAL, domainInfo, testCallback);
|
||||
std::unique_lock<std::mutex> lock(testCallback->mutex);
|
||||
testCallback->cv.wait_for(lock, std::chrono::seconds(WAIT_TIME),
|
||||
[lockCallback = testCallback]() { return lockCallback->isReady; });
|
||||
EXPECT_EQ(errCode, ERR_OK);
|
||||
|
||||
auto func = [] {
|
||||
DomainAccountInfo domainInfo;
|
||||
domainInfo.accountName_ = "testaccount";
|
||||
domainInfo.domain_ = "test.example.com";
|
||||
domainInfo.accountId_ = "testid";
|
||||
bool isExpired = false;
|
||||
EXPECT_EQ(DomainAccountClient::GetInstance().IsAuthenticationExpired(domainInfo, isExpired), ERR_OK);
|
||||
EXPECT_TRUE(isExpired);
|
||||
};
|
||||
|
||||
GTEST_RUN_TASK(func);
|
||||
|
||||
UnloadPluginMethods();
|
||||
|
||||
int32_t userId = -1;
|
||||
EXPECT_EQ(OsAccountManager::GetOsAccountLocalIdFromDomain(domainInfo, userId), ERR_OK);
|
||||
EXPECT_EQ(OsAccountManager::RemoveOsAccount(userId), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DomainAccountClientModuleTest_SetAuthenticationExpiryThreshold_MultiThread_001
|
||||
* @tc.desc: MultiThread SetAccountPolicy success.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(DomainAccountClientMockPluginSoModuleTest,
|
||||
DomainAccountClientModuleTest_SetAuthenticationExpiryThreshold_MultiThread_001, TestSize.Level0)
|
||||
{
|
||||
AccessTokenID tokenID;
|
||||
ASSERT_TRUE(AllocPermission({"ohos.permission.MANAGE_LOCAL_ACCOUNTS"}, tokenID));
|
||||
setuid(EDM_UID);
|
||||
LoadPluginMethods();
|
||||
GTEST_RUN_TASK([]() {
|
||||
DomainAccountPolicy policy;
|
||||
policy.authenicationValidityPeriod = 10;
|
||||
EXPECT_EQ(DomainAccountClient::GetInstance().SetAccountPolicy(policy), ERR_OK);
|
||||
});
|
||||
UnloadPluginMethods();
|
||||
setuid(ROOT_UID);
|
||||
ASSERT_TRUE(RecoveryPermission(tokenID));
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include <thread>
|
||||
|
||||
@ -30,7 +29,6 @@
|
||||
#include "token_setproc.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
@ -46,11 +44,9 @@ const std::string STRING_VALUE = "value";
|
||||
const std::string STRING_VALUE_TWO = "value_two";
|
||||
const std::string STRING_EMPTY = "";
|
||||
constexpr std::int32_t UID = 10000;
|
||||
const int32_t THREAD_NUM = 10;
|
||||
std::shared_ptr<AppAccountManagerService> g_accountManagerService =
|
||||
std::make_shared<AppAccountManagerService>();
|
||||
static constexpr int32_t DEFAULT_API_VERSION = 8;
|
||||
static int g_testNameCounter = 0;
|
||||
uint64_t g_tokenId = GetSelfTokenID();
|
||||
static OHOS::Security::AccessToken::PermissionStateFull g_testState1 = {
|
||||
.permissionName = "",
|
||||
@ -295,123 +291,4 @@ HWTEST_F(AppAccountManagerServiceAssocaitedDataTest, AppAccountManagerService_Se
|
||||
|
||||
ErrCode result = g_accountManagerService->SetAssociatedData(STRING_NAME, STRING_KEY, STRING_VALUE);
|
||||
EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_ACCOUNT_INFO_BY_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_SetAssociatedDataM
|
||||
* @tc.desc: Set associated data with valid data.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceAssocaitedDataTest, AppAccountManagerService_SetAssociatedDataM,
|
||||
TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
ErrCode result = g_accountManagerService->AddAccount(STRING_NAME, STRING_EXTRA_INFO);
|
||||
|
||||
result = g_accountManagerService->SetAssociatedData(STRING_NAME, STRING_KEY, STRING_VALUE);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
std::string value;
|
||||
result = g_accountManagerService->GetAssociatedData(STRING_NAME, STRING_KEY, value);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_EQ(value, STRING_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_GetAssociatedDataM
|
||||
* @tc.desc: Set associated data with valid data.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceAssocaitedDataTest, AppAccountManagerService_GetAssociatedDataM,
|
||||
TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
ErrCode result = g_accountManagerService->AddAccount(STRING_NAME, STRING_EXTRA_INFO);
|
||||
|
||||
result = g_accountManagerService->SetAssociatedData(STRING_NAME, STRING_KEY, STRING_VALUE);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
std::string value;
|
||||
result = g_accountManagerService->GetAssociatedData(STRING_NAME, STRING_KEY, value);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_EQ(value, STRING_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_RemoveAssociatedDataCacheByUidM
|
||||
* @tc.desc: remove associated data cache by uid.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceAssocaitedDataTest, AppAccountManagerService_RemoveAssociatedDataCacheByUidM,
|
||||
TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "testString" << g_testNameCounter++;
|
||||
std::string stringName = STRING_NAME + ss.str();
|
||||
std::string stringExtra = STRING_EXTRA_INFO + ss.str();
|
||||
|
||||
int32_t callingUid = -1;
|
||||
std::string bundleName;
|
||||
uint32_t appIndex;
|
||||
ErrCode result = g_accountManagerService->GetCallingInfo(callingUid, bundleName, appIndex);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
AppAccountInfo appAccountInfo(stringName, bundleName);
|
||||
appAccountInfo.SetAppIndex(appIndex);
|
||||
|
||||
result = AppAccountControlManager::GetInstance().AddAccount(
|
||||
stringName, stringExtra, callingUid, bundleName, appAccountInfo);
|
||||
|
||||
result = g_accountManagerService->SetAssociatedData(stringName, STRING_KEY, STRING_VALUE);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
AppAccountControlManager::GetInstance().RemoveAssociatedDataCacheByUid(callingUid);
|
||||
|
||||
auto it = AppAccountControlManager::GetInstance().associatedDataCache_.find(callingUid);
|
||||
if ((it == AppAccountControlManager::GetInstance().associatedDataCache_.end())
|
||||
|| (it->second.name != stringName)) {
|
||||
result = ERR_OK;
|
||||
}
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
result = g_accountManagerService->DeleteAccount(stringName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_RemoveAssociatedDataCacheByAccountM
|
||||
* @tc.desc: remove associated data cache by uid.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceAssocaitedDataTest, AppAccountManagerService_RemoveAssociatedDataCacheByAccountM,
|
||||
TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "testString" << g_testNameCounter++;
|
||||
std::string stringName = STRING_NAME + ss.str();
|
||||
std::string stringExtra = STRING_EXTRA_INFO + ss.str();
|
||||
|
||||
int32_t callingUid = -1;
|
||||
std::string bundleName;
|
||||
uint32_t appIndex;
|
||||
ErrCode result = g_accountManagerService->GetCallingInfo(callingUid, bundleName, appIndex);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
AppAccountInfo appAccountInfo(stringName, bundleName);
|
||||
appAccountInfo.SetAppIndex(appIndex);
|
||||
result = AppAccountControlManager::GetInstance().AddAccount(
|
||||
stringName, stringExtra, callingUid, bundleName, appAccountInfo);
|
||||
|
||||
result = g_accountManagerService->SetAssociatedData(stringName, STRING_KEY, STRING_VALUE);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
AppAccountControlManager::GetInstance().RemoveAssociatedDataCacheByAccount(callingUid, stringName);
|
||||
|
||||
auto it = AppAccountControlManager::GetInstance().associatedDataCache_.find(callingUid);
|
||||
if ((it == AppAccountControlManager::GetInstance().associatedDataCache_.end())
|
||||
|| (it->second.name != stringName)) {
|
||||
result = ERR_OK;
|
||||
}
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
result = g_accountManagerService->DeleteAccount(stringName);
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
|
||||
#include <thread>
|
||||
#include <gmock/gmock.h>
|
||||
@ -38,7 +37,6 @@
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
@ -71,7 +69,6 @@ const std::string STRING_AUTH_TYPE = "read";
|
||||
const std::string STRING_AUTH_TYPE_TWO = "write";
|
||||
const std::string STRING_SESSION_ID = "100";
|
||||
const std::string STRING_ABILITY_NAME = "com.example.owner.MainAbility";
|
||||
const int32_t THREAD_NUM = 10;
|
||||
const std::vector<std::string> TEST_LABELS = {
|
||||
"test_label1",
|
||||
"test_label2",
|
||||
@ -2578,76 +2575,3 @@ HWTEST_F(AppAccountManagerServiceModuleTest, AppAccountManagerService_OnUserRemo
|
||||
ErrCode result = g_accountManagerService->OnUserRemoved(TEST_USER_ID);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_SetOAuthTokenM
|
||||
* @tc.desc: Set oauth token successfully.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceModuleTest, AppAccountManagerService_SetOAuthTokenM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
ErrCode result = g_accountManagerService->AddAccount(STRING_NAME, STRING_EXTRA_INFO);
|
||||
|
||||
result = g_accountManagerService->SetOAuthToken(STRING_NAME, STRING_AUTH_TYPE, STRING_TOKEN);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
result = g_accountManagerService->SetOAuthToken(STRING_NAME, STRING_AUTH_TYPE_TWO, STRING_TOKEN_TWO);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
std::vector<AppAccountInfo> appAccounts;
|
||||
result = g_accountManagerService->GetAllAccessibleAccounts(appAccounts);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
ASSERT_EQ(appAccounts.size(), SIZE_ONE);
|
||||
std::string owner;
|
||||
appAccounts[0].GetOwner(owner);
|
||||
|
||||
std::string token;
|
||||
result = g_accountManagerService->GetOAuthToken(STRING_NAME, owner, STRING_AUTH_TYPE_TWO, token);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_EQ(token, STRING_TOKEN_TWO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_DeleteOAuthTokenM
|
||||
* @tc.desc: Delete oauth token failed with non-exist account.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceModuleTest, AppAccountManagerService_DeleteOAuthTokenM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
ErrCode result = g_accountManagerService->DeleteOAuthToken(STRING_NAME,
|
||||
STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
|
||||
EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_ACCOUNT_NOT_EXIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppAccountManagerService_SetOAuthTokenVisibilityM
|
||||
* @tc.desc: Set oauth token visibility with existent authType successfully.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5N90B
|
||||
*/
|
||||
HWMTEST_F(AppAccountManagerServiceModuleTest, AppAccountManagerService_SetOAuthTokenVisibilityM,
|
||||
TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
ErrCode result = g_accountManagerService->AddAccount(STRING_NAME, STRING_EXTRA_INFO);
|
||||
|
||||
std::vector<AppAccountInfo> appAccounts;
|
||||
g_accountManagerService->GetAllAccessibleAccounts(appAccounts);
|
||||
ASSERT_EQ(appAccounts.size(), SIZE_ONE);
|
||||
std::string owner;
|
||||
appAccounts[0].GetOwner(owner);
|
||||
|
||||
result = g_accountManagerService->SetOAuthToken(STRING_NAME, STRING_AUTH_TYPE, STRING_TOKEN);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
result = g_accountManagerService->SetOAuthTokenVisibility(STRING_NAME,
|
||||
STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
bool isVisible = false;
|
||||
result = g_accountManagerService->CheckOAuthTokenVisibility(STRING_NAME,
|
||||
STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_EQ(isVisible, true);
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
#include <cerrno>
|
||||
#include <filesystem>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include "account_error_no.h"
|
||||
@ -31,7 +30,6 @@
|
||||
namespace OHOS {
|
||||
namespace AccountSA {
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS;
|
||||
using namespace AccountSA;
|
||||
@ -50,7 +48,6 @@ const gid_t ACCOUNT_GID = 3058;
|
||||
const uid_t ACCOUNT_UID = 3058;
|
||||
const std::int32_t ROOT_UID = 0;
|
||||
const std::int32_t TEST_UID = 1;
|
||||
const int32_t THREAD_NUM = 10;
|
||||
|
||||
const std::vector<std::string> CONSTANTS_VECTOR {
|
||||
"constraint.print",
|
||||
@ -2160,32 +2157,6 @@ HWTEST_F(OsAccountManagerServiceModuleTest, OsAccountManagerServiceModuleTest124
|
||||
osAccountManagerService_->SetOsAccountProfilePhoto(MAIN_ACCOUNT_ID, ""), ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetDefaultActivatedOsAccountM
|
||||
* @tc.desc: Test SetDefaultActivatedOsAccount Multithreading.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6AQUQ
|
||||
*/
|
||||
HWMTEST_F(OsAccountManagerServiceModuleTest, SetDefaultActivatedOsAccountM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
setuid(TEST_UID);
|
||||
EXPECT_EQ(ERR_ACCOUNT_COMMON_PERMISSION_DENIED,
|
||||
std::make_shared<OsAccountManagerService>()->SetDefaultActivatedOsAccount(MAIN_ACCOUNT_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetSubscribeRecordInfoM
|
||||
* @tc.desc: Test GetSubscribeRecordInfo Multithreading.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountManagerServiceModuleTest, GetSubscribeRecordInfoM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
setuid(TEST_UID);
|
||||
sptr<IRemoteObject> eventListener = nullptr;
|
||||
EXPECT_EQ(ERR_OK, std::make_shared<OsAccountManagerService>()->UnsubscribeOsAccount(eventListener));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerServiceModuleTest125
|
||||
* @tc.desc: test CreateOsAccount permission with EDM
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
@ -32,7 +31,6 @@
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace Security::AccessToken;
|
||||
@ -52,7 +50,6 @@ namespace {
|
||||
static bool g_fscryptEnable = false;
|
||||
const uid_t ACCOUNT_UID = 3058;
|
||||
const int32_t WAIT_TIME = 20;
|
||||
const int32_t THREAD_NUM = 10;
|
||||
}
|
||||
|
||||
class MockStorageMgrProxy : public StorageManager::IStorageManager {
|
||||
@ -506,22 +503,6 @@ HWTEST_F(AccountIamManagerTest, OpenSession001, TestSize.Level2)
|
||||
InnerAccountIAMManager::GetInstance().CloseSession(TEST_USER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OpenSessionM001
|
||||
* @tc.desc: Open Session.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(AccountIamManagerTest, OpenSessionM001, TestSize.Level2, THREAD_NUM)
|
||||
{
|
||||
std::vector<uint8_t> challenge;
|
||||
InnerAccountIAMManager::GetInstance().OpenSession(TEST_USER_ID, challenge); // 1111: invalid userid
|
||||
EXPECT_TRUE(challenge.size() != 0);
|
||||
|
||||
InnerAccountIAMManager::GetInstance().CloseSession(0);
|
||||
InnerAccountIAMManager::GetInstance().CloseSession(TEST_USER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AddCredential001
|
||||
* @tc.desc: Add credential.
|
||||
@ -613,32 +594,6 @@ HWTEST_F(AccountIamManagerTest, Cancel003, TestSize.Level0)
|
||||
EXPECT_EQ(ret, ResultCode::GENERAL_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CancelM001
|
||||
* @tc.desc: Cancel with .
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(AccountIamManagerTest, CancelM001, TestSize.Level0, THREAD_NUM)
|
||||
{
|
||||
InnerAccountIAMManager::GetInstance().SetState(TEST_USER_ID, AFTER_OPEN_SESSION);
|
||||
int32_t ret = InnerAccountIAMManager::GetInstance().Cancel(TEST_USER_ID);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CancelM002
|
||||
* @tc.desc: Cancel after add credential.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(AccountIamManagerTest, CancelM002, TestSize.Level0, THREAD_NUM)
|
||||
{
|
||||
InnerAccountIAMManager::GetInstance().SetState(TEST_USER_ID, AFTER_ADD_CRED);
|
||||
int32_t ret = InnerAccountIAMManager::GetInstance().Cancel(TEST_USER_ID);
|
||||
EXPECT_EQ(ret, ResultCode::GENERAL_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DelCred001
|
||||
* @tc.desc: Delete credential.
|
||||
@ -746,20 +701,6 @@ HWTEST_F(AccountIamManagerTest, GetState001, TestSize.Level0)
|
||||
EXPECT_NE(IDLE, InnerAccountIAMManager::GetInstance().GetState(TEST_USER_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetStateM001
|
||||
* @tc.desc: Get state multithread.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(AccountIamManagerTest, GetStateM001, TestSize.Level0, THREAD_NUM)
|
||||
{
|
||||
int32_t userId = 4444; // 1111: invalid userId
|
||||
EXPECT_EQ(IDLE, InnerAccountIAMManager::GetInstance().GetState(userId));
|
||||
|
||||
EXPECT_NE(IDLE, InnerAccountIAMManager::GetInstance().GetState(TEST_USER_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ActivateUserKey001
|
||||
* @tc.desc: ActivateUserKey.
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <thread>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include "account_error_no.h"
|
||||
#include "account_log_wrapper.h"
|
||||
#define private public
|
||||
@ -34,7 +33,6 @@ namespace OHOS {
|
||||
namespace AccountSA {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS;
|
||||
using namespace AccountSA;
|
||||
@ -50,7 +48,6 @@ const int32_t WAIT_TIME = 20;
|
||||
const std::vector<uint8_t> TEST_TOKEN = {0};
|
||||
const std::vector<uint8_t> TEST_PASSWORD = {0};
|
||||
std::shared_ptr<MockDomainPlugin> g_plugin = std::make_shared<MockDomainPlugin>();
|
||||
const int THREAD_NUM = 10;
|
||||
} // namespace
|
||||
|
||||
class DomainAccountManagerInnerServiceTest : public testing::Test {
|
||||
@ -661,102 +658,5 @@ HWTEST_F(DomainAccountManagerInnerServiceTest, DomainAccountManagerInnerServiceT
|
||||
EXPECT_EQ(instance->PluginGetAuthStatusInfo(info, authInfo), ERR_JS_CAPABILITY_NOT_SUPPORTED);
|
||||
EXPECT_EQ(instance->PluginGetDomainAccountInfo(options, info), ERR_JS_CAPABILITY_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/******
|
||||
* MultiThread test
|
||||
*************/
|
||||
|
||||
/**
|
||||
* @tc.name: DomainAccountManagerInnerServiceMultiThreadTest001
|
||||
* @tc.desc: Multithread LoaderLib.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI64KAM
|
||||
*/
|
||||
HWMTEST_F(DomainAccountManagerInnerServiceTest, DomainAccountManagerInnerServiceMultiThreadTest001, TestSize.Level0,
|
||||
THREAD_NUM)
|
||||
{
|
||||
InnerDomainAccountManager *instance = new (std::nothrow) InnerDomainAccountManager();
|
||||
instance->libHandle_ = nullptr;
|
||||
std::string rightPath = "/rightPath/";
|
||||
std::string rightSoName = "right.z.so";
|
||||
// LoadLib success
|
||||
instance->LoaderLib(rightPath, rightSoName);
|
||||
EXPECT_NE(instance->libHandle_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DomainAccountManagerInnerServiceMultiThreadTest002
|
||||
* @tc.desc: Multithread CloseLib.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI64KAM
|
||||
*/
|
||||
HWMTEST_F(DomainAccountManagerInnerServiceTest, DomainAccountManagerInnerServiceMultiThreadTest002, TestSize.Level0,
|
||||
THREAD_NUM)
|
||||
{
|
||||
InnerDomainAccountManager *instance = new (std::nothrow) InnerDomainAccountManager();
|
||||
instance->CloseLib();
|
||||
EXPECT_EQ(instance->libHandle_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DomainAccountManagerInnerServiceMultiThreadTest003
|
||||
* @tc.desc: AddServerConfig.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(DomainAccountManagerInnerServiceTest, DomainAccountManagerInnerServiceMultiThreadTest003, TestSize.Level0,
|
||||
THREAD_NUM)
|
||||
{
|
||||
InnerDomainAccountManager *instance = new (std::nothrow) InnerDomainAccountManager();
|
||||
DomainServerConfig config;
|
||||
std::string identifier;
|
||||
DomainAccountInfo info;
|
||||
std::string configId = STRING_TEST_NAME;
|
||||
std::vector<uint8_t> password;
|
||||
DomainAuthResult resultParcel;
|
||||
int32_t isVaild;
|
||||
GetAccessTokenOptions option;
|
||||
AuthStatusInfo authInfo;
|
||||
GetDomainAccountInfoOptions options;
|
||||
std::string rightPath = "/rightPath/";
|
||||
std::string rightSoName = "right.z.so";
|
||||
// LoadLib success
|
||||
instance->LoaderLib(rightPath, rightSoName);
|
||||
info.accountId_ = STRING_TEST_NAME;
|
||||
info.domain_ = STRING_TEST_NAME;
|
||||
info.accountName_ = STRING_TEST_NAME;
|
||||
info.serverConfigId_ = STRING_TEST_NAME;
|
||||
info.isAuthenticated = 0;
|
||||
|
||||
EXPECT_EQ(instance->PluginBindAccount(info, 100, resultParcel), ERR_OK);
|
||||
EXPECT_EQ(instance->PluginUnBindAccount(info, resultParcel), ERR_OK);
|
||||
password.push_back(0);
|
||||
EXPECT_EQ(instance->PluginIsAccountTokenValid(info, password, isVaild), ERR_OK);
|
||||
EXPECT_EQ(instance->PluginGetAccessToken(option, password, info, resultParcel), ERR_OK);
|
||||
option.callingUid_ = 1;
|
||||
EXPECT_EQ(instance->PluginGetAccessToken(option, password, info, resultParcel), ERR_OK);
|
||||
EXPECT_EQ(instance->PluginAuthWithPopup(info, resultParcel), ERR_OK);
|
||||
EXPECT_EQ(instance->PluginAuthToken(info, password, resultParcel), ERR_OK);
|
||||
EXPECT_EQ(instance->PluginGetAuthStatusInfo(info, authInfo), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DomainAccountManagerInnerServiceMultiThreadTest004
|
||||
* @tc.desc: MultiThread Test GetAuthStatusInfo with plugin is not nullptr.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI64KAM
|
||||
*/
|
||||
HWMTEST_F(DomainAccountManagerInnerServiceTest, DomainAccountManagerInnerServiceMultiThreadTest004, TestSize.Level1,
|
||||
THREAD_NUM)
|
||||
{
|
||||
DomainAccountInfo domainInfo;
|
||||
domainInfo.accountName_ = TEST_DOMAIN_ACCOUNT_NAME;
|
||||
domainInfo.domain_ = TEST_DOMAIN;
|
||||
domainInfo.accountId_ = TEST_ACCOUNT_ID;
|
||||
sptr<DomainAccountPluginService> pluginService = new (std::nothrow) DomainAccountPluginService(g_plugin);
|
||||
ASSERT_NE(pluginService, nullptr);
|
||||
InnerDomainAccountManager::GetInstance().plugin_ = pluginService;
|
||||
EXPECT_EQ(InnerDomainAccountManager::GetInstance().GetAuthStatusInfo(domainInfo, nullptr), ERR_OK);
|
||||
}
|
||||
} // namespace AccountSA
|
||||
} // namespace OHOS
|
@ -18,7 +18,6 @@
|
||||
#include <dirent.h>
|
||||
#include <fstream>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
#include <sys/stat.h>
|
||||
@ -35,7 +34,6 @@
|
||||
namespace OHOS {
|
||||
namespace AccountSA {
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS;
|
||||
using namespace AccountSA;
|
||||
@ -48,7 +46,6 @@ const int64_t STRING_TEST_USER_SHELLNUMBER = 1000;
|
||||
const int32_t INVALID_TYPE = 100000;
|
||||
const gid_t ACCOUNT_GID = 3058;
|
||||
const uid_t ACCOUNT_UID = 3058;
|
||||
const int32_t THREAD_NUM = 10;
|
||||
const std::string STRING_PHOTO =
|
||||
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gAUU29mdHdhcmU6IFNuaXBhc3Rl/"
|
||||
"9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/"
|
||||
@ -713,99 +710,5 @@ HWTEST_F(OsAccountControlFileManagerTest, OsAccountControlFileManagerCovTest030,
|
||||
ErrCode ret = g_controlManager->GetPhotoById(id, photo);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetSerialNumberM
|
||||
* @tc.desc: Test GetSerialNumber Multithreading
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000GGV0U
|
||||
*/
|
||||
HWMTEST_F(OsAccountControlFileManagerTest, GetSerialNumberM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
int64_t serialNumber1;
|
||||
int64_t serialNumber2;
|
||||
EXPECT_EQ(g_controlManager->GetSerialNumber(serialNumber1), ERR_OK);
|
||||
EXPECT_EQ(g_controlManager->GetSerialNumber(serialNumber2), ERR_OK);
|
||||
EXPECT_GT(serialNumber2, serialNumber1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetAllowCreateIdM
|
||||
* @tc.desc: Test GetAllowCreateId Multithreading
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000GGV0U
|
||||
*/
|
||||
HWMTEST_F(OsAccountControlFileManagerTest, GetAllowCreateIdM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
int id1 = 0;
|
||||
int id2 = 0;
|
||||
EXPECT_EQ(g_controlManager->GetAllowCreateId(id1), ERR_OK);
|
||||
EXPECT_EQ(g_controlManager->GetAllowCreateId(id2), ERR_OK);
|
||||
bool ret = false;
|
||||
if (id2 > id1) {
|
||||
ret = true;
|
||||
}
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SaveBaseOAConstraintsToFileM
|
||||
* @tc.desc: Test SaveBaseOAConstraintsToFile Multithreading
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountControlFileManagerTest, SaveBaseOAConstraintsToFileM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
Json baseOAConstraintsJson;
|
||||
ErrCode ret = g_controlManager->GetBaseOAConstraintsFromFile(baseOAConstraintsJson);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
ret = g_controlManager->SaveBaseOAConstraintsToFile(baseOAConstraintsJson);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SaveAccountListToFileM
|
||||
* @tc.desc: Test SaveBaseOAConstraintsToFile Multithreading
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountControlFileManagerTest, SaveAccountListToFileM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
Json accountListJson;
|
||||
ErrCode ret = g_controlManager->GetAccountListFromFile(accountListJson);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
ret = g_controlManager->SaveAccountListToFile(accountListJson);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SaveGlobalOAConstraintsToFileM
|
||||
* @tc.desc: Test SaveGlobalOAConstraintsToFile Multithreading
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountControlFileManagerTest, SaveGlobalOAConstraintsToFileM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
g_controlManager->BuildAndSaveGlobalOAConstraintsJsonFile();
|
||||
bool ret = false;
|
||||
ret = g_controlManager->accountFileOperator_
|
||||
->IsJsonFileReady(Constants::GLOBAL_OSACCOUNT_CONSTRAINTS_JSON_PATH);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SaveSpecificOAConstraintsToFileM
|
||||
* @tc.desc: Test SaveSpecificOAConstraintsToFile Multithreading
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountControlFileManagerTest, SaveSpecificOAConstraintsToFileM, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
g_controlManager->BuildAndSaveSpecificOAConstraintsJsonFile();
|
||||
bool ret = false;
|
||||
ret = g_controlManager->accountFileOperator_
|
||||
->IsJsonFileReady(Constants::SPECIFIC_OSACCOUNT_CONSTRAINTS_JSON_PATH);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
} // namespace AccountSA
|
||||
} // namespace OHOS
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include <filesystem>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <map>
|
||||
|
||||
#include "account_error_no.h"
|
||||
@ -44,9 +43,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccountSA {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS::AccountSA;
|
||||
using namespace OHOS;
|
||||
using namespace AccountSA;
|
||||
@ -66,11 +63,6 @@ const int TEST_USER_ID10 = 10;
|
||||
const int TEST_USER_ID55 = 55;
|
||||
const int TEST_USER_ID100 = 100;
|
||||
const int TEST_USER_ID108 = 108;
|
||||
const int THREAD_NUM = 10;
|
||||
const std::int32_t MAIN_ACCOUNT_ID = 100;
|
||||
|
||||
OsAccountInfo osAccountInfo;
|
||||
const std::string STRING_PHOTO_MAX(1024 * 1024, '1'); // length 1024*1024*10+1
|
||||
|
||||
const std::string STRING_TEST_NAME = "test_account_name";
|
||||
const std::string STRING_DOMAIN_NAME_OUT_OF_RANGE(200, '1'); // length 200
|
||||
@ -1430,215 +1422,5 @@ HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountPluginMockTest001, TestSize.Leve
|
||||
|
||||
innerMgrService_->pluginManager_.CloseLib();
|
||||
}
|
||||
|
||||
/******
|
||||
* MultiThread test
|
||||
*************/
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread001
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread001, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
bool ret = false;
|
||||
IInnerOsAccountManager::GetInstance().RemoveLocalIdToOperating(TEST_USER_ID10);
|
||||
ret = IInnerOsAccountManager::GetInstance().CheckAndAddLocalIdOperating(TEST_USER_ID10);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread002
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread002, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
bool ret = false;
|
||||
IInnerOsAccountManager::GetInstance().PushIdIntoActiveList(TEST_USER_ID10);
|
||||
ret = IInnerOsAccountManager::GetInstance().IsOsAccountIDInActiveList(TEST_USER_ID10);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread003
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread003, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
bool ret = false;
|
||||
IInnerOsAccountManager::GetInstance().EraseIdFromActiveList(TEST_USER_ID10);
|
||||
ret = IInnerOsAccountManager::GetInstance().IsOsAccountIDInActiveList(TEST_USER_ID10);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread004
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWMTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread004, TestSize.Level1, THREAD_NUM)
|
||||
{
|
||||
std::vector<int32_t> activatedIds;
|
||||
IInnerOsAccountManager::GetInstance().CopyFromActiveList(activatedIds);
|
||||
EXPECT_EQ(activatedIds, IInnerOsAccountManager::GetInstance().activeAccountId_);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread005
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread005, TestSize.Level1)
|
||||
{
|
||||
std::string privateTestName = "PrivateTestName001";
|
||||
ASSERT_EQ(
|
||||
IInnerOsAccountManager::GetInstance().CreateOsAccount(privateTestName, OsAccountType::PRIVATE, osAccountInfo),
|
||||
ERR_OK);
|
||||
GTEST_RUN_TASK([]() {
|
||||
std::string privateTestName = "PrivateTestName001";
|
||||
EXPECT_EQ(IInnerOsAccountManager::GetInstance().SetOsAccountName(osAccountInfo.GetLocalId(), privateTestName),
|
||||
ERR_OK);
|
||||
});
|
||||
|
||||
EXPECT_EQ(IInnerOsAccountManager::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId()), ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread006
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread006, TestSize.Level1)
|
||||
{
|
||||
std::string privateTestName = "PrivateTestName001";
|
||||
ASSERT_EQ(
|
||||
IInnerOsAccountManager::GetInstance().CreateOsAccount(privateTestName, OsAccountType::GUEST, osAccountInfo),
|
||||
ERR_OK);
|
||||
GTEST_RUN_TASK([]() {
|
||||
EXPECT_EQ(IInnerOsAccountManager::GetInstance().SetOsAccountProfilePhoto(osAccountInfo.GetLocalId(),
|
||||
STRING_PHOTO_MAX),
|
||||
ERR_OK);
|
||||
});
|
||||
|
||||
ASSERT_EQ(IInnerOsAccountManager::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId()), ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread007
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread007, TestSize.Level1)
|
||||
{
|
||||
ErrCode ret = IInnerOsAccountManager::GetInstance().CreateOsAccount("OsAccountInnerAccmgrMockTestMultiThread007",
|
||||
OsAccountType::NORMAL, osAccountInfo);
|
||||
ASSERT_EQ(ret, ERR_OK);
|
||||
GTEST_RUN_TASK([]() {
|
||||
// login
|
||||
int localId = osAccountInfo.GetLocalId();
|
||||
EXPECT_EQ(IInnerOsAccountManager::GetInstance().SetOsAccountIsLoggedIn(localId, true), ERR_OK);
|
||||
});
|
||||
|
||||
IInnerOsAccountManager::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread008
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread008, TestSize.Level1)
|
||||
{
|
||||
ErrCode ret = IInnerOsAccountManager::GetInstance().CreateOsAccount("OsAccountInnerAccmgrMockTestMultiThread008",
|
||||
OsAccountType::NORMAL, osAccountInfo);
|
||||
ASSERT_EQ(ret, ERR_OK);
|
||||
GTEST_RUN_TASK([]() {
|
||||
// login
|
||||
int localId = osAccountInfo.GetLocalId();
|
||||
EXPECT_EQ(IInnerOsAccountManager::GetInstance().SetOsAccountCredentialId(localId, true), ERR_OK);
|
||||
});
|
||||
|
||||
IInnerOsAccountManager::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread009
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread009, TestSize.Level1)
|
||||
{
|
||||
ErrCode ret = IInnerOsAccountManager::GetInstance().CreateOsAccount("OsAccountInnerAccmgrMockTestMultiThread009",
|
||||
OsAccountType::NORMAL, osAccountInfo);
|
||||
ASSERT_EQ(ret, ERR_OK);
|
||||
GTEST_RUN_TASK([]() {
|
||||
// login
|
||||
int localId = osAccountInfo.GetLocalId();
|
||||
EXPECT_EQ(ERR_OK, IInnerOsAccountManager::GetInstance().UpdateAccountToBackground(localId));
|
||||
});
|
||||
|
||||
IInnerOsAccountManager::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread010
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread010, TestSize.Level1)
|
||||
{
|
||||
ErrCode ret = IInnerOsAccountManager::GetInstance().CreateOsAccount("OsAccountInnerAccmgrMockTestMultiThread010",
|
||||
OsAccountType::NORMAL, osAccountInfo);
|
||||
ASSERT_EQ(ret, ERR_OK);
|
||||
GTEST_RUN_TASK([]() {
|
||||
// login
|
||||
EXPECT_EQ(ERR_OK, IInnerOsAccountManager::GetInstance().UpdateAccountToForeground(0, osAccountInfo));
|
||||
});
|
||||
|
||||
IInnerOsAccountManager::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread011
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread011, TestSize.Level1)
|
||||
{
|
||||
GTEST_RUN_TASK([]() {
|
||||
ErrCode ret = IInnerOsAccountManager::GetInstance().DeactivateOsAccountById(Constants::ADMIN_LOCAL_ID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: OsAccountInnerAccmgrMockTestMultiThread012
|
||||
* @tc.desc: coverage test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountInnerAccmgrMockTest, OsAccountInnerAccmgrMockTestMultiThread012, TestSize.Level1)
|
||||
{
|
||||
GTEST_RUN_TASK([]() {
|
||||
int id;
|
||||
ErrCode ret = IInnerOsAccountManager::GetInstance().GetDefaultActivatedOsAccount(id);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_EQ(id, MAIN_ACCOUNT_ID);
|
||||
});
|
||||
}
|
||||
} // namespace AccountSA
|
||||
} // namespace OHOS
|
||||
|
@ -29,23 +29,7 @@ using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
const int ENUM_MAX = 4;
|
||||
const uint32_t TOKEN_LEN = 10;
|
||||
const std::u16string ACCOUNT_TOKEN = u"ohos.accountfwk.IDomainAccount";
|
||||
|
||||
class TestGetDomainAccountInfoCallback : public DomainAccountCallbackStub {
|
||||
public:
|
||||
TestGetDomainAccountInfoCallback(){};
|
||||
virtual ~TestGetDomainAccountInfoCallback();
|
||||
void OnResult(const int32_t errCode, Parcel &parcel) override;
|
||||
};
|
||||
|
||||
TestGetDomainAccountInfoCallback::~TestGetDomainAccountInfoCallback() {}
|
||||
|
||||
void TestGetDomainAccountInfoCallback::OnResult(const int32_t errCode, Parcel &parcel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool ProcAddServerConfigStubFuzzTest(const uint8_t* data, size_t size)
|
||||
@ -66,193 +50,6 @@ bool ProcAddServerConfigStubFuzzTest(const uint8_t* data, size_t size)
|
||||
uint32_t code = static_cast<uint32_t>(DomainAccountInterfaceCode::ADD_SERVER_CONFIG);
|
||||
auto domainAccountService = std::make_shared<DomainAccountManagerService>();
|
||||
domainAccountService->OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetAccountStatusStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DomainAccountInfo info;
|
||||
FuzzData fuzzData(data, size);
|
||||
info.domain_ = fuzzData.GenerateRandomString();
|
||||
info.accountName_ = fuzzData.GenerateRandomString();
|
||||
info.accountId_ = fuzzData.GenerateRandomString();
|
||||
info.isAuthenticated = fuzzData.GenerateRandomBool();
|
||||
info.serverConfigId_ = fuzzData.GenerateRandomString();
|
||||
int typeNumber = fuzzData.GetData<int>() % ENUM_MAX;
|
||||
info.status_ = static_cast<DomainAccountStatus>(typeNumber);
|
||||
|
||||
if (!dataTemp.WriteParcelable(&info)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
uint32_t code = static_cast<uint32_t>(DomainAccountInterfaceCode::DOMAIN_ACCOUNT_STATUS_ENQUIRY);
|
||||
auto domainAccountService = std::make_shared<DomainAccountManagerService>();
|
||||
domainAccountService->OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetDomainAccessTokenStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DomainAccountInfo info;
|
||||
FuzzData fuzzData(data, size);
|
||||
info.domain_ = fuzzData.GenerateRandomString();
|
||||
info.accountName_ = fuzzData.GenerateRandomString();
|
||||
info.accountId_ = fuzzData.GenerateRandomString();
|
||||
info.isAuthenticated = fuzzData.GenerateRandomBool();
|
||||
info.serverConfigId_ = fuzzData.GenerateRandomString();
|
||||
int typeNumber = fuzzData.GetData<int>() % ENUM_MAX;
|
||||
info.status_ = static_cast<DomainAccountStatus>(typeNumber);
|
||||
|
||||
if (!dataTemp.WriteParcelable(&info)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AAFwk::WantParams workParams;
|
||||
if (!dataTemp.WriteParcelable(&workParams)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto testCallback = new TestGetDomainAccountInfoCallback();
|
||||
|
||||
if (testCallback == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dataTemp.WriteRemoteObject(testCallback->AsObject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
uint32_t code = static_cast<uint32_t>(DomainAccountInterfaceCode::DOMAIN_GET_ACCESS_TOKEN);
|
||||
auto domainAccountService = std::make_shared<DomainAccountManagerService>();
|
||||
domainAccountService->OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcRegisterAccountStatusListenerStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto testCallback = new TestGetDomainAccountInfoCallback();
|
||||
|
||||
if (testCallback == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dataTemp.WriteRemoteObject(testCallback->AsObject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
uint32_t code = static_cast<uint32_t>(DomainAccountInterfaceCode::DOMAIN_ACCOUNT_STATUS_LISTENER_REGISTER);
|
||||
auto domainAccountService = std::make_shared<DomainAccountManagerService>();
|
||||
domainAccountService->OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcUnregisterAccountStatusListenerStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto testCallback = new TestGetDomainAccountInfoCallback();
|
||||
|
||||
if (testCallback == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dataTemp.WriteRemoteObject(testCallback->AsObject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
uint32_t code = static_cast<uint32_t>(DomainAccountInterfaceCode::DOMAIN_ACCOUNT_STATUS_LISTENER_UNREGISTER);
|
||||
auto domainAccountService = std::make_shared<DomainAccountManagerService>();
|
||||
domainAccountService->OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcUpdateAccountTokenStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DomainAccountInfo info;
|
||||
FuzzData fuzzData(data, size);
|
||||
info.domain_ = fuzzData.GenerateRandomString();
|
||||
info.accountName_ = fuzzData.GenerateRandomString();
|
||||
info.accountId_ = fuzzData.GenerateRandomString();
|
||||
info.isAuthenticated = fuzzData.GenerateRandomBool();
|
||||
info.serverConfigId_ = fuzzData.GenerateRandomString();
|
||||
int typeNumber = fuzzData.GetData<int>() % ENUM_MAX;
|
||||
info.status_ = static_cast<DomainAccountStatus>(typeNumber);
|
||||
|
||||
if (!dataTemp.WriteParcelable(&info)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> buffer;
|
||||
for (uint32_t i = 0; i < TOKEN_LEN; i++) {
|
||||
uint8_t bit = fuzzData.GetData<uint8_t>();
|
||||
buffer.emplace_back(bit);
|
||||
}
|
||||
if (!dataTemp.WriteUInt8Vector(buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
uint32_t code = static_cast<uint32_t>(DomainAccountInterfaceCode::DOMAIN_UPDATE_ACCOUNT_TOKEN);
|
||||
auto domainAccountService = std::make_shared<DomainAccountManagerService>();
|
||||
domainAccountService->OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -262,10 +59,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::ProcAddServerConfigStubFuzzTest(data, size);
|
||||
OHOS::ProcGetAccountStatusStubFuzzTest(data, size);
|
||||
OHOS::ProcGetDomainAccessTokenStubFuzzTest(data, size);
|
||||
OHOS::ProcRegisterAccountStatusListenerStubFuzzTest(data, size);
|
||||
OHOS::ProcUnregisterAccountStatusListenerStubFuzzTest(data, size);
|
||||
OHOS::ProcUpdateAccountTokenStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#define private public
|
||||
#include "account_iam_client.h"
|
||||
#include "account_iam_mgr_proxy.h"
|
||||
#undef private
|
||||
#include "fuzz_data.h"
|
||||
|
||||
|
||||
@ -36,156 +33,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class MockPreRemoteAuthCallback : public OHOS::AccountSA::PreRemoteAuthCallback {
|
||||
public:
|
||||
void OnResult(int32_t result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
virtual ~MockPreRemoteAuthCallback() {}
|
||||
};
|
||||
class PreRemoteAuthCallbackMockTest final : public OHOS::AccountSA::PreRemoteAuthCallback {
|
||||
public:
|
||||
void OnResult(int32_t result) override
|
||||
{
|
||||
result_ = result;
|
||||
}
|
||||
int32_t result_;
|
||||
};
|
||||
|
||||
class MockIDMCallback1 : public OHOS::AccountSA::IDMCallback {
|
||||
public:
|
||||
virtual ~MockIDMCallback1() {}
|
||||
void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override
|
||||
{
|
||||
return;
|
||||
}
|
||||
void OnResult(int32_t result, const Attributes &extraInfo) override
|
||||
{
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
class MockGetEnrolledIdCallback final : public GetEnrolledIdCallback {
|
||||
public:
|
||||
void OnEnrolledId(int32_t result, uint64_t enrolledId) override
|
||||
{
|
||||
result_ = result;
|
||||
return;
|
||||
}
|
||||
|
||||
public:
|
||||
int32_t result_ = -1;
|
||||
};
|
||||
|
||||
class MockIInputer : public OHOS::AccountSA::IInputer {
|
||||
public:
|
||||
virtual ~MockIInputer() {}
|
||||
void OnGetData(int32_t authSubType, std::vector<uint8_t> challenge,
|
||||
std::shared_ptr<IInputerData> inputerData) override
|
||||
{
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
namespace OHOS {
|
||||
bool GetCredentialInfoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
bool GetCredentialInfoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
AuthType authType = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::RECOVERY_KEY);
|
||||
std::shared_ptr<GetCredInfoCallback> callback = make_shared<MockIDMCallback>();
|
||||
int32_t result = AccountIAMClient::GetInstance().GetCredentialInfo(userId, authType, callback);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
AuthType authType = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::RECOVERY_KEY);
|
||||
std::shared_ptr<GetCredInfoCallback> callback = make_shared<MockIDMCallback>();
|
||||
int32_t result = AccountIAMClient::GetInstance().GetCredentialInfo(userId, authType, callback);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool StartDomainAuthFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
std::shared_ptr<IDMCallback> callback = make_shared<MockIDMCallback1>();
|
||||
int32_t result = AccountIAMClient::GetInstance().StartDomainAuth(userId, callback);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool PrepareRemoteAuthFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
std::string remoteNetworkId(fuzzData.GenerateRandomString());
|
||||
std::shared_ptr<PreRemoteAuthCallback> callback = make_shared<MockPreRemoteAuthCallback>();
|
||||
int32_t result = AccountIAMClient::GetInstance().PrepareRemoteAuth(remoteNetworkId, callback);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool GetEnrolledIdFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
AuthType authType = static_cast<AuthType>(fuzzData.GenerateRandomEnmu(IAMAuthType::TYPE_END));
|
||||
auto callback = std::make_shared<MockGetEnrolledIdCallback>();
|
||||
AccountIAMClient::GetInstance().GetEnrolledId(userId, authType, callback);
|
||||
return callback->result_ == ERR_OK;
|
||||
}
|
||||
|
||||
bool RegisterPINInputerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<IInputer> inputer = make_shared<MockIInputer>();
|
||||
int32_t result = AccountIAMClient::GetInstance().RegisterPINInputer(inputer);
|
||||
result = AccountIAMClient::GetInstance().RegisterDomainInputer(inputer);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool OpenSessionFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
std::shared_ptr<AccountIAMMgrProxy> accountIAMMgrProxy = std::make_shared<AccountIAMMgrProxy>(nullptr);
|
||||
std::vector<uint8_t> challenge;
|
||||
int32_t result = accountIAMMgrProxy->OpenSession(userId, challenge);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool CloseSessionFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
std::shared_ptr<AccountIAMMgrProxy> accountIAMMgrProxy = std::make_shared<AccountIAMMgrProxy>(nullptr);
|
||||
int32_t result = accountIAMMgrProxy->CloseSession(userId);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool CancelFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
std::shared_ptr<AccountIAMMgrProxy> accountIAMMgrProxy = std::make_shared<AccountIAMMgrProxy>(nullptr);
|
||||
int32_t result = accountIAMMgrProxy->Cancel(userId);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
@ -193,12 +50,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::GetCredentialInfoFuzzTest(data, size);
|
||||
OHOS::StartDomainAuthFuzzTest(data, size);
|
||||
OHOS::PrepareRemoteAuthFuzzTest(data, size);
|
||||
OHOS::GetEnrolledIdFuzzTest(data, size);
|
||||
OHOS::RegisterPINInputerTest(data, size);
|
||||
OHOS::OpenSessionFuzzTest(data, size);
|
||||
OHOS::CloseSessionFuzzTest(data, size);
|
||||
OHOS::CancelFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ ohos_fuzztest("GetOhosAccountInfoFuzzTest") {
|
||||
include_dirs = [
|
||||
"${innerkits_native_path}/include",
|
||||
"${innerkits_path}/include",
|
||||
"${os_account_path}/test/fuzztest/ohosaccount/common",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
|
@ -18,124 +18,21 @@
|
||||
#include "account_proxy.h"
|
||||
#include "account_info.h"
|
||||
#include "account_log_wrapper.h"
|
||||
#include "distributed_account_subscribe_callback.h"
|
||||
#include "fuzz_data.h"
|
||||
#include "ohos_account_kits.h"
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
class MockDistributedAccountSubscribeCallback final : public DistributedAccountSubscribeCallback {
|
||||
public:
|
||||
explicit MockDistributedAccountSubscribeCallback()
|
||||
{}
|
||||
|
||||
void OnAccountsChanged(const DistributedAccountEventData &eventData)
|
||||
{}
|
||||
};
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
static constexpr uint32_t OHOS_ACCOUNT_STATE_NUM = 5;
|
||||
}
|
||||
bool GetOhosAccountInfoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
int32_t result;
|
||||
OhosAccountInfo testOhosAccountInfo;
|
||||
result = OhosAccountKits::GetInstance().GetOhosAccountInfo(testOhosAccountInfo);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool GetOhosAccountInfoByUserIdFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
bool GetOhosAccountInfoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
int32_t result;
|
||||
OhosAccountInfo testOhosAccountInfo;
|
||||
result = OhosAccountKits::GetInstance().GetOhosAccountInfo(testOhosAccountInfo);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
int32_t result;
|
||||
OhosAccountInfo testOhosAccountInfo;
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
result = OhosAccountKits::GetInstance().GetOhosAccountInfoByUserId(userId, testOhosAccountInfo);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool SubscribeDistributedAccountEventFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
int32_t result;
|
||||
FuzzData fuzzData(data, size);
|
||||
auto loginSubscribeCallback = std::make_shared<MockDistributedAccountSubscribeCallback>();
|
||||
DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type = static_cast<DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE>(
|
||||
fuzzData.GetData<int32_t>() % 4);
|
||||
result = OhosAccountKits::GetInstance().SubscribeDistributedAccountEvent(type, loginSubscribeCallback);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool UnsubscribeDistributedAccountEventFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
int32_t result;
|
||||
FuzzData fuzzData(data, size);
|
||||
auto loginSubscribeCallback = std::make_shared<MockDistributedAccountSubscribeCallback>();
|
||||
DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type = static_cast<DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE>(
|
||||
fuzzData.GetData<int32_t>() % 4);
|
||||
result = OhosAccountKits::GetInstance().UnsubscribeDistributedAccountEvent(type, loginSubscribeCallback);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool SetOhosAccountInfoByUserIdFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<AccountProxy> accountProxy = std::make_shared<AccountProxy>(nullptr);
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
OhosAccountInfo testOhosAccountInfo(
|
||||
fuzzData.GenerateRandomString(),
|
||||
fuzzData.GenerateRandomString(),
|
||||
fuzzData.GetData<int32_t>() % OHOS_ACCOUNT_STATE_NUM - 1
|
||||
);
|
||||
std::string testEventStr(fuzzData.GenerateRandomString());
|
||||
int32_t result = accountProxy->SetOhosAccountInfoByUserId(userId, testOhosAccountInfo, testEventStr);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool GetOhosAccountInfoByUserIdProxyFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<AccountProxy> accountProxy = std::make_shared<AccountProxy>(nullptr);
|
||||
OhosAccountInfo testOhosAccountInfo;
|
||||
int32_t result = accountProxy->QueryOhosAccountInfo(testOhosAccountInfo);
|
||||
result = accountProxy->GetOhosAccountInfo(testOhosAccountInfo);
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
result = accountProxy->GetOhosAccountInfoByUserId(userId, testOhosAccountInfo);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool QueryOhosAccountInfoByUserIdProxyFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<AccountProxy> accountProxy = std::make_shared<AccountProxy>(nullptr);
|
||||
OhosAccountInfo testOhosAccountInfo;
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
int32_t accountId = 0;
|
||||
int32_t result = accountProxy->QueryDeviceAccountId(accountId);
|
||||
result = accountProxy->QueryOhosAccountInfoByUserId(userId, testOhosAccountInfo);
|
||||
return result == ERR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
@ -143,12 +40,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::GetOhosAccountInfoFuzzTest(data, size);
|
||||
OHOS::GetOhosAccountInfoByUserIdFuzzTest(data, size);
|
||||
OHOS::SubscribeDistributedAccountEventFuzzTest(data, size);
|
||||
OHOS::UnsubscribeDistributedAccountEventFuzzTest(data, size);
|
||||
OHOS::SetOhosAccountInfoByUserIdFuzzTest(data, size);
|
||||
OHOS::GetOhosAccountInfoByUserIdProxyFuzzTest(data, size);
|
||||
OHOS::QueryOhosAccountInfoByUserIdProxyFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "createosaccount_fuzzer.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "os_account_manager.h"
|
||||
@ -115,74 +114,6 @@ bool CreateOsAccountForDomainFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool UpdateOsAccountWithFullInfoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
bool result = false;
|
||||
if ((data != nullptr) && (size != 0)) {
|
||||
FuzzData fuzzData(data, size);
|
||||
OsAccountInfo osAccountInfo;
|
||||
osAccountInfo.SetLocalName(fuzzData.GenerateRandomString());
|
||||
osAccountInfo.SetLocalId(fuzzData.GetData<int64_t>());
|
||||
osAccountInfo.SetSerialNumber(fuzzData.GetData<int64_t>());
|
||||
osAccountInfo.SetCreateTime(fuzzData.GetData<int64_t>());
|
||||
osAccountInfo.SetLastLoginTime(fuzzData.GetData<int64_t>());
|
||||
result = OsAccountManager::UpdateOsAccountWithFullInfo(osAccountInfo);
|
||||
if (result == ERR_OK) {
|
||||
ACCOUNT_LOGI("CreateOsAccountFuzzTest RemoveOsAccount");
|
||||
OsAccountManager::RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CreateOsAccountWithFullInfoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
bool result = false;
|
||||
if ((data != nullptr) && (size != 0)) {
|
||||
FuzzData fuzzData(data, size);
|
||||
OsAccountInfo osAccountInfo;
|
||||
osAccountInfo.SetLocalName(fuzzData.GenerateRandomString());
|
||||
osAccountInfo.SetLocalId(fuzzData.GetData<int64_t>());
|
||||
osAccountInfo.SetSerialNumber(fuzzData.GetData<int64_t>());
|
||||
osAccountInfo.SetCreateTime(fuzzData.GetData<int64_t>());
|
||||
osAccountInfo.SetLastLoginTime(fuzzData.GetData<int64_t>());
|
||||
result = OsAccountManager::CreateOsAccountWithFullInfo(osAccountInfo);
|
||||
if (result == ERR_OK) {
|
||||
ACCOUNT_LOGI("CreateOsAccountFuzzTest RemoveOsAccount");
|
||||
OsAccountManager::RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CovWithoutParamFunctionFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
bool result = false;
|
||||
if ((data != nullptr) && (size != 0)) {
|
||||
std::string nameStr;
|
||||
std::vector<ForegroundOsAccount> accounts;
|
||||
std::vector<int32_t> localIds;
|
||||
OsAccountManager::GetOsAccountShortName(nameStr);
|
||||
OsAccountManager::GetOsAccountName(nameStr);
|
||||
OsAccountManager::GetForegroundOsAccounts(accounts);
|
||||
OsAccountManager::GetBackgroundOsAccountLocalIds(localIds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CheckOsAccountConstraintEnabledFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
bool result = false;
|
||||
if ((data != nullptr) && (size != 0)) {
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
std::string constraintStr(fuzzData.GenerateRandomString());
|
||||
bool isEnabled = false;
|
||||
result = OsAccountManager::CheckOsAccountConstraintEnabled(userId, constraintStr, isEnabled);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
/* Fuzzer entry point */
|
||||
@ -192,10 +123,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
OHOS::CreateOsAccountWithShortNameFuzzTest(data, size);
|
||||
OHOS::CreateOsAccountFuzzTest(data, size);
|
||||
OHOS::CreateOsAccountForDomainFuzzTest(data, size);
|
||||
OHOS::UpdateOsAccountWithFullInfoFuzzTest(data, size);
|
||||
OHOS::CreateOsAccountWithFullInfoFuzzTest(data, size);
|
||||
OHOS::CovWithoutParamFunctionFuzzTest(data, size);
|
||||
OHOS::CheckOsAccountConstraintEnabledFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@ namespace OHOS {
|
||||
FuzzData fuzzData(data, size);
|
||||
int32_t testId = fuzzData.GetData<int32_t>();
|
||||
result = OsAccountManager::DeactivateOsAccount(testId);
|
||||
OsAccountManager::DeactivateAllOsAccounts();
|
||||
}
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
@ -26,9 +26,6 @@ using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
const int ENUM_TYPE_MAX = 5;
|
||||
const int PRIVATE_NUMBER = 3;
|
||||
const int END_NUMBER = 4;
|
||||
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
|
||||
bool ActivateOsAccountStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
@ -46,342 +43,14 @@ bool ActivateOsAccountStubFuzzTest(const uint8_t *data, size_t size)
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
|
||||
osAccountManagerService_ ->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::ACTIVATE_OS_ACCOUNT), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcCreateOsAccountWithFullInfoStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
|
||||
OsAccountInfo osAccountInfo;
|
||||
osAccountInfo.SetLocalId(fuzzData.GetData<int>());
|
||||
osAccountInfo.SetLocalName(fuzzData.GenerateRandomString());
|
||||
osAccountInfo.SetShortName(fuzzData.GenerateRandomString());
|
||||
int typeNumber = fuzzData.GetData<int>() % ENUM_TYPE_MAX;
|
||||
if (typeNumber == PRIVATE_NUMBER) {
|
||||
osAccountInfo.SetType(PRIVATE);
|
||||
} else if (typeNumber == END_NUMBER) {
|
||||
osAccountInfo.SetType(END);
|
||||
} else {
|
||||
OsAccountType testType = static_cast<OsAccountType>(typeNumber);
|
||||
osAccountInfo.SetType(testType);
|
||||
}
|
||||
osAccountInfo.SetSerialNumber(fuzzData.GetData<int64_t>());
|
||||
|
||||
if (!datas.WriteParcelable(&osAccountInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_WITH_FULL_INFO), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcDeactivateAllOsAccountsStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::DEACTIVATE_ALL_OS_ACCOUNTS), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetBackgroundOsAccountLocalIdsStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_BACKGROUND_OS_ACCOUNT_LOCAL_IDS), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetCreatedOsAccountNumFromDatabaseStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
if (!datas.WriteString(fuzzData.GenerateRandomString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_CREATED_OS_ACCOUNT_NUM_FROM_DATABASE), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetDefaultActivatedOsAccountStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_DEFAULT_ACTIVATED_OS_ACCOUNT), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetForegroundOsAccountsStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_FOREGROUND_OS_ACCOUNTS), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetMaxAllowCreateIdFromDatabaseStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
if (!datas.WriteString(fuzzData.GenerateRandomString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_MAX_ALLOW_CREATE_ID_FROM_DATABASE), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetOsAccountFromDatabaseStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
if (!datas.WriteString(fuzzData.GenerateRandomString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!datas.WriteInt32(fuzzData.GetData<int32_t>())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_OS_ACCOUNT_FROM_DATABASE), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetOsAccountListFromDatabaseStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
if (!datas.WriteString(fuzzData.GenerateRandomString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_OS_ACCOUNT_LIST_FROM_DATABASE), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetOsAccountShortNameStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_OS_ACCOUNT_SHORT_NAME), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetOsAccountTypeFromProcessStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_OS_ACCOUNT_TYPE_FROM_PROCESS), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcGetSerialNumberFromDatabaseStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
if (!datas.WriteString(fuzzData.GenerateRandomString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::GET_SERIAL_NUM_FROM_DATABASE), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcIsCurrentOsAccountVerifiedStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::IS_CURRENT_OS_ACCOUNT_VERIFIED), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcIsMultiOsAccountEnableStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::IS_MULTI_OS_ACCOUNT_ENABLE), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
@ -389,19 +58,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::ActivateOsAccountStubFuzzTest(data, size);
|
||||
OHOS::ProcGetCreatedOsAccountNumFromDatabaseStubFuzzTest(data, size);
|
||||
OHOS::ProcDeactivateAllOsAccountsStubFuzzTest(data, size);
|
||||
OHOS::ProcCreateOsAccountWithFullInfoStubFuzzTest(data, size);
|
||||
OHOS::ProcGetBackgroundOsAccountLocalIdsStubFuzzTest(data, size);
|
||||
OHOS::ProcGetDefaultActivatedOsAccountStubFuzzTest(data, size);
|
||||
OHOS::ProcGetForegroundOsAccountsStubFuzzTest(data, size);
|
||||
OHOS::ProcGetMaxAllowCreateIdFromDatabaseStubFuzzTest(data, size);
|
||||
OHOS::ProcGetOsAccountFromDatabaseStubFuzzTest(data, size);
|
||||
OHOS::ProcGetOsAccountListFromDatabaseStubFuzzTest(data, size);
|
||||
OHOS::ProcGetOsAccountShortNameStubFuzzTest(data, size);
|
||||
OHOS::ProcGetOsAccountTypeFromProcessStubFuzzTest(data, size);
|
||||
OHOS::ProcGetSerialNumberFromDatabaseStubFuzzTest(data, size);
|
||||
OHOS::ProcIsCurrentOsAccountVerifiedStubFuzzTest(data, size);
|
||||
OHOS::ProcIsMultiOsAccountEnableStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,9 +26,6 @@ using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
const int ENUM_MAX = 5;
|
||||
const int PRIVATE_NUMBER = 3;
|
||||
const int END_NUMBER = 4;
|
||||
const std::u16string IOS_ACCOUNT_DESCRIPTOR = u"ohos.accountfwk.IOsAccount";
|
||||
bool CheckOsAccountConstraintEnabledStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
@ -46,133 +43,14 @@ bool CheckOsAccountConstraintEnabledStubFuzzTest(const uint8_t *data, size_t siz
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
|
||||
osAccountManagerService_ ->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::CHECK_OS_ACCOUNT_CONSTRAINT_ENABLED), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcQueryActiveOsAccountIdsStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::QUERY_ACTIVE_OS_ACCOUNT_IDS), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcQueryAllCreatedOsAccountsStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::QUERY_ALL_CREATED_OS_ACCOUNTS), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcQueryCurrentOsAccountStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::QUERY_CURRENT_OS_ACCOUNT), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcQueryMaxLoggedInOsAccountNumberStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::QUERY_MAX_LOGGED_IN_OS_ACCOUNT_NUMBER), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcUpdateOsAccountWithFullInfoStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel datas;
|
||||
if (!datas.WriteInterfaceToken(IOS_ACCOUNT_DESCRIPTOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
|
||||
OsAccountInfo osAccountInfo;
|
||||
osAccountInfo.SetLocalId(fuzzData.GetData<int>());
|
||||
osAccountInfo.SetLocalName(fuzzData.GenerateRandomString());
|
||||
osAccountInfo.SetShortName(fuzzData.GenerateRandomString());
|
||||
int typeNumber = fuzzData.GetData<int>() % ENUM_MAX;
|
||||
if (typeNumber == PRIVATE_NUMBER) {
|
||||
osAccountInfo.SetType(PRIVATE);
|
||||
} else if (typeNumber == END_NUMBER) {
|
||||
osAccountInfo.SetType(END);
|
||||
} else {
|
||||
OsAccountType testType = static_cast<OsAccountType>(typeNumber);
|
||||
osAccountInfo.SetType(testType);
|
||||
}
|
||||
osAccountInfo.SetSerialNumber(fuzzData.GetData<int64_t>());
|
||||
|
||||
if (!datas.WriteParcelable(&osAccountInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto osAccountManagerService_ = std::make_shared<OsAccountManagerService>();
|
||||
osAccountManagerService_->OnRemoteRequest(
|
||||
static_cast<int32_t>(OsAccountInterfaceCode::UPDATE_OS_ACCOUNT_WITH_FULL_INFO), datas, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
@ -180,10 +58,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::CheckOsAccountConstraintEnabledStubFuzzTest(data, size);
|
||||
OHOS::ProcQueryActiveOsAccountIdsStubFuzzTest(data, size);
|
||||
OHOS::ProcQueryAllCreatedOsAccountsStubFuzzTest(data, size);
|
||||
OHOS::ProcQueryCurrentOsAccountStubFuzzTest(data, size);
|
||||
OHOS::ProcQueryMaxLoggedInOsAccountNumberStubFuzzTest(data, size);
|
||||
OHOS::ProcUpdateOsAccountWithFullInfoStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user