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