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 featureAbility from '@ohos.ability.featureAbility' 17import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' 18 19const NAMELIMIT = 512; 20const LENGTHLIMIT = 1024; 21const name = 'zhangsan' 22const owner = 'com.example.accountauthenticator' 23const self_owner = 'com.example.actsaccounttest' 24export default function ActsAccountAuthenticator() { 25 describe('ActsAccountAuthenticator', function () { 26 beforeAll(async function (done) { 27 console.debug("====>accountauthenticatorbeforeAll start===="); 28 await featureAbility.startAbilityForResult( 29 { 30 want: 31 { 32 deviceId: "", 33 bundleName: "com.example.accountauthenticator", 34 abilityName: "com.example.accountauthenticator.MainAbility", 35 action: "action1", 36 parameters: 37 {}, 38 }, 39 }, (err, data) => { 40 console.debug("====>accountauthenticatorfeatureAbility.startAbility err:" + JSON.stringify(err)) 41 console.debug("====>accountauthenticatorfeatureAbility.startAbility data:" + JSON.stringify(data)) 42 done(); 43 }) 44 console.debug("====>accountauthenticatorfeatureAbility.startAbility end") 45 }); 46 beforeEach(async function (done) { 47 console.debug("====>afterEach start===="); 48 var appAccountManager = account.createAppAccountManager(); 49 var accounts = await appAccountManager.getAccountsByOwner(self_owner) 50 for (var i=0;i<accounts.length;i++){ 51 var localName = accounts[i].name 52 if(localName == 'zhangsan'){ 53 await appAccountManager.removeAccount(localName) 54 } 55 } 56 done(); 57 }); 58 /* 59 * @tc.number : ActsAccountCheckAccountLabels_0100 60 * @tc.name : Check Account Labels callback form 61 * @tc.desc : 62 */ 63 it('ActsAccountCheckAccountLabels_0100', 0, async function (done) { 64 console.debug("====>ActsAccountCheckAccountLabels_0100 start===="); 65 var appAccountManager = account.createAppAccountManager(); 66 console.debug("====>start finish===="); 67 appAccountManager.addAccount(name, 'test_extraInfo', (err)=>{ 68 console.debug("====>ActsAccountCheckAccountLabels_0100 add_account_err:" + JSON.stringify(err)); 69 expect(err).assertEqual(null); 70 appAccountManager.checkAccountLabels(name, owner, ['level4'], (err, data)=>{ 71 console.debug("====>ActsAccountCheckAccountLabels_0100 err:" + JSON.stringify(err)); 72 expect(err).assertEqual(null); 73 console.debug("====>ActsAccountCheckAccountLabels_0100 data:" + JSON.stringify(data)); 74 expect(data).assertEqual(true); 75 appAccountManager.deleteAccount(name, (err) =>{ 76 console.debug("====>ActsAccountCheckAccountLabels_0100 deleteAccount_err:" + JSON.stringify(err)) 77 expect(err).assertEqual(null); 78 console.debug("====>ActsAccountCheckAccountLabels_0100 end===="); 79 done(); 80 }) 81 }); 82 }); 83 }); 84 85 86 /* 87 * @tc.number : ActsAccountCheckAccountLabels_0200 88 * @tc.name : Check Account Labels callback form 89 * @tc.desc : 90 */ 91 92 it('ActsAccountCheckAccountLabels_0200', 0, async function (done) { 93 console.debug("====>ActsAccountCheckAccountLabels_0200 start===="); 94 var appAccountManager = account.createAppAccountManager(); 95 console.debug("====>start finish===="); 96 appAccountManager.addAccount(name, (err)=>{ 97 console.debug("====>ActsAccountCheckAccountLabels_0200 add_account_err:" + JSON.stringify(err)); 98 expect(err).assertEqual(null); 99 appAccountManager.checkAccountLabels(name, owner, ['20-30'], (err, data)=>{ 100 console.debug("====>ActsAccountCheckAccountLabels_0200 err:" + JSON.stringify(err)); 101 expect(err).assertEqual(null); 102 console.debug("====>ActsAccountCheckAccountLabels_0200 data:" + JSON.stringify(data)); 103 expect(data).assertEqual(false); 104 appAccountManager.deleteAccount(name, (err) =>{ 105 console.debug("====>ActsAccountCheckAccountLabels_0200 deleteAccount_err:" + JSON.stringify(err)) 106 expect(err).assertEqual(null); 107 console.debug("====>ActsAccountCheckAccountLabels_0200 end===="); 108 done(); 109 }) 110 }); 111 }); 112 }); 113 114 /* 115 * @tc.number : ActsAccountCheckAccountLabels_0300 116 * @tc.name : Check Account Labels callback form 117 * @tc.desc : 118 */ 119 120 it('ActsAccountCheckAccountLabels_0300', 0, async function (done) { 121 console.debug("====>ActsAccountCheckAccountLabels_0300 start===="); 122 var appAccountManager = account.createAppAccountManager(); 123 console.debug("====>start finish===="); 124 appAccountManager.addAccount('CheckAccountLabels_0300', (err)=>{ 125 console.debug("====>ActsAccountCheckAccountLabels_0300 add_account_err:" + JSON.stringify(err)); 126 expect(err).assertEqual(null); 127 appAccountManager.checkAccountLabels('CheckAccountLabels_0300', owner, ['male'], (err, data)=>{ 128 console.debug("====>ActsAccountCheckAccountLabels_0300 err:" + JSON.stringify(err)); 129 expect(err).assertEqual(null); 130 console.debug("====>ActsAccountCheckAccountLabels_0300 data:" + JSON.stringify(data)); 131 expect(data).assertEqual(false); 132 appAccountManager.deleteAccount("CheckAccountLabels_0300", (err) =>{ 133 console.debug("====>ActsAccountCheckAccountLabels_0300 deleteAccount_err:" + JSON.stringify(err)) 134 expect(err).assertEqual(null); 135 console.debug("====>ActsAccountCheckAccountLabels_0300 end===="); 136 done(); 137 }) 138 }); 139 }); 140 }); 141 142 /* 143 * @tc.number : ActsAccountCheckAccountLabels_0400 144 * @tc.name : Check Account Labels promise form 145 * @tc.desc : 146 */ 147 148 it('ActsAccountCheckAccountLabels_0400', 0, async function (done) { 149 console.debug("====>ActsAccountCheckAccountLabels_0400 start===="); 150 var appAccountManager = account.createAppAccountManager(); 151 await appAccountManager.addAccount(name, 'test_extraInfo').then((data) =>{ 152 console.debug("====>ActsAccountCheckAccountLabels_0400 add_account_success"); 153 appAccountManager.checkAccountLabels(name, owner, ['level4']).then((data) =>{ 154 console.debug("====>ActsAccountCheckAccountLabels_0400 data:" + JSON.stringify(data)); 155 expect(data).assertEqual(true); 156 appAccountManager.deleteAccount(name).then((data) =>{ 157 console.debug("====>ActsAccountCheckAccountLabels_0400 delete_account_success"); 158 done(); 159 }).catch((err) =>{ 160 console.debug("====>ActsAccountCheckAccountLabels_0400 delete_account_err"); 161 expect().assertFail(); 162 done(); 163 }); 164 }).catch((err) =>{ 165 console.debug("====>ActsAccountCheckAccountLabels_0400 err:" + JSON.stringify(err)) 166 expect(typeof(err) != undefined).assertTrue(); 167 done(); 168 }) 169 }).catch((err) => { 170 console.debug("====>ActsAccountCheckAccountLabels_0400 add_account_err:" + JSON.stringify(err)) 171 expect().assertFail(); 172 done(); 173 }) 174 }); 175 176 /* 177 * @tc.number : ActsAccountCheckAccountLabels_0500 178 * @tc.name : Check Account Labels promise form 179 * @tc.desc : 180 */ 181 182 it('ActsAccountCheckAccountLabels_0500', 0, async function (done) { 183 console.debug("====>ActsAccountCheckAccountLabels_0500 start===="); 184 var appAccountManager = account.createAppAccountManager(); 185 await appAccountManager.addAccount(name, 'test_extraInfo').then((data) =>{ 186 console.debug("====>ActsAccountCheckAccountLabels_0500 add_account_success"); 187 appAccountManager.checkAccountLabels(name, owner, ['20-30']).then((data) =>{ 188 console.debug("====>ActsAccountCheckAccountLabels_0500 data:" + JSON.stringify(data)); 189 expect(data).assertEqual(false); 190 expect(account.Constants.KEY_REQUIRED_LABELS).assertEqual('requiredLabels') 191 expect(account.Constants.KEY_BOOLEAN_RESULT).assertEqual('booleanResult') 192 appAccountManager.deleteAccount(name).then((data) =>{ 193 console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_success"); 194 done() 195 }).catch((err) =>{ 196 console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_err"); 197 done() 198 }); 199 }).catch((err) =>{ 200 console.debug("====>ActsAccountCheckAccountLabels_0500 err:" + JSON.stringify(err)) 201 expect(typeof(err) != undefined).assertTrue(); 202 done(); 203 }) 204 }).catch((err) => { 205 console.debug("====>ActsAccountCheckAccountLabels_0500 add_account_err:" + JSON.stringify(err)) 206 expect().assertFail(); 207 done(); 208 }) 209 }); 210 211 /* 212 * @tc.number : ActsAccountCheckAccountLabels_0600 213 * @tc.name : Check Account Labels promise form 214 * @tc.desc : 215 */ 216 217 it('ActsAccountCheckAccountLabels_0600', 0, async function (done) { 218 console.debug("====>ActsAccountCheckAccountLabels_0600 start===="); 219 var appAccountManager = account.createAppAccountManager(); 220 await appAccountManager.addAccount('CheckAccountLabels_0600', 'test_extraInfo').then((data) =>{ 221 console.debug("====>ActsAccountCheckAccountLabels_0600 add_account_success:" + JSON.stringify(data)); 222 appAccountManager.checkAccountLabels('CheckAccountLabels_0600', owner, ['male']).then((data) =>{ 223 console.debug("====>ActsAccountCheckAccountLabels_0600 data:" + JSON.stringify(data)); 224 expect(data).assertEqual(false); 225 appAccountManager.deleteAccount('CheckAccountLabels_0600').then((data) =>{ 226 console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_success"); 227 done() 228 }).catch((err) =>{ 229 console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_err"); 230 done() 231 }); 232 }).catch((err) =>{ 233 console.debug("====>ActsAccountCheckAccountLabels_0600 err:" + JSON.stringify(err)) 234 expect().assertFail(); 235 done(); 236 }) 237 }).catch((err) => { 238 console.debug("====>ActsAccountCheckAccountLabels_0600 add_account_err:" + JSON.stringify(err)) 239 expect().assertFail(); 240 done(); 241 }) 242 }); 243 244 /* 245 * @tc.number : ActsAccountCheckAppAccess_0100 246 * @tc.name : Check App Access callback form 247 * @tc.desc : 248 */ 249 250 it('ActsAccountCheckAppAccess_0100', 0, async function (done) { 251 console.debug("====>ActsAccountCheckAppAccess_0100 start===="); 252 var appAccountManager = account.createAppAccountManager(); 253 appAccountManager.addAccount(name, (err)=>{ 254 console.debug("====>ActsAccountCheckAppAccess_0100 add_account_err:" + JSON.stringify(err)); 255 expect(err).assertEqual(null); 256 appAccountManager.checkAppAccess(name, owner, (err, data)=>{ 257 console.debug("====>ActsAccountCheckAppAccess_0100 first_err:" + JSON.stringify(err)); 258 expect(err).assertEqual(null); 259 console.debug("====>ActsAccountCheckAppAccess_0100 first_data:" + JSON.stringify(data)); 260 expect(data).assertEqual(false) 261 appAccountManager.enableAppAccess(name, owner, (err, data) =>{ 262 console.debug("====>ActsAccountCheckAppAccess_0100 enableAppAccess_err:" + JSON.stringify(err)); 263 expect(err).assertEqual(null); 264 appAccountManager.checkAppAccess(name, owner, (err, data) =>{ 265 console.debug("====>ActsAccountCheckAppAccess_0100 second_err:" + JSON.stringify(err)); 266 expect(err).assertEqual(null); 267 expect(data).assertEqual(true) 268 appAccountManager.disableAppAccess(name, owner, (err, data) =>{ 269 console.debug("====>ActsAccountCheckAppAccess_0100 disableAppAccount_err:" + JSON.stringify(err)); 270 expect(err).assertEqual(null); 271 appAccountManager.checkAppAccess(name, owner, async (err, data)=>{ 272 console.debug("====>ActsAccountCheckAppAccess_0100 third_err:" + JSON.stringify(err)) 273 expect(err).assertEqual(null) 274 expect(data).assertEqual(false) 275 try { 276 await appAccountManager.deleteAccount(name) 277 console.debug('====>ActsAccountCheckAppAccess_0100 deleteAccount_success') 278 } 279 catch{ 280 console.debug('====>ActsAccountCheckAppAccess_0100 deleteAccount_err') 281 expect().assertFail() 282 } 283 done(); 284 }) 285 }) 286 }) 287 }) 288 }); 289 }); 290 }); 291 292 293 /* 294 * @tc.number : ActsAccountCheckAppAccess_0200 295 * @tc.name : Check App Access promise form 296 * @tc.desc : 297 */ 298 299 it('ActsAccountCheckAppAccess_0200', 0, async function (done) { 300 console.debug("====>ActsAccountCheckAppAccess_0200 start===="); 301 var appAccountManager = account.createAppAccountManager(); 302 appAccountManager.addAccount(name, 'test_extraInfo').then((data) =>{ 303 console.debug("====>ActsAccountCheckAppAccess_0200 add_account_success:"); 304 appAccountManager.checkAppAccess(name, owner).then((data) =>{ 305 console.debug("====>ActsAccountCheckAppAccess_0200 first_data:" + JSON.stringify(data)); 306 expect(data).assertEqual(false); 307 appAccountManager.enableAppAccess(name, owner).then((data) =>{ 308 console.debug("====>ActsAccountCheckAppAccess_0200 enableAppAccess_success"); 309 appAccountManager.checkAppAccess(name, owner).then((data) =>{ 310 console.debug("====>ActsAccountCheckAppAccess_0200 second_data:" + JSON.stringify(data)); 311 expect(data).assertEqual(true); 312 appAccountManager.disableAppAccess(name, owner).then((data)=>{ 313 console.debug("====>ActsAccountCheckAppAccess_0200 disabAppAccess_data:" + JSON.stringify(data)); 314 appAccountManager.checkAppAccess(name, owner).then(async (data) =>{ 315 console.debug("====>ActsAccountCheckAppAccess_0200 third_data:" + JSON.stringify(data)); 316 expect(data).assertEqual(false); 317 try{ 318 await appAccountManager.deleteAccount(name) 319 console.debug('====>ActsAccountCheckAppAccess_0200 deleteAccount_success') 320 } 321 catch{ 322 console.debug('====>ActsAccountCheckAppAccess_0100 deleteAccount_err') 323 expect().assertFail() 324 } 325 done(); 326 }).catch((err)=>{ 327 console.debug("====>ActsAccountCheckAppAccess_0200 third_err:" + JSON.stringify(err)); 328 expect().assertFail(); 329 done(); 330 }) 331 }).catch((err) =>{ 332 console.debug("====>ActsAccountCheckAppAccess_0200 disableAppAccess_err:" + JSON.stringify(err)); 333 expect().assertFail(); 334 done(); 335 }) 336 }).catch((err) =>{ 337 console.debug("====>ActsAccountCheckAppAccess_0200 second_err:" + JSON.stringify(err)); 338 expect().assertFail(); 339 done(); 340 }) 341 }).catch((err)=>{ 342 console.debug("====>ActsAccountCheckAppAccess_0200 enableAppAccess_err:" + JSON.stringify(err)); 343 expect().assertFail(); 344 done(); 345 }) 346 }).catch((err) =>{ 347 console.debug("====>ActsAccountCheckAppAccess_0200 first_err:" + JSON.stringify(err)); 348 expect().assertFail(); 349 done(); 350 }) 351 }).catch((err) => { 352 console.debug("====>ActsAccountCheckAppAccess_0200 addAccount_err:" + JSON.stringify(err)); 353 expect().assertFail(); 354 done(); 355 }) 356 357 }); 358 359 360 /* 361 * @tc.number : ActsAccountDeleteAccountCredential_0100 362 * @tc.name : Delete Account Credential callback form 363 * @tc.desc : 364 */ 365 366 it('ActsAccountDeleteAccountCredential_0100', 0, async function (done) { 367 console.debug("====>ActsAccountDeleteAccountCredential_0100 start===="); 368 var appAccountManager = account.createAppAccountManager(); 369 console.debug("====>start finish===="); 370 appAccountManager.addAccount(name, (err)=>{ 371 console.debug("====>ActsAccountDeleteAccountCredential_0100 add_account_err:" + JSON.stringify(err)); 372 expect(err).assertEqual(null); 373 appAccountManager.setAccountCredential(name, "PIN", '123456', (err, data)=>{ 374 console.debug("====>ActsAccountDeleteAccountCredential_0100 setAccountCredential_err:" + JSON.stringify(err)); 375 expect(err).assertEqual(null); 376 appAccountManager.getAccountCredential(name, "PIN", (err, data) =>{ 377 console.debug("====>ActsAccountDeleteAccountCredential_0100 getAccountCredential_err:" + JSON.stringify(err)) 378 expect(err).assertEqual(null); 379 console.debug("====>ActsAccountDeleteAccountCredential_0100 getAccountCredential_success:" + JSON.stringify(data)); 380 appAccountManager.deleteAccountCredential(name, "PIN", async (err, data)=>{ 381 console.debug("====>ActsAccountDeleteAccountCredential_0100 deleteAccountCredential_err:" + JSON.stringify(err)); 382 expect(err).assertEqual(null); 383 expect(data).assertEqual(undefined); 384 console.debug("====>ActsAccountDeleteAccountCredential_0100 deleteAccountCredential_data:" + JSON.stringify(data)); 385 try{ 386 await appAccountManager.deleteAccount(name) 387 console.debug('====>ActsAccountDeleteAccountCredential_0100 deleteAccount_success') 388 } 389 catch{ 390 console.debug('====>ActsAccountDeleteAccountCredential_0100 deleteAccount_err') 391 expect().assertFail() 392 } 393 done(); 394 }) 395 }) 396 }); 397 }); 398 }); 399 400 /* 401 * @tc.number : ActsAccountDeleteAccountCredential_0200 402 * @tc.name : Delete Account Credential promise form 403 * @tc.desc : 404 */ 405 406 it('ActsAccountDeleteAccountCredential_0200', 0, async function (done) { 407 console.debug("====>ActsAccountDeleteAccountCredential_0200 start===="); 408 var appAccountManager = account.createAppAccountManager(); 409 appAccountManager.addAccount(name, 'test_extraInfo').then((data) =>{ 410 console.debug("====>ActsAccountDeleteAccountCredential_0200 add_account_success"); 411 appAccountManager.setAccountCredential(name, "PIN", '123456').then(() =>{ 412 console.debug("====>ActsAccountDeleteAccountCredential_0200 setAccountCredential_success"); 413 appAccountManager.getAccountCredential(name, "PIN").then((data) =>{ 414 console.debug("====>ActsAccountDeleteAccountCredential_0200 getAccountCredential_data:" + JSON.stringify(data)); 415 appAccountManager.deleteAccountCredential(name, "PIN").then(async (data) =>{ 416 console.debug("====>ActsAccountDeleteAccountCredential_0200 data:" + JSON.stringify(data)); 417 try{ 418 await appAccountManager.deleteAccount(name) 419 console.debug('====>ActsAccountDeleteAccountCredential_0200 deleteAccount_success') 420 } 421 catch{ 422 console.debug('====>ActsAccountDeleteAccountCredential_0200 deleteAccount_err') 423 expect().assertFail() 424 } 425 done(); 426 }).catch((err) =>{ 427 console.debug("====>ActsAccountDeleteAccountCredential_0200 err:" + JSON.stringify(err)); 428 expect().assertFail(); 429 done(); 430 }) 431 }).catch((err)=>{ 432 console.debug("====>ActsAccountDeleteAccountCredential_0200 getAccountCredential_err:" + JSON.stringify(err)); 433 expect().assertFail(); 434 done(); 435 }) 436 }).catch((err) =>{ 437 console.debug("====>ActsAccountDeleteAccountCredential_0200 setAccountCredential_err:" + JSON.stringify(err)); 438 expect().assertFail(); 439 done(); 440 }) 441 }).catch((err) => { 442 console.debug("====>ActsAccountDeleteAccountCredential_0200 addAccount_err:" + JSON.stringify(err)); 443 expect().assertFail(); 444 done(); 445 }) 446 }); 447 448 /* 449 * @tc.number : ActsAccountVerifyCredential_0100 450 * @tc.name : Verify Credential callback form, options 451 * @tc.desc : 452 */ 453 454 it('ActsAccountVerifyCredential_0100', 0, async function (done) { 455 console.debug("====>ActsAccountVerifyCredential_0100 start===="); 456 var appAccountManager = account.createAppAccountManager(); 457 var options = {credentialType: "PIN", credential: "123456"} 458 console.debug("====>start finish===="); 459 appAccountManager.addAccount(name, (err)=>{ 460 console.debug("====>ActsAccountVerifyCredential_0100 add_account_err:" + JSON.stringify(err)); 461 expect(err).assertEqual(null); 462 appAccountManager.verifyCredential(name, owner, options, { 463 onResult: async (resultCode, resultData)=>{ 464 console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultcode:" + JSON.stringify(resultCode)); 465 expect(resultCode).assertEqual(0) 466 console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultData:" + JSON.stringify(resultData)); 467 expect(resultData.booleanResult).assertEqual(true) 468 try{ 469 await appAccountManager.deleteAccount(name) 470 console.debug('====>ActsAccountVerifyCredential_0100 deleteAccount_success') 471 } 472 catch{ 473 console.debug('====>ActsAccountVerifyCredential_0100 deleteAccount_err') 474 expect().assertFail() 475 } 476 done(); 477 }, 478 onRequestRedirected:null, 479 onRequestContinued: function(){ 480 console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_onRequestContinued") 481 } 482 }); 483 }); 484 }); 485 486 /* 487 * @tc.number : ActsAccountVerifyCredential_0200 488 * @tc.name : Verify Credential callback form 489 * @tc.desc : 490 */ 491 492 it('ActsAccountVerifyCredential_0200', 0, async function (done) { 493 console.debug("====>ActsAccountVerifyCredential_0200 start===="); 494 var appAccountManager = account.createAppAccountManager(); 495 console.debug("====>start finish===="); 496 appAccountManager.addAccount(name, (err)=>{ 497 console.debug("====>ActsAccountVerifyCredential_0200 add_account_err:" + JSON.stringify(err)); 498 expect(err).assertEqual(null); 499 appAccountManager.verifyCredential(name, owner, { 500 onResult: async (resultCode, resultData)=>{ 501 console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultcode:" + JSON.stringify(resultCode)); 502 expect(resultCode).assertEqual(0) 503 console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultData:" + JSON.stringify(resultData)); 504 expect(resultData.booleanResult).assertEqual(false) 505 try{ 506 await appAccountManager.deleteAccount(name) 507 console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_success') 508 } 509 catch{ 510 console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_err') 511 expect().assertFail() 512 } 513 done(); 514 }, 515 onRequestRedirected:null, 516 onRequestContinued: function(){ 517 console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_onRequestContinued") 518 } 519 }); 520 }); 521 }); 522 /* 523 * @tc.number : ActsAccountSetAuthenticatorProperties_0100 524 * @tc.name : Verify Credential callback form, options 525 * @tc.desc : 526 */ 527 528 it('ActsAccountSetAuthenticatorProperties_0100', 0, async function (done) { 529 console.debug("====>ActsAccountSetAuthenticatorProperties_0100 start===="); 530 var appAccountManager = account.createAppAccountManager(); 531 var options = {credentialType: "PIN", credential: "123456"} 532 console.debug("====>start finish===="); 533 appAccountManager.addAccount(name, (err)=>{ 534 console.debug("====>ActsAccountSetAuthenticatorProperties_0100 add_account_err:" + JSON.stringify(err)); 535 expect(err).assertEqual(null); 536 appAccountManager.setAuthenticatorProperties(owner, options, { 537 onResult: async (resultCode, resultData)=>{ 538 console.debug("====>ActsAccountSetAuthenticatorProperties_0100 setAuthenticatorProperties_resultcode:" + JSON.stringify(resultCode)); 539 expect(resultCode).assertEqual(10016) 540 console.debug("====>ActsAccountSetAuthenticatorProperties_0100 setAuthenticatorProperties_resultData:" + JSON.stringify(resultData)); 541 try{ 542 await appAccountManager.deleteAccount(name) 543 console.debug('====>ActsAccountSetAuthenticatorProperties_0100 deleteAccount_success') 544 } 545 catch{ 546 console.debug('====>ActsAccountSetAuthenticatorProperties_0100 deleteAccount_err') 547 expect().assertFail() 548 } 549 done(); 550 }, 551 onRequestRedirected:null, 552 onRequestContinued: function(){ 553 console.debug("====>ActsAccountSetAuthenticatorProperties_0100 verifyCredential_onRequestContinued") 554 } 555 }); 556 }); 557 }); 558 559 /* 560 * @tc.number : ActsAccountSetAuthenticatorProperties_0200 561 * @tc.name : Verify Credential callback form 562 * @tc.desc : 563 */ 564 565 it('ActsAccountSetAuthenticatorProperties_0200', 0, async function (done) { 566 console.debug("====>ActsAccountSetAuthenticatorProperties_0200 start===="); 567 var appAccountManager = account.createAppAccountManager(); 568 console.debug("====>start finish===="); 569 appAccountManager.addAccount(name, (err)=>{ 570 console.debug("====>ActsAccountSetAuthenticatorProperties_0200 add_account_err:" + JSON.stringify(err)); 571 expect(err).assertEqual(null); 572 appAccountManager.setAuthenticatorProperties(owner, { 573 onResult: async (resultCode, resultData)=>{ 574 console.debug("====>ActsAccountSetAuthenticatorProperties_0200 setAuthenticatorProperties_resultcode:" + JSON.stringify(resultCode)); 575 expect(resultCode).assertEqual(10016) 576 console.debug("====>ActsAccountSetAuthenticatorProperties_0200 setAuthenticatorProperties_resultData:" + JSON.stringify(resultData)); 577 try{ 578 await appAccountManager.deleteAccount(name) 579 console.debug('====>ActsAccountSetAuthenticatorProperties_0200 deleteAccount_success') 580 } 581 catch{ 582 console.debug('====>ActsAccountSetAuthenticatorProperties_0200 deleteAccount_err') 583 expect().assertFail() 584 } 585 done(); 586 }, 587 onRequestRedirected:null, 588 onRequestContinued: function(){ 589 console.debug("====>ActsAccountSetAuthenticatorProperties_0200 verifyCredential_onRequestContinued") 590 } 591 }); 592 }); 593 }); 594 595 /* 596 * @tc.number : ActsAccountSelectAccountByOptions_0100 597 * @tc.name : Verify Credential callback form 598 * @tc.desc : 599 */ 600 601 it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) { 602 console.debug("====>ActsAccountSelectAccountByOptions_0100 start===="); 603 var appAccountManager = account.createAppAccountManager(); 604 var select_options = {allowedAccounts:[{"name":name,"owner":owner}]} 605 console.debug("====>start finish===="); 606 appAccountManager.addAccount(name, async (err)=>{ 607 console.debug("====>ActsAccountSelectAccountByOptions_0100 add_account_err:" + JSON.stringify(err)); 608 expect(err).assertEqual(null); 609 try { 610 var data = await appAccountManager.selectAccountsByOptions(select_options) 611 console.debug("====>ActsAccountSelectAccountByOptions_0100 data:" + JSON.stringify(data)); 612 expect(data.length).assertEqual(1) 613 } catch(err) { 614 console.debug("====>ActsAccountSelectAccountByOptions_0100 err:" + JSON.stringify(err)); 615 expect(err).assertEqual(null) 616 done() 617 } 618 try{ 619 await appAccountManager.deleteAccount(name) 620 console.debug('====>ActsAccountSelectAccountByOptions_0100 deleteAccount_success') 621 } 622 catch{ 623 console.debug('====>ActsAccountSelectAccountByOptions_0100 deleteAccount_err') 624 expect().assertFail() 625 } 626 done(); 627 }); 628 }); 629 630 /* 631 * @tc.number : ActsAccountSelectAccountByOptions_0100 632 * @tc.name : Verify Credential callback form 633 * @tc.desc : 634 */ 635 636 it('ActsAccountSelectAccountByOptions_0200', 0, async function (done) { 637 console.debug("====>ActsAccountSelectAccountByOptions_0200 start===="); 638 var appAccountManager = account.createAppAccountManager(); 639 var select_options = {allowedOwners: [owner]} 640 console.debug("====>start finish===="); 641 appAccountManager.addAccount(name, async (err)=>{ 642 console.debug("====>ActsAccountSelectAccountByOptions_0200 add_account_err:" + JSON.stringify(err)); 643 expect(err).assertEqual(null); 644 try { 645 var data = await appAccountManager.selectAccountsByOptions(select_options) 646 console.debug("====>ActsAccountSelectAccountByOptions_0200 data:" + JSON.stringify(data)); 647 expect(data.length).assertEqual(3) 648 } catch(err) { 649 console.debug("====>ActsAccountSelectAccountByOptions_0200 err:" + JSON.stringify(err)); 650 expect(err).assertEqual(null) 651 done() 652 } 653 try{ 654 await appAccountManager.deleteAccount(name) 655 console.debug('====>ActsAccountSelectAccountByOptions_0200 deleteAccount_success') 656 } 657 catch{ 658 console.debug('====>ActsAccountSelectAccountByOptions_0200 deleteAccount_err') 659 expect().assertFail() 660 } 661 done(); 662 }); 663 }); 664 665 /* 666 * @tc.number : ActsAccountSelectAccountByOptions_0100 667 * @tc.name : Verify Credential callback form 668 * @tc.desc : 669 */ 670 671 it('ActsAccountSelectAccountByOptions_0300', 0, async function (done) { 672 console.debug("====>ActsAccountSelectAccountByOptions_0300 start===="); 673 var appAccountManager = account.createAppAccountManager(); 674 var options = {requiredLabels: ["male", "30-40"]} 675 console.debug("====>start finish===="); 676 appAccountManager.addAccount(name, async (err)=>{ 677 console.debug("====>ActsAccountSelectAccountByOptions_0300 add_account_err:" + JSON.stringify(err)); 678 expect(err).assertEqual(null); 679 try { 680 var data = await appAccountManager.selectAccountsByOptions(options) 681 console.debug("====>ActsAccountSelectAccountByOptions_0300 data:" + JSON.stringify(data)); 682 expect(data.length).assertEqual(1) 683 } catch(err) { 684 console.debug("====>ActsAccountSelectAccountByOptions_0300 err:" + JSON.stringify(err)); 685 expect(err).assertEqual(null) 686 done() 687 } 688 try{ 689 await appAccountManager.deleteAccount(name) 690 console.debug('====>ActsAccountSelectAccountByOptions_0300 deleteAccount_success') 691 } 692 catch{ 693 console.debug('====>ActsAccountSelectAccountByOptions_0300 deleteAccount_err') 694 expect().assertFail() 695 } 696 done(); 697 }); 698 }); 699 }) 700} 701