Security_IAM_Interface_Func_CallbackJsunit.test.js 8.9 KB
Newer Older
J
jiyong_sd 已提交
1
/*
2
 * Copyright (C) 2022 Huawei Device Co., Ltd.
J
jiyong_sd 已提交
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'
J
jiyong_sd 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
import * as publicFC from './Publicfunction-n.js'


describe('userauthTest', function () {

    it('Security_IAM_Face_Interface_check_IDMAuthSubType_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_IDMAuthSubType_0101 start');
        expect(10000).assertEqual(userIDM.AuthSubType.PIN_SIX);
        expect(10001).assertEqual(userIDM.AuthSubType.PIN_NUMBER);
        expect(10002).assertEqual(userIDM.AuthSubType.PIN_MIXED);
        expect(20000).assertEqual(userIDM.AuthSubType.FACE_2D);
        expect(20001).assertEqual(userIDM.AuthSubType.FACE_3D);
        console.info('testFace Security_IAM_Face_Interface_check_IDMAuthSubType_0101 end');
        done();
    })

36
    it('Security_IAM_Face_Interface_check_IDMAuthType_0101', 0, async function (done) {
J
jiyong_sd 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 122 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
        console.info('testFace Security_IAM_Face_Interface_check_IDMAuthSubType_0101 start');
        expect(1).assertEqual(userIDM.AuthType.PIN);
        expect(2).assertEqual(userIDM.AuthType.FACE);
        console.info('testFace Security_IAM_Face_Interface_check_IDMAuthSubType_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_pinauthAuthSubType_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_pinauthAuthSubType_0101 start');
        expect(10000).assertEqual(pinAuth.AuthSubType.PIN_SIX);
        expect(10001).assertEqual(pinAuth.AuthSubType.PIN_NUMBER);
        expect(10002).assertEqual(pinAuth.AuthSubType.PIN_MIXED);
        expect(20000).assertEqual(pinAuth.AuthSubType.FACE_2D);
        expect(20001).assertEqual(pinAuth.AuthSubType.FACE_3D);
        console.info('testFace Security_IAM_Face_Interface_check_pinauthAuthSubType_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthAuthSubType_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthSubType_0101 start');
        expect(10000).assertEqual(userAuth.AuthSubType.PIN_SIX);
        expect(10001).assertEqual(userAuth.AuthSubType.PIN_NUMBER);
        expect(10002).assertEqual(userAuth.AuthSubType.PIN_MIXED);
        expect(20000).assertEqual(userAuth.AuthSubType.FACE_2D);
        expect(20001).assertEqual(userAuth.AuthSubType.FACE_3D);
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthSubType_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthAuthTrustLevel_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthTrustLevel_0101 start');
        expect(10000).assertEqual(userAuth.AuthTrustLevel.ATL1);
        expect(20000).assertEqual(userAuth.AuthTrustLevel.ATL2);
        expect(30000).assertEqual(userAuth.AuthTrustLevel.ATL3);
        expect(40000).assertEqual(userAuth.AuthTrustLevel.ATL4);
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthTrustLevel_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthAuthType_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthType_0101 start');
        expect(1).assertEqual(userAuth.AuthType.PIN);
        expect(2).assertEqual(userAuth.AuthType.FACE);
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthType_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthGetPropertyType_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthGetPropertyType_0101 start');
        expect(1).assertEqual(userAuth.GetPropertyType.AUTH_SUB_TYPE);
        expect(2).assertEqual(userAuth.GetPropertyType.REMAIN_TIMES);
        expect(3).assertEqual(userAuth.GetPropertyType.FREEZING_TIME);
        console.info('testFace Security_IAM_Face_Interface_check_userauthGetPropertyType_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthAuthMethod_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthMethod_0101 start');
        expect(0xF).assertEqual(userAuth.AuthMethod.PIN_ONLY);
        expect(0xF0).assertEqual(userAuth.AuthMethod.FACE_ONLY);
        console.info('testFace Security_IAM_Face_Interface_check_userauthAuthMethod_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthSetPropertyType_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthSetPropertyType_0101 start');
        expect(1).assertEqual(userAuth.SetPropertyType.INIT_ALGORITHM);
        console.info('testFace Security_IAM_Face_Interface_check_userauthSetPropertyType_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthModule_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthModule_0101 start');
        expect(1).assertEqual(userAuth.Module.FACE_AUTH);
        console.info('testFace Security_IAM_Face_Interface_check_userauthModule_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthResultCode_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthResultCode_0101 start');
        expect(0).assertEqual(userAuth.ResultCode.SUCCESS);
        expect(1).assertEqual(userAuth.ResultCode.FAIL);
        expect(2).assertEqual(userAuth.ResultCode.GENERAL_ERROR);
        expect(3).assertEqual(userAuth.ResultCode.CANCELED);
        expect(4).assertEqual(userAuth.ResultCode.TIMEOUT);
        expect(5).assertEqual(userAuth.ResultCode.TYPE_NOT_SUPPORT);
        expect(6).assertEqual(userAuth.ResultCode.TRUST_LEVEL_NOT_SUPPORT);
        expect(7).assertEqual(userAuth.ResultCode.BUSY);
        expect(8).assertEqual(userAuth.ResultCode.INVALID_PARAMETERS);
        expect(9).assertEqual(userAuth.ResultCode.LOCKED);
        expect(10).assertEqual(userAuth.ResultCode.NOT_ENROLLED);
        console.info('testFace Security_IAM_Face_Interface_check_userauthResultCode_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101 start');
        expect(1).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_BRIGHT);
        expect(2).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_DARK);
        expect(3).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_CLOSE);
        expect(4).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_FAR);
        expect(5).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_HIGH);
        expect(6).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_LOW);
        expect(7).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_RIGHT);
        expect(8).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_LEFT);
        expect(9).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_TOO_MUCH_MOTION);
        expect(10).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_POOR_GAZE);
        expect(11).assertEqual(userAuth.FaceTipsCode.FACE_AUTH_TIP_NOT_DETECTED);
        console.info('testFace Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101 end');
        done();
    })

    it('Security_IAM_Face_Interface_check_userauthFingerprintTips_0101', 0, async function (done) {
        console.info('testFace Security_IAM_Face_Interface_check_userauthFingerprintTips_0101 start');
        expect(0).assertEqual(userAuth.FingerprintTips.FINGERPRINT_TIP_GOOD);
        expect(1).assertEqual(userAuth.FingerprintTips.FINGERPRINT_TIP_IMAGER_DIRTY);
        expect(2).assertEqual(userAuth.FingerprintTips.FINGERPRINT_TIP_INSUFFICIENT);
        expect(3).assertEqual(userAuth.FingerprintTips.FINGERPRINT_TIP_PARTIAL);
        expect(4).assertEqual(userAuth.FingerprintTips.FINGERPRINT_TIP_TOO_FAST);
        expect(5).assertEqual(userAuth.FingerprintTips.FINGERPRINT_TIP_TOO_SLOW);
        console.info('testFace Security_IAM_Face_Interface_check_userauthFingerprintTips_0101 end');
        done();
    })
})