Security_IAM_Face_Func_CallbackJsunit.test.js 44.6 KB
Newer Older
H
hu-jixiang1 已提交
1
/*
2
 * Copyright (C) 2022 Huawei Device Co., Ltd.
H
hu-jixiang1 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {describe, it, expect} from 'deccjsunit/index'
17 18 19
import userAuth from '@ohos.userAuth'
import userIDM from '@ohos.userIDM'
import pinAuth from '@ohos.pinAuth'
H
hu-jixiang1 已提交
20 21
import * as publicFC from './Publicfunction-n.js'

22 23 24
let UserIDM = new userIDM.UserIdentityManager();
let PinAuth = new pinAuth.PINAuth();
let UserAuth = new userAuth.UserAuth();
H
hu-jixiang1 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

let AuthType = {
    PIN : 1,
    FACE : 2
}
let AuthSubType = {
    PIN_SIX : 10000,
    PIN_NUMBER : 10001,
    PIN_MIXED : 10002,
    FACE_2D : 20000,
    FACE_3D : 20001
}
let AuthTurstLevel = {
    ATL1 : 10000,
    ATL2 : 20000,
    ATL3 : 30000,
    ATL4 : 40000
}

let SetPropertyType = {
    PROCESS_ALGORITHM : 1,
}

let userID = {
J
jiyong_sd 已提交
49
    User1 : 100,
H
hu-jixiang1 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    User2 : 2,
    User3 : 3,
    User4 : 4,
    User5 : 5
}

let ResultCode = {
    SUCCESS : 0,
    FAIL : 1,
    GENERAL_ERROR : 2,
    CANCELED : 3,
    TIMEOUT : 4,
    TYPE_NOT_SUPPORT : 5,
    TRUST_LEVEL_NOT_SUPPORT : 6,
    BUSY : 7,
    INVALID_PARAMETERS : 8,
    LOCKED : 9,
J
jiyong_sd 已提交
67 68
    NOT_ENROLLED : 10,
    Authfail: 14
H
hu-jixiang1 已提交
69 70 71 72 73 74 75 76
}

let GetPropertyType = {
    AUTH_SUB_TYPE : 1,
    REMAIN_TIMES : 2,
    FREEZING_TIME : 3
}

J
jiyong_sd 已提交
77
let Inputerdata = new Uint8Array([1,2,3,4,5,6]);
H
hu-jixiang1 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

let GetPropertyTypearray=new Array();
GetPropertyTypearray[0]=GetPropertyType.AUTH_SUB_TYPE;      
GetPropertyTypearray[1]=GetPropertyType.FREEZING_TIME;
GetPropertyTypearray[2]=GetPropertyType.REMAIN_TIMES;

let GetPropertyRequestpin = {
    authType:AuthType.PIN,
    keys:GetPropertyTypearray
    }

let GetPropertyRequestface = {
    authType:AuthType.FACE,
    keys:GetPropertyTypearray
    }

let CredentialInfopinsix = {
    credType: AuthType.PIN,
    credSubType: AuthSubType.PIN_SIX,
    token:new Uint8Array([1,2,3,4,5,6])
}

let CredentialInfopinnum = {
    credType: AuthType.PIN,
    credSubType: AuthSubType.PIN_NUMBER,
    token: null
}

let CredentialInfopinmix = {
    credType: AuthType.PIN,
    credSubType: AuthSubType.PIN_MIXED,
    token: null
}

let CredentialInfoface2d = {
    credType: AuthType.FACE,
    credSubType: AuthSubType.FACE_2D,
    token: null
}

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

J
jiyong_sd 已提交
122
describe('userauthTest_two4', function () {
H
hu-jixiang1 已提交
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

    it('Security_IAM_Face_AddCred_Func_0101', 0, async function (done) {
        try {
            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
            let challenge ;
            publicFC.publicOpenSession(UserIDM, function (data) {
                console.info('Security_IAM_Face_AddCred_Func_0101 openSession challenge = ' + data);
                challenge = data;
                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) {
                    console.info('Face_AddCred_Func_0101 addCredential Result1 = ' + JSON.stringify(onresult));
                    let info101;
                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
                        console.info('Security_IAM_Face_AddCred_Func_0101 auth onResult = ' + JSON.stringify(data));
                        info101 = data;
                        let token = info101.authextr.token;
                        CredentialInfoface2d.token = token;
                        let addfaceresult;
                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) {
                            console.info('Face_AddCred_Func_0101 addCredential Result2=' + JSON.stringify(onresult));
                            addfaceresult = onresult;
                            expect(ResultCode.SUCCESS).assertEqual(addfaceresult.addCredresult);
                            publicFC.publicauth(UserAuth,challenge,AuthType.FACE,AuthTurstLevel.ATL1, function (data) {
                                console.info('testFace Face_AddCred_Func_0101 onResult = ' + JSON.stringify(data));
                                let faceauth101 = data;
                                expect(ResultCode.SUCCESS).assertEqual(faceauth101.authresult);
                                publicFC.publicauthUser(
                                    UserAuth,userID.User1,challenge,AuthType.FACE,AuthTurstLevel.ATL1,function (data) {
                                    console.info('testFace Face_AddCred_Func_0101 onResult= ' + JSON.stringify(data));
                                    faceauth101 = data;
                                    expect(ResultCode.SUCCESS).assertEqual(faceauth101.authresult);
                                    let credentialId = addfaceresult.credentialId;
                                    let delcredresult ;
                                    publicFC.publicdelCred(UserIDM,credentialId,token, function (data) {
                                        console.info('testFace Face_AddCred_Func_0101 del=' + JSON.stringify(data));
                                        delcredresult = data;
                                        expect(ResultCode.SUCCESS).assertEqual(delcredresult.delCredresult);
                                        publicFC.publicdelUser(UserIDM,token, function (data) {
                                            console.info('Face_AddCred_Func_0101 delUser= ' + JSON.stringify(data));
                                            publicFC.publicCloseSession(UserIDM, function (data) {
                                                console.info('Security_IAM_Face_AddCred_Func_0101 closeSession');
                                                publicFC.publicunRegisterInputer(PinAuth, function (data) {
                                                    console.info('Security_IAM_Face_AddCred_Func_0101 unRegister');
                                                    done();
                                                })
                                            })
                                        }, function (data) {
                                        })
                                    }, function (onacquireinfo) {
                                    })
                                }, function (onacquireinfo) {
                                })
                            }, function (onacquireinfo) {
                            })
                        }, function (onacquireinfo) {
                        })
                    }, function (data) {
                    })
                }, function (onacquireinfo) {
                })
            })
        } catch (e) {
            console.log("Security_IAM_Face_AddCred_Func_0101 fail " + e);
            expect(null).assertFail();
        }
    })

J
jiyong_sd 已提交
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
    it('Security_IAM_Face_AddCred_Func_0103', 0, async function (done) {
        try {
            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
            let challenge ;
            publicFC.publicOpenSession(UserIDM, function (data) {
                console.info('Security_IAM_Face_AddCred_Func_0103 openSession challenge = ' + data);
                challenge = data;
                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) {
                    console.info('Face_AddCred_Func_0103 addCredential Result1 = ' + JSON.stringify(onresult));
                    let info101;
                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, async function (data) {
                        console.info('Security_IAM_Face_AddCred_Func_0103 auth onResult = ' + JSON.stringify(data));
                        info101 = data;
                        let token = info101.authextr.token;
                        CredentialInfoface2d.token = token;
                        let addfaceresult;
                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) {
                            console.info('Face_AddCred_Func_0103 addCredential Result2=' + JSON.stringify(onresult));
                            addfaceresult = onresult;
                        }, function (onacquireinfo) {
                        })
                        let cancelresult = publicFC.publiccancel(UserIDM,challenge);
211
                        await sleep(2500);
J
jiyong_sd 已提交
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
                        if(cancelresult == 1){
                            console.info('Face_AddCred_Func_0103 cancel1 authresult = ' + addfaceresult.addCredresult);
                            expect(ResultCode.SUCCESS).assertEqual(addfaceresult.addCredresult);
                        }else if(cancelresult == 0){
                            console.info('Face_AddCred_Func_0103 cancel0 authresult = ' + addfaceresult.addCredresult);
                            expect(ResultCode.CANCELED).assertEqual(addfaceresult.addCredresult);
                        }
                        await publicFC.publicdelUser(UserIDM,token, function (data) {
                            console.info('Face_AddCred_Func_0103 delUser= ' + JSON.stringify(data));
                            publicFC.publicCloseSession(UserIDM, function (data) {
                                console.info('Security_IAM_Face_AddCred_Func_0103 closeSession');
                                publicFC.publicunRegisterInputer(PinAuth, function (data) {
                                    console.info('Security_IAM_Face_AddCred_Func_0103 unRegister');
                                    done();
                                })
                            })
                        }, function (data) {
                        })
                    }, function (data) {
                    })
                }, function (onacquireinfo) {
                })
            })
        } catch (e) {
            console.log("Security_IAM_Face_AddCred_Func_0101 fail " + e);
            expect(null).assertFail();
        }
    })

H
hu-jixiang1 已提交
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
//    it('testaddfacecancel101', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge;
//            let result1 = null;
//            let extraInfo1 = null;
//            let module1 = null;
//            let acquire1 = null;
//            let extr1 = null;
//            let token;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testaddfacecancel101 OpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testaddfacecancel101 addCredential onResult = ' + JSON.stringify(data));
//                    let info101;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testaddfacecancel101 publicauth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        token = info101.authextr.token
//                        CredentialInfoface2d.token = token
//                        UserIDM.addCredential(CredentialInfoface2d, {
//                            onResult: function(result,extraInfo){
//                                console.log(result)
//                                result1 = result
//                                extraInfo1 = extraInfo.credentialId
//                            },
//                            onAcquireInfo:function (module,acquire,extr){
//                                module1 = module
//                                acquire1 = acquire
//                                extr1 = extr
//                                console.info(module);
//                            }
//                        })
//                    }, function (data) {
//                    })
//                }, function (data) {
//                })
//            })
//            await sleep(13000);
//            let cancelresult = publicFC.publiccancel(UserIDM,challenge)
//            expect(ResultCode.SUCCESS).assertEqual(cancelresult);
//            await sleep(1000);
//            expect(ResultCode.CANCELED).assertEqual(result1);
//            publicFC.publicCloseSession(UserIDM, function (data) {
//                console.info('testFace testaddfacecancel101 publicCloseSession ');
//                publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                    console.info('testFace testaddfacecancel101 publicunRegisterInputer ');
//                })
//                done();
//            })
//        } catch (e) {
//            console.log("testaddfacecancel101 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testaddfacecancel102', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testaddfacecancel102 OpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testaddfacecancel102 addCredential onResult = ' + JSON.stringify(data));
//                    let info101;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1,async function (data) {
//                        console.info('testFace testaddfacecancel102 publicauth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token
//                        CredentialInfoface2d.token = token
//                        let result1 = null
//                        let extraInfo1 = null
//                        let module1 = null
//                        let acquire1 = null
//                        let extr1 = null
//                        await UserIDM.addCredential(CredentialInfoface2d, {
//                            onResult: function(result,extraInfo){
//                                console.log(result)
//                                result1 = result
//                                extraInfo1 = extraInfo.credentialId
//                            },
//                            onAcquireInfo:function (module,acquire,extr){
//                                module1 = module
//                                acquire1 = acquire
//                                extr1 = extr
//                                console.info(module);
//                            }
//                        })
//                        await sleep(3000);
//                        let cancelresult = publicFC.publiccancel(UserIDM,challenge)
//                        expect(ResultCode.SUCCESS).assertEqual(cancelresult);
//                        expect(ResultCode.CANCELED).assertEqual(result1);
//                        publicFC.publicCloseSession(UserIDM, function (data) {
//                            console.info('testFace testaddfacecancel102 publicCloseSession ');
//                            publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                console.info('testFace testaddfacecancel102 publicunRegisterInputer ');
//                            })
//                            done();
//                        })
//                    }, function (data) {
//                    })
//                }, function (data) {
//                })
//            })
//        } catch (e) {
//            console.log("testaddfacecancel102 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testaddfacecancel103', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testaddfacecancel103 OpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testaddfacecancel103 addCredential onResult = ' + JSON.stringify(data));
//                    let info101;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, async function (data) {
//                        console.info('testFace testaddfacecancel103 publicauth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token
//                        CredentialInfoface2d.token = token
//                        let result1 = null
//                        let extraInfo1 = null
//                        let module1 = null
//                        let acquire1 = null
//                        let extr1 = null
//                        await UserIDM.addCredential(CredentialInfoface2d, {
//                            onResult: function(result,extraInfo){
//                                console.log(result)
//                                result1 = result
//                                extraInfo1 = extraInfo.credentialId
//                            },
//                            onAcquireInfo:function (module,acquire,extr){
//                                module1 = module
//                                acquire1 = acquire
//                                extr1 = extr
//                                console.info(module);
//                            }
//                        })
//                        await sleep(3000);
//                        let cancelresult = publicFC.publiccancel(UserIDM,challenge)
//                        expect(ResultCode.SUCCESS).assertEqual(cancelresult);
//                        expect(ResultCode.CANCELED).assertEqual(result1);
//                        publicFC.publicCloseSession(UserIDM, function (data) {
//                            console.info('testFace testaddfacecancel103 publicCloseSession ');
//                            publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                console.info('testFace testaddfacecancel103 publicunRegisterInputer ');
//                            })
//                            done();
//                        })
//                    }, function (data) {
//                    })
//                }, function (data) {
//                })
//            })
//        } catch (e) {
//            console.log("testaddfacecancel103 fail " + e);
//            expect(null).assertFail();
//        }
//    })

//    it('testauthfacecancel101', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge ;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testauthfacecancel101 publicOpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testauthfacecancel101 addCredential onResult=' + JSON.stringify(data));
//                    let info101 ;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testauthfacecancel101 auth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token
//                        CredentialInfoface2d.token = token
//                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, async function (data) {
//                            console.info('testFace testauthfacecancel101 addCredential = ' + JSON.stringify(data));
//                            let result1 = null;
//                            let extraInfo1 = null;
//                            let module1 = null;
//                            let acquire1 = null;
//                            let extr1 = null;
//                            let contextID1 = null;
//                            contextID1 = await UserAuth.auth(challenge, AuthType.FACE, AuthTurstLevel.ATL1, {
//                                onResult: function(result,extraInfo){
//                                    console.log(result);
//                                    result1 = result;
//                                    extraInfo1 = extraInfo;
//                                },
//                                onAcquireInfo:function (module,acquire,extr){
//                                    module1 = module;
//                                    acquire1 = acquire;
//                                    extr1 = extr;
//                                    console.info(module);
//                                }
//                            });
//                            await sleep(3000);
//                            let authfacecancel101 = publicFC.publicgecancelAuth(UserAuth,contextID1)
//                            expect(ResultCode.SUCCESS).assertEqual(authfacecancel101);
//                            expect(ResultCode.CANCELED).assertEqual(result1);
//                            publicFC.publicdelUser(UserIDM,token, function (data) {
//                                console.info('testFace testauthfacecancel101 delUser = ' + JSON.stringify(data));
//                                publicFC.publicCloseSession(UserIDM, function (data) {
//                                    console.info('testFace testauthfacecancel101 publicCloseSession');
//                                    publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                        console.info('testFace testauthfacecancel101 publicunRegisterInputer');
//                                        done();
//                                    })
//                                })
//                            })
//                        }, function (data) {
//                        })
//                    }, function (data) {
//                    })
//                }, function (data) {
//                })
//            })
//
//        } catch (e) {
//            console.log("testauthfacecancel101 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testauthfacecancel102', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge ;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testauthfacecancel102 publicOpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testauthfacecancel102 addCredential onResult = ' + JSON.stringify(data));
//                    let info101 ;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testauthfacecancel102 publicauth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token
//                        CredentialInfoface2d.token = token
//                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, async function (data) {
//                            console.info('testFace testauthfacecancel102 addCredential = ' + JSON.stringify(data));
//                            let result1 = null;
//                            let extraInfo1 = null;
//                            let module1 = null;
//                            let acquire1 = null;
//                            let extr1 = null;
//                            let contextID1 = null;
//                            contextID1 = await UserAuth.auth(challenge, AuthType.FACE, AuthTurstLevel.ATL1, {
//                                onResult: function(result,extraInfo){
//                                    console.log(result);
//                                    result1 = result;
//                                    extraInfo1 = extraInfo;
//                                },
//                                onAcquireInfo:function (module,acquire,extr){
//                                    module1 = module;
//                                    acquire1 = acquire;
//                                    extr1 = extr;
//                                    console.info(module);
//                                }
//                            });
//                            await sleep(8000);
//                            let authfacecancel101 = publicFC.publicgecancelAuth(UserAuth,contextID1)
//                            expect(ResultCode.SUCCESS).assertEqual(authfacecancel101);
//                            expect(ResultCode.CANCELED).assertEqual(result1);
//                            publicFC.publicdelUser(UserIDM,token, function (data) {
//                                console.info('testFace testauthfacecancel102 delUser = ' + JSON.stringify(data));
//                                publicFC.publicCloseSession(UserIDM, function (data) {
//                                    console.info('testFace testauthfacecancel102 publicCloseSession');
//                                    publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                        console.info('testFace testauthfacecancel102 publicunRegisterInputer');
//                                        done();
//                                    })
//                                })
//                            }, function (data) {
//                            })
//                        }, function (data) {
//                        })
//                    }, function (data) {
//                    })
//                }, function (data) {
//                })
//            })
//
//        } catch (e) {
//            console.log("testauthfacecancel102 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testauthfacecancel103', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge ;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testauthfacecancel103 publicOpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testauthfacecancel103 addCredential= ' + JSON.stringify(data));
//                    let info101 ;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testauthfacecancel103 publicauth = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token
//                        CredentialInfoface2d.token = token
//                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, async function (data) {
//                            console.info('testFace testauthfacecancel103 addCredential= ' + JSON.stringify(data));
//                            let result1 = null;
//                            let extraInfo1 = null;
//                            let module1 = null;
//                            let acquire1 = null;
//                            let extr1 = null;
//                            let contextID1 = null;
//                            contextID1 = await UserAuth.auth(challenge, AuthType.FACE, AuthTurstLevel.ATL1, {
//                                onResult: function(result,extraInfo){
//                                    console.log(result);
//                                    result1 = result;
//                                    extraInfo1 = extraInfo;
//                                },
//                                onAcquireInfo:function (module,acquire,extr){
//                                    module1 = module;
//                                    acquire1 = acquire;
//                                    extr1 = extr;
//                                    console.info(module);
//                                }
//                            });
//                            await sleep(10000);
//                            let authfacecancel101 = publicFC.publicgecancelAuth(UserAuth,contextID1)
//                            expect(ResultCode.SUCCESS).assertEqual(authfacecancel101);
//                            expect(ResultCode.CANCELED).assertEqual(result1);
//                            publicFC.publicdelUser(UserIDM,token, function (data) {
//                                console.info('testFace testauthfacecancel103 delUser = ' + JSON.stringify(data));
//                                publicFC.publicCloseSession(UserIDM, function (data) {
//                                    console.info('testFace testauthfacecancel103 publicCloseSession');
//                                    publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                        console.info('testFace testauthfacecancel103 publicunRegisterInputer');
//                                        done();
//                                    })
//                                })
//                            }, function (data) {
//                            })
//                        }, function (data) {
//                        })
//                    }, function (data) {
//                    })
//                }, function (data) {
//                })
//            })
//
//        } catch (e) {
//            console.log("testauthfacecancel103 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testauthuserfacecancel101', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge ;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testauthuserfacecancel101 publicOpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testauthuserfacecancel101 addCredential= ' + JSON.stringify(data));
//                    let info101 ;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testauthuserfacecancel101 auth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token;
//                        CredentialInfoface2d.token = token;
//                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, async function (data) {
//                            console.info('testFace testauthuserfacecancel101addCredential=' + JSON.stringify(data));
//                            let result1 = null;
//                            let extraInfo1 = null;
//                            let module1 = null;
//                            let acquire1 = null;
//                            let extr1 = null;
//                            let contextID1 = null;
//                            contextID1 = await UserAuth.authUser(
    //                            userID.User1, challenge, AuthType.FACE, AuthTurstLevel.ATL1, {
//                                onResult: function(result,extraInfo){
//                                    console.log(result);
//                                    result1 = result;
//                                    extraInfo1 = extraInfo;
//                                },
//                                onAcquireInfo:function (module,acquire,extr){
//                                    module1 = module;
//                                    acquire1 = acquire;
//                                    extr1 = extr;
//                                    console.info(module);
//                                }
//                            })
//                            await sleep(3000);
//                            let authfacecancel101 = publicFC.publicgecancelAuth(UserAuth,contextID1);
//                            expect(ResultCode.SUCCESS).assertEqual(authfacecancel101);
//                            expect(ResultCode.CANCELED).assertEqual(result1);
//                            publicFC.publicCloseSession(UserIDM, function (data) {
//                                console.info('testFace testauthuserfacecancel101 publicCloseSession');
//                                publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                    console.info('testFace testauthuserfacecancel101 publicunRegisterInputer');
//                                    done();
//                                })
//                            })
//                        }, function (data) {
//                        })
//                    }, function (data) {
//                    });
//                }, function (data) {
//                })
//            })
//        } catch (e) {
//            console.log("testauthuserfacecancel101 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testauthuserfacecancel102', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge ;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testauthuserfacecancel102 publicOpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testauthuserfacecancel102 addCredential Result=' + JSON.stringify(data));
//                    let info101 ;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testauthuserfacecancel102 auth onResult = ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token;
//                        CredentialInfoface2d.token = token;
//                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, async function (data) {
//                            console.info('testFace testauthuserfacecancel102 addCred=' + JSON.stringify(data));
//                            let result1 = null;
//                            let extraInfo1 = null;
//                            let module1 = null;
//                            let acquire1 = null;
//                            let extr1 = null;
//                            let contextID1 = null;
//                            contextID1 = await UserAuth.authUser(
    //                            userID.User1, challenge, AuthType.FACE, AuthTurstLevel.ATL1, {
//                                onResult: function(result,extraInfo){
//                                    console.log(result);
//                                    result1 = result;
//                                    extraInfo1 = extraInfo;
//                                },
//                                onAcquireInfo:function (module,acquire,extr){
//                                    module1 = module;
//                                    acquire1 = acquire;
//                                    extr1 = extr;
//                                    console.info(module);
//                                }
//                            })
//                            await sleep(8000);
//                            let authfacecancel101 = publicFC.publicgecancelAuth(UserAuth,contextID1);
//                            expect(ResultCode.SUCCESS).assertEqual(authfacecancel101);
//                            expect(ResultCode.CANCELED).assertEqual(result1);
//                            publicFC.publicCloseSession(UserIDM, function (data) {
//                                console.info('testFace testauthuserfacecancel102 publicCloseSession');
//                                publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                    console.info('testFace testauthuserfacecancel102 publicunRegisterInputer');
//                                    done();
//                                })
//                            })
//                        }, function (data) {
//                        })
//                    }, function (data) {
//                    });
//                }, function (data) {
//                })
//            })
//        } catch (e) {
//            console.log("testauthuserfacecancel102 fail " + e);
//            expect(null).assertFail();
//        }
//    })
//
//    it('testauthuserfacecancel103', 0, async function (done) {
//        try {
//            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
//            let challenge ;
//            publicFC.publicOpenSession(UserIDM, function (data) {
//                console.info('testFace testauthuserfacecancel103 publicOpenSession challenge = ' + data);
//                challenge = data;
//                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
//                    console.info('testFace testauthuserfacecancel103 addCredential= ' + JSON.stringify(data));
//                    let info101 ;
//                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
//                        console.info('testFace testauthuserfacecancel103 publicauth= ' + JSON.stringify(data));
//                        info101 = data;
//                        let token = info101.authextr.token;
//                        CredentialInfoface2d.token = token;
//                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, async function (data) {
//                            console.info('testFace testauthuserfacecancel103 addCred=' + JSON.stringify(data));
//                            let result1 = null;
//                            let extraInfo1 = null;
//                            let module1 = null;
//                            let acquire1 = null;
//                            let extr1 = null;
//                            let contextID1 = null;
//                            contextID1 = await UserAuth.authUser(
    //                            userID.User1, challenge, AuthType.FACE, AuthTurstLevel.ATL1, {
//                                onResult: function(result,extraInfo){
//                                    console.log(result);
//                                    result1 = result;
//                                    extraInfo1 = extraInfo;
//                                },
//                                onAcquireInfo:function (module,acquire,extr){
//                                    module1 = module;
//                                    acquire1 = acquire;
//                                    extr1 = extr;
//                                    console.info(module);
//                                }
//                            })
//                            await sleep(11000);
//                            let authfacecancel101 = publicFC.publicgecancelAuth(UserAuth,contextID1);
//                            expect(ResultCode.SUCCESS).assertEqual(authfacecancel101);
//                            expect(ResultCode.CANCELED).assertEqual(result1);
//                            publicFC.publicCloseSession(UserIDM, function (data) {
//                                console.info('testFace testauthuserfacecancel103 publicCloseSession');
//                                publicFC.publicunRegisterInputer(PinAuth, function (data) {
//                                    console.info('testFace testauthuserfacecancel103 publicunRegisterInputer');
//                                    done();
//                                })
//                            })
//                        }, function (data) {
//                        })
//                    }, function (data) {
//                    });
//                }, function (data) {
//                })
//            })
//        } catch (e) {
//            console.log("testauthuserfacecancel103 fail " + e);
//            expect(null).assertFail();
//        }
//    })

    it('Security_IAM_Face_AddCred_Func_0102', 2, async function (done) {
        try {
            publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
            let challenge ;
            publicFC.publicOpenSession(UserIDM, function (data) {
                console.info('testFace Security_IAM_Face_AddCred_Func_0102 publicOpenSession challenge = ' + data);
                challenge = data;
                publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
                    console.info('testFace Face_AddCred_Func_0102 addCredential= ' + JSON.stringify(data));
                    let info101 ;
                    publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
                        console.info('testFace Face_AddCred_Func_0102 publicauth = ' + JSON.stringify(data));
                        info101 = data;
                        let token = info101.authextr.token;
                        CredentialInfoface2d.token = token;
                        let addfaceresult ;
                        publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (data) {
                            console.info('testFace Face_AddCred_Func_0102 addCredential=' + JSON.stringify(data));
                            addfaceresult = data;
                            let credentialId = addfaceresult.credentialId;
                            let token1 = token + "Wrong Word";
                            let delcredresult ;
                            publicFC.publicdelCred(UserIDM,credentialId,token1, function (data) {
                                console.info('testFace Face_AddCred_Func_0102 publicdelCred=' + JSON.stringify(data));
                                delcredresult = data;
J
jiyong_sd 已提交
810
                                expect(ResultCode.Authfail).assertEqual(delcredresult.delCredresult);
H
hu-jixiang1 已提交
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
                                publicFC.publicdelUser(UserIDM,token, function (data) {
                                    console.info('testFace Face_AddCred_Func_0102 delUser= ' + JSON.stringify(data));
                                    publicFC.publicCloseSession(UserIDM, function (data) {
                                        console.info('testFace Face_AddCred_Func_0102 publicCloseSession ');
                                        publicFC.publicunRegisterInputer(PinAuth, function (data) {
                                            console.info('testFace Face_AddCred_Func_0102 publicunRegister ');
                                            done();
                                        })
                                    })
                                }, function (data) {
                                })
                            }, function (data) {
                            })
                        }, function (data) {
                        })
                    }, function (data) {
                    })
                }, function (data) {
                })
            })
        } catch (e) {
            console.log("testdelface102 fail " + e);
            expect(null).assertFail();
        }
    })
J
jiyong_sd 已提交
836

H
hu-jixiang1 已提交
837
})