1/* 2 * Copyright (c) 2021 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 */ 15import account from '@ohos.account.appAccount' 16import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 17import { AccountErrCode } from './AccountErrCode.test.js' 18 19const NAMELIMIT = 512; 20const LENGTHLIMIT = 1024; 21const ERR_PARAMETER_CHECK_FAILD = 401 22const ERR_INVALID_PARAMETER = 12300002 23const createAccountOptions = { customData: { age: '12' } } //k and v length 1024 ,k and v size 1024 24const createAccountOptionsDiff = { customData: { sex: 'male' } } 25 26export default function ActsAccountCreateAccount() { 27 describe('ActsAccountCreateAccount', function () { 28 29 /* 30 * @tc.number : ActsAccountCreateAccount_0100 31 * @tc.name : Add account callback form 32 * @tc.desc : Add account in callback form without additional information 33 */ 34 it('ActsAccountCreateAccount_0100', 0, async function (done) { 35 console.info("====>ActsAccountCreateAccount_0100 start===="); 36 var appAccountManager = account.createAppAccountManager(); 37 console.info("====>creat finish===="); 38 appAccountManager.createAccount("account_name_callback_first", (err) => { 39 console.info("====>add account ActsAccountCreateAccount_0100 err:" + JSON.stringify(err)); 40 expect(err).assertEqual(null); 41 appAccountManager.removeAccount("account_name_callback_first", (err) => { 42 console.info("====>delete Account ActsAccountCreateAccount_0100 err:" + JSON.stringify(err)); 43 expect(err).assertEqual(null); 44 console.info("====>ActsAccountCreateAccount_0100 end===="); 45 done(); 46 }); 47 }); 48 }); 49 50 /* 51 * @tc.number : ActsAccountCreateAccount_0200 52 * @tc.name : Add account promise form 53 * @tc.desc : Add account in promise form without additional information 54 */ 55 it('ActsAccountCreateAccount_0200', 0, async function (done) { 56 console.info("====>ActsAccountCreateAccount_0200 start===="); 57 var appAccountManager = account.createAppAccountManager(); 58 console.info("====>creat finish===="); 59 console.info("====>add account start===="); 60 try { 61 await appAccountManager.createAccount("account_name_promise_first"); 62 } catch (err) { 63 console.error("====>add account fail err:" + JSON.stringify(err)); 64 expect().assertFail(); 65 } 66 try { 67 console.info("====>delete account ActsAccountCreateAccount_0200 start===="); 68 await appAccountManager.removeAccount("account_name_promise_first"); 69 } catch (err) { 70 console.info("====>delete account err:" + JSON.stringify(err)); 71 } 72 console.info("====>ActsAccountCreateAccount_0200 end===="); 73 done(); 74 }); 75 76 /* 77 * @tc.number : ActsAccountCreateAccount_0300 78 * @tc.name : Add account callback form 79 * @tc.desc : Add account in callback form with additional information 80 */ 81 it('ActsAccountCreateAccount_0300', 0, async function (done) { 82 console.info("====>ActsAccountCreateAccount_0300 start===="); 83 var appAccountManager = account.createAppAccountManager(); 84 console.info("====>creat finish===="); 85 appAccountManager.createAccount("account_name_callback_second", createAccountOptions, (err) => { 86 console.info("====>add account ActsAccountCreateAccount_0300 err:" + JSON.stringify(err)); 87 expect(err).assertEqual(null); 88 appAccountManager.removeAccount("account_name_callback_second", (err) => { 89 console.info("====>delete Account ActsAccountCreateAccount_0300 err:" + JSON.stringify(err)); 90 expect(err).assertEqual(null); 91 console.info("====>ActsAccountCreateAccount_0300 end===="); 92 done(); 93 }); 94 }); 95 }); 96 97 /* 98 * @tc.number : ActsAccountCreateAccount_0400 99 * @tc.name : Add account promise form 100 * @tc.desc : Add account in promise form with additional information 101 */ 102 it('ActsAccountCreateAccount_0400', 0, async function (done) { 103 console.info("====>ActsAccountCreateAccount_0400 start===="); 104 var appAccountManager = account.createAppAccountManager(); 105 console.info("====>creat finish===="); 106 console.info("====>add account start===="); 107 try { 108 await appAccountManager.createAccount("account_name_promise_second", createAccountOptions); 109 } catch (err) { 110 console.error("====>add account fail err:" + JSON.stringify(err)); 111 expect().assertFail(); 112 } 113 try { 114 console.info("====>delete account ActsAccountCreateAccount_0400 start===="); 115 await appAccountManager.removeAccount("account_name_promise_second"); 116 } catch (err) { 117 console.info("====>delete account err:" + JSON.stringify(err)); 118 } 119 console.info("====>ActsAccountCreateAccount_0400 end===="); 120 done(); 121 }); 122 123 124 /* 125 * @tc.number : ActsAccountCreateAccount_0500 126 * @tc.name : Add account callback form 127 * @tc.desc : Repeatedly add the same name account and the same additional information 128 */ 129 it('ActsAccountCreateAccount_0500', 0, async function (done) { 130 console.info("====>ActsAccountCreateAccount_0500 start===="); 131 var appAccountManager = account.createAppAccountManager(); 132 appAccountManager.createAccount("account_name_callback_third", createAccountOptions, (err) => { 133 console.info("====>add account first time ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); 134 expect(err).assertEqual(null); 135 appAccountManager.createAccount("account_name_callback_third", createAccountOptions, (err) => { 136 console.info("====>add account second time ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); 137 console.info("====>ActsAccountCreateAccount_0500 AccountErrCode.JsErrCode:" + AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST); 138 expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST); 139 appAccountManager.removeAccount("account_name_callback_third", (err) => { 140 console.info("====>delete Account ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); 141 expect(err).assertEqual(null); 142 console.info("====>ActsAccountCreateAccount_0500 end===="); 143 done(); 144 }); 145 }); 146 }); 147 }); 148 149 /* 150 * @tc.number : ActsAccountCreateAccount_0600 151 * @tc.name : Add account promise form 152 * @tc.desc : Repeatedly add the same name account and the same additional information 153 */ 154 it('ActsAccountCreateAccount_0600', 0, async function (done) { 155 console.info("====>ActsAccountCreateAccount_0600 start===="); 156 var appAccountManager = account.createAppAccountManager(); 157 console.info("====>add account for the first time ActsAccountCreateAccount_0600===="); 158 await appAccountManager.createAccount("account_name_promise_third", createAccountOptions); 159 console.info("====>add account for the second time ActsAccountCreateAccount_0600 start===="); 160 try { 161 await appAccountManager.createAccount("account_name_promise_third", createAccountOptions); 162 } catch (err) { 163 console.info("====>add account for the second time 0600 err:" + JSON.stringify(err)); 164 expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST); 165 await appAccountManager.removeAccount("account_name_promise_third"); 166 console.info("====>ActsAccountCreateAccount_0600 end===="); 167 done(); 168 } 169 }); 170 171 /* 172 * @tc.number : ActsAccountCreateAccount_0700 173 * @tc.name : Add account callback form 174 * @tc.desc : The account name exceeds the length limit of 512 characters 175 */ 176 it('ActsAccountCreateAccount_0700', 0, async function (done) { 177 console.info("====>ActsAccountCreateAccount_0700 start===="); 178 var limitAccountName = ''; 179 for (var i = 0; i < NAMELIMIT + 1; i++) { 180 limitAccountName += 't'; 181 } 182 var appAccountManager = account.createAppAccountManager(); 183 appAccountManager.createAccount(limitAccountName, createAccountOptions, (err) => { 184 console.info("====>add account ActsAccountCreateAccount_0700 err:" + JSON.stringify(err)); 185 expect(err.code).assertEqual(ERR_INVALID_PARAMETER); 186 console.info("====>ActsAccountCreateAccount_0700 end===="); 187 done(); 188 }); 189 }); 190 191 /* 192 * @tc.number : ActsAccountCreateAccount_0800 193 * @tc.name : Add account promise form 194 * @tc.desc : The account name exceeds the length limit of 512 characters 195 */ 196 it('ActsAccountCreateAccount_0800', 0, async function (done) { 197 console.info("====>ActsAccountCreateAccount_0800 start===="); 198 var limitAccountName = ''; 199 for (var i = 0; i < NAMELIMIT + 1; i++) { 200 limitAccountName += 'n'; 201 } 202 var appAccountManager = account.createAppAccountManager(); 203 try { 204 await appAccountManager.createAccount(limitAccountName, createAccountOptions); 205 expect().assertFail(); 206 done(); 207 } catch (err) { 208 console.info("====>add account ActsAccountCreateAccount_0800 err:" + JSON.stringify(err)); 209 expect(err.code).assertEqual(ERR_INVALID_PARAMETER); 210 console.info("====>ActsAccountCreateAccount_0800 end===="); 211 done(); 212 } 213 }); 214 215 /* 216 * @tc.number : ActsAccountCreateAccount_0900 217 * @tc.name : Add account callback form 218 * @tc.desc : Additional information exceeds the length limit of 1024 characters 219 */ 220 it('ActsAccountCreateAccount_0900', 0, async function (done) { 221 console.info("====>ActsAccountCreateAccount_0900 start===="); 222 var limitAccountExtra = ''; 223 for (var i = 0; i < LENGTHLIMIT + 1; i++) { 224 limitAccountExtra += 't'; 225 } 226 var appAccountManager = account.createAppAccountManager(); 227 appAccountManager.createAccount("account_name_callback_fifth", { 228 customData: { 229 age: limitAccountExtra 230 } 231 }, (err) => { 232 console.info("====>add account ActsAccountCreateAccount_0900 err:" + JSON.stringify(err)); 233 expect(err.code).assertEqual(ERR_INVALID_PARAMETER); 234 console.info("====>ActsAccountCreateAccount_0900 end===="); 235 done(); 236 }); 237 }); 238 239 /* 240 * @tc.number : ActsAccountCreateAccount_1000 241 * @tc.name : Add account promise form 242 * @tc.desc : Additional information exceeds the length limit of 1024 characters 243 */ 244 it('ActsAccountCreateAccount_1000', 0, async function (done) { 245 console.info("====>ActsAccountCreateAccount_1000 start===="); 246 var limitAccountExtra = ''; 247 for (var i = 0; i < LENGTHLIMIT + 1; i++) { 248 limitAccountExtra += 'e'; 249 } 250 var appAccountManager = account.createAppAccountManager(); 251 try { 252 await appAccountManager.createAccount("account_name_promise_fifth", { 253 customData: { 254 [limitAccountExtra]: '12' 255 } 256 }); 257 } catch (err) { 258 console.info("====>add account ActsAccountCreateAccount_1000 err:" + JSON.stringify(err)); 259 expect(err.code).assertEqual(ERR_INVALID_PARAMETER); 260 console.info("====>ActsAccountCreateAccount_1000 end===="); 261 done(); 262 } 263 }); 264 265 /* 266 * @tc.number : ActsAccountCreateAccount_1100 267 * @tc.name : Add account callback form 268 * @tc.desc : The account name is an empty string 269 */ 270 it('ActsAccountCreateAccount_1100', 0, async function (done) { 271 console.info("====>ActsAccountCreateAccount_1100 start===="); 272 var appAccountManager = account.createAppAccountManager(); 273 appAccountManager.createAccount("", createAccountOptions, (err) => { 274 console.info("====>add account ActsAccountCreateAccount_1100 err:" + JSON.stringify(err)); 275 expect(err.code).assertEqual(ERR_INVALID_PARAMETER); 276 console.info("====>ActsAccountCreateAccount_1100 end===="); 277 done(); 278 }); 279 }); 280 281 /* 282 * @tc.number : ActsAccountCreateAccount_1200 283 * @tc.name : Add account promise form 284 * @tc.desc : The account name is an empty string 285 */ 286 it('ActsAccountCreateAccount_1200', 0, async function (done) { 287 console.info("====>ActsAccountCreateAccount_1200 start===="); 288 console.info("====>ActsAccountCreateAccount_1200 add account start===="); 289 var appAccountManager = account.createAppAccountManager(); 290 try { 291 await appAccountManager.createAccount("", createAccountOptions); 292 } catch (err) { 293 console.info("====>add account ActsAccountCreateAccount_1200 err:" + JSON.stringify(err)); 294 expect(err.code).assertEqual(ERR_INVALID_PARAMETER); 295 console.info("====>ActsAccountCreateAccount_1200 end===="); 296 done(); 297 } 298 }); 299 300 /* 301 * @tc.number : ActsAccountCreateAccount_1300 302 * @tc.name : Add account callback form 303 * @tc.desc : Additional information is an empty string 304 */ 305 it('ActsAccountCreateAccount_1300', 0, async function (done) { 306 console.info("====>ActsAccountCreateAccount_1300 start===="); 307 var appAccountManager = account.createAppAccountManager(); 308 try { 309 appAccountManager.createAccount("account_name_callback_seventh", "", (err) => { 310 expect().assertFail(); 311 done(); 312 }); 313 } catch (err) { 314 expect(err.code).assertEqual(401); 315 console.info("====>ActsAccountCreateAccount_1300 end===="); 316 done(); 317 } 318 }); 319 320 /* 321 * @tc.number : ActsAccountCreateAccount_1400 322 * @tc.name : Add account promise form 323 * @tc.desc : Additional information is an empty string 324 */ 325 it('ActsAccountCreateAccount_1400', 0, async function (done) { 326 console.info("====>ActsAccountCreateAccount_1400 start===="); 327 var appAccountManager = account.createAppAccountManager(); 328 console.info("====>add account ActsAccountCreateAccount_1400 start===="); 329 try { 330 await appAccountManager.createAccount("account_name_promise_seventh", ""); 331 } catch (err) { 332 console.error("====>add account ActsAccountCreateAccount_1400 err:" + JSON.stringify(err)); 333 expect(err.code).assertEqual(401); 334 done(); 335 } 336 }); 337 338 /* 339 * @tc.number : ActsAccountCreateAccount_1500 340 * @tc.name : Add account callback form 341 * @tc.desc : The account name is a special character such as a space 342 */ 343 it('ActsAccountCreateAccount_1500', 0, async function (done) { 344 console.info("====>ActsAccountCreateAccount_1500 start===="); 345 var appAccountManager = account.createAppAccountManager(); 346 var specialStr = " "; 347 try { 348 appAccountManager.createAccount(specialStr, createAccountOptions, (err) => { 349 console.error("====>createAccount ActsAccountCreateAccount_1500 err:" + JSON.stringify(err)); 350 expect(err).assertEqual(null); 351 console.info("====>ActsAccountCreateAccount_1500 end===="); 352 appAccountManager.removeAccount(" ", (err) => { 353 console.error("====>removeAccount ActsAccountCreateAccount_1500 err:" + JSON.stringify(err)); 354 expect(err).assertEqual(null); 355 done(); 356 }); 357 }); 358 } catch (err) { 359 expect().assertFail(); 360 done(); 361 } 362 }); 363 364 /* 365 * @tc.number : ActsAccountCreateAccount_1600 366 * @tc.name : Add account promise form 367 * @tc.desc : The account name is a special character such as a space 368 */ 369 it('ActsAccountCreateAccount_1600', 0, async function (done) { 370 console.info("====>ActsAccountCreateAccount_1600 start===="); 371 var appAccountManager = account.createAppAccountManager(); 372 var specialStr = " "; 373 try { 374 await appAccountManager.createAccount(specialStr, createAccountOptions); 375 await appAccountManager.removeAccount(specialStr); 376 done(); 377 } catch (err) { 378 console.info("====>createAccount ActsAccountCreateAccount_1600 err:" + JSON.stringify(err)); 379 expect().assertFail(); 380 console.info("====>ActsAccountCreateAccount_1600 end===="); 381 done(); 382 } 383 }); 384 385 386 /* 387 * @tc.number : ActsAccountCreateAccount_1700 388 * @tc.name : Add account callback form 389 * @tc.desc : The account name is a special string 390 */ 391 it('ActsAccountCreateAccount_1700', 0, async function (done) { 392 console.info("====>ActsAccountCreateAccount_1700 start===="); 393 var appAccountManager = account.createAppAccountManager(); 394 var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; 395 appAccountManager.createAccount(specialStr, createAccountOptions, (err) => { 396 console.info("====>add account ActsAccountCreateAccount_1700 err:" + JSON.stringify(err)); 397 expect(err).assertEqual(null); 398 appAccountManager.removeAccount(specialStr, (err) => { 399 console.info("====>delete Account ActsAccountCreateAccount_1700 err" + JSON.stringify(err)); 400 expect(err).assertEqual(null); 401 console.info("====>ActsAccountCreateAccount_1700 end===="); 402 done(); 403 }); 404 }); 405 }); 406 407 /* 408 * @tc.number : ActsAccountCreateAccount_1800 409 * @tc.name : Add account promise form 410 * @tc.desc : The account name is a special string 411 */ 412 it('ActsAccountCreateAccount_1800', 0, async function (done) { 413 console.info("====>ActsAccountCreateAccount_1800 start===="); 414 var appAccountManager = account.createAppAccountManager(); 415 var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; 416 console.info("====>add account ActsAccountCreateAccount_1800===="); 417 try { 418 await appAccountManager.createAccount(specialStr, createAccountOptions); 419 } catch (err) { 420 console.error("====>add Account ActsAccountCreateAccount_1800 err:" + JSON.stringify(err)); 421 expect().assertFail(); 422 } 423 try { 424 console.info("====>delete account ActsAccountCreateAccount_1800===="); 425 await appAccountManager.removeAccount(specialStr); 426 } catch (err) { 427 console.info("====>delete account err:" + JSON.stringify(err)); 428 } 429 console.info("====>ActsAccountCreateAccount_1800 end===="); 430 done(); 431 }); 432 433 /* 434 * @tc.number : ActsAccountCreateAccount_1900 435 * @tc.name : Add account callback form 436 * @tc.desc : Additional information is a special character such as a space 437 */ 438 it('ActsAccountCreateAccount_1900', 0, async function (done) { 439 console.info("====>ActsAccountCreateAccount_1900 start===="); 440 var appAccountManager = account.createAppAccountManager(); 441 var specialStr = " "; 442 try { 443 appAccountManager.createAccount("account_name_callback_tenth", specialStr, (err) => { 444 expect().assertFail(); 445 done(); 446 }); 447 } catch (err) { 448 expect(err.code).assertEqual(401); 449 console.info("====>ActsAccountCreateAccount_1900 end===="); 450 done(); 451 } 452 }); 453 454 /* 455 * @tc.number : ActsAccountCreateAccount_2000 456 * @tc.name : Add account promise form 457 * @tc.desc : Additional information is a special character such as a space 458 */ 459 it('ActsAccountCreateAccount_2000', 0, async function (done) { 460 console.info("====>ActsAccountCreateAccount_2000 start===="); 461 var appAccountManager = account.createAppAccountManager(); 462 var specialStr = " "; 463 console.info("====>add account ActsAccountCreateAccount_2000===="); 464 try { 465 await appAccountManager.createAccount("account_name_promise_tenth", specialStr); 466 } catch (err) { 467 console.error("====>add Account ActsAccountCreateAccount_2000 err:" + JSON.stringify(err)); 468 expect(err.code).assertEqual(401); 469 console.info("====>ActsAccountCreateAccount_2000 end===="); 470 done(); 471 } 472 }); 473 474 /* 475 * @tc.number : ActsAccountCreateAccount_2100 476 * @tc.name : Add account callback form 477 * @tc.desc : Additional information is a special string 478 */ 479 it('ActsAccountCreateAccount_2100', 0, async function (done) { 480 console.info("====>ActsAccountCreateAccount_2100 start===="); 481 var appAccountManager = account.createAppAccountManager(); 482 var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; 483 try { 484 appAccountManager.createAccount("account_extraInfo_callback_eleventh", specialStr, (err) => { 485 expect().assertFail(); 486 done(); 487 }); 488 } catch (err) { 489 expect(err.code).assertEqual(401); 490 console.info("====>ActsAccountCreateAccount_2100 end===="); 491 done(); 492 } 493 }); 494 495 /* 496 * @tc.number : ActsAccountCreateAccount_2200 497 * @tc.name : Add account promise form 498 * @tc.desc : Additional information is a special string 499 */ 500 it('ActsAccountCreateAccount_2200', 0, async function (done) { 501 console.info("====>ActsAccountCreateAccount_2200 start===="); 502 var appAccountManager = account.createAppAccountManager(); 503 var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; 504 console.info("====>add account ActsAccountCreateAccount_2200===="); 505 try { 506 await appAccountManager.createAccount("account_extraInfo_promise_eleventh", specialStr); 507 } catch (err) { 508 console.error("====>add Account ActsAccountCreateAccount_2200 err:" + JSON.stringify(err)); 509 expect(err.code).assertEqual(401); 510 console.info("====>ActsAccountCreateAccount_2200 end===="); 511 done(); 512 } 513 }); 514 515 /* 516 * @tc.number : ActsAccountCreateAccount_2300 517 * @tc.name : Add account callback form 518 * @tc.desc : Repeatedly add accounts with the same name and different additional information 519 */ 520 it('ActsAccountCreateAccount_2300', 0, async function (done) { 521 console.info("====>ActsAccountCreateAccount_2300 start===="); 522 var appAccountManager = account.createAppAccountManager(); 523 appAccountManager.createAccount("account_name_callback_same", createAccountOptions, (err) => { 524 console.info("====>add account first time ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); 525 expect(err).assertEqual(null); 526 appAccountManager.createAccount("account_name_callback_same", createAccountOptionsDiff, (err) => { 527 console.info("====>add account second time ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); 528 expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST); 529 appAccountManager.removeAccount("account_name_callback_same", (err) => { 530 console.info("====>delete Account ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); 531 expect(err).assertEqual(null); 532 console.info("====>ActsAccountCreateAccount_2300 end===="); 533 done(); 534 }); 535 }); 536 }); 537 }); 538 539 /* 540 * @tc.number : ActsAccountCreateAccount_2400 541 * @tc.name : Add account promise form 542 * @tc.desc : Repeatedly add accounts with the same name and different additional information 543 */ 544 it('ActsAccountCreateAccount_2400', 0, async function (done) { 545 console.info("====>ActsAccountCreateAccount_2400 start===="); 546 var appAccountManager = account.createAppAccountManager(); 547 console.info("====>add account for the first time ActsAccountCreateAccount_2400===="); 548 await appAccountManager.createAccount("account_name_promise_same", createAccountOptions); 549 console.info("====>add account for the second time ActsAccountCreateAccount_2400===="); 550 try { 551 await appAccountManager.createAccount("account_name_promise_same", createAccountOptionsDiff); 552 } catch (err) { 553 console.info("====>add account for the second time err:" + JSON.stringify(err)); 554 expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST); 555 await appAccountManager.removeAccount("account_name_promise_same"); 556 console.info("====>ActsAccountCreateAccount_2400 end===="); 557 done(); 558 } 559 }); 560 561 /* 562 * @tc.number : ActsAccountCreateAccount_2500 563 * @tc.name : Add account callback form 564 * @tc.desc : The account name reaches the limit of 512 characters 565 */ 566 it('ActsAccountCreateAccount_2500', 0, async function (done) { 567 console.info("====>ActsAccountCreateAccount_2500 start===="); 568 var limitName = ''; 569 for (var i = 0; i < NAMELIMIT; i++) { 570 limitName += 't'; 571 } 572 var appAccountManager = account.createAppAccountManager(); 573 appAccountManager.createAccount(limitName, createAccountOptions, (err) => { 574 console.info("====>add account ActsAccountCreateAccount_2500 err:" + JSON.stringify(err)); 575 expect(err).assertEqual(null); 576 appAccountManager.removeAccount(limitName, (err) => { 577 console.info("====>delete Account ActsAccountCreateAccount_2500 err:" + JSON.stringify(err)); 578 expect(err).assertEqual(null); 579 console.info("====>ActsAccountCreateAccount_2500 end===="); 580 done(); 581 }); 582 }); 583 }); 584 585 /* 586 * @tc.number : ActsAccountCreateAccount_2600 587 * @tc.name : Add account promise form 588 * @tc.desc : The account name reaches the limit of 512 characters 589 */ 590 it('ActsAccountCreateAccount_2600', 0, async function (done) { 591 console.info("====>ActsAccountCreateAccount_2600 start===="); 592 var nameLimit = ''; 593 for (var i = 0; i < NAMELIMIT; i++) { 594 nameLimit += 't'; 595 } 596 var appAccountManager = account.createAppAccountManager(); 597 console.info("====>add account ActsAccountCreateAccount_2600 start===="); 598 try { 599 await appAccountManager.createAccount(nameLimit, createAccountOptions); 600 } catch (err) { 601 console.error("====>add account ActsAccountCreateAccount_2600 err:" + JSON.stringify(err)); 602 expect().assertFail(); 603 } 604 try { 605 console.info("====>delete account ActsAccountCreateAccount_2600 start===="); 606 await appAccountManager.removeAccount(nameLimit); 607 } catch (err) { 608 console.info("====>delete account err:" + JSON.stringify(err)); 609 } 610 console.info("====>ActsAccountCreateAccount_2600 end===="); 611 done(); 612 }); 613 614 /* 615 * @tc.number : ActsAccountCreateAccount_2700 616 * @tc.name : Add account callback form 617 * @tc.desc : Additional information reaches the limit of 1024 characters 618 */ 619 it('ActsAccountCreateAccount_2700', 0, async function (done) { 620 console.info("====>ActsAccountCreateAccount_2700 start===="); 621 var limitExtra = ''; 622 for (var i = 0; i < LENGTHLIMIT; i++) { 623 limitExtra += 't'; 624 } 625 var appAccountManager = account.createAppAccountManager(); 626 try { 627 appAccountManager.createAccount("account_extra_callback_limit", limitExtra, (err) => { 628 expect().assertFail(); 629 done(); 630 }); 631 } catch (err) { 632 expect(err.code).assertEqual(401); 633 console.info("====>ActsAccountCreateAccount_2700 end===="); 634 done(); 635 } 636 }); 637 638 /* 639 * @tc.number : ActsAccountCreateAccount_2800 640 * @tc.name : Add account promise form 641 * @tc.desc : Additional information reaches the limit of 1024 characters 642 */ 643 it('ActsAccountCreateAccount_2800', 0, async function (done) { 644 console.info("====>ActsAccountCreateAccount_2800 start===="); 645 var extraLimit = ''; 646 for (var i = 0; i < LENGTHLIMIT; i++) { 647 extraLimit += 't'; 648 } 649 var appAccountManager = account.createAppAccountManager(); 650 try { 651 await appAccountManager.createAccount("account_extra_promise_limit", extraLimit); 652 } catch (err) { 653 console.error("====>add account ActsAccountCreateAccount_2800 err:" + JSON.stringify(err)); 654 console.info("====>ActsAccountCreateAccount_2800 end===="); 655 expect(err.code).assertEqual(401); 656 done(); 657 } 658 }); 659 }) 660}