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