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