1 /*
2 * Copyright (c) 2022-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 <gmock/gmock.h>
17 #include "app_account_manager.h"
18 #include "app_account_authenticator_callback_stub.h"
19
20 namespace OHOS {
21 namespace AccountTest {
22 namespace {
23 const std::string STRING_NAME = "name";
24 const std::string STRING_EXTRA_INFO = "extra_info";
25 const std::string STRING_BUNDLE_NAME = "com.example.third_party";
26 const std::string STRING_KEY = "key";
27 const std::string STRING_VALUE = "value";
28 const std::string STRING_CREDENTIAL_TYPE = "password";
29 const std::string STRING_CREDENTIAL = "1024";
30 const std::string STRING_OWNER = "com.example.owner";
31 const std::string STRING_AUTH_TYPE = "all";
32 const std::string STRING_ABILITY_NAME = "MainAbility";
33 const std::string STRING_SESSION_ID = "123456";
34 const std::string STRING_TOKEN = "1024";
35 const bool SYNC_ENABLE_FALSE = false;
36 }
37
38 using namespace testing;
39 using namespace testing::ext;
40 using namespace OHOS::AccountSA;
41
42 class AuthenticatorCallbackMockTest final : public AccountSA::AppAccountAuthenticatorCallbackStub {
43 public:
44 MOCK_METHOD2(OnResult, void(int32_t resultCode, const AAFwk::Want &result));
45 MOCK_METHOD1(OnRequestRedirected, void(AAFwk::Want &request));
46 MOCK_METHOD0(OnRequestContinued, void());
47 };
48
49 class AppAccountProxyMockTest : public testing::Test {
50 public:
51 static void SetUpTestCase(void);
52 static void TearDownTestCase(void);
53 void SetUp(void) override;
54 void TearDown(void) override;
55 };
56
SetUpTestCase(void)57 void AppAccountProxyMockTest::SetUpTestCase(void)
58 {}
59
TearDownTestCase(void)60 void AppAccountProxyMockTest::TearDownTestCase(void)
61 {}
62
SetUp(void)63 void AppAccountProxyMockTest::SetUp(void)
64 {}
65
TearDown(void)66 void AppAccountProxyMockTest::TearDown(void)
67 {}
68 /**
69 * @tc.name: AppAccountManager_AddAccount_0100
70 * @tc.desc: Add an app account with invalid data.
71 * @tc.type: FUNC
72 * @tc.require: issueI4MBQW
73 */
74 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_AddAccount_0100, TestSize.Level0)
75 {
76 ErrCode result = AppAccountManager::AddAccount(STRING_NAME, STRING_EXTRA_INFO);
77 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
78 }
79
80 /**
81 * @tc.name: AppAccountManager_CreateAccount_0100
82 * @tc.desc: Test func with proxy is nullptr.
83 * @tc.type: FUNC
84 * @tc.require: issueI5RWXN
85 */
86 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CreateAccount_0100, TestSize.Level1)
87 {
88 CreateAccountOptions option;
89 ErrCode result = AppAccountManager::CreateAccount("test", option);
90 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
91 }
92
93 /**
94 * @tc.name: AppAccountManager_AddAccountImplicitly_0100
95 * @tc.desc: Test func with proxy is nullptr.
96 * @tc.type: FUNC
97 * @tc.require: issueI4ITYY
98 */
99 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_AddAccountImplicitly_0100, TestSize.Level1)
100 {
101 AAFwk::Want options;
102 options.SetParam(Constants::KEY_CALLER_ABILITY_NAME, STRING_ABILITY_NAME);
103 sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) AuthenticatorCallbackMockTest();
104 ASSERT_NE(callback, nullptr);
105 ErrCode result = AppAccountManager::AddAccountImplicitly(STRING_OWNER, STRING_AUTH_TYPE, options, callback);
106 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
107 }
108
109 /**
110 * @tc.name: AppAccountManager_CreateAccountImplicitly_0100
111 * @tc.desc: Test func with proxy is nullptr.
112 * @tc.type: FUNC
113 * @tc.require: issueI5RWXN
114 */
115 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CreateAccountImplicitly_0100, TestSize.Level1)
116 {
117 CreateAccountImplicitlyOptions options;
118 options.parameters.SetParam(Constants::KEY_CALLER_ABILITY_NAME, STRING_ABILITY_NAME);
119 sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) AuthenticatorCallbackMockTest();
120 ASSERT_NE(callback, nullptr);
121 ErrCode result = AppAccountManager::CreateAccountImplicitly(STRING_OWNER, options, callback);
122 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
123 }
124
125 /**
126 * @tc.name: AppAccountManager_DeleteAccount_0100
127 * @tc.desc: Test func with proxy is nullptr.
128 * @tc.type: FUNC
129 * @tc.require: issueI4MBQW
130 */
131 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_DeleteAccount_0100, TestSize.Level1)
132 {
133 ErrCode result = AppAccountManager::DeleteAccount(STRING_NAME);
134 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
135 }
136
137 /**
138 * @tc.name: AppAccountManager_GetAccountExtraInfo_0100
139 * @tc.desc: Test func with proxy is nullptr.
140 * @tc.type: FUNC
141 * @tc.require: issueI4MBQT
142 */
143 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAccountExtraInfo_0100, TestSize.Level1)
144 {
145 std::string extraInfo;
146 ErrCode result = AppAccountManager::GetAccountExtraInfo(STRING_NAME, extraInfo);
147 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
148 }
149
150 /**
151 * @tc.name: AppAccountManager_SetAccountExtraInfo_0100
152 * @tc.desc: Test func with proxy is nullptr.
153 * @tc.type: FUNC
154 * @tc.require: issueI4MBQT
155 */
156 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAccountExtraInfo_0100, TestSize.Level1)
157 {
158 ErrCode result = AppAccountManager::SetAccountExtraInfo(STRING_NAME, STRING_EXTRA_INFO);
159 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
160 }
161
162
163 /**
164 * @tc.name: AppAccountManager_EnableAppAccess_0100
165 * @tc.desc: Test func with proxy is nullptr.
166 * @tc.type: FUNC
167 * @tc.require: issueI4MBQT
168 */
169 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_EnableAppAccess_0100, TestSize.Level1)
170 {
171 ErrCode result = AppAccountManager::EnableAppAccess(STRING_NAME, STRING_BUNDLE_NAME);
172 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
173 }
174
175 /**
176 * @tc.name: AppAccountManager_DisableAppAccess_0100
177 * @tc.desc: Test func with proxy is nullptr.
178 * @tc.type: FUNC
179 * @tc.require: issueI4MBQT
180 */
181 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_DisableAppAccess_0100, TestSize.Level1)
182 {
183 ErrCode result = AppAccountManager::DisableAppAccess(STRING_NAME, STRING_BUNDLE_NAME);
184 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
185 }
186
187 /**
188 * @tc.name: AppAccountManager_SetAppAccess_0100
189 * @tc.desc: Test func with proxy is nullptr.
190 * @tc.type: FUNC
191 * @tc.require:
192 */
193 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAppAccess_0100, TestSize.Level1)
194 {
195 ErrCode result = AppAccountManager::SetAppAccess(STRING_NAME, STRING_BUNDLE_NAME, false);
196 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
197 }
198
199 /**
200 * @tc.name: AppAccountManager_CheckAppAccountSyncEnable_0100
201 * @tc.desc: Test func with proxy is nullptr.
202 * @tc.type: FUNC
203 * @tc.require: issueI4MBQT
204 */
205 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CheckAppAccountSyncEnable_0100, TestSize.Level1)
206 {
207 bool syncEnable = SYNC_ENABLE_FALSE;
208 ErrCode result = AppAccountManager::CheckAppAccountSyncEnable(STRING_NAME, syncEnable);
209 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
210 }
211
212 /**
213 * @tc.name: AppAccountManager_SetAppAccountSyncEnable_0100
214 * @tc.desc: Test func with proxy is nullptr.
215 * @tc.type: FUNC
216 * @tc.require: issueI4MBQT
217 */
218 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAppAccountSyncEnable_0100, TestSize.Level1)
219 {
220 ErrCode result = AppAccountManager::SetAppAccountSyncEnable(STRING_NAME, SYNC_ENABLE_FALSE);
221 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
222 }
223
224 /**
225 * @tc.name: AppAccountManager_GetAssociatedData_0100
226 * @tc.desc: Test func with proxy is nullptr.
227 * @tc.type: FUNC
228 * @tc.require: issueI4MBQT
229 */
230 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAssociatedData_0100, TestSize.Level1)
231 {
232 std::string value;
233 ErrCode result = AppAccountManager::GetAssociatedData(STRING_NAME, STRING_KEY, value);
234 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
235 }
236
237 /**
238 * @tc.name: AppAccountManager_SetAssociatedData_0100
239 * @tc.desc: Test func with proxy is nullptr.
240 * @tc.type: FUNC
241 * @tc.require: issueI4MBQT
242 */
243 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAssociatedData_0600, TestSize.Level1)
244 {
245 ErrCode result = AppAccountManager::SetAssociatedData(STRING_NAME, STRING_KEY, STRING_VALUE);
246 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
247 }
248
249 /**
250 * @tc.name: AppAccountManager_GetAccountCredential_0100
251 * @tc.desc: Test func with proxy is nullptr.
252 * @tc.type: FUNC
253 * @tc.require: issueI4MBQT
254 */
255 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAccountCredential_0100, TestSize.Level1)
256 {
257 std::string credential;
258 ErrCode result = AppAccountManager::GetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE, credential);
259 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
260 }
261
262 /**
263 * @tc.name: AppAccountManager_SetAccountCredential_0100
264 * @tc.desc: Test func with proxy is nullptr.
265 * @tc.type: FUNC
266 * @tc.require: issueI4MBQT
267 */
268 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAccountCredential_0100, TestSize.Level1)
269 {
270 ErrCode result = AppAccountManager::SetAccountCredential(STRING_NAME, STRING_CREDENTIAL_TYPE, STRING_CREDENTIAL);
271 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
272 }
273
274 /**
275 * @tc.name: AppAccountManager_GetOAuthToken_0100
276 * @tc.desc: Test func with proxy is nullptr.
277 * @tc.type: FUNC
278 * @tc.require: issueI4ITYY
279 */
280 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetOAuthToken_0100, TestSize.Level1)
281 {
282 std::string token;
283 ErrCode result = AppAccountManager::GetOAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, token);
284 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
285 }
286
287 /**
288 * @tc.name: AppAccountManager_GetAuthToken_0100
289 * @tc.desc: Test func with proxy is nullptr.
290 * @tc.type: FUNC
291 * @tc.require:
292 */
293 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAuthToken_0100, TestSize.Level1)
294 {
295 std::string token;
296 ErrCode result = AppAccountManager::GetAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, token);
297 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
298 }
299
300 /**
301 * @tc.name: AppAccountManager_SetOAuthToken_0100
302 * @tc.desc: Test func with proxy is nullptr.
303 * @tc.type: FUNC
304 * @tc.require: issueI4ITYY
305 */
306 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetOAuthToken_0100, TestSize.Level1)
307 {
308 ErrCode result = AppAccountManager::SetOAuthToken(STRING_NAME, STRING_AUTH_TYPE, STRING_TOKEN);
309 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
310 }
311
312 /**
313 * @tc.name: AppAccountManager_DeleteOAuthToken_0100
314 * @tc.desc: Test func with proxy is nullptr.
315 * @tc.type: FUNC
316 * @tc.require: issueI4ITYY
317 */
318 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_DeleteOAuthToken_0100, TestSize.Level1)
319 {
320 ErrCode result = AppAccountManager::DeleteOAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
321 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
322 }
323
324 /**
325 * @tc.name: AppAccountManager_DeleteAuthToken_0100
326 * @tc.desc: Test func with proxy is nullptr.
327 * @tc.type: FUNC
328 * @tc.require:
329 */
330 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_DeleteAuthToken_0100, TestSize.Level1)
331 {
332 ErrCode result = AppAccountManager::DeleteAuthToken(STRING_NAME, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN);
333 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
334 }
335
336 /**
337 * @tc.name: AppAccountManager_SetOAuthTokenVisibility_0100
338 * @tc.desc: Test func with proxy is nullptr.
339 * @tc.type: FUNC
340 * @tc.require: issueI4ITYY
341 */
342 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetOAuthTokenVisibility_0100, TestSize.Level1)
343 {
344 ErrCode result = AppAccountManager::SetOAuthTokenVisibility(
345 STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
346 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
347 }
348
349 /**
350 * @tc.name: AppAccountManager_SetAuthTokenVisibility_0100
351 * @tc.desc: Test func with proxy is nullptr.
352 * @tc.type: FUNC
353 * @tc.require:
354 */
355 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAuthTokenVisibility_0100, TestSize.Level1)
356 {
357 ErrCode result = AppAccountManager::SetAuthTokenVisibility(
358 STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, true);
359 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
360 }
361
362 /**
363 * @tc.name: AppAccountManager_CheckOAuthTokenVisibility_0100
364 * @tc.desc: Test func with proxy is nullptr.
365 * @tc.type: FUNC
366 * @tc.require: issueI4ITYY
367 */
368 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CheckOAuthTokenVisibility_0100, TestSize.Level1)
369 {
370 bool isVisible = false;
371 ErrCode result = AppAccountManager::CheckOAuthTokenVisibility(
372 STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
373 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
374 }
375
376 /**
377 * @tc.name: AppAccountManager_CheckAuthTokenVisibility_0100
378 * @tc.desc: Test func with proxy is nullptr.
379 * @tc.type: FUNC
380 * @tc.require:
381 */
382 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CheckAuthTokenVisibility_0100, TestSize.Level1)
383 {
384 bool isVisible = false;
385 ErrCode result = AppAccountManager::CheckAuthTokenVisibility(
386 STRING_NAME, STRING_AUTH_TYPE, STRING_BUNDLE_NAME, isVisible);
387 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
388 }
389
390
391 /**
392 * @tc.name: AppAccountManager_GetAuthenticatorInfo_0100
393 * @tc.desc: Test func with proxy is nullptr.
394 * @tc.type: FUNC
395 * @tc.require: issueI4ITYY
396 */
397 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAuthenticatorInfo_0100, TestSize.Level1)
398 {
399 AuthenticatorInfo info;
400 ErrCode result = AppAccountManager::GetAuthenticatorInfo(STRING_SESSION_ID, info);
401 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
402 }
403
404 /**
405 * @tc.name: AppAccountManager_GetAllOAuthTokens_0100
406 * @tc.desc: Test func with proxy is nullptr.
407 * @tc.type: FUNC
408 * @tc.require: issueI4ITYY
409 */
410 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAllOAuthTokens_0100, TestSize.Level1)
411 {
412 std::vector<OAuthTokenInfo> tokenInfos;
413 ErrCode result = AppAccountManager::GetAllOAuthTokens(STRING_NAME, STRING_OWNER, tokenInfos);
414 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
415 }
416
417 /**
418 * @tc.name: AppAccountManager_GetOAuthList_0100
419 * @tc.desc: Test func with proxy is nullptr.
420 * @tc.type: FUNC
421 * @tc.require: issueI4ITYY
422 */
423 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetOAuthList_0100, TestSize.Level1)
424 {
425 std::set<std::string> oauthList;
426 ErrCode result = AppAccountManager::GetOAuthList(STRING_OWNER, STRING_AUTH_TYPE, oauthList);
427 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
428 }
429
430 /**
431 * @tc.name: AppAccountManager_GetAuthList_0100
432 * @tc.desc: Test func with proxy is nullptr.
433 * @tc.type: FUNC
434 * @tc.require:
435 */
436 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAuthList_0100, TestSize.Level1)
437 {
438 std::set<std::string> oauthList;
439 ErrCode result = AppAccountManager::GetAuthList(STRING_OWNER, STRING_AUTH_TYPE, oauthList);
440 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
441 }
442
443 /**
444 * @tc.name: AppAccountManager_GetAuthenticatorCallback_0100
445 * @tc.desc: Test func with proxy is nullptr.
446 * @tc.type: FUNC
447 * @tc.require: issueI4ITYY
448 */
449 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAuthenticatorCallback_0100, TestSize.Level1)
450 {
451 sptr<IRemoteObject> callback;
452 ErrCode result = AppAccountManager::GetAuthenticatorCallback(STRING_SESSION_ID, callback);
453 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
454 }
455
456 /**
457 * @tc.name: AppAccountManager_GetAllAccounts_0300
458 * @tc.desc: Test func with proxy is nullptr.
459 * @tc.type: FUNC
460 * @tc.require: issueI4MBQS
461 */
462 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAllAccounts_0300, TestSize.Level1)
463 {
464 std::vector<AppAccountInfo> appAccounts;
465 ErrCode result = AppAccountManager::GetAllAccounts(STRING_OWNER, appAccounts);
466 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
467 }
468
469 /**
470 * @tc.name: AppAccountManager_GetAllAccessibleAccounts_0100
471 * @tc.desc: Test func with proxy is nullptr.
472 * @tc.type: FUNC
473 * @tc.require: issueI4MBQS
474 */
475 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_GetAllAccessibleAccounts_0100, TestSize.Level1)
476 {
477 std::vector<AppAccountInfo> appAccounts;
478 ErrCode result = AppAccountManager::GetAllAccessibleAccounts(appAccounts);
479 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
480 }
481
482 /**
483 * @tc.name: AppAccountManager_QueryAllAccessibleAccounts_0100
484 * @tc.desc: Test func with proxy is nullptr.
485 * @tc.type: FUNC
486 * @tc.require: issueI4MBQS
487 */
488 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_QueryAllAccessibleAccounts_0100, TestSize.Level1)
489 {
490 std::vector<AppAccountInfo> appAccounts;
491 std::string owner = "";
492 ErrCode result = AppAccountManager::QueryAllAccessibleAccounts(owner, appAccounts);
493 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
494 }
495
496 /**
497 * @tc.name: AppAccountManager_CheckAppAccess_0100
498 * @tc.desc: Test func with proxy is nullptr.
499 * @tc.type: FUNC
500 * @tc.require: issueI4ITYY
501 */
502 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CheckAppAccess_0100, TestSize.Level1)
503 {
504 bool isAccess = false;
505 ErrCode result = AppAccountManager::CheckAppAccess(STRING_NAME, STRING_BUNDLE_NAME, isAccess);
506 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
507 }
508
509 /**
510 * @tc.name: AppAccountManager_DeleteAccountCredential_0100
511 * @tc.desc: Test func with proxy is nullptr.
512 * @tc.type: FUNC
513 * @tc.require: issueI4ITYY
514 */
515 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_DeleteAccountCredential_0100, TestSize.Level1)
516 {
517 ErrCode result = AppAccountManager::DeleteAccountCredential(STRING_NAME, STRING_CREDENTIAL);
518 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
519 }
520
521 /**
522 * @tc.name: AppAccountManager_SelectAccountsByOptions_0100
523 * @tc.desc: Test func with proxy is nullptr.
524 * @tc.type: FUNC
525 * @tc.require: issueI4ITYY
526 */
527 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SelectAccountsByOptions_0100, TestSize.Level1)
528 {
529 SelectAccountsOptions options;
530 sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) AuthenticatorCallbackMockTest();
531 ASSERT_NE(callback, nullptr);
532 ErrCode result = AppAccountManager::SelectAccountsByOptions(options, callback);
533 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
534 }
535
536 /**
537 * @tc.name: AppAccountManager_VerifyCredential_0100
538 * @tc.desc: Test func with proxy is nullptr.
539 * @tc.type: FUNC
540 * @tc.require: issueI4ITYY
541 */
542 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_VerifyCredential_0100, TestSize.Level1)
543 {
544 VerifyCredentialOptions options;
545 sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) AuthenticatorCallbackMockTest();
546 ASSERT_NE(callback, nullptr);
547 ErrCode result = AppAccountManager::VerifyCredential(STRING_NAME, STRING_OWNER, options, callback);
548 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
549 }
550
551 /**
552 * @tc.name: AppAccountManager_CheckAccountLabels_0100
553 * @tc.desc: Test func with proxy is nullptr.
554 * @tc.type: FUNC
555 * @tc.require: issueI4ITYY
556 */
557 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_CheckAccountLabels_0100, TestSize.Level1)
558 {
559 std::vector<std::string> labels;
560 sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) AuthenticatorCallbackMockTest();
561 ASSERT_NE(callback, nullptr);
562 labels.emplace_back("test");
563 ErrCode result = AppAccountManager::CheckAccountLabels(STRING_NAME, STRING_OWNER, labels, callback);
564 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
565 }
566
567 /**
568 * @tc.name: AppAccountManager_SetAuthenticatorProperties_0100
569 * @tc.desc: Test func with proxy is nullptr.
570 * @tc.type: FUNC
571 * @tc.require: issueI4ITYY
572 */
573 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SetAuthenticatorProperties_0100, TestSize.Level1)
574 {
575 SetPropertiesOptions options;
576 sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) AuthenticatorCallbackMockTest();
577 ASSERT_NE(callback, nullptr);
578 ErrCode result = AppAccountManager::SetAuthenticatorProperties(STRING_OWNER, options, callback);
579 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
580 }
581
582 /**
583 * @tc.name: AppAccountManager_SubscribeAppAccount_0100
584 * @tc.desc: Test func with proxy is nullptr.
585 * @tc.type: FUNC
586 * @tc.require:
587 */
588 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_SubscribeAppAccount_0100, TestSize.Level1)
589 {
590 ErrCode result = AppAccountManager::SubscribeAppAccount(nullptr);
591 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
592 }
593
594 /**
595 * @tc.name: AppAccountManager_UnsubscribeAppAccount_0100
596 * @tc.desc: Test func with proxy is nullptr.
597 * @tc.type: FUNC
598 * @tc.require:
599 */
600 HWTEST_F(AppAccountProxyMockTest, AppAccountManager_UnsubscribeAppAccount_0100, TestSize.Level1)
601 {
602 ErrCode result = AppAccountManager::UnsubscribeAppAccount(nullptr);
603 ASSERT_EQ(ERR_APPACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER, result);
604 }
605 } // namespace AccountTest
606 } // namespace OHOS