• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #ifdef PROXY_MOCK
18 #include <thread>
19 #endif
20 
21 #include "account_error_no.h"
22 #include "account_log_wrapper.h"
23 #include "app_account_manager.h"
24 #include "app_account_manager_test_callback.h"
25 #include "app_account_subscribe_info.h"
26 #define private public
27 #include "app_account.h"
28 #ifdef PROXY_MOCK
29 #include "app_account_manager_service.h"
30 #include "app_account_proxy.h"
31 #undef private
32 #endif
33 #include "singleton.h"
34 
35 using namespace testing::ext;
36 using namespace OHOS;
37 using namespace OHOS::AccountSA;
38 using namespace OHOS::AccountTest;
39 
40 namespace {
41 const std::string STRING_NAME = "name";
42 const std::string STRING_NAME_OUT_OF_RANGE(513, '1');  // length 513
43 const std::string STRING_EXTRA_INFO = "extra_info";
44 const std::string STRING_EXTRA_INFO_OUT_OF_RANGE(1200, '1');  // length 1200
45 const std::string STRING_BUNDLE_NAME = "com.example.third_party";
46 const std::string STRING_OWNER_OUT_OF_RANGE(1200, '1');  // length 1200
47 const std::string STRING_EMPTY = "";
48 const std::string STRING_KEY = "key";
49 const std::string STRING_KEY_OUT_OF_RANGE(1200, '1');  // length 1200
50 const std::string STRING_VALUE = "value";
51 const std::string STRING_VALUE_OUT_OF_RANGE(1200, '1');  // length 1200
52 const std::string STRING_CREDENTIAL_TYPE = "password";
53 const std::string STRING_CREDENTIAL_TYPE_OUT_OF_RANGE(1200, '1');  // length 1200
54 const std::string STRING_AUTHORIZED_APP_OUT_OF_RANGE(1200, '1');  // length 1200
55 const std::string STRING_CREDENTIAL = "1024";
56 const std::string STRING_CREDENTIAL_OUT_OF_RANGE(1200, '1');  // length 1200
57 const std::string STRING_TOKEN = "1024";
58 const std::string STRING_TOKEN_OUT_OF_RANGE(1200, '1');  // length 1200
59 const std::string STRING_OWNER = "com.example.owner";
60 const std::string STRING_AUTH_TYPE = "all";
61 const std::string STRING_OUT_OF_RANGE(1200, '1');  // length 1200
62 const std::string STRING_ABILITY_NAME = "MainAbility";
63 const std::string STRING_SESSION_ID = "123456";
64 constexpr int32_t MAX_CUSTOM_DATA_SIZE = 1024;
65 constexpr int32_t ALLOWED_ARRAY_MAX_SIZE = 1024;
66 constexpr int32_t CREDENTIAL_TYPE_MAX_SIZE = 1024;
67 constexpr int32_t CREDENTIAL_MAX_SIZE = 1024;
68 const bool SYNC_ENABLE_FALSE = false;
69 #ifdef PROXY_MOCK
70 const int32_t SLEEP_TIME = 2000;
71 #endif
72 constexpr std::size_t SIZE_ZERO = 0;
73 }  // namespace
74 
75 class AppAccountManagerTest : public testing::Test {
76 public:
77     static void SetUpTestCase(void);
78     static void TearDownTestCase(void);
79     void SetUp(void) override;
80     void TearDown(void) override;
81 };
82 
83 class AppAccountSubscriberTest : public AppAccountSubscriber {
84 public:
AppAccountSubscriberTest(const AppAccountSubscribeInfo & subscribeInfo)85     explicit AppAccountSubscriberTest(const AppAccountSubscribeInfo &subscribeInfo)
86         : AppAccountSubscriber(subscribeInfo)
87     {
88         ACCOUNT_LOGI("enter");
89     }
90 
~AppAccountSubscriberTest()91     ~AppAccountSubscriberTest()
92     {}
93 
OnAccountsChanged(const std::vector<AppAccountInfo> & accounts)94     virtual void OnAccountsChanged(const std::vector<AppAccountInfo> &accounts)
95     {
96         ACCOUNT_LOGI("enter");
97     }
98 };
99 
SetUpTestCase(void)100 void AppAccountManagerTest::SetUpTestCase(void)
101 {
102 #ifdef PROXY_MOCK
103     sptr<IAppAccount> appAccountService = new (std::nothrow) AppAccountManagerService();
104     ASSERT_NE(appAccountService, nullptr);
105     AppAccount::GetInstance().proxy_ = new (std::nothrow) AppAccountProxy(appAccountService->AsObject());
106     ASSERT_NE(AppAccount::GetInstance().proxy_, nullptr);
107 #endif
108 }
109 
TearDownTestCase(void)110 void AppAccountManagerTest::TearDownTestCase(void)
111 {}
112 
SetUp(void)113 void AppAccountManagerTest::SetUp(void) __attribute__((no_sanitize("cfi")))
114 {
115     testing::UnitTest *test = testing::UnitTest::GetInstance();
116     ASSERT_NE(test, nullptr);
117     const testing::TestInfo *testinfo = test->current_test_info();
118     ASSERT_NE(testinfo, nullptr);
119     string testCaseName = string(testinfo->name());
120     ACCOUNT_LOGI("[SetUp] %{public}s start", testCaseName.c_str());
121 
122 #ifdef PROXY_MOCK
123     std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
124 #endif
125 }
126 
TearDown(void)127 void AppAccountManagerTest::TearDown(void)
128 {}
129 
130 /**
131  * @tc.name: AppAccountManager_AddAccount_0100
132  * @tc.desc: Add an app account with invalid data.
133  * @tc.type: FUNC
134  * @tc.require: issueI4MBQW
135  */
136 HWTEST_F(AppAccountManagerTest, AppAccountManager_AddAccount_0100, TestSize.Level0)
137 {
138     ACCOUNT_LOGI("AppAccountManager_AddAccount_0100");
139 
140     ErrCode result = AppAccountManager::AddAccount(STRING_EMPTY);
141     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
142 }
143 
144 /**
145  * @tc.name: AppAccountManager_AddAccount_0200
146  * @tc.desc: Add an app account with invalid data.
147  * @tc.type: FUNC
148  * @tc.require: issueI4MBQW
149  */
150 HWTEST_F(AppAccountManagerTest, AppAccountManager_AddAccount_0200, TestSize.Level1)
151 {
152     ACCOUNT_LOGI("AppAccountManager_AddAccount_0200");
153 
154     ErrCode result = AppAccountManager::AddAccount(STRING_NAME_OUT_OF_RANGE);
155     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
156 }
157 
158 /**
159  * @tc.name: AppAccountManager_AddAccount_0300
160  * @tc.desc: Add an app account with invalid data.
161  * @tc.type: FUNC
162  * @tc.require: issueI4MBQW
163  */
164 HWTEST_F(AppAccountManagerTest, AppAccountManager_AddAccount_0300, TestSize.Level1)
165 {
166     ACCOUNT_LOGI("AppAccountManager_AddAccount_0300");
167 
168     ErrCode result = AppAccountManager::AddAccount(STRING_NAME, STRING_EXTRA_INFO_OUT_OF_RANGE);
169     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
170 }
171 
172 /**
173  * @tc.name: AppAccountManager_AddAccount_0400
174  * @tc.desc: Fail to Add an app account from shell process.
175  * @tc.type: FUNC
176  * @tc.require: issueI4MBQW
177  */
178 HWTEST_F(AppAccountManagerTest, AppAccountManager_AddAccount_0400, TestSize.Level1)
179 {
180     ACCOUNT_LOGI("AppAccountManager_AddAccount_0300");
181 
182     ErrCode result = AppAccountManager::AddAccount(STRING_NAME, STRING_EXTRA_INFO);
183     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
184 }
185 
186 /**
187  * @tc.name: AppAccountManager_CreateAccount_0100
188  * @tc.desc: create an app account with invalid name data.
189  * @tc.type: FUNC
190  * @tc.require: issueI5RWXN
191  */
192 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccount_0100, TestSize.Level1)
193 {
194     ACCOUNT_LOGI("AppAccountManager_CreateAccount_0100");
195     CreateAccountOptions option;
196     ErrCode result = AppAccountManager::CreateAccount(STRING_NAME_OUT_OF_RANGE, option);
197     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
198 }
199 
200 /**
201  * @tc.name: AppAccountManager_CreateAccount_0200
202  * @tc.desc: create an app account with invalid name data.
203  * @tc.type: FUNC
204  * @tc.require: issueI5RWXN
205  */
206 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccount_0200, TestSize.Level1)
207 {
208     ACCOUNT_LOGI("AppAccountManager_CreateAccount_0200");
209     CreateAccountOptions option;
210     ErrCode result = AppAccountManager::CreateAccount(STRING_EMPTY, option);
211     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
212 }
213 
214 /**
215  * @tc.name: AppAccountManager_CreateAccount_0300
216  * @tc.desc: create an app account with invalid option data.
217  * @tc.type: FUNC
218  * @tc.require: issueI5RWXN
219  */
220 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccount_0300, TestSize.Level1)
221 {
222     ACCOUNT_LOGI("AppAccountManager_CreateAccount_0300");
223     CreateAccountOptions option;
224     option.customData.emplace(STRING_KEY_OUT_OF_RANGE, STRING_VALUE);
225     ErrCode result = AppAccountManager::CreateAccount(STRING_EMPTY, option);
226     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
227 }
228 
229 /**
230  * @tc.name: AppAccountManager_CreateAccount_0400
231  * @tc.desc: create an app account with invalid option data.
232  * @tc.type: FUNC
233  * @tc.require: issueI5RWXN
234  */
235 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccount_0400, TestSize.Level1)
236 {
237     ACCOUNT_LOGI("AppAccountManager_CreateAccount_0400");
238     CreateAccountOptions option;
239     option.customData.emplace(STRING_KEY, STRING_VALUE_OUT_OF_RANGE);
240     ErrCode result = AppAccountManager::CreateAccount(STRING_EMPTY, option);
241     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
242 }
243 
244 /**
245  * @tc.name: AppAccountManager_CreateAccount_0500
246  * @tc.desc: create an app account with invalid option data.
247  * @tc.type: FUNC
248  * @tc.require: issueI5RWXN
249  */
250 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccount_0500, TestSize.Level1)
251 {
252     ACCOUNT_LOGI("AppAccountManager_CreateAccount_0500");
253     CreateAccountOptions option;
254     for (int i = 0; i < MAX_CUSTOM_DATA_SIZE + 1; i++) {
255         std::string test_key = "test_key" + std::to_string(i);
256         std::string test_value = "test_value" + std::to_string(i);
257         option.customData.emplace(test_key, test_value);
258     }
259     GTEST_LOG_(INFO) << "customData map size = " << option.customData.size();
260     ErrCode result = AppAccountManager::CreateAccount(STRING_EMPTY, option);
261     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
262 }
263 
264 /**
265  * @tc.name: AppAccountManager_AddAccountImplicitly_0100
266  * @tc.desc: Fail to add an app account implicitly with invalid parameters.
267  * @tc.type: FUNC
268  * @tc.require: issueI4ITYY
269  */
270 HWTEST_F(AppAccountManagerTest, AppAccountManager_AddAccountImplicitly_0100, TestSize.Level1)
271 {
272     ACCOUNT_LOGI("AppAccountManager_AddAccountImplicitly_0100");
273     AAFwk::Want options;
274 
275     ErrCode result = AppAccountManager::AddAccountImplicitly(
276         STRING_OWNER_OUT_OF_RANGE, STRING_AUTH_TYPE, options, nullptr);
277     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
278     result = AppAccountManager::AddAccountImplicitly(STRING_EMPTY, STRING_AUTH_TYPE, options, nullptr);
279     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
280 
281     result = AppAccountManager::AddAccountImplicitly(STRING_OWNER, STRING_OUT_OF_RANGE, options, nullptr);
282     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
283 }
284 
285 /**
286  * @tc.name: AppAccountManager_AddAccountImplicitly_0200
287  * @tc.desc: Fail to add an app account implicitly from shell process.
288  * @tc.type: FUNC
289  * @tc.require: issueI4ITYY
290  */
291 HWTEST_F(AppAccountManagerTest, AppAccountManager_AddAccountImplicitly_0200, TestSize.Level1)
292 {
293     ACCOUNT_LOGI("AppAccountManager_AddAccountImplicitly_0200");
294     AAFwk::Want options;
295     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
296     EXPECT_NE(callback, nullptr);
297     ErrCode result = AppAccountManager::AddAccountImplicitly(STRING_OWNER, STRING_AUTH_TYPE, options, callback);
298     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
299 }
300 
301 /**
302  * @tc.name: AppAccountManager_CreateAccountImplicitly_0100
303  * @tc.desc: Fail to add an app account implicitly with invalid parameters.
304  * @tc.type: FUNC
305  * @tc.require: issueI5RWXN
306  */
307 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccountImplicitly_0100, TestSize.Level1)
308 {
309     ACCOUNT_LOGI("AppAccountManager_CreateAccountImplicitly_0100");
310     CreateAccountImplicitlyOptions options;
311     // check owner
312     ErrCode result = AppAccountManager::CreateAccountImplicitly(
313         STRING_OWNER_OUT_OF_RANGE, options, nullptr);
314     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
315     result = AppAccountManager::CreateAccountImplicitly(STRING_EMPTY, options, nullptr);
316     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
317 
318     // check options.authType
319     options.authType = STRING_OUT_OF_RANGE;
320     result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, nullptr);
321     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
322     options.authType = "";
323     result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, nullptr);
324     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
325     // check callback nullptr
326     result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, nullptr);
327     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
328     // check options.requiredLabels
329     for (int i = 0; i < ALLOWED_ARRAY_MAX_SIZE; i++) {
330         std::string testLabel = "test_label_" + std::to_string(i);
331         options.requiredLabels.emplace_back(testLabel);
332     }
333     result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, nullptr);
334     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
335     options.requiredLabels.emplace_back("test_label_oversize");
336     result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, nullptr);
337     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
338 }
339 
340 /**
341  * @tc.name: AppAccountManager_CreateAccountImplicitly_0200
342  * @tc.desc: Fail to add an app account implicitly from shell process.
343  * @tc.type: FUNC
344  * @tc.require: issueI5RWXN
345  */
346 HWTEST_F(AppAccountManagerTest, AppAccountManager_CreateAccountImplicitly_0200, TestSize.Level1)
347 {
348     ACCOUNT_LOGI("AppAccountManager_CreateAccountImplicitly_0200");
349     CreateAccountImplicitlyOptions options;
350     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
351     EXPECT_NE(callback, nullptr);
352     ErrCode result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, callback);
353     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
354 }
355 
356 /**
357  * @tc.name: AppAccountManager_Authenticate_0100
358  * @tc.desc: Fail to authenticate an app account with invalid name.
359  * @tc.type: FUNC
360  * @tc.require: issueI4ITYY
361  */
362 HWTEST_F(AppAccountManagerTest, AppAccountManager_Authenticate_0100, TestSize.Level1)
363 {
364     ACCOUNT_LOGI("AppAccountManager_Authenticate_0100");
365     AAFwk::Want options;
366     ErrCode result = AppAccountManager::Authenticate(
367         STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, options, nullptr);
368     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
369 
370     result = AppAccountManager::Authenticate(
371         STRING_NAME_OUT_OF_RANGE, STRING_OWNER, STRING_AUTH_TYPE, options, nullptr);
372     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
373     result = AppAccountManager::Authenticate(
374         STRING_EMPTY, STRING_OWNER, STRING_AUTH_TYPE, options, nullptr);
375     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
376 
377     result = AppAccountManager::Authenticate(
378         STRING_NAME, STRING_OWNER_OUT_OF_RANGE, STRING_AUTH_TYPE, options, nullptr);
379     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
380     result = AppAccountManager::Authenticate(
381         STRING_NAME, STRING_EMPTY, STRING_AUTH_TYPE, options, nullptr);
382     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
383 
384     result = AppAccountManager::Authenticate(
385         STRING_NAME, STRING_OWNER, STRING_OUT_OF_RANGE, options, nullptr);
386     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
387 }
388 
389 /**
390  * @tc.name: AppAccountManager_Authenticate_0200
391  * @tc.desc: Fail to authenticate account from shell process.
392  * @tc.type: FUNC
393  * @tc.require: issueI4ITYY
394  */
395 HWTEST_F(AppAccountManagerTest, AppAccountManager_Authenticate_0200, TestSize.Level1)
396 {
397     ACCOUNT_LOGI("AppAccountManager_Authenticate_0200");
398     AAFwk::Want options;
399     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
400     EXPECT_NE(callback, nullptr);
401     ErrCode result = AppAccountManager::Authenticate(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, options, callback);
402     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
403 }
404 
405 /**
406  * @tc.name: AppAccountManager_SetOAuthTokenVisibility_0100
407  * @tc.desc: Fail to set oauth token visibility with invalid name.
408  * @tc.type: FUNC
409  * @tc.require: issueI4ITYY
410  */
411 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetOAuthTokenVisibility_0100, TestSize.Level1)
412 {
413     ACCOUNT_LOGI("AppAccountManager_SetOAuthTokenVisibility_0100");
414     ErrCode result = AppAccountManager::SetOAuthTokenVisibility(
415         STRING_EMPTY, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
416     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
417     result = AppAccountManager::SetOAuthTokenVisibility(
418         STRING_NAME_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
419     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
420 
421     result = AppAccountManager::SetOAuthTokenVisibility(
422         STRING_NAME, STRING_OUT_OF_RANGE, STRING_BUNDLE_NAME, true);
423     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
424 
425     result = AppAccountManager::SetOAuthTokenVisibility(
426         STRING_NAME, STRING_AUTH_TYPE, STRING_EMPTY, true);
427     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
428     result = AppAccountManager::SetOAuthTokenVisibility(
429         STRING_NAME, STRING_AUTH_TYPE, STRING_OWNER_OUT_OF_RANGE, true);
430     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
431 }
432 
433 /**
434  * @tc.name: AppAccountManager_SetOAuthTokenVisibility_0200
435  * @tc.desc: Fail to set oauth token visibility from shell process.
436  * @tc.type: FUNC
437  * @tc.require: issueI4ITYY
438  */
439 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetOAuthTokenVisibility_0200, TestSize.Level1)
440 {
441     ACCOUNT_LOGI("AppAccountManager_SetOAuthTokenVisibility_0200");
442     ErrCode result = AppAccountManager::SetOAuthTokenVisibility(
443         STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
444     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
445 }
446 
447 /**
448  * @tc.name: AppAccountManager_SetAuthTokenVisibility_0100
449  * @tc.desc: Fail to set oauth token visibility with invalid parameter.
450  * @tc.type: FUNC
451  * @tc.require:
452  */
453 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAuthTokenVisibility_0100, TestSize.Level1)
454 {
455     ACCOUNT_LOGI("AppAccountManager_SetAuthTokenVisibility_0100");
456     ErrCode result = AppAccountManager::SetAuthTokenVisibility(
457         STRING_EMPTY, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
458     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
459     result = AppAccountManager::SetAuthTokenVisibility(
460         STRING_NAME_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
461     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
462 
463     result = AppAccountManager::SetAuthTokenVisibility(
464         STRING_NAME, STRING_OUT_OF_RANGE, STRING_BUNDLE_NAME, true);
465     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
466 
467     result = AppAccountManager::SetAuthTokenVisibility(
468         STRING_NAME, STRING_AUTH_TYPE, STRING_EMPTY, true);
469     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
470     result = AppAccountManager::SetAuthTokenVisibility(
471         STRING_NAME, STRING_AUTH_TYPE, STRING_OWNER_OUT_OF_RANGE, true);
472     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
473 }
474 
475 /**
476  * @tc.name: AppAccountManager_SetAuthTokenVisibility_0200
477  * @tc.desc: Fail to set oauth token visibility from shell process.
478  * @tc.type: FUNC
479  * @tc.require:
480  */
481 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAuthTokenVisibility_0200, TestSize.Level1)
482 {
483     ACCOUNT_LOGI("AppAccountManager_SetAuthTokenVisibility_0200");
484     ErrCode result = AppAccountManager::SetAuthTokenVisibility(
485         STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
486     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
487 }
488 
489 /**
490  * @tc.name: AppAccountManager_CheckOAuthTokenVisibility_0100
491  * @tc.desc: Fail to check oauth token visibility with invalid name.
492  * @tc.type: FUNC
493  * @tc.require: issueI4ITYY
494  */
495 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckOAuthTokenVisibility_0100, TestSize.Level1)
496 {
497     ACCOUNT_LOGI("AppAccountManager_CheckOAuthTokenVisibility_0100");
498     bool isVisible = false;
499     ErrCode result = AppAccountManager::CheckOAuthTokenVisibility(
500         STRING_EMPTY, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
501     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
502     EXPECT_FALSE(isVisible);
503     result = AppAccountManager::CheckOAuthTokenVisibility(
504         STRING_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
505     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
506     EXPECT_FALSE(isVisible);
507 
508     result = AppAccountManager::CheckOAuthTokenVisibility(
509         STRING_NAME, STRING_OUT_OF_RANGE, STRING_BUNDLE_NAME, isVisible);
510     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
511     EXPECT_FALSE(isVisible);
512 
513     result = AppAccountManager::CheckOAuthTokenVisibility(
514         STRING_NAME, STRING_AUTH_TYPE, STRING_EMPTY, isVisible);
515     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
516     EXPECT_FALSE(isVisible);
517     result = AppAccountManager::CheckOAuthTokenVisibility(
518         STRING_NAME, STRING_AUTH_TYPE, STRING_OUT_OF_RANGE, isVisible);
519     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
520     EXPECT_FALSE(isVisible);
521 }
522 
523 /**
524  * @tc.name: AppAccountManager_CheckOAuthTokenVisibility_0200
525  * @tc.desc: Fail to check oauth token visibility from shell process.
526  * @tc.type: FUNC
527  * @tc.require: issueI4ITYY
528  */
529 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckOAuthTokenVisibility_0200, TestSize.Level1)
530 {
531     ACCOUNT_LOGI("AppAccountManager_CheckOAuthTokenVisibility_0200");
532     bool isVisible = false;
533     ErrCode result = AppAccountManager::CheckOAuthTokenVisibility(
534         STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
535     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
536     EXPECT_FALSE(isVisible);
537 }
538 
539 /**
540  * @tc.name: AppAccountManager_CheckAuthTokenVisibility_0100
541  * @tc.desc: Fail to check oauth token visibility with invalid name.
542  * @tc.type: FUNC
543  * @tc.require:
544  */
545 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAuthTokenVisibility_0100, TestSize.Level1)
546 {
547     ACCOUNT_LOGI("AppAccountManager_CheckAuthTokenVisibility_0100");
548     bool isVisible = false;
549     ErrCode result = AppAccountManager::CheckAuthTokenVisibility(
550         STRING_EMPTY, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
551     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
552     EXPECT_FALSE(isVisible);
553     result = AppAccountManager::CheckAuthTokenVisibility(
554         STRING_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
555     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
556     EXPECT_FALSE(isVisible);
557 
558     result = AppAccountManager::CheckAuthTokenVisibility(
559         STRING_NAME, STRING_OUT_OF_RANGE, STRING_BUNDLE_NAME, isVisible);
560     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
561     EXPECT_FALSE(isVisible);
562 
563     result = AppAccountManager::CheckAuthTokenVisibility(
564         STRING_NAME, STRING_AUTH_TYPE, STRING_EMPTY, isVisible);
565     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
566     EXPECT_FALSE(isVisible);
567     result = AppAccountManager::CheckAuthTokenVisibility(
568         STRING_NAME, STRING_AUTH_TYPE, STRING_OUT_OF_RANGE, isVisible);
569     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
570     EXPECT_FALSE(isVisible);
571 }
572 
573 /**
574  * @tc.name: AppAccountManager_CheckAuthTokenVisibility_0200
575  * @tc.desc: Fail to check oauth token visibility from shell process.
576  * @tc.type: FUNC
577  * @tc.require:
578  */
579 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAuthTokenVisibility_0200, TestSize.Level1)
580 {
581     ACCOUNT_LOGI("AppAccountManager_CheckAuthTokenVisibility_0200");
582     bool isVisible = false;
583     ErrCode result = AppAccountManager::CheckAuthTokenVisibility(
584         STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
585     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
586     EXPECT_FALSE(isVisible);
587 }
588 
589 /**
590  * @tc.name: AppAccountManager_DeleteAccount_0100
591  * @tc.desc: Delete an app account with invalid data.
592  * @tc.type: FUNC
593  * @tc.require: issueI4MBQW
594  */
595 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAccount_0100, TestSize.Level0)
596 {
597     ACCOUNT_LOGI("AppAccountManager_DeleteAccount_0100");
598 
599     ErrCode result = AppAccountManager::DeleteAccount(STRING_EMPTY);
600     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
601 }
602 
603 /**
604  * @tc.name: AppAccountManager_DeleteAccount_0200
605  * @tc.desc: Delete an app account with invalid data.
606  * @tc.type: FUNC
607  * @tc.require: issueI4MBQW
608  */
609 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAccount_0200, TestSize.Level1)
610 {
611     ACCOUNT_LOGI("AppAccountManager_DeleteAccount_0200");
612 
613     ErrCode result = AppAccountManager::DeleteAccount(STRING_NAME_OUT_OF_RANGE);
614     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
615 }
616 
617 /**
618  * @tc.name: AppAccountManager_DeleteAccount_0300
619  * @tc.desc: Failt to delete an app account from shell process.
620  * @tc.type: FUNC
621  * @tc.require: issueI4MBQW
622  */
623 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAccount_0300, TestSize.Level1)
624 {
625     ACCOUNT_LOGI("AppAccountManager_DeleteAccount_0300");
626 
627     ErrCode result = AppAccountManager::DeleteAccount(STRING_NAME);
628     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
629 }
630 
631 /**
632  * @tc.name: AppAccountManager_GetAccountExtraInfo_0100
633  * @tc.desc: Get extra info of an app account with invalid data.
634  * @tc.type: FUNC
635  * @tc.require: issueI4MBQT
636  */
637 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountExtraInfo_0100, TestSize.Level1)
638 {
639     ACCOUNT_LOGI("AppAccountManager_GetAccountExtraInfo_0100");
640 
641     std::string extraInfo;
642     ErrCode result = AppAccountManager::GetAccountExtraInfo(STRING_EMPTY, extraInfo);
643     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
644     EXPECT_EQ(extraInfo, STRING_EMPTY);
645 }
646 
647 /**
648  * @tc.name: AppAccountManager_GetAccountExtraInfo_0200
649  * @tc.desc: Get extra info of an app account with invalid data.
650  * @tc.type: FUNC
651  * @tc.require: issueI4MBQT
652  */
653 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountExtraInfo_0200, TestSize.Level1)
654 {
655     ACCOUNT_LOGI("AppAccountManager_GetAccountExtraInfo_0200");
656 
657     std::string extraInfo;
658     ErrCode result = AppAccountManager::GetAccountExtraInfo(STRING_NAME_OUT_OF_RANGE, extraInfo);
659     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
660     EXPECT_EQ(extraInfo, STRING_EMPTY);
661 }
662 
663 /**
664  * @tc.name: AppAccountManager_GetAccountExtraInfo_0300
665  * @tc.desc: Fail to get extra info of an app account from shell process.
666  * @tc.type: FUNC
667  * @tc.require: issueI4MBQT
668  */
669 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountExtraInfo_0300, TestSize.Level1)
670 {
671     ACCOUNT_LOGI("AppAccountManager_GetAccountExtraInfo_0300");
672     std::string extraInfo;
673     ErrCode result = AppAccountManager::GetAccountExtraInfo(STRING_NAME, extraInfo);
674     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
675     EXPECT_EQ(extraInfo, STRING_EMPTY);
676 }
677 
678 /**
679  * @tc.name: AppAccountManager_SetAccountExtraInfo_0100
680  * @tc.desc: Set extra info of an app account with invalid data.
681  * @tc.type: FUNC
682  * @tc.require: issueI4MBQT
683  */
684 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountExtraInfo_0100, TestSize.Level1)
685 {
686     ACCOUNT_LOGI("AppAccountManager_SetAccountExtraInfo_0100");
687 
688     ErrCode result = AppAccountManager::SetAccountExtraInfo(STRING_EMPTY, STRING_EXTRA_INFO);
689     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
690 }
691 
692 /**
693  * @tc.name: AppAccountManager_SetAccountExtraInfo_0200
694  * @tc.desc: Set extra info of an app account with invalid data.
695  * @tc.type: FUNC
696  * @tc.require: issueI4MBQT
697  */
698 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountExtraInfo_0200, TestSize.Level1)
699 {
700     ACCOUNT_LOGI("AppAccountManager_SetAccountExtraInfo_0200");
701 
702     ErrCode result = AppAccountManager::SetAccountExtraInfo(STRING_NAME_OUT_OF_RANGE, STRING_EXTRA_INFO);
703     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
704 }
705 
706 /**
707  * @tc.name: AppAccountManager_SetAccountExtraInfo_0300
708  * @tc.desc: Set extra info of an app account with invalid data.
709  * @tc.type: FUNC
710  * @tc.require: issueI4MBQT
711  */
712 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountExtraInfo_0300, TestSize.Level1)
713 {
714     ACCOUNT_LOGI("AppAccountManager_SetAccountExtraInfo_0300");
715 
716     ErrCode result = AppAccountManager::SetAccountExtraInfo(STRING_NAME, STRING_EXTRA_INFO_OUT_OF_RANGE);
717     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
718 }
719 
720 /**
721  * @tc.name: AppAccountManager_SetAccountExtraInfo_0400
722  * @tc.desc: Fail to set extra info of an app account from shell process.
723  * @tc.type: FUNC
724  * @tc.require: issueI4MBQT
725  */
726 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountExtraInfo_0400, TestSize.Level1)
727 {
728     ACCOUNT_LOGI("AppAccountManager_SetAccountExtraInfo_0400");
729 
730     ErrCode result = AppAccountManager::SetAccountExtraInfo(STRING_NAME, STRING_EXTRA_INFO);
731     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
732 }
733 
734 /**
735  * @tc.name: AppAccountManager_EnableAppAccess_0100
736  * @tc.desc: Enable app access with invalid data.
737  * @tc.type: FUNC
738  * @tc.require: issueI4MBQT
739  */
740 HWTEST_F(AppAccountManagerTest, AppAccountManager_EnableAppAccess_0100, TestSize.Level1)
741 {
742     ACCOUNT_LOGI("AppAccountManager_EnableAppAccess_0100");
743 
744     ErrCode result = AppAccountManager::EnableAppAccess(STRING_EMPTY, STRING_BUNDLE_NAME);
745     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
746 }
747 
748 /**
749  * @tc.name: AppAccountManager_EnableAppAccess_0200
750  * @tc.desc: Enable app access with invalid data.
751  * @tc.type: FUNC
752  * @tc.require: issueI4MBQT
753  */
754 HWTEST_F(AppAccountManagerTest, AppAccountManager_EnableAppAccess_0200, TestSize.Level1)
755 {
756     ACCOUNT_LOGI("AppAccountManager_EnableAppAccess_0200");
757 
758     ErrCode result = AppAccountManager::EnableAppAccess(STRING_NAME_OUT_OF_RANGE, STRING_BUNDLE_NAME);
759     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
760 }
761 
762 /**
763  * @tc.name: AppAccountManager_EnableAppAccess_0300
764  * @tc.desc: Enable app access with invalid data.
765  * @tc.type: FUNC
766  * @tc.require: issueI4MBQT
767  */
768 HWTEST_F(AppAccountManagerTest, AppAccountManager_EnableAppAccess_0300, TestSize.Level1)
769 {
770     ACCOUNT_LOGI("AppAccountManager_EnableAppAccess_0300");
771 
772     ErrCode result = AppAccountManager::EnableAppAccess(STRING_NAME, STRING_EMPTY);
773     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
774 }
775 
776 /**
777  * @tc.name: AppAccountManager_EnableAppAccess_0400
778  * @tc.desc: Enable app access with invalid data.
779  * @tc.type: FUNC
780  * @tc.require: issueI4MBQT
781  */
782 HWTEST_F(AppAccountManagerTest, AppAccountManager_EnableAppAccess_0400, TestSize.Level1)
783 {
784     ACCOUNT_LOGI("AppAccountManager_EnableAppAccess_0400");
785 
786     ErrCode result = AppAccountManager::EnableAppAccess(STRING_NAME, STRING_AUTHORIZED_APP_OUT_OF_RANGE);
787     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
788 }
789 
790 /**
791  * @tc.name: AppAccountManager_EnableAppAccess_0500
792  * @tc.desc: Fail to enable app access from shell process.
793  * @tc.type: FUNC
794  * @tc.require: issueI4MBQT
795  */
796 HWTEST_F(AppAccountManagerTest, AppAccountManager_EnableAppAccess_0500, TestSize.Level1)
797 {
798     ACCOUNT_LOGI("AppAccountManager_EnableAppAccess_0500");
799     ErrCode result = AppAccountManager::EnableAppAccess(STRING_NAME, STRING_BUNDLE_NAME);
800     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
801 }
802 
803 /**
804  * @tc.name: AppAccountManager_DisableAppAccess_0100
805  * @tc.desc: Disable app access with invalid data.
806  * @tc.type: FUNC
807  * @tc.require: issueI4MBQT
808  */
809 HWTEST_F(AppAccountManagerTest, AppAccountManager_DisableAppAccess_0100, TestSize.Level1)
810 {
811     ACCOUNT_LOGI("AppAccountManager_DisableAppAccess_0100");
812 
813     ErrCode result = AppAccountManager::DisableAppAccess(STRING_EMPTY, STRING_BUNDLE_NAME);
814     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
815 }
816 
817 /**
818  * @tc.name: AppAccountManager_DisableAppAccess_0200
819  * @tc.desc: Disable app access with invalid data.
820  * @tc.type: FUNC
821  * @tc.require: issueI4MBQT
822  */
823 HWTEST_F(AppAccountManagerTest, AppAccountManager_DisableAppAccess_0200, TestSize.Level1)
824 {
825     ACCOUNT_LOGI("AppAccountManager_DisableAppAccess_0200");
826 
827     ErrCode result = AppAccountManager::DisableAppAccess(STRING_NAME_OUT_OF_RANGE, STRING_BUNDLE_NAME);
828     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
829 }
830 
831 /**
832  * @tc.name: AppAccountManager_DisableAppAccess_0300
833  * @tc.desc: Disable app access with invalid data.
834  * @tc.type: FUNC
835  * @tc.require: issueI4MBQT
836  */
837 HWTEST_F(AppAccountManagerTest, AppAccountManager_DisableAppAccess_0300, TestSize.Level1)
838 {
839     ACCOUNT_LOGI("AppAccountManager_DisableAppAccess_0300");
840 
841     ErrCode result = AppAccountManager::DisableAppAccess(STRING_NAME, STRING_EMPTY);
842     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
843 }
844 
845 /**
846  * @tc.name: AppAccountManager_DisableAppAccess_0400
847  * @tc.desc: Disable app access with invalid data.
848  * @tc.type: FUNC
849  * @tc.require: issueI4MBQT
850  */
851 HWTEST_F(AppAccountManagerTest, AppAccountManager_DisableAppAccess_0400, TestSize.Level1)
852 {
853     ACCOUNT_LOGI("AppAccountManager_DisableAppAccess_0400");
854 
855     ErrCode result = AppAccountManager::DisableAppAccess(STRING_NAME, STRING_AUTHORIZED_APP_OUT_OF_RANGE);
856     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
857 }
858 
859 /**
860  * @tc.name: AppAccountManager_DisableAppAccess_0500
861  * @tc.desc: Fail to disable app access from shell process.
862  * @tc.type: FUNC
863  * @tc.require: issueI4MBQT
864  */
865 HWTEST_F(AppAccountManagerTest, AppAccountManager_DisableAppAccess_0500, TestSize.Level1)
866 {
867     ACCOUNT_LOGI("AppAccountManager_DisableAppAccess_0500");
868     ErrCode result = AppAccountManager::DisableAppAccess(STRING_NAME, STRING_BUNDLE_NAME);
869     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
870 }
871 
872 /**
873  * @tc.name: AppAccountManager_SetAppAccess_0100
874  * @tc.desc: Fail to set app access from shell process.
875  * @tc.type: FUNC
876  * @tc.require:
877  */
878 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAppAccess_0100, TestSize.Level1)
879 {
880     ACCOUNT_LOGI("AppAccountManager_SetAppAccess_0100");
881     ErrCode result = AppAccountManager::SetAppAccess(STRING_EMPTY, STRING_BUNDLE_NAME, true);
882     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
883 
884     result = AppAccountManager::SetAppAccess(STRING_NAME_OUT_OF_RANGE, STRING_BUNDLE_NAME, true);
885     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
886 
887     result = AppAccountManager::SetAppAccess(STRING_NAME, STRING_AUTHORIZED_APP_OUT_OF_RANGE, true);
888     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
889 
890     result = AppAccountManager::SetAppAccess(STRING_NAME, STRING_EMPTY, true);
891     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
892 
893     result = AppAccountManager::SetAppAccess(STRING_NAME, STRING_BUNDLE_NAME, true);
894     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
895 
896     result = AppAccountManager::SetAppAccess(STRING_NAME, STRING_BUNDLE_NAME, false);
897     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
898 }
899 
900 /**
901  * @tc.name: AppAccountManager_CheckAppAccountSyncEnable_0100
902  * @tc.desc: Check account sync enable with invalid data.
903  * @tc.type: FUNC
904  * @tc.require: issueI4MBQT
905  */
906 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAppAccountSyncEnable_0100, TestSize.Level1)
907 {
908     ACCOUNT_LOGI("AppAccountManager_CheckAppAccountSyncEnable_0100");
909 
910     bool syncEnable = SYNC_ENABLE_FALSE;
911     ErrCode result = AppAccountManager::CheckAppAccountSyncEnable(STRING_EMPTY, syncEnable);
912     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
913     EXPECT_EQ(syncEnable, SYNC_ENABLE_FALSE);
914 }
915 
916 /**
917  * @tc.name: AppAccountManager_CheckAppAccountSyncEnable_0200
918  * @tc.desc: Check account sync enable with invalid data.
919  * @tc.type: FUNC
920  * @tc.require: issueI4MBQT
921  */
922 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAppAccountSyncEnable_0200, TestSize.Level1)
923 {
924     ACCOUNT_LOGI("AppAccountManager_CheckAppAccountSyncEnable_0200");
925 
926     bool syncEnable = SYNC_ENABLE_FALSE;
927     ErrCode result = AppAccountManager::CheckAppAccountSyncEnable(STRING_NAME_OUT_OF_RANGE, syncEnable);
928     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
929     EXPECT_EQ(syncEnable, SYNC_ENABLE_FALSE);
930 }
931 
932 /**
933  * @tc.name: AppAccountManager_CheckAppAccountSyncEnable_0300
934  * @tc.desc: Fail to check account sync enable from shell process.
935  * @tc.type: FUNC
936  * @tc.require: issueI4MBQT
937  */
938 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAppAccountSyncEnable_0300, TestSize.Level1)
939 {
940     ACCOUNT_LOGI("AppAccountManager_CheckAppAccountSyncEnable_0300");
941     bool syncEnable = SYNC_ENABLE_FALSE;
942     ErrCode result = AppAccountManager::CheckAppAccountSyncEnable(STRING_NAME, syncEnable);
943     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
944     EXPECT_EQ(syncEnable, SYNC_ENABLE_FALSE);
945 }
946 
947 /**
948  * @tc.name: AppAccountManager_SetAppAccountSyncEnable_0100
949  * @tc.desc: Set account sync enable with invalid data.
950  * @tc.type: FUNC
951  * @tc.require: issueI4MBQT
952  */
953 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAppAccountSyncEnable_0100, TestSize.Level1)
954 {
955     ACCOUNT_LOGI("AppAccountManager_SetAppAccountSyncEnable_0100");
956 
957     ErrCode result = AppAccountManager::SetAppAccountSyncEnable(STRING_EMPTY, SYNC_ENABLE_FALSE);
958     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
959 }
960 
961 /**
962  * @tc.name: AppAccountManager_SetAppAccountSyncEnable_0200
963  * @tc.desc: Set account sync enable with invalid data.
964  * @tc.type: FUNC
965  * @tc.require: issueI4MBQT
966  */
967 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAppAccountSyncEnable_0200, TestSize.Level1)
968 {
969     ACCOUNT_LOGI("AppAccountManager_SetAppAccountSyncEnable_0200");
970 
971     ErrCode result = AppAccountManager::SetAppAccountSyncEnable(STRING_NAME_OUT_OF_RANGE, SYNC_ENABLE_FALSE);
972     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
973 }
974 
975 /**
976  * @tc.name: AppAccountManager_SetAppAccountSyncEnable_0300
977  * @tc.desc: Fail to set account sync enable from shell process.
978  * @tc.type: FUNC
979  * @tc.require: issueI4MBQT
980  */
981 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAppAccountSyncEnable_0300, TestSize.Level1)
982 {
983     ACCOUNT_LOGI("AppAccountManager_SetAppAccountSyncEnable_0300");
984     ErrCode result = AppAccountManager::SetAppAccountSyncEnable(STRING_NAME, SYNC_ENABLE_FALSE);
985     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
986 }
987 
988 /**
989  * @tc.name: AppAccountManager_GetAssociatedData_0100
990  * @tc.desc: Get associated data with invalid data.
991  * @tc.type: FUNC
992  * @tc.require: issueI4MBQT
993  */
994 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAssociatedData_0100, TestSize.Level1)
995 {
996     ACCOUNT_LOGI("AppAccountManager_GetAssociatedData_0100");
997 
998     std::string value;
999     ErrCode result = AppAccountManager::GetAssociatedData(STRING_EMPTY, STRING_KEY, value);
1000     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1001     EXPECT_EQ(value, STRING_EMPTY);
1002 }
1003 
1004 /**
1005  * @tc.name: AppAccountManager_GetAssociatedData_0200
1006  * @tc.desc: Get associated data with invalid data.
1007  * @tc.type: FUNC
1008  * @tc.require: issueI4MBQT
1009  */
1010 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAssociatedData_0200, TestSize.Level1)
1011 {
1012     ACCOUNT_LOGI("AppAccountManager_GetAssociatedData_0200");
1013 
1014     std::string value;
1015     ErrCode result = AppAccountManager::GetAssociatedData(STRING_NAME_OUT_OF_RANGE, STRING_KEY, value);
1016     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1017     EXPECT_EQ(value, STRING_EMPTY);
1018 }
1019 
1020 /**
1021  * @tc.name: AppAccountManager_GetAssociatedData_0300
1022  * @tc.desc: Get associated data with invalid data.
1023  * @tc.type: FUNC
1024  * @tc.require: issueI4MBQT
1025  */
1026 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAssociatedData_0300, TestSize.Level1)
1027 {
1028     ACCOUNT_LOGI("AppAccountManager_GetAssociatedData_0300");
1029 
1030     std::string value;
1031     ErrCode result = AppAccountManager::GetAssociatedData(STRING_NAME, STRING_EMPTY, value);
1032     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1033     EXPECT_EQ(value, STRING_EMPTY);
1034 }
1035 
1036 /**
1037  * @tc.name: AppAccountManager_GetAssociatedData_0400
1038  * @tc.desc: Get associated data with invalid data.
1039  * @tc.type: FUNC
1040  * @tc.require: issueI4MBQT
1041  */
1042 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAssociatedData_0400, TestSize.Level1)
1043 {
1044     ACCOUNT_LOGI("AppAccountManager_GetAssociatedData_0400");
1045 
1046     std::string value;
1047     ErrCode result = AppAccountManager::GetAssociatedData(STRING_NAME, STRING_KEY_OUT_OF_RANGE, value);
1048     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1049     EXPECT_EQ(value, STRING_EMPTY);
1050 }
1051 
1052 /**
1053  * @tc.name: AppAccountManager_GetAssociatedData_0500
1054  * @tc.desc: Fail to get associated data from shell process.
1055  * @tc.type: FUNC
1056  * @tc.require: issueI4MBQT
1057  */
1058 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAssociatedData_0500, TestSize.Level1)
1059 {
1060     ACCOUNT_LOGI("AppAccountManager_GetAssociatedData_0500");
1061     std::string value;
1062     ErrCode result = AppAccountManager::GetAssociatedData(STRING_NAME, STRING_KEY, value);
1063     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_APP_INDEX);
1064     EXPECT_EQ(value, STRING_EMPTY);
1065 }
1066 
1067 /**
1068  * @tc.name: AppAccountManager_SetAssociatedData_0100
1069  * @tc.desc: Set associated data with invalid data.
1070  * @tc.type: FUNC
1071  * @tc.require: issueI4MBQT
1072  */
1073 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAssociatedData_0100, TestSize.Level1)
1074 {
1075     ACCOUNT_LOGI("AppAccountManager_SetAssociatedData_0100");
1076 
1077     ErrCode result = AppAccountManager::SetAssociatedData(STRING_EMPTY, STRING_KEY, STRING_VALUE);
1078     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1079 }
1080 
1081 /**
1082  * @tc.name: AppAccountManager_SetAssociatedData_0200
1083  * @tc.desc: Set associated data with invalid data.
1084  * @tc.type: FUNC
1085  * @tc.require: issueI4MBQT
1086  */
1087 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAssociatedData_0200, TestSize.Level1)
1088 {
1089     ACCOUNT_LOGI("AppAccountManager_SetAssociatedData_0200");
1090 
1091     ErrCode result = AppAccountManager::SetAssociatedData(STRING_NAME_OUT_OF_RANGE, STRING_KEY, STRING_VALUE);
1092     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1093 }
1094 
1095 /**
1096  * @tc.name: AppAccountManager_SetAssociatedData_0300
1097  * @tc.desc: Set associated data with invalid data.
1098  * @tc.type: FUNC
1099  * @tc.require: issueI4MBQT
1100  */
1101 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAssociatedData_0300, TestSize.Level1)
1102 {
1103     ACCOUNT_LOGI("AppAccountManager_SetAssociatedData_0300");
1104 
1105     ErrCode result = AppAccountManager::SetAssociatedData(STRING_NAME, STRING_EMPTY, STRING_VALUE);
1106     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1107 }
1108 
1109 /**
1110  * @tc.name: AppAccountManager_SetAssociatedData_0400
1111  * @tc.desc: Set associated data with invalid data.
1112  * @tc.type: FUNC
1113  * @tc.require: issueI4MBQT
1114  */
1115 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAssociatedData_0400, TestSize.Level1)
1116 {
1117     ACCOUNT_LOGI("AppAccountManager_SetAssociatedData_0400");
1118 
1119     ErrCode result = AppAccountManager::SetAssociatedData(STRING_NAME, STRING_KEY_OUT_OF_RANGE, STRING_VALUE);
1120     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1121 }
1122 
1123 /**
1124  * @tc.name: AppAccountManager_SetAssociatedData_0500
1125  * @tc.desc: Set associated data with invalid data.
1126  * @tc.type: FUNC
1127  * @tc.require: issueI4MBQT
1128  */
1129 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAssociatedData_0500, TestSize.Level1)
1130 {
1131     ACCOUNT_LOGI("AppAccountManager_SetAssociatedData_0500");
1132 
1133     ErrCode result = AppAccountManager::SetAssociatedData(STRING_NAME, STRING_KEY, STRING_VALUE_OUT_OF_RANGE);
1134     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1135 }
1136 
1137 /**
1138  * @tc.name: AppAccountManager_SetAssociatedData_0600
1139  * @tc.desc: Fail to set associated data from shell process.
1140  * @tc.type: FUNC
1141  * @tc.require: issueI4MBQT
1142  */
1143 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAssociatedData_0600, TestSize.Level1)
1144 {
1145     ACCOUNT_LOGI("AppAccountManager_SetAssociatedData_0600");
1146     ErrCode result = AppAccountManager::SetAssociatedData(STRING_NAME, STRING_KEY, STRING_VALUE);
1147     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1148 }
1149 
1150 /**
1151  * @tc.name: AppAccountManager_GetAccountCredential_0100
1152  * @tc.desc: Get account credential with invalid data.
1153  * @tc.type: FUNC
1154  * @tc.require: issueI4MBQT
1155  */
1156 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountCredential_0100, TestSize.Level1)
1157 {
1158     ACCOUNT_LOGI("AppAccountManager_GetAccountCredential_0100");
1159 
1160     std::string credential;
1161     ErrCode result = AppAccountManager::GetAccountCredential(STRING_EMPTY, STRING_CREDENTIAL_TYPE, credential);
1162     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1163     EXPECT_EQ(credential, STRING_EMPTY);
1164 }
1165 
1166 /**
1167  * @tc.name: AppAccountManager_GetAccountCredential_0200
1168  * @tc.desc: Get account credential with invalid data.
1169  * @tc.type: FUNC
1170  * @tc.require: issueI4MBQT
1171  */
1172 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountCredential_0200, TestSize.Level1)
1173 {
1174     ACCOUNT_LOGI("AppAccountManager_GetAccountCredential_0200");
1175 
1176     std::string credential;
1177     ErrCode result =
1178         AppAccountManager::GetAccountCredential(STRING_NAME_OUT_OF_RANGE, STRING_CREDENTIAL_TYPE, credential);
1179     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1180     EXPECT_EQ(credential, STRING_EMPTY);
1181 }
1182 
1183 /**
1184  * @tc.name: AppAccountManager_GetAccountCredential_0300
1185  * @tc.desc: Get account credential with invalid data.
1186  * @tc.type: FUNC
1187  * @tc.require: issueI4MBQT
1188  */
1189 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountCredential_0300, TestSize.Level1)
1190 {
1191     ACCOUNT_LOGI("AppAccountManager_GetAccountCredential_0300");
1192 
1193     std::string credential;
1194     ErrCode result = AppAccountManager::GetAccountCredential(STRING_NAME, STRING_EMPTY, credential);
1195     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1196     EXPECT_EQ(credential, STRING_EMPTY);
1197 }
1198 
1199 /**
1200  * @tc.name: AppAccountManager_GetAccountCredential_0400
1201  * @tc.desc: Get account credential with invalid data.
1202  * @tc.type: FUNC
1203  * @tc.require: issueI4MBQT
1204  */
1205 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountCredential_0400, TestSize.Level1)
1206 {
1207     ACCOUNT_LOGI("AppAccountManager_GetAccountCredential_0400");
1208 
1209     std::string credential;
1210     ErrCode result =
1211         AppAccountManager::GetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE_OUT_OF_RANGE, credential);
1212     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1213     EXPECT_EQ(credential, STRING_EMPTY);
1214 }
1215 
1216 /**
1217  * @tc.name: AppAccountManager_GetAccountCredential_0500
1218  * @tc.desc: Fail to get account credential from shell process.
1219  * @tc.type: FUNC
1220  * @tc.require: issueI4MBQT
1221  */
1222 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAccountCredential_0500, TestSize.Level1)
1223 {
1224     ACCOUNT_LOGI("AppAccountManager_GetAccountCredential_0500");
1225     std::string credential;
1226     ErrCode result = AppAccountManager::GetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE, credential);
1227     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1228     EXPECT_EQ(credential, STRING_EMPTY);
1229 }
1230 
1231 /**
1232  * @tc.name: AppAccountManager_SetAccountCredential_0100
1233  * @tc.desc: Set account credential with invalid data.
1234  * @tc.type: FUNC
1235  * @tc.require: issueI4MBQT
1236  */
1237 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountCredential_0100, TestSize.Level1)
1238 {
1239     ACCOUNT_LOGI("AppAccountManager_SetAccountCredential_0100");
1240 
1241     ErrCode result = AppAccountManager::SetAccountCredential(STRING_EMPTY, STRING_CREDENTIAL_TYPE, STRING_CREDENTIAL);
1242     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1243 }
1244 
1245 /**
1246  * @tc.name: AppAccountManager_SetAccountCredential_0200
1247  * @tc.desc: Set account credential with invalid data.
1248  * @tc.type: FUNC
1249  * @tc.require: issueI4MBQT
1250  */
1251 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountCredential_0200, TestSize.Level1)
1252 {
1253     ACCOUNT_LOGI("AppAccountManager_SetAccountCredential_0200");
1254 
1255     ErrCode result =
1256         AppAccountManager::SetAccountCredential(STRING_NAME_OUT_OF_RANGE, STRING_CREDENTIAL_TYPE, STRING_CREDENTIAL);
1257     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1258 }
1259 
1260 /**
1261  * @tc.name: AppAccountManager_SetAccountCredential_0300
1262  * @tc.desc: Set account credential with invalid data.
1263  * @tc.type: FUNC
1264  * @tc.require: issueI4MBQT
1265  */
1266 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountCredential_0300, TestSize.Level1)
1267 {
1268     ACCOUNT_LOGI("AppAccountManager_SetAccountCredential_0300");
1269 
1270     ErrCode result = AppAccountManager::SetAccountCredential(STRING_NAME, STRING_EMPTY, STRING_CREDENTIAL);
1271     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1272 }
1273 
1274 /**
1275  * @tc.name: AppAccountManager_SetAccountCredential_0400
1276  * @tc.desc: Set account credential with invalid data.
1277  * @tc.type: FUNC
1278  * @tc.require: issueI4MBQT
1279  */
1280 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountCredential_0400, TestSize.Level1)
1281 {
1282     ACCOUNT_LOGI("AppAccountManager_SetAccountCredential_0400");
1283 
1284     ErrCode result =
1285         AppAccountManager::SetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE_OUT_OF_RANGE, STRING_CREDENTIAL);
1286     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1287 }
1288 
1289 /**
1290  * @tc.name: AppAccountManager_SetAccountCredential_0500
1291  * @tc.desc: Set account credential with invalid data.
1292  * @tc.type: FUNC
1293  * @tc.require: issueI4MBQT
1294  */
1295 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountCredential_0500, TestSize.Level1)
1296 {
1297     ACCOUNT_LOGI("AppAccountManager_SetAccountCredential_0500");
1298 
1299     ErrCode result =
1300         AppAccountManager::SetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE, STRING_CREDENTIAL_OUT_OF_RANGE);
1301     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1302 }
1303 
1304 /**
1305  * @tc.name: AppAccountManager_SetAccountCredential_0600
1306  * @tc.desc: Fail to set account credential from shell process.
1307  * @tc.type: FUNC
1308  * @tc.require: issueI4MBQT
1309  */
1310 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAccountCredential_0600, TestSize.Level1)
1311 {
1312     ACCOUNT_LOGI("AppAccountManager_SetAccountCredential_0600");
1313     ErrCode result = AppAccountManager::SetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE, STRING_CREDENTIAL);
1314     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1315 }
1316 
1317 /**
1318  * @tc.name: AppAccountManager_GetOAuthToken_0100
1319  * @tc.desc: Get oauth token with invalid data.
1320  * @tc.type: FUNC
1321  * @tc.require: issueI4ITYY
1322  */
1323 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetOAuthToken_0100, TestSize.Level1)
1324 {
1325     ACCOUNT_LOGI("AppAccountManager_GetOAuthToken_0100");
1326     std::string token;
1327     ErrCode result = AppAccountManager::GetOAuthToken(STRING_EMPTY, STRING_OWNER, STRING_AUTH_TYPE, token);
1328     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1329     EXPECT_EQ(token, STRING_EMPTY);
1330 
1331     result = AppAccountManager::GetOAuthToken(STRING_NAME, STRING_EMPTY, STRING_AUTH_TYPE, token);
1332     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1333     EXPECT_EQ(token, STRING_EMPTY);
1334 }
1335 
1336 /**
1337  * @tc.name: AppAccountManager_GetOAuthToken_0200
1338  * @tc.desc: Get oauth token with invalid data.
1339  * @tc.type: FUNC
1340  * @tc.require: issueI4ITYY
1341  */
1342 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetOAuthToken_0200, TestSize.Level1)
1343 {
1344     ACCOUNT_LOGI("AppAccountManager_GetOAuthToken_0200");
1345     std::string token;
1346     ErrCode result = AppAccountManager::GetOAuthToken(STRING_NAME_OUT_OF_RANGE, STRING_OWNER, STRING_AUTH_TYPE, token);
1347     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1348     EXPECT_EQ(token, STRING_EMPTY);
1349 
1350     result = AppAccountManager::GetOAuthToken(STRING_NAME, STRING_OWNER_OUT_OF_RANGE, STRING_AUTH_TYPE, token);
1351     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1352     EXPECT_EQ(token, STRING_EMPTY);
1353 
1354     result = AppAccountManager::GetOAuthToken(STRING_NAME, STRING_OWNER, STRING_OUT_OF_RANGE, token);
1355     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1356     EXPECT_EQ(token, STRING_EMPTY);
1357 }
1358 
1359 /**
1360  * @tc.name: AppAccountManager_GetOAuthToken_0300
1361  * @tc.desc: Fail to get oauth token from shell process.
1362  * @tc.type: FUNC
1363  * @tc.require: issueI4ITYY
1364  */
1365 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetOAuthToken_0300, TestSize.Level1)
1366 {
1367     ACCOUNT_LOGI("AppAccountManager_GetOAuthToken_0300");
1368     std::string token;
1369     ErrCode result = AppAccountManager::GetOAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, token);
1370     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1371     EXPECT_EQ(token, STRING_EMPTY);
1372 }
1373 
1374 /**
1375  * @tc.name: AppAccountManager_GetAuthToken_0100
1376  * @tc.desc: Get oauth token with invalid data.
1377  * @tc.type: FUNC
1378  * @tc.require:
1379  */
1380 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAuthToken_0100, TestSize.Level1)
1381 {
1382     ACCOUNT_LOGI("AppAccountManager_GetAuthToken_0100");
1383     std::string token;
1384     ErrCode result = AppAccountManager::GetAuthToken(STRING_EMPTY, STRING_OWNER, STRING_AUTH_TYPE, token);
1385     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1386     EXPECT_EQ(token, STRING_EMPTY);
1387 
1388     result = AppAccountManager::GetAuthToken(STRING_NAME, STRING_EMPTY, STRING_AUTH_TYPE, token);
1389     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1390     EXPECT_EQ(token, STRING_EMPTY);
1391 }
1392 
1393 /**
1394  * @tc.name: AppAccountManager_GetAuthToken_0200
1395  * @tc.desc: Get oauth token with invalid data.
1396  * @tc.type: FUNC
1397  * @tc.require:
1398  */
1399 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAuthToken_0200, TestSize.Level1)
1400 {
1401     ACCOUNT_LOGI("AppAccountManager_GetAuthToken_0200");
1402     std::string token;
1403     ErrCode result = AppAccountManager::GetAuthToken(STRING_NAME_OUT_OF_RANGE, STRING_OWNER, STRING_AUTH_TYPE, token);
1404     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1405     EXPECT_EQ(token, STRING_EMPTY);
1406 
1407     result = AppAccountManager::GetAuthToken(STRING_NAME, STRING_OWNER_OUT_OF_RANGE, STRING_AUTH_TYPE, token);
1408     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1409     EXPECT_EQ(token, STRING_EMPTY);
1410 
1411     result = AppAccountManager::GetAuthToken(STRING_NAME, STRING_OWNER, STRING_OUT_OF_RANGE, token);
1412     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1413     EXPECT_EQ(token, STRING_EMPTY);
1414 }
1415 
1416 /**
1417  * @tc.name: AppAccountManager_GetAuthToken_0300
1418  * @tc.desc: Fail to get oauth token from shell process.
1419  * @tc.type: FUNC
1420  * @tc.require:
1421  */
1422 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAuthToken_0300, TestSize.Level1)
1423 {
1424     ACCOUNT_LOGI("AppAccountManager_GetAuthToken_0300");
1425     std::string token;
1426     ErrCode result = AppAccountManager::GetAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, token);
1427     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1428     EXPECT_EQ(token, STRING_EMPTY);
1429 }
1430 
1431 /**
1432  * @tc.name: AppAccountManager_SetOAuthToken_0100
1433  * @tc.desc: Set oauth token with invalid data.
1434  * @tc.type: FUNC
1435  * @tc.require: issueI4ITYY
1436  */
1437 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetOAuthToken_0100, TestSize.Level1)
1438 {
1439     ACCOUNT_LOGI("AppAccountManager_SetOAuthToken_0100");
1440     ErrCode result = AppAccountManager::SetOAuthToken(STRING_EMPTY, STRING_AUTH_TYPE, STRING_TOKEN);
1441     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1442 }
1443 
1444 /**
1445  * @tc.name: AppAccountManager_SetOAuthToken_0200
1446  * @tc.desc: Set oauth token with invalid data.
1447  * @tc.type: FUNC
1448  * @tc.require: issueI4ITYY
1449  */
1450 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetOAuthToken_0200, TestSize.Level1)
1451 {
1452     ACCOUNT_LOGI("AppAccountManager_SetOAuthToken_0200");
1453     ErrCode result = AppAccountManager::SetOAuthToken(STRING_NAME_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_TOKEN);
1454     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1455 
1456     result = AppAccountManager::SetOAuthToken(STRING_NAME, STRING_OUT_OF_RANGE, STRING_TOKEN);
1457     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1458 
1459     result = AppAccountManager::SetOAuthToken(STRING_NAME, STRING_AUTH_TYPE, STRING_TOKEN_OUT_OF_RANGE);
1460     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1461 }
1462 
1463 /**
1464  * @tc.name: AppAccountManager_SetOAuthToken_0300
1465  * @tc.desc: Fail to set oauth token from shell process.
1466  * @tc.type: FUNC
1467  * @tc.require: issueI4ITYY
1468  */
1469 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetOAuthToken_0300, TestSize.Level1)
1470 {
1471     ACCOUNT_LOGI("AppAccountManager_SetOAuthToken_0300");
1472     ErrCode result = AppAccountManager::SetOAuthToken(STRING_NAME, STRING_AUTH_TYPE, STRING_TOKEN);
1473     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1474 }
1475 
1476 /**
1477  * @tc.name: AppAccountManager_DeleteOAuthToken_0100
1478  * @tc.desc: Delete oauth token with invalid data.
1479  * @tc.type: FUNC
1480  * @tc.require: issueI4ITYY
1481  */
1482 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteOAuthToken_0100, TestSize.Level1)
1483 {
1484     ACCOUNT_LOGI("AppAccountManager_DeleteOAuthToken_0100");
1485     ErrCode result = AppAccountManager::DeleteOAuthToken(STRING_EMPTY, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
1486     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1487 
1488     result = AppAccountManager::DeleteOAuthToken(STRING_NAME, STRING_EMPTY, STRING_AUTH_TYPE, STRING_TOKEN);
1489     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1490 }
1491 
1492 /**
1493  * @tc.name: AppAccountManager_DeleteOAuthToken_0200
1494  * @tc.desc: Delete oauth token with invalid data.
1495  * @tc.type: FUNC
1496  * @tc.require: issueI4ITYY
1497  */
1498 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteOAuthToken_0200, TestSize.Level1)
1499 {
1500     ACCOUNT_LOGI("AppAccountManager_DeleteOAuthToken_0200");
1501     ErrCode result = AppAccountManager::DeleteOAuthToken(
1502             STRING_NAME_OUT_OF_RANGE, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
1503     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1504 
1505     result = AppAccountManager::DeleteOAuthToken(
1506         STRING_NAME, STRING_OWNER_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_TOKEN);
1507     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1508 
1509     result = AppAccountManager::DeleteOAuthToken(
1510         STRING_NAME, STRING_OWNER, STRING_OUT_OF_RANGE, STRING_TOKEN);
1511     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1512 
1513     result = AppAccountManager::DeleteOAuthToken(
1514         STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN_OUT_OF_RANGE);
1515     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1516 }
1517 
1518 /**
1519  * @tc.name: AppAccountManager_DeleteOAuthToken_0300
1520  * @tc.desc: Delete oauth token with invalid data.
1521  * @tc.type: FUNC
1522  * @tc.require: issueI4ITYY
1523  */
1524 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteOAuthToken_0300, TestSize.Level1)
1525 {
1526     ACCOUNT_LOGI("AppAccountManager_DeleteOAuthToken_0300");
1527     ErrCode result = AppAccountManager::DeleteOAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
1528     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1529 }
1530 
1531 /**
1532  * @tc.name: AppAccountManager_DeleteAuthToken_0100
1533  * @tc.desc: Delete oauth token with invalid data.
1534  * @tc.type: FUNC
1535  * @tc.require:
1536  */
1537 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAuthToken_0100, TestSize.Level1)
1538 {
1539     ACCOUNT_LOGI("AppAccountManager_DeleteAuthToken_0100");
1540     ErrCode result = AppAccountManager::DeleteAuthToken(STRING_EMPTY, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
1541     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1542 
1543     result = AppAccountManager::DeleteAuthToken(STRING_NAME, STRING_EMPTY, STRING_AUTH_TYPE, STRING_TOKEN);
1544     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1545 }
1546 
1547 /**
1548  * @tc.name: AppAccountManager_DeleteAuthToken_0200
1549  * @tc.desc: Delete oauth token with invalid data.
1550  * @tc.type: FUNC
1551  * @tc.require:
1552  */
1553 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAuthToken_0200, TestSize.Level1)
1554 {
1555     ACCOUNT_LOGI("AppAccountManager_DeleteAuthToken_0200");
1556     ErrCode result = AppAccountManager::DeleteAuthToken(
1557             STRING_NAME_OUT_OF_RANGE, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
1558     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1559 
1560     result = AppAccountManager::DeleteAuthToken(
1561         STRING_NAME, STRING_OWNER_OUT_OF_RANGE, STRING_AUTH_TYPE, STRING_TOKEN);
1562     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1563 
1564     result = AppAccountManager::DeleteAuthToken(
1565         STRING_NAME, STRING_OWNER, STRING_OUT_OF_RANGE, STRING_TOKEN);
1566     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1567 
1568     result = AppAccountManager::DeleteAuthToken(
1569         STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN_OUT_OF_RANGE);
1570     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1571 }
1572 
1573 /**
1574  * @tc.name: AppAccountManager_DeleteAuthToken_0300
1575  * @tc.desc: Delete oauth token with invalid data.
1576  * @tc.type: FUNC
1577  * @tc.require:
1578  */
1579 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAuthToken_0300, TestSize.Level1)
1580 {
1581     ACCOUNT_LOGI("AppAccountManager_DeleteAuthToken_0300");
1582     ErrCode result = AppAccountManager::DeleteAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
1583     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1584 }
1585 
1586 /**
1587  * @tc.name: AppAccountManager_GetAllOAuthTokens_0100
1588  * @tc.desc: Get all oauth tokens with invalid data.
1589  * @tc.type: FUNC
1590  * @tc.require: issueI4ITYY
1591  */
1592 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllOAuthTokens_0100, TestSize.Level1)
1593 {
1594     ACCOUNT_LOGI("AppAccountManager_GetAllOAuthTokens_0100");
1595     std::vector<OAuthTokenInfo> tokenInfos;
1596     ErrCode result = AppAccountManager::GetAllOAuthTokens(STRING_EMPTY, STRING_OWNER, tokenInfos);
1597     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1598     EXPECT_EQ(tokenInfos.size(), 0);
1599 
1600     result = AppAccountManager::GetAllOAuthTokens(STRING_NAME, STRING_EMPTY, tokenInfos);
1601     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1602     EXPECT_EQ(tokenInfos.size(), 0);
1603 }
1604 
1605 /**
1606  * @tc.name: AppAccountManager_GetAllOAuthTokens_0200
1607  * @tc.desc: Get all oauth tokens with invalid data.
1608  * @tc.type: FUNC
1609  * @tc.require: issueI4ITYY
1610  */
1611 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllOAuthTokens_0200, TestSize.Level1)
1612 {
1613     ACCOUNT_LOGI("AppAccountManager_GetAllOAuthTokens_0200");
1614     std::vector<OAuthTokenInfo> tokenInfos;
1615     ErrCode result = AppAccountManager::GetAllOAuthTokens(STRING_NAME_OUT_OF_RANGE, STRING_OWNER, tokenInfos);
1616     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1617     EXPECT_EQ(tokenInfos.size(), 0);
1618 
1619     result = AppAccountManager::GetAllOAuthTokens(STRING_NAME, STRING_OWNER_OUT_OF_RANGE, tokenInfos);
1620     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1621     EXPECT_EQ(tokenInfos.size(), 0);
1622 
1623     result = AppAccountManager::GetAllOAuthTokens(STRING_NAME, STRING_OWNER, tokenInfos);
1624     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1625     EXPECT_EQ(tokenInfos.size(), 0);
1626 }
1627 
1628 /**
1629  * @tc.name: AppAccountManager_GetAllOAuthTokens_0300
1630  * @tc.desc: Fail to get all oauth tokens from shell process.
1631  * @tc.type: FUNC
1632  * @tc.require: issueI4ITYY
1633  */
1634 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllOAuthTokens_0300, TestSize.Level1)
1635 {
1636     ACCOUNT_LOGI("AppAccountManager_GetAllOAuthTokens_0300");
1637     std::vector<OAuthTokenInfo> tokenInfos;
1638     ErrCode result = AppAccountManager::GetAllOAuthTokens(STRING_NAME, STRING_OWNER, tokenInfos);
1639     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1640     EXPECT_EQ(tokenInfos.size(), 0);
1641 }
1642 
1643 /**
1644  * @tc.name: AppAccountManager_GetAuthenticatorInfo_0100
1645  * @tc.desc: Fail to get authenticator info with invalid owner.
1646  * @tc.type: FUNC
1647  * @tc.require: issueI4ITYY
1648  */
1649 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAuthenticatorInfo_0100, TestSize.Level1)
1650 {
1651     ACCOUNT_LOGI("AppAccountManager_GetAuthenticatorInfo_0100");
1652     AuthenticatorInfo info;
1653     ErrCode result = AppAccountManager::GetAuthenticatorInfo(STRING_OUT_OF_RANGE, info);
1654     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1655     result = AppAccountManager::GetAuthenticatorInfo(STRING_EMPTY, info);
1656     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1657 
1658     result = AppAccountManager::GetAuthenticatorInfo(STRING_SESSION_ID, info);
1659     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_APP_INDEX);
1660 }
1661 
1662 /**
1663  * @tc.name: AppAccountManager_GetOAuthList_0100
1664  * @tc.desc: Get all oauth tokens with invalid owner.
1665  * @tc.type: FUNC
1666  * @tc.require: issueI4ITYY
1667  */
1668 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetOAuthList_0100, TestSize.Level1)
1669 {
1670     ACCOUNT_LOGI("AppAccountManager_GetOAuthList_0100");
1671     std::set<std::string> oauthList;
1672     ErrCode result = AppAccountManager::GetOAuthList(STRING_OUT_OF_RANGE, STRING_AUTH_TYPE, oauthList);
1673     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1674     EXPECT_TRUE(oauthList.empty());
1675     result = AppAccountManager::GetOAuthList(STRING_EMPTY, STRING_AUTH_TYPE, oauthList);
1676     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1677     EXPECT_TRUE(oauthList.empty());
1678     result = AppAccountManager::GetOAuthList(STRING_OWNER, STRING_OUT_OF_RANGE, oauthList);
1679     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1680     EXPECT_TRUE(oauthList.empty());
1681 
1682     result = AppAccountManager::GetOAuthList(STRING_OWNER, STRING_AUTH_TYPE, oauthList);
1683     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1684     EXPECT_TRUE(oauthList.empty());
1685 }
1686 
1687 /**
1688  * @tc.name: AppAccountManager_GetAuthList_0100
1689  * @tc.desc: Get all oauth tokens with invalid owner.
1690  * @tc.type: FUNC
1691  * @tc.require:
1692  */
1693 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAuthList_0100, TestSize.Level1)
1694 {
1695     ACCOUNT_LOGI("AppAccountManager_GetAuthList_0100");
1696     std::set<std::string> oauthList;
1697     ErrCode result = AppAccountManager::GetAuthList(STRING_OUT_OF_RANGE, STRING_AUTH_TYPE, oauthList);
1698     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1699     EXPECT_TRUE(oauthList.empty());
1700     result = AppAccountManager::GetAuthList(STRING_EMPTY, STRING_AUTH_TYPE, oauthList);
1701     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1702     EXPECT_TRUE(oauthList.empty());
1703     result = AppAccountManager::GetAuthList(STRING_OWNER, STRING_OUT_OF_RANGE, oauthList);
1704     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1705     EXPECT_TRUE(oauthList.empty());
1706 
1707     result = AppAccountManager::GetAuthList(STRING_OWNER, STRING_AUTH_TYPE, oauthList);
1708     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1709     EXPECT_TRUE(oauthList.empty());
1710 }
1711 
1712 /**
1713  * @tc.name: AppAccountManager_GetAuthenticatorCallback_0100
1714  * @tc.desc: Fail to get authenticator callback with invalid session id.
1715  * @tc.type: FUNC
1716  * @tc.require: issueI4ITYY
1717  */
1718 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAuthenticatorCallback_0100, TestSize.Level1)
1719 {
1720     ACCOUNT_LOGI("AppAccountManager_GetAuthenticatorCallback_0100");
1721     sptr<IRemoteObject> callback;
1722     ErrCode result = AppAccountManager::GetAuthenticatorCallback(STRING_OUT_OF_RANGE, callback);
1723     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1724     result = AppAccountManager::GetAuthenticatorCallback(STRING_EMPTY, callback);
1725     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1726 
1727     result = AppAccountManager::GetAuthenticatorCallback(STRING_SESSION_ID, callback);
1728 #ifdef PROXY_MOCK
1729     EXPECT_NE(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1730 #else // BUNDLE_ADAPTER_MOCK
1731     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1732 #endif
1733 }
1734 
1735 /**
1736  * @tc.name: AppAccountManager_CheckAppAccess_0100
1737  * @tc.desc: Fail to check app access with invalid name and bundle name.
1738  * @tc.type: FUNC
1739  * @tc.require: issueI4ITYY
1740  */
1741 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAppAccess_0100, TestSize.Level1)
1742 {
1743     ACCOUNT_LOGI("AppAccountManager_CheckAppAccess_0100");
1744     bool isAccess = false;
1745     ErrCode result = AppAccountManager::CheckAppAccess(STRING_OUT_OF_RANGE, STRING_BUNDLE_NAME, isAccess);
1746     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1747     result = AppAccountManager::CheckAppAccess(STRING_EMPTY, STRING_BUNDLE_NAME, isAccess);
1748     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1749     result = AppAccountManager::CheckAppAccess(STRING_NAME, STRING_OUT_OF_RANGE, isAccess);
1750     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1751     result = AppAccountManager::CheckAppAccess(STRING_NAME, STRING_EMPTY, isAccess);
1752     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1753 
1754     result = AppAccountManager::CheckAppAccess(STRING_NAME, STRING_BUNDLE_NAME, isAccess);
1755     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1756 }
1757 
1758 /**
1759  * @tc.name: AppAccountManager_DeleteAccountCredential_0100
1760  * @tc.desc: Fail to check app access with invalid name and bundle name.
1761  * @tc.type: FUNC
1762  * @tc.require: issueI4ITYY
1763  */
1764 HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteAccountCredential_0100, TestSize.Level1)
1765 {
1766     ACCOUNT_LOGI("AppAccountManager_DeleteAccountCredential_0100");
1767     ErrCode result = AppAccountManager::DeleteAccountCredential(STRING_OUT_OF_RANGE, STRING_CREDENTIAL);
1768     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1769     result = AppAccountManager::DeleteAccountCredential(STRING_EMPTY, STRING_CREDENTIAL);
1770     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1771     result = AppAccountManager::DeleteAccountCredential(STRING_NAME, STRING_OUT_OF_RANGE);
1772     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1773     result = AppAccountManager::DeleteAccountCredential(STRING_NAME, STRING_EMPTY);
1774     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1775 
1776     result = AppAccountManager::DeleteAccountCredential(STRING_NAME, STRING_CREDENTIAL);
1777     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1778 }
1779 
1780 /**
1781  * @tc.name: AppAccountManager_SelectAccountsByOptions_0100
1782  * @tc.desc: Fail to select accounts by options with invalid parameters.
1783  * @tc.type: FUNC
1784  * @tc.require: issueI4ITYY
1785  */
1786 HWTEST_F(AppAccountManagerTest, AppAccountManager_SelectAccountsByOptions_0100, TestSize.Level1)
1787 {
1788     // check callback
1789     ACCOUNT_LOGI("AppAccountManager_SelectAccountsByOptions_0100");
1790     SelectAccountsOptions options;
1791     ErrCode result = AppAccountManager::SelectAccountsByOptions(options, nullptr);
1792     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1793 
1794     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
1795     EXPECT_NE(callback, nullptr);
1796     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1797     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1798 
1799     // check options.allowedAccounts array size
1800     options.allowedAccounts.clear();
1801     for (int i = 0; i < ALLOWED_ARRAY_MAX_SIZE; i++) {
1802         std::string testAccountName = "test_name_" + std::to_string(i);
1803         std::string testAccountOwner = "test_owner_" + std::to_string(i);
1804         options.allowedAccounts.emplace_back(testAccountOwner, testAccountName);
1805     }
1806     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1807     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1808     options.allowedAccounts.emplace_back("test_name_oversize", "test_owner_oversize");
1809     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1810     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1811 
1812     // check options.allowedOwners array size
1813     options.allowedAccounts.clear();
1814     for (int i = 0; i < ALLOWED_ARRAY_MAX_SIZE; i++) {
1815         std::string testOwner = "test_owner_" + std::to_string(i);
1816         options.allowedOwners.emplace_back(testOwner);
1817     }
1818     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1819     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1820     options.allowedOwners.emplace_back("test_owner_oversize");
1821     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1822     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1823 
1824     // check SelectAccountsOptions.requiredLabels array size
1825     options.allowedOwners.clear();
1826     for (int i = 0; i < ALLOWED_ARRAY_MAX_SIZE; i++) {
1827         std::string testLabel= "test_label_" + std::to_string(i);
1828         options.requiredLabels.emplace_back(testLabel);
1829     }
1830     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1831     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1832     options.requiredLabels.emplace_back("test_label_oversize");
1833     result = AppAccountManager::SelectAccountsByOptions(options, callback);
1834     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1835 }
1836 
1837 /**
1838  * @tc.name: AppAccountManager_VerifyCredential_0100
1839  * @tc.desc: Fail to select accounts by options with invalid parameters.
1840  * @tc.type: FUNC
1841  * @tc.require: issueI4ITYY
1842  */
1843 HWTEST_F(AppAccountManagerTest, AppAccountManager_VerifyCredential_0100, TestSize.Level1)
1844 {
1845     ACCOUNT_LOGI("AppAccountManager_SelectAccountsByOptions_0100");
1846     VerifyCredentialOptions options;
1847     // check name
1848     ErrCode result = AppAccountManager::VerifyCredential(STRING_OUT_OF_RANGE, STRING_OWNER, options, nullptr);
1849     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1850     result = AppAccountManager::VerifyCredential(STRING_EMPTY, STRING_OWNER, options, nullptr);
1851     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1852     // check owner
1853     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OUT_OF_RANGE, options, nullptr);
1854     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1855     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_EMPTY, options, nullptr);
1856     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1857     // check callback
1858     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OWNER, options, nullptr);
1859     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1860 
1861     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
1862     EXPECT_NE(callback, nullptr);
1863     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OWNER, options, callback);
1864     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1865     // check option.credentialType
1866     std::string testCredentialType = "";
1867     for (int i = 0; i < CREDENTIAL_TYPE_MAX_SIZE + 1; i++) {
1868         testCredentialType += 'c';
1869     }
1870     options.credentialType = testCredentialType;
1871     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OWNER, options, callback);
1872     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1873     options.credentialType = "";
1874     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OWNER, options, callback);
1875     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1876     // check option.credential
1877     std::string testCredential = "";
1878     for (int i = 0; i < CREDENTIAL_MAX_SIZE + 1; i++) {
1879         testCredential += 'c';
1880     }
1881     options.credential = testCredential;
1882     result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OWNER, options, callback);
1883     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1884 }
1885 
1886 /**
1887  * @tc.name: AppAccountManager_CheckAccountLabels_0100
1888  * @tc.desc: Fail to check account labels with invalid parameters.
1889  * @tc.type: FUNC
1890  * @tc.require: issueI4ITYY
1891  */
1892 HWTEST_F(AppAccountManagerTest, AppAccountManager_CheckAccountLabels_0100, TestSize.Level1)
1893 {
1894     ACCOUNT_LOGI("AppAccountManager_CheckAccountLabels_0100");
1895     std::vector<std::string> labels;
1896     labels.clear();
1897     ErrCode result = AppAccountManager::CheckAccountLabels(STRING_OUT_OF_RANGE, STRING_OWNER, labels, nullptr);
1898     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1899     result = AppAccountManager::CheckAccountLabels(STRING_EMPTY, STRING_OWNER, labels, nullptr);
1900     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1901     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OUT_OF_RANGE, labels, nullptr);
1902     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1903     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_EMPTY, labels, nullptr);
1904     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1905     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OWNER, labels, nullptr);
1906     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1907 
1908     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
1909     EXPECT_NE(callback, nullptr);
1910     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OWNER, labels, callback);
1911     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1912 
1913     for (int i = 0; i < ALLOWED_ARRAY_MAX_SIZE; i++) {
1914         std::string testLabel = "test_label_" + std::to_string(i);
1915         labels.emplace_back(testLabel);
1916     }
1917     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OWNER, labels, callback);
1918     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1919     labels.emplace_back("test_label_oversize");
1920     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OWNER, labels, callback);
1921     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1922 
1923     labels.clear();
1924     labels.emplace_back("test_label");
1925     result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OWNER, labels, callback);
1926     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1927 }
1928 
1929 /**
1930  * @tc.name: AppAccountManager_SetAuthenticatorProperties_0100
1931  * @tc.desc: Fail to set authenticator properties with invalid parameters.
1932  * @tc.type: FUNC
1933  * @tc.require: issueI4ITYY
1934  */
1935 HWTEST_F(AppAccountManagerTest, AppAccountManager_SetAuthenticatorProperties_0100, TestSize.Level1)
1936 {
1937     ACCOUNT_LOGI("AppAccountManager_SetAuthenticatorProperties_0100");
1938     SetPropertiesOptions options;
1939     // check owner
1940     ErrCode result = AppAccountManager::SetAuthenticatorProperties(STRING_OUT_OF_RANGE, options, nullptr);
1941     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1942     result = AppAccountManager::SetAuthenticatorProperties(STRING_EMPTY, options, nullptr);
1943     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1944     // check callback
1945     result = AppAccountManager::SetAuthenticatorProperties(STRING_OWNER, options, nullptr);
1946     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1947 
1948     sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
1949     EXPECT_NE(callback, nullptr);
1950     result = AppAccountManager::SetAuthenticatorProperties(STRING_OWNER, options, callback);
1951     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1952 }
1953 
1954 /**
1955  * @tc.name: AppAccountManager_GetAllAccounts_0100
1956  * @tc.desc: Get all accounts with invalid data.
1957  * @tc.type: FUNC
1958  * @tc.require: issueI4MBQS
1959  */
1960 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllAccounts_0100, TestSize.Level0)
1961 {
1962     ACCOUNT_LOGI("AppAccountManager_GetAllAccounts_0100");
1963 
1964     std::vector<AppAccountInfo> appAccounts;
1965     ErrCode result = AppAccountManager::GetAllAccounts(STRING_EMPTY, appAccounts);
1966     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1967     EXPECT_EQ(appAccounts.size(), SIZE_ZERO);
1968 }
1969 
1970 /**
1971  * @tc.name: AppAccountManager_GetAllAccounts_0200
1972  * @tc.desc: Get all accounts with invalid data.
1973  * @tc.type: FUNC
1974  * @tc.require: issueI4MBQS
1975  */
1976 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllAccounts_0200, TestSize.Level1)
1977 {
1978     ACCOUNT_LOGI("AppAccountManager_GetAllAccounts_0200");
1979 
1980     std::vector<AppAccountInfo> appAccounts;
1981     ErrCode result = AppAccountManager::GetAllAccounts(STRING_OWNER_OUT_OF_RANGE, appAccounts);
1982     EXPECT_EQ(result, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
1983     EXPECT_EQ(appAccounts.size(), SIZE_ZERO);
1984 }
1985 
1986 /**
1987  * @tc.name: AppAccountManager_GetAllAccounts_0300
1988  * @tc.desc: Fail to get all accounts from shell process.
1989  * @tc.type: FUNC
1990  * @tc.require: issueI4MBQS
1991  */
1992 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllAccounts_0300, TestSize.Level1)
1993 {
1994     ACCOUNT_LOGI("AppAccountManager_GetAllAccounts_0300");
1995     std::vector<AppAccountInfo> appAccounts;
1996     ErrCode result = AppAccountManager::GetAllAccounts(STRING_OWNER, appAccounts);
1997     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
1998     EXPECT_TRUE(appAccounts.empty());
1999 }
2000 
2001 /**
2002  * @tc.name: AppAccountManager_GetAllAccessibleAccounts_0100
2003  * @tc.desc: Fail to get all accessible accounts from shell process.
2004  * @tc.type: FUNC
2005  * @tc.require: issueI4MBQS
2006  */
2007 HWTEST_F(AppAccountManagerTest, AppAccountManager_GetAllAccessibleAccounts_0100, TestSize.Level1)
2008 {
2009     std::vector<AppAccountInfo> appAccounts;
2010     ErrCode result = AppAccountManager::GetAllAccessibleAccounts(appAccounts);
2011     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
2012     EXPECT_TRUE(appAccounts.empty());
2013 }
2014 
2015 /**
2016  * @tc.name: AppAccountManager_QueryAllAccessibleAccounts_0100
2017  * @tc.desc: Fail to query all accessible accounts from shell process.
2018  * @tc.type: FUNC
2019  * @tc.require: issueI4MBQS
2020  */
2021 HWTEST_F(AppAccountManagerTest, AppAccountManager_QueryAllAccessibleAccounts_0100, TestSize.Level1)
2022 {
2023     std::vector<AppAccountInfo> appAccounts;
2024     std::string owner = "";
2025     ErrCode result = AppAccountManager::QueryAllAccessibleAccounts(owner, appAccounts);
2026     EXPECT_EQ(result, ERR_APPACCOUNT_SERVICE_GET_BUNDLE_NAME);
2027     EXPECT_TRUE(appAccounts.empty());
2028 }
2029 
2030 
2031 /**
2032  * @tc.name: AppAccountManager_UnsubscribeAppAccount_0100
2033  * @tc.desc: Test func success UnsubscribeAppAccount.
2034  * @tc.type: FUNC
2035  * @tc.require:
2036  */
2037 HWTEST_F(AppAccountManagerTest, AppAccountManager_UnsubscribeAppAccount_0100, TestSize.Level1)
2038 {
2039     AppAccountSubscribeInfo subscribeInfo;
2040     std::shared_ptr<AppAccountSubscriberTest> appAccountSubscriberPtr =
2041         std::make_shared<AppAccountSubscriberTest>(subscribeInfo);
2042     ASSERT_NE(appAccountSubscriberPtr, nullptr);
2043     auto appAccountEventListenerSptr = new (std::nothrow) AppAccountEventListener(appAccountSubscriberPtr);
2044     ASSERT_NE(appAccountEventListenerSptr, nullptr);
2045     AppAccount::GetInstance().eventListeners_[appAccountSubscriberPtr] = appAccountEventListenerSptr;
2046     ErrCode result = AppAccount::GetInstance().UnsubscribeAppAccount(appAccountSubscriberPtr);
2047     ASSERT_EQ(result, ERR_OK);
2048 }
2049