mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-26 19:50:37 +00:00
删除STOP_OS_ACCOUNT
Signed-off-by: swg3156201044 <shiweigang2@huawei.com>
This commit is contained in:
parent
db5ca73048
commit
494d556d07
@ -71,7 +71,6 @@ enum class OsAccountInterfaceCode : uint32_t {
|
||||
DEACTIVATE_OS_ACCOUNT,
|
||||
DEACTIVATE_ALL_OS_ACCOUNTS,
|
||||
START_OS_ACCOUNT,
|
||||
STOP_OS_ACCOUNT,
|
||||
SUBSCRIBE_OS_ACCOUNT,
|
||||
UNSUBSCRIBE_OS_ACCOUNT,
|
||||
GET_OS_ACCOUNT_LOCAL_ID_FOR_SERIAL_NUMBER,
|
||||
|
@ -70,7 +70,6 @@ public:
|
||||
virtual ErrCode DeactivateOsAccount(const int id) = 0;
|
||||
virtual ErrCode DeactivateAllOsAccounts() = 0;
|
||||
virtual ErrCode StartOsAccount(const int id) = 0;
|
||||
virtual ErrCode StopOsAccount(const int id) = 0;
|
||||
virtual ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) = 0;
|
||||
virtual ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) = 0;
|
||||
virtual ErrCode SubscribeOsAccount(
|
||||
|
@ -61,7 +61,6 @@ public:
|
||||
ErrCode DeactivateOsAccount(const int id);
|
||||
ErrCode DeactivateAllOsAccounts();
|
||||
ErrCode StartOsAccount(const int id);
|
||||
ErrCode StopOsAccount(const int id);
|
||||
ErrCode SubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
|
||||
ErrCode UnsubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
|
||||
ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id);
|
||||
|
@ -64,7 +64,6 @@ public:
|
||||
ErrCode DeactivateOsAccount(const int id) override;
|
||||
ErrCode DeactivateAllOsAccounts() override;
|
||||
ErrCode StartOsAccount(const int id) override;
|
||||
ErrCode StopOsAccount(const int id) override;
|
||||
ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) override;
|
||||
ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) override;
|
||||
ErrCode SubscribeOsAccount(
|
||||
|
@ -24,7 +24,6 @@
|
||||
"OHOS::AccountSA::OsAccount::ActivateOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccount::DeactivateOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccount::DeactivateAllOsAccounts()";
|
||||
"OHOS::AccountSA::OsAccount::StopOsAccount(int)";
|
||||
"VTT for OHOS::AccountSA::OsAccountInfo";
|
||||
"VTT for OHOS::AccountSA::CreateOsAccountOptions";
|
||||
"vtable for OHOS::AccountSA::CreateOsAccountOptions";
|
||||
|
@ -524,19 +524,6 @@ ErrCode OsAccount::StartOsAccount(const int id)
|
||||
return proxy->StartOsAccount(id);
|
||||
}
|
||||
|
||||
ErrCode OsAccount::StopOsAccount(const int id)
|
||||
{
|
||||
ErrCode result = CheckLocalId(id);
|
||||
if (result != ERR_OK) {
|
||||
return result;
|
||||
}
|
||||
auto proxy = GetOsAccountProxy();
|
||||
if (proxy == nullptr) {
|
||||
return ERR_ACCOUNT_COMMON_GET_PROXY;
|
||||
}
|
||||
return proxy->StopOsAccount(id);
|
||||
}
|
||||
|
||||
ErrCode OsAccount::GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id)
|
||||
{
|
||||
auto proxy = GetOsAccountProxy();
|
||||
|
@ -772,12 +772,6 @@ ErrCode OsAccountProxy::StartOsAccount(const int id)
|
||||
return SendRequestWithAccountId(OsAccountInterfaceCode::START_OS_ACCOUNT, reply, id);
|
||||
}
|
||||
|
||||
ErrCode OsAccountProxy::StopOsAccount(const int id)
|
||||
{
|
||||
MessageParcel reply;
|
||||
return SendRequestWithAccountId(OsAccountInterfaceCode::STOP_OS_ACCOUNT, reply, id);
|
||||
}
|
||||
|
||||
ErrCode OsAccountProxy::GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -391,18 +391,6 @@ HWTEST_F(OsAccountMockTest, StartOsAccountMockTest001, TestSize.Level1)
|
||||
g_osAccount->StartOsAccount(MAIN_ACCOUNT_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopOsAccountMockTest001
|
||||
* @tc.desc: Test StopOsAccount getosaccountproxy faild
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountMockTest, StopOsAccountMockTest001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(ERR_ACCOUNT_COMMON_GET_SYSTEM_ABILITY_MANAGER,
|
||||
g_osAccount->StopOsAccount(MAIN_ACCOUNT_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetOsAccountLocalIdBySerialNumberMockTest001
|
||||
* @tc.desc: Test GetOsAccountLocalIdBySerialNumber getosaccountproxy faild
|
||||
|
@ -52,7 +52,6 @@
|
||||
"OHOS::AccountSA::OsAccount::DeactivateOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccount::DeactivateAllOsAccounts()";
|
||||
"OHOS::AccountSA::OsAccount::StartOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccount::StopOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccount::GetOsAccountLocalIdBySerialNumber(long long, int&)";
|
||||
"OHOS::AccountSA::OsAccount::GetOsAccountLocalIdBySerialNumber(long, int&)";
|
||||
"OHOS::AccountSA::OsAccount::GetSerialNumberByOsAccountLocalId(int const&, long long&)";
|
||||
@ -97,7 +96,6 @@
|
||||
"OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(int&)";
|
||||
"OHOS::AccountSA::OsAccountManager::SetOsAccountIsVerified(int, bool)";
|
||||
"OHOS::AccountSA::OsAccountManager::StartOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccountManager::StopOsAccount(int)";
|
||||
"OHOS::AccountSA::OsAccountManager::GetOsAccountFromDatabase(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, int, OHOS::AccountSA::OsAccountInfo&)";
|
||||
"OHOS::AccountSA::OsAccountManager::SetSpecificOsAccountConstraints(std::__h::vector<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, std::__h::allocator<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>> const&, bool, int, int, bool)";
|
||||
"OHOS::AccountSA::OsAccountManager::IsOsAccountCompleted(int, bool&)";
|
||||
|
@ -223,11 +223,6 @@ ErrCode OsAccountManager::StartOsAccount(const int id)
|
||||
return OsAccount::GetInstance().StartOsAccount(id);
|
||||
}
|
||||
|
||||
ErrCode OsAccountManager::StopOsAccount(const int id)
|
||||
{
|
||||
return OsAccount::GetInstance().StopOsAccount(id);
|
||||
}
|
||||
|
||||
ErrCode OsAccountManager::GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id)
|
||||
{
|
||||
return OsAccount::GetInstance().GetOsAccountLocalIdBySerialNumber(serialNumber, id);
|
||||
|
@ -1139,22 +1139,7 @@ HWTEST_F(OsAccountManagerModuleTest, OsAccountManagerModuleTest047, TestSize.Lev
|
||||
OsAccountInfo osAccountInfoOne;
|
||||
ASSERT_EQ(OsAccountManager::CreateOsAccount("ModuleTest047", OsAccountType::GUEST, osAccountInfoOne), ERR_OK);
|
||||
EXPECT_EQ(OsAccountManager::StartOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(OsAccountManager::StopOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
ASSERT_EQ(OsAccountManager::RemoveOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerModuleTest050
|
||||
* @tc.desc: Test StopOsAccount with valid data.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI4IU3B
|
||||
*/
|
||||
HWTEST_F(OsAccountManagerModuleTest, OsAccountManagerModuleTest050, TestSize.Level1)
|
||||
{
|
||||
OsAccountInfo osAccountInfoOne;
|
||||
ASSERT_EQ(OsAccountManager::CreateOsAccount("ModuleTest050", OsAccountType::GUEST, osAccountInfoOne), ERR_OK);
|
||||
EXPECT_EQ(OsAccountManager::StartOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(OsAccountManager::StopOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(OsAccountManager::DeactivateOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
ASSERT_EQ(OsAccountManager::RemoveOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
}
|
||||
#endif // ENABLE_MULTIPLE_OS_ACCOUNTS
|
||||
@ -1182,18 +1167,6 @@ HWTEST_F(OsAccountManagerModuleTest, OsAccountManagerModuleTest049, TestSize.Lev
|
||||
EXPECT_EQ(OsAccountManager::StartOsAccount(Constants::START_USER_ID), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerModuleTest051
|
||||
* @tc.desc: Test StopOsAccount with invalid data.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI4IU3B
|
||||
*/
|
||||
HWTEST_F(OsAccountManagerModuleTest, OsAccountManagerModuleTest051, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(OsAccountManager::StopOsAccount(Constants::MAX_USER_ID + 1),
|
||||
ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerModuleTest052
|
||||
* @tc.desc: Test IsOsAccountVerified with invalid data.
|
||||
|
@ -414,18 +414,6 @@ HWTEST_F(AccountOsProxyMockTest, StartOsAccountTest001, TestSize.Level1)
|
||||
ASSERT_EQ(ERR_ACCOUNT_COMMON_GET_SYSTEM_ABILITY_MANAGER, errCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopOsAccountTest001
|
||||
* @tc.desc: Test func with proxy is nullptr.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountOsProxyMockTest, StopOsAccountTest001, TestSize.Level1)
|
||||
{
|
||||
ErrCode errCode = OsAccountManager::StopOsAccount(TEST_USER_ID);
|
||||
ASSERT_EQ(ERR_ACCOUNT_COMMON_GET_SYSTEM_ABILITY_MANAGER, errCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetOsAccountLocalIdBySerialNumberTest001
|
||||
* @tc.desc: Test func with proxy is nullptr.
|
||||
|
@ -387,13 +387,6 @@ public:
|
||||
*/
|
||||
static ErrCode StartOsAccount(const int id);
|
||||
|
||||
/**
|
||||
* @brief Stops the specified OS account.
|
||||
* @param id - Indicates the local ID of the OS account.
|
||||
* @return error code, see account_error_no.h
|
||||
*/
|
||||
static ErrCode StopOsAccount(const int id);
|
||||
|
||||
/**
|
||||
* @brief Gets localId according to serial number.
|
||||
* @param serialNumber - Indicates serial number.
|
||||
|
@ -60,7 +60,6 @@ public:
|
||||
virtual ErrCode ActivateOsAccount(const int id, const bool startStorage = true, const uint64_t displayId = 0) = 0;
|
||||
virtual ErrCode DeactivateOsAccount(const int id) = 0;
|
||||
virtual ErrCode StartOsAccount(const int id) = 0;
|
||||
virtual ErrCode StopOsAccount(const int id) = 0;
|
||||
virtual ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) = 0;
|
||||
virtual ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) = 0;
|
||||
virtual ErrCode SubscribeOsAccount(
|
||||
|
@ -65,7 +65,6 @@ public:
|
||||
ErrCode ActivateOsAccount(const int id, const bool startStorage = true, const uint64_t displayId = 0) override;
|
||||
ErrCode DeactivateOsAccount(const int id) override;
|
||||
ErrCode StartOsAccount(const int id) override;
|
||||
ErrCode StopOsAccount(const int id) override;
|
||||
ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) override;
|
||||
ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) override;
|
||||
ErrCode SubscribeOsAccount(
|
||||
|
@ -82,7 +82,6 @@ public:
|
||||
ErrCode DeactivateAllOsAccounts() override;
|
||||
|
||||
ErrCode StartOsAccount(const int id) override;
|
||||
ErrCode StopOsAccount(const int id) override;
|
||||
|
||||
ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) override;
|
||||
ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) override;
|
||||
|
@ -1644,58 +1644,6 @@ ErrCode IInnerOsAccountManager::StartOsAccount(const int id)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode IInnerOsAccountManager::StopOsAccount(const int id)
|
||||
{
|
||||
if (id == Constants::START_USER_ID) {
|
||||
ACCOUNT_LOGW("Account id=%{public}d can't stop", id);
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_STOP_ACTIVE_ERROR;
|
||||
}
|
||||
|
||||
if (!CheckAndAddLocalIdOperating(id)) {
|
||||
ACCOUNT_LOGW("Account id=%{public}d already in operating", id);
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_OPERATING_ERROR;
|
||||
}
|
||||
if (!IsOsAccountIDInActiveList(id)) {
|
||||
RemoveLocalIdToOperating(id);
|
||||
ACCOUNT_LOGI("Account id=%{public}d already stop", id);
|
||||
return ERR_OK;
|
||||
}
|
||||
// get information
|
||||
OsAccountInfo osAccountInfo;
|
||||
ErrCode errCode = osAccountControl_->GetOsAccountInfoById(id, osAccountInfo);
|
||||
if (errCode != ERR_OK) {
|
||||
RemoveLocalIdToOperating(id);
|
||||
ACCOUNT_LOGW("Cannot find os account info by id:%{public}d, errCode %{public}d.", id, errCode);
|
||||
return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR;
|
||||
}
|
||||
|
||||
// check complete
|
||||
if (!osAccountInfo.GetIsCreateCompleted()) {
|
||||
RemoveLocalIdToOperating(id);
|
||||
ACCOUNT_LOGW("Account id=%{public}d is not completed", id);
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_IS_UNCOMPLETED_ERROR;
|
||||
}
|
||||
|
||||
// check to be removed
|
||||
if (osAccountInfo.GetToBeRemoved()) {
|
||||
RemoveLocalIdToOperating(id);
|
||||
ACCOUNT_LOGW("Account id=%{public}d will be removed, don't need to stop!", id);
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_TO_BE_REMOVED_ERROR;
|
||||
}
|
||||
|
||||
// stop
|
||||
errCode = SendMsgForAccountStop(osAccountInfo);
|
||||
if (errCode != ERR_OK) {
|
||||
RemoveLocalIdToOperating(id);
|
||||
ReportOsAccountOperationFail(id, "stop", errCode, "stop os account failed");
|
||||
ACCOUNT_LOGE("Update account failed, id=%{public}d, errCode %{public}d.", id, errCode);
|
||||
return errCode;
|
||||
}
|
||||
RemoveLocalIdToOperating(id);
|
||||
ACCOUNT_LOGI("IInnerOsAccountManager StopOsAccount end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode IInnerOsAccountManager::GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id)
|
||||
{
|
||||
if (serialNumber ==
|
||||
|
@ -688,11 +688,6 @@ ErrCode OsAccountManagerService::StartOsAccount(const int id)
|
||||
return innerManager_.StartOsAccount(id);
|
||||
}
|
||||
|
||||
ErrCode OsAccountManagerService::StopOsAccount(const int id)
|
||||
{
|
||||
return innerManager_.StopOsAccount(id);
|
||||
}
|
||||
|
||||
ErrCode OsAccountManagerService::SubscribeOsAccount(
|
||||
const OsAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
{
|
||||
|
@ -236,12 +236,6 @@ const std::map<uint32_t, OsAccountStub::OsAccountMessageProc> messageProcMap = {
|
||||
.messageProcFunction = &OsAccountStub::ProcStartOsAccount,
|
||||
}
|
||||
},
|
||||
{
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::STOP_OS_ACCOUNT),
|
||||
{
|
||||
.messageProcFunction = &OsAccountStub::ProcStopOsAccount,
|
||||
}
|
||||
},
|
||||
{
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::SUBSCRIBE_OS_ACCOUNT),
|
||||
{
|
||||
@ -1178,21 +1172,6 @@ ErrCode OsAccountStub::ProcStartOsAccount(MessageParcel &data, MessageParcel &re
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
ErrCode OsAccountStub::ProcStopOsAccount(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t localId;
|
||||
if (!data.ReadInt32(localId)) {
|
||||
ACCOUNT_LOGE("failed to read localId");
|
||||
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
|
||||
}
|
||||
ErrCode result = StopOsAccount(localId);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
ACCOUNT_LOGE("failed to write reply, result %{public}d.", result);
|
||||
return IPC_STUB_WRITE_PARCEL_ERR;
|
||||
}
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
ErrCode OsAccountStub::ProcGetOsAccountSwitchMod(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
OS_ACCOUNT_SWITCH_MOD osAccountSwitchMod = GetOsAccountSwitchMod();
|
||||
|
@ -876,7 +876,7 @@ HWTEST_F(OsAccountManagerServiceModuleTest, OsAccountManagerServiceModuleTest046
|
||||
OsAccountInfo osAccountInfoOne;
|
||||
ASSERT_EQ(osAccountManagerService_->CreateOsAccount("Test046", INT_TEST_TYPE, osAccountInfoOne), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->StartOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->StopOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->DeactivateOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->RemoveOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
}
|
||||
#endif // ENABLE_MULTIPLE_OS_ACCOUNTS
|
||||
@ -905,35 +905,6 @@ HWTEST_F(OsAccountManagerServiceModuleTest, OsAccountManagerServiceModuleTest048
|
||||
ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerServiceModuleTest049
|
||||
* @tc.desc: Test StopOsAccount with valid data.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
#ifdef ENABLE_MULTIPLE_OS_ACCOUNTS
|
||||
HWTEST_F(OsAccountManagerServiceModuleTest, OsAccountManagerServiceModuleTest049, TestSize.Level1)
|
||||
{
|
||||
OsAccountInfo osAccountInfoOne;
|
||||
ASSERT_EQ(osAccountManagerService_->CreateOsAccount("Test049", INT_TEST_TYPE, osAccountInfoOne), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->StartOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->StopOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
EXPECT_EQ(osAccountManagerService_->RemoveOsAccount(osAccountInfoOne.GetLocalId()), ERR_OK);
|
||||
}
|
||||
#endif // ENABLE_MULTIPLE_OS_ACCOUNTS
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerServiceModuleTest050
|
||||
* @tc.desc: Test StopOsAccount with invalid data.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(OsAccountManagerServiceModuleTest, OsAccountManagerServiceModuleTest050, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(osAccountManagerService_->StopOsAccount(Constants::MAX_USER_ID + 1),
|
||||
ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OsAccountManagerServiceModuleTest051
|
||||
* @tc.desc: Test ActivateOsAccount with valid data.
|
||||
|
@ -35,12 +35,12 @@ bool StartOsAccountFuzzTest(const uint8_t* data, size_t size)
|
||||
return result == ERR_OK;
|
||||
}
|
||||
|
||||
bool StopOsAccountFuzzTest(const uint8_t* data, size_t size)
|
||||
bool DeactivateOsAccountFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
int32_t result = ERR_OK;
|
||||
if (size > 0) {
|
||||
int testId = static_cast<int>(size);
|
||||
result = OsAccountManager::StopOsAccount(testId);
|
||||
result = OsAccountManager::DeactivateOsAccount(testId);
|
||||
}
|
||||
return result == ERR_OK;
|
||||
}
|
||||
@ -51,7 +51,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::StartOsAccountFuzzTest(data, size);
|
||||
OHOS::StopOsAccountFuzzTest(data, size);
|
||||
OHOS::DeactivateOsAccountFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@ group("fuzztest") {
|
||||
"setosaccountprofilephotostub_fuzzer:SetOsAccountProfilePhotoStubFuzzTest",
|
||||
"setosaccounttoberemovedstub_fuzzer:SetOsAccountToBeRemovedStubFuzzTest",
|
||||
"setspecificosaccountconstraintsstub_fuzzer:SetSpecificOsAccountConstraintsStubFuzzTest",
|
||||
"stoposaccountstub_fuzzer:StopOsAccountStubFuzzTest",
|
||||
"subscribeosaccountstub_fuzzer:SubscribeOsAccountStubFuzzTest",
|
||||
"unsubscribeosaccountstub_fuzzer:UnSubscribeOsAccountStubFuzzTest",
|
||||
]
|
||||
|
@ -47,7 +47,6 @@
|
||||
"GetDistributedVirtualDeviceId": [],
|
||||
"ActivateOsAccount": [],
|
||||
"StartOsAccount": [],
|
||||
"StopOsAccount": [],
|
||||
"GetOsAccountLocalIdBySerialNumber": [],
|
||||
"GetSerialNumberByOsAccountLocalId": [],
|
||||
"SubscribeOsAccount": [],
|
||||
|
@ -29,7 +29,6 @@ const std::string HELP_MSG = "usage: acm <command> [<options>]\n"
|
||||
" delete delete a local account with options\n"
|
||||
" switch switch to a local account with options\n"
|
||||
" deactivate deactivate to a local account with options\n"
|
||||
" stop stop the local accounts\n"
|
||||
" set set constraints of a local account\n"
|
||||
" dump dump the info of local accounts\n";
|
||||
|
||||
@ -119,7 +118,6 @@ private:
|
||||
ErrCode RunAsDeleteCommand(void);
|
||||
ErrCode RunAsSwitchCommand(void);
|
||||
ErrCode RunAsDeactivateCommand(void);
|
||||
ErrCode RunAsStopCommand(void);
|
||||
ErrCode RunAsDumpCommand(void);
|
||||
ErrCode RunAsSetCommand(void);
|
||||
|
||||
|
@ -38,7 +38,6 @@ const struct option LONG_OPTIONS[] = {
|
||||
{nullptr, no_argument, nullptr, no_argument}
|
||||
};
|
||||
|
||||
static const std::string STOP_COMMAND = "stop";
|
||||
static const std::string DEACTIVATE_COMMAND = "deactivate";
|
||||
static const std::string DELETE_COMMAND = "delete";
|
||||
static const std::string SWITCH_COMMAND = "switch";
|
||||
@ -68,7 +67,6 @@ ErrCode AccountCommand::CreateCommandMap()
|
||||
{"set", std::bind(&AccountCommand::RunAsSetCommand, this)},
|
||||
{"switch", std::bind(&AccountCommand::RunAsSwitchCommand, this)},
|
||||
{"deactivate", std::bind(&AccountCommand::RunAsDeactivateCommand, this)},
|
||||
{"stop", std::bind(&AccountCommand::RunAsStopCommand, this)},
|
||||
};
|
||||
|
||||
return ERR_OK;
|
||||
@ -380,32 +378,6 @@ ErrCode AccountCommand::RunAsDeactivateCommand(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrCode AccountCommand::RunAsStopCommand(void)
|
||||
{
|
||||
ErrCode result = ERR_OK;
|
||||
int id = -1;
|
||||
|
||||
ParseCommandOpt(STOP_COMMAND, result, id);
|
||||
|
||||
if (result != ERR_OK) {
|
||||
resultReceiver_.append(HELP_MSG_STOP);
|
||||
} else {
|
||||
/* stop */
|
||||
|
||||
// stop an os account
|
||||
result = OsAccount::GetInstance().StopOsAccount(id);
|
||||
if (result == ERR_OK) {
|
||||
resultReceiver_ = STRING_STOP_OS_ACCOUNT_OK + "\n";
|
||||
} else {
|
||||
resultReceiver_ = STRING_STOP_OS_ACCOUNT_NG + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
ACCOUNT_LOGD("result = %{public}d, id = %{public}d", result, id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrCode AccountCommand::RunAsCreateCommandMissingOptionArgument(void)
|
||||
{
|
||||
ErrCode result = ERR_OK;
|
||||
|
@ -152,210 +152,4 @@ HWTEST_F(AccountCommandTest, Acm_Command_0500, TestSize.Level1)
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_0600
|
||||
* @tc.desc: Verify the "acm stop" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_0600, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_0700
|
||||
* @tc.desc: Verify the "acm stop xxx" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_0700, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("xxx"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_0800
|
||||
* @tc.desc: Verify the "acm stop -x" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_0800, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("-x"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_UNKNOWN_OPTION + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_0900
|
||||
* @tc.desc: Verify the "acm stop -xxx" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_0900, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("-xxx"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_UNKNOWN_OPTION + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_1000
|
||||
* @tc.desc: Verify the "acm stop --x" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_1000, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("--x"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_UNKNOWN_OPTION + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_1100
|
||||
* @tc.desc: Verify the "acm stop --xxx" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_1100, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("--xxx"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_UNKNOWN_OPTION + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_1200
|
||||
* @tc.desc: Verify the "acm stop -h" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_1200, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("-h"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_1300
|
||||
* @tc.desc: Verify the "acm stop -help" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_1300, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("--help"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_1400
|
||||
* @tc.desc: Verify the "acm stop -i" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_1400, TestSize.Level1)
|
||||
{
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("-i"),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_OPTION_REQUIRES_AN_ARGUMENT + "\n" + HELP_MSG_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Acm_Command_1500
|
||||
* @tc.desc: Verify the "acm stop -i" command.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(AccountCommandTest, Acm_Command_1500, TestSize.Level1)
|
||||
{
|
||||
OsAccountInfo osAccountInfo;
|
||||
// create an os account
|
||||
EXPECT_EQ(ERR_OK, OsAccount::GetInstance().CreateOsAccount(TOOL_NAME, OsAccountType::NORMAL, osAccountInfo));
|
||||
|
||||
std::string userId = std::to_string(osAccountInfo.GetLocalId());
|
||||
char *argv[] = {
|
||||
const_cast<char *>(TOOL_NAME.c_str()),
|
||||
const_cast<char *>(cmd_.c_str()),
|
||||
const_cast<char *>("-i"),
|
||||
const_cast<char *>(userId.c_str()),
|
||||
const_cast<char *>(""),
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]) - 1;
|
||||
|
||||
AccountCommand cmd(argc, argv);
|
||||
EXPECT_EQ(cmd.ExecCommand(), STRING_STOP_OS_ACCOUNT_OK + "\n");
|
||||
OsAccount::GetInstance().RemoveOsAccount(osAccountInfo.GetLocalId());
|
||||
}
|
Loading…
Reference in New Issue
Block a user