提交 c1294d25 编写于 作者: H hu-jixiang1

hujixiang1@huawei.com

Signed-off-by: Nhu-jixiang1 <hujixiang1@huawei.com>
Change-Id: I9f85a415dc079bb5694598a2ff64542b155e7e10
上级 2aa1f55b
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* 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,
* 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.
*/
require("./Security_IAM_PIN_Func_CallbackJsunit.test.js")
require("./Security_IAM_Coauth_Func_CallbackJsunit.test.js")
require("./Security_IAM_Face_Func_CallbackJsunit.test.js")
\ No newline at end of file
require('./Security_IAM_PIN_Kit_CallbackJsunit.test.js')
require('./Security_IAM_PIN_Func_CallbackJsunit.test.js')
require('./Security_IAM_PIN_DFX_CallbackJsunit.test.js')
require('./Security_IAM_Coauth_DFX_CallbackJsunit.test.js')
require('./Security_IAM_Coauth_Func_CallbackJsunit.test.js')
require('./Security_IAM_Face_DFX_CallbackJsunit.test.js')
require('./Security_IAM_Face_Func_CallbackJsunit.test.js')
\ No newline at end of file
......@@ -58,7 +58,7 @@ function publicunRegisterInputer(PinAuth,callback){
callback(unRegist)
}
catch (e) {
console.log("testFace publicRegisterInputer fail " + e);
console.log("testFace unpublicRegisterInputer fail " + e);
expect(null).assertFail();
}
}
......@@ -121,6 +121,7 @@ async function publicaddCredential(UserIDM,CredentialInfo,callback1,callback2){
console.info('faceTest publicaddCredential UserIDM = ' + UserIDM);
UserIDM.addCredential(CredentialInfo, {
onResult: function(result,extraInfo){
console.info('testFace aaaaaaaaaaaaa');
console.info("testFace addCredential result = " + result);
console.info("testFace addCredential extraInfo = " + JSON.stringify(extraInfo));
console.log(result)
......@@ -329,17 +330,17 @@ function publicgetallAuthInfo(UserIDM,callback){
//同步
function publicgetAvailabeStatus(UserAuth,authType,authTrustLevel){
console.info('testFace publicgetAvailabeStatus in');
console.info('testFace publicgetAvailableStatus in');
try {
console.info('testFace publicgetAvailabeStatus in try');
console.info('testFace publicgetAvailabeStatus UserAuth = ' + UserAuth);
console.info('testFace publicgetAvailableStatus in try');
console.info('testFace publicgetAvailableStatus UserAuth = ' + UserAuth);
let AvailabeStatus = null
AvailabeStatus = UserAuth.getAvailabeStatus(authType, authTrustLevel);
console.info('testFace publicgetAvailabeStatus result = ' + JSON.stringify(AsyncCallback));
AvailabeStatus = UserAuth.getAvailableStatus(authType, authTrustLevel);
console.info('testFace publicgetAvailableStatus result = ' + JSON.stringify(AvailabeStatus));
return AvailabeStatus
}
catch (e) {
console.log("testFace publicgetAvailabeStatus fail " + e);
console.log("testFace publicgetAvailableStatus fail " + e);
expect(null).assertFail();
}
}
......@@ -367,7 +368,7 @@ function publicsetProperty(UserAuth,SetPropertyRequest,callback){
console.info('testFace publicsetProperty in try');
console.info('testFace publicsetProperty UserAuth = ' + UserAuth);
UserAuth.setProperty(SetPropertyRequest,function (AsyncCallback) {
console.log("testFace faceDemo getallAuthInfo AsyncCallback = " + JSON.stringify(AsyncCallback))
console.log("testFace faceDemo setProperty AsyncCallback = " + JSON.stringify(AsyncCallback))
callback(AsyncCallback)
})
}
......@@ -439,7 +440,7 @@ function publicauthUser(UserAuth,userID,challenge,authType,authTrustLevel,callba
onResult: function(result,extraInfo){
console.log("testFace faceDemo authUser result = " + result)
onresult.authresult = result
console.log("testFace faceDemo authUser authextr = " + extraInfo)
console.log("testFace faceDemo authUser authextr = " + JSON.stringify(extraInfo))
onresult.authextr = extraInfo;
console.info('testFace publicauthUser authUser onResult = ' + JSON.stringify(onresult));
callback1(onresult)
......@@ -449,7 +450,7 @@ function publicauthUser(UserAuth,userID,challenge,authType,authTrustLevel,callba
onacquireinfo.authmodule = modulea
onacquireinfo.authacquire = acquire
onacquireinfo.authextr = extr
console.log("testFace faceDemo authUser module = " + modulea);
console.log("testFace faceDemo authUser module = " + JSON.stringify(modulea));
console.info('testFace publicauthUser authUser onacquireinfo = ' + JSON.stringify(onacquireinfo));
callback2(onacquireinfo)
}
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
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 = {
User1: 0,
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,
NOT_ENROLLED: 10,
Authfail: 14
}
let GetPropertyType = {
AUTH_SUB_TYPE: 1,
REMAIN_TIMES: 2,
FREEZING_TIME: 3
}
let Inputerdata = new Uint8Array([1, 2, 3, 4, 5, 6]);
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: null
}
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));
}
describe('userauthTest', function () {
it('Security_IAM_Coauth_DFX_0105', 1, async function (done) {
console.info('testFace Security_IAM_Coauth_DFX_0105 start');
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata);
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace Security_IAM_Coauth_DFX_0105 publicOpenSession data = ' + JSON.stringify(data));
let challenge1 = data;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace Security_IAM_Coauth_DFX_0105 publicOpenSession data = ' + JSON.stringify(data));
let challenge2 = data;
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
console.info('testFace Security_IAM_Coauth_DFX_0105 callback data = ' + JSON.stringify(data));
let token1;
console.info('testFace Security_IAM_Coauth_DFX_0105 addSuccess');
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
console.info('testFace Coauth_DFX_0105 publicauth = ' + JSON.stringify(data));
console.info('testFace Coauth_DFX_0105 publicauth.authresult = ' + data.authresult);
console.info('testFace Coauth_DFX_0105 ResultCode.SUCCESS = ' + ResultCode.SUCCESS);
expect(ResultCode.SUCCESS).assertEqual(data.authresult);
token1 = data.authextr.token;
publicFC.publicauth(UserAuth, challenge2, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
console.info('testFace Security_IAM_Coauth_DFX_0105 publicauth');
let token2;
token2 = data.authextr.token;
console.info('testFace Coauth_DFX_0105 publicauth.authresult2 = ' + data.authresult);
console.info('testFace Coauth_DFX_0105 ResultCode.SUCCESS = ' + ResultCode.SUCCESS);
expect(ResultCode.SUCCESS).assertEqual(data.authresult);
console.info("testFace Security_IAM_Coauth_DFX_0105 token = " + token2);
CredentialInfoface2d.token = token1;
publicFC.publicaddCredential(UserIDM, CredentialInfoface2d, function (data) {
console.info('testFace Coauth_DFX_0105 addCredresult = ' + data.addCredresult);
expect(ResultCode.FAIL).assertEqual(data.addCredresult);
publicFC.publicdelUser(UserIDM, token2, function (data) {
console.info("testFace Security_IAM_Coauth_DFX_0105 publicdelUser");
let deluserresult = data.delUserresult;
console.info("testFace Coauth_DFX_0105 delUser="+ deluserresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info("testFace Coauth_DFX_0105 CloseSession= " + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info("testFace Coauth_DFX_0105 unRegister= " + data);
done();
})
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
})
})
} catch (e) {
console.log("Security_IAM_Coauth_DFX_0105 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_Coauth_DFX_0106', 3, async function (done) {
console.info('testFace Security_IAM_Coauth_DFX_0106 start');
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge1 = data;
console.info('Security_IAM_Coauth_DFX_0106 publicOpenSession challenge1 = ' + challenge1);
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge2 = data;
console.info('Security_IAM_Coauth_DFX_0106 publicOpenSession challenge2 = ' + challenge2);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('Security_IAM_Coauth_DFX_0106 publicCloseSession data = ' + data);
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
let addcredresult101 = data.addCredresult;
console.info('Security_IAM_Coauth_DFX_0106 addCredential= ' + addcredresult101);
expect(ResultCode.FAIL).assertEqual(addcredresult101);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('Security_IAM_Coauth_DFX_0106 publicunRegisterInputer data = ' + data);
done();
})
})
})
})
})
} catch (e) {
console.log("Security_IAM_Coauth_DFX_0106 fail " + e);
expect(null).assertFail();
}
})
})
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
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 userID = {
User1: 100,
User2: 2,
User3: 3,
User4: 4,
User5: 5
}
let CredentialInfoface2d = {
credType: AuthType.FACE,
credSubType: AuthSubType.FACE_2D,
token: null
}
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,
NOT_ENROLLED : 10
}
let Inputerdata = new Uint8Array([1,2,3,4,5,6]);
let CredentialInfopinsix = {
credType: AuthType.PIN,
credSubType: AuthSubType.PIN_SIX,
token: null
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function authcycle(challenge,fcycle){
let finishicon = 0
let token;
for(let i = 0; i < 5; i++){
//未到达10个认证时,完成认证
//闭包方法
(function c(output){
publicFC.publicauth(UserAuth ,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace Coauth_Auth_MTBF_0101 pinauth '+output + '=' + data.authresult);
if(i == 4){
finishicon = finishicon + 1
token = data.authextr.token
}
},
function(data){
})
publicFC.publicauth(UserAuth ,challenge,AuthType.FACE,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace Coauth_Auth_MTBF_0101 faceauth '+output + '=' + data.authresult);
if(i == 4){
finishicon = finishicon + 1
}
},
function(data){
})
})(i)
}
publicFC.publicauth(UserAuth, challenge,AuthType.FACE,AuthTurstLevel.ATL1,
async function (data) {
console.info('testFace Coauth_Auth_MTBF_0101 auth11 =' + data.authresult);
if(data.authresult == ResultCode.SUCCESS){
}
while(finishicon < 2){
await sleep(100);
}
fcycle(data.authresult)
},
function(data){
})
}
function authUsercycle(challenge,fcycle){
let finishicon = 0
for(let i = 0; i < 10; i++){
//未到达10个认证时,完成认证
//闭包方法
(function c(output){
publicFC.publicauthUser(UserAuth ,userID.User1,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace FACE_Auth_MTBF_0102 auth '+output + '=' + data.authresult);
if(i == 4){
finishicon = finishicon + 1
}
},
function(data){
})
publicFC.publicauthUser(UserAuth ,userID.User1,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace FACE_Auth_MTBF_0102 auth '+output + '=' + data.authresult);
if(i == 4){
finishicon = finishicon + 1
}
},
function(data){
})
})(i)
}
publicFC.publicauthUser(UserAuth, userID.User1,challenge,AuthType.FACE,AuthTurstLevel.ATL1,
async function (data) {
console.info('testFace FACE_Auth_MTBF_0102 auth11 =' + data.authresult);
if(data.authresult == ResultCode.SUCCESS){
}
while(finishicon < 2){
await sleep(100);
}
fcycle(data.authresult)
},
function(data){
})
}
describe('userauthTest', function () {
it('Security_IAM_FACE_Auth_MTBF_0101', 4, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 OpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 addCredential onResult = ' + JSON.stringify(data));
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('FACE_Auth_MTBF_0101 auth onResult = ' + JSON.stringify(data));
let info101 = data;
let token = info101.authextr.token;
CredentialInfoface2d.token = token;
publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) {
console.info('testface FACE_Auth_MTBF_0101 addCredential=' + JSON.stringify(onresult));
authcycle(challenge,function(data){
publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 delUser = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 publicCloseSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 publicunRegisterInputer');
done();
})
})
}, function (data) {
})
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
})
} catch (e) {
console.log("FACE_Auth_MTBF_0101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_FACE_Auth_MTBF_0102', 4, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 OpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 addCredential onResult = ' + JSON.stringify(data));
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('testface FACE_Auth_MTBF_0102 auth onResult = ' + JSON.stringify(data));
let info101 = data;
let token = info101.authextr.token;
CredentialInfoface2d.token = token;
publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) {
console.info('FACE_Auth_MTBF_0102 addCredential Result2=' + JSON.stringify(onresult));
authUsercycle(challenge,function(data){
publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 delUser = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 publicCloseSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 publicunRegisterInputer');
done();
})
})
}, function (data) {
})
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
})
} catch (e) {
console.log("FACE_Auth_MTBF_0102 fail " + e);
expect(null).assertFail();
}
})
})
......@@ -13,16 +13,15 @@
* limitations under the License.
*/
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIAM from '@ohos.UserIAM.userAuth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n.js'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
let UserAuth = userIAM.constructor()
let AuthType = {
PIN : 1,
......@@ -47,7 +46,7 @@ let SetPropertyType = {
}
let userID = {
User1 : 1000,
User1 : 100,
User2 : 2,
User3 : 3,
User4 : 4,
......@@ -65,7 +64,8 @@ let ResultCode = {
BUSY : 7,
INVALID_PARAMETERS : 8,
LOCKED : 9,
NOT_ENROLLED : 10
NOT_ENROLLED : 10,
Authfail: 14
}
let GetPropertyType = {
......@@ -74,7 +74,7 @@ let GetPropertyType = {
FREEZING_TIME : 3
}
let Inputerdata = new Uint8Array([12,34,56]);
let Inputerdata = new Uint8Array([1,2,3,4,5,6]);
let GetPropertyTypearray=new Array();
GetPropertyTypearray[0]=GetPropertyType.AUTH_SUB_TYPE;
......@@ -186,6 +186,58 @@ describe('userauthTest', function () {
}
})
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);
await sleep(100);
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();
}
})
// it('testaddfacecancel101', 0, async function (done) {
// try {
// publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
......@@ -755,7 +807,7 @@ describe('userauthTest', function () {
publicFC.publicdelCred(UserIDM,credentialId,token1, function (data) {
console.info('testFace Face_AddCred_Func_0102 publicdelCred=' + JSON.stringify(data));
delcredresult = data;
expect(ResultCode.FAIL).assertEqual(delcredresult.authresult);
expect(ResultCode.Authfail).assertEqual(delcredresult.delCredresult);
publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('testFace Face_AddCred_Func_0102 delUser= ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
......@@ -781,4 +833,5 @@ describe('userauthTest', function () {
expect(null).assertFail();
}
})
})
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
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 userID = {
User1: 100,
User2: 2,
User3: 3,
User4: 4,
User5: 5
}
let CredentialInfoface2d = {
credType: AuthType.FACE,
credSubType: AuthSubType.FACE_2D,
token: null
}
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,
NOT_ENROLLED : 10
}
let Inputerdata = new Uint8Array([1,2,3,4,5,6]);
let CredentialInfopinsix = {
credType: AuthType.PIN,
credSubType: AuthSubType.PIN_SIX,
token: null
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function authcycle(challenge,fcycle){
let finishicon = 0
for(let i = 0; i < 10; i++){
//未到达10个认证时,完成认证
//闭包方法
(function c(output){
publicFC.publicauth(UserAuth ,challenge,AuthType.FACE,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace FACE_Auth_MTBF_0101 auth '+output + '=' + data.authresult);
if(i == 9){
finishicon = 1
}
},
function(data){
})
})(i)
}
publicFC.publicauth(UserAuth, challenge,AuthType.FACE,AuthTurstLevel.ATL1,
async function (data) {
console.info('testFace FACE_Auth_MTBF_0101 auth11 =' + data.authresult);
if(data.authresult == ResultCode.SUCCESS){
}
while(finishicon = 0){
await sleep(100);
}
fcycle(data.authresult)
},
function(data){
})
}
function authUsercycle(challenge,fcycle){
let finishicon = 0
for(let i = 0; i < 10; i++){
//未到达10个认证时,完成认证
//闭包方法
(function c(output){
publicFC.publicauthUser(UserAuth ,userID.User1,challenge,AuthType.FACE,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace FACE_Auth_MTBF_0102 auth '+output + '=' + data.authresult);
if(i == 9){
finishicon = 1
}
},
function(data){
})
})(i)
}
publicFC.publicauthUser(UserAuth, userID.User1,challenge,AuthType.FACEs,AuthTurstLevel.ATL1,
async function (data) {
console.info('testFace FACE_Auth_MTBF_0102 auth11 =' + data.authresult);
if(data.authresult == ResultCode.SUCCESS){
}
while(finishicon = 0){
await sleep(100);
}
fcycle(data.authresult)
},
function(data){
})
}
describe('userauthTest', function () {
it('Security_IAM_FACE_Auth_MTBF_0101', 4, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 OpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 addCredential onResult = ' + JSON.stringify(data));
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('FACE_Auth_MTBF_0101 auth onResult = ' + JSON.stringify(data));
let info101 = data;
let token = info101.authextr.token;
CredentialInfoface2d.token = token;
publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) {
console.info('testface FACE_Auth_MTBF_0101 addCredential=' + JSON.stringify(onresult));
authcycle(challenge,function(data){
publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 delUser = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 publicCloseSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace FACE_Auth_MTBF_0101 publicunRegisterInputer');
done();
})
})
}, function (data) {
})
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
})
} catch (e) {
console.log("FACE_Auth_MTBF_0101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_FACE_Auth_MTBF_0102', 4, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 OpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 addCredential onResult = ' + JSON.stringify(data));
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('testface FACE_Auth_MTBF_0102 auth onResult = ' + JSON.stringify(data));
let info101 = data;
let token = info101.authextr.token;
CredentialInfoface2d.token = token;
publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) {
console.info('FACE_Auth_MTBF_0102 addCredential Result2=' + JSON.stringify(onresult));
authUsercycle(challenge,function(data){
publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 delUser = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 publicCloseSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace FACE_Auth_MTBF_0102 publicunRegisterInputer');
done();
})
})
}, function (data) {
})
})
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
})
} catch (e) {
console.log("FACE_Auth_MTBF_0102 fail " + e);
expect(null).assertFail();
}
})
})
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
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();
})
it('Security_IAM_Face_Interface_check_IDMAuthSubType_0101', 0, async function (done) {
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();
})
})
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
let AuthType = {
PIN : 1,
FACE : 2
}
let userID = {
User1 : 100,
User2 : 2,
User3 : 3,
User4 : 4,
User5 : 5
}
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 SetPropertyType1 = {
PROCESS_ALGORITHM : 1,
}
let SetPropertyType0 = {
PROCESS_ALGORITHM : 0,
}
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,
NOT_ENROLLED : 10
}
let GetPropertyType = {
AUTH_SUB_TYPE : 1,
REMAIN_TIMES : 2,
FREEZING_TIME : 3
}
let Inputerdata = new Uint8Array([1, 2, 3, 4, 5, 6]);
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: null
}
let CredentialInfoface2d = {
credType: AuthType.FACE,
credSubType: AuthSubType.FACE_2D,
token: null
}
describe('userauthTest', function () {
/*
* @tc.number : testGetEntriesString101
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.desc : Mixed strings value can be obtained correctly
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('Security_IAM_Interface_MTBF_0101', 4, async function (done) {
try {
let verisioninfo = UserAuth.getVersion();
console.log("Security_IAM_Interface_MTBF_0101 Version is: " + verisioninfo);
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace Security_IAM_Interface_MTBF_0101 publicOpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace Interface_MTBF_0101 publicaddCredential= ' + JSON.stringify(data));
let info101;
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('testFace Interface_MTBF_0101 publicauth = ' + JSON.stringify(data));
info101 = data;
let token = info101.authextr.token;
CredentialInfoface2d.token = token;
let faceinfo101 ;
publicFC.publicauthUser(UserAuth,userID.User1,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function (data) {
console.info('testFace Interface_MTBF_0101 publicauthUser = ' + JSON.stringify(data));
faceinfo101 = data;
expect(ResultCode.SUCCESS).assertEqual(faceinfo101.authresult);
// publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (data) {
// console.info('testFace Interface_MTBF_0101 addCredential = ' + JSON.stringify(data));
let EnrolledCredInfo ;
publicFC.publicgetAuthInfo(UserIDM, AuthType.PIN, function (data) {
console.info('testFace Interface_MTBF_0101 getAuthInfo' + JSON.stringify(data));
EnrolledCredInfo = data;
expect(AuthSubType.PIN_SIX).assertEqual(EnrolledCredInfo[0].authSubType);
let ExecutorProperty101;
publicFC.publicgetProperty(UserAuth,GetPropertyRequestpin, function (data) {
console.info('testFace Interface getProperty data' + JSON.stringify(data));
ExecutorProperty101 = data;
expect(ResultCode.SUCCESS).assertEqual(ExecutorProperty101.result);
// expect(AuthSubType.PIN_SIX).assertEqual(ExecutorProperty101.authSubType);
// publicFC.publicsetProperty(UserAuth,SetPropertyType1, function (data) {
// console.info('testFace Interface setProperty'+ JSON.stringify(data));
// publicFC.publicsetProperty(UserAuth,SetPropertyType0, function (data) {
// console.info('testFace setProperty data' + JSON.stringify(data));
// let AvailabeStatus = publicFC.publicgetAvailabeStatus(
// UserAuth,AuthType.FACE,AuthTurstLevel.ATL1)
// expect(ResultCode.SUCCESS).assertEqual(AvailabeStatus);
publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('testFace Interface delUser='+ JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace Interface_MTBF_0101 CloseSession ');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace Interface_MTBF unRegisterInputer');
done();
})
})
}, function (data) {
})
// })
// })
})
})
// }, function (data) {
// })
}, function (data) {
})
}, function (data) {
})
}, function (data) {
})
})
} catch (e) {
console.log("Security_IAM_Interface_MTBF_0101 fail " + e);
expect(null).assertFail();
}
})
})
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
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 = {
User1: 1000,
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,
NOT_ENROLLED: 10,
Authfail: 14
}
let GetPropertyType = {
AUTH_SUB_TYPE: 1,
REMAIN_TIMES: 2,
FREEZING_TIME: 3
}
let Inputerdata = new Uint8Array([1, 2, 3, 4, 5, 6]);
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: null
}
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));
}
describe('userauthTest', function () {
it('Security_IAM_PIN_AddCred_DFX_0102', 3, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge = data;
console.info('Security_IAM_PIN_AddCred_DFX_0102 publicOpenSession challenge = ' + challenge);
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
let addcredresult101 = data.addCredresult;
console.info('Security_IAM_PIN_AddCred_DFX_0102 addcredresult101 = ' + addcredresult101);
expect(ResultCode.SUCCESS).assertEqual(addcredresult101);
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
let addcredresult102 = data.addCredresult;
expect(ResultCode.FAIL).assertEqual(addcredresult102);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let info101 = data;
console.info('Security_IAM_PIN_AddCred_DFX_0102 publicauth= ' + JSON.stringify(info101));
let token = info101.authextr.token;
publicFC.publicdelUser(UserIDM, token, function (data) {
let deluserresult = data.delUserresult;
console.info('Security_IAM_PIN_AddCred_DFX_0102 publicdelUser = ' + deluserresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('Security_IAM_PIN_AddCred_DFX_0102 publicCloseSession= ' + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('Security_IAM_PIN_AddCred_DFX_0102 unRegisterInputer= ' + data);
done();
})
})
})
}, function (data) {
console.info('Security_IAM_PIN_AddCred_DFX_0102 publicauth data = ' + data);
})
})
})
})
} catch (e) {
console.log("Security_IAM_PIN_AddCred_DFX_0102 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_AddCred_DFX_0103', 3, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge = data;
console.info('Security_IAM_PIN_AddCred_DFX_0103 publicOpenSession challenge = ' + challenge);
let CredentialInfopinsix2 = {
credType: AuthType.PIN,
credSubType: AuthSubType.PIN_SIX,
}
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix2, function (data) {
let addcredresult101 = data.addCredresult;
expect(ResultCode.SUCCESS).assertEqual(addcredresult101);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let info101 = data;
console.info('Security_IAM_PIN_AddCred_DFX_0103 publicauth= ' + JSON.stringify(info101));
let token = info101.authextr.token;
publicFC.publicdelUser(UserIDM, token, function (data) {
let deluserresult = data.delUserresult;
console.info('Security_IAM_PIN_AddCred_DFX_0103 publicdelUser = ' + deluserresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('Security_IAM_PIN_AddCred_DFX_0103 publicCloseSession data = ' + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('Security_IAM_PIN_AddCred_DFX_0103 unRegisterInputer data= ' + data);
done();
})
})
})
}, function (data) {
console.info('Security_IAM_PIN_AddCred_DFX_0103 publicauth data = ' + data);
})
})
})
} catch (e) {
console.log("Security_IAM_PIN_AddCred_DFX_0103 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_Update_DFX_0101', 3, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge = data;
console.info('Security_IAM_PIN_Update_DFX_0101 publicOpenSession challenge = ' + challenge);
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
let addcredresult102 = data.addCredresult;
console.info('Security_IAM_PIN_Update_DFX_0101 publicaddCredential= ' + addcredresult102);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let addcredresult102 = data;
console.info('Security_IAM_PIN_Update_DFX_0101 auth= ' + JSON.stringify(addcredresult102));
let token = addcredresult102.authextr.token
publicFC.publicdelUser(UserIDM, token, function (data) {
let deluserresult = data.delUserresult;
console.info('Security_IAM_PIN_Update_DFX_0101 publicdelUser= ' + deluserresult);
publicFC.publicupdateCred(UserIDM, CredentialInfopinsix, function (data) {
let updateresult = data.updateCredresult;
expect(ResultCode.FAIL).assertEqual(updateresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('Security_IAM_PIN_Update_DFX_0101 publicCloseSession= ' + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('Security_IAM_PIN_Update_DFX_0101 unRegisterInputer= ' + data);
done();
})
})
})
})
}, function (data) {
})
})
})
} catch (e) {
console.log("Security_IAM_PIN_Update_DFX_0101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_Update_DFX_0103', 3, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge = data;
console.info('Security_IAM_PIN_Update_DFX_0103 publicOpenSession challenge = ' + challenge);
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
let addcredresult102 = data.addCredresult;
console.info('Security_IAM_PIN_Update_DFX_0103 publicaddCredential = ' + addcredresult102);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let auth101 = data;
console.info('Security_IAM_PIN_Update_DFX_0103 publicauth = ' + JSON.stringify(auth101));
let token = auth101.authextr.token;
CredentialInfopinsix.token = token;
publicFC.publicupdateCred(UserIDM, CredentialInfopinsix, function (data) {
let updateresult = data.updateCredresult;
expect(ResultCode.SUCCESS).assertEqual(updateresult);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
auth101 = data;
console.info('Security_IAM_PIN_Update_DFX_0103 auth= ' + JSON.stringify(auth101));
let token1 = auth101.authextr.token
publicFC.publicdelUser(UserIDM, token1, function (data) {
let deluserresult = data.delUserresult;
console.info('Security_IAM_PIN_Update_DFX_0103 publicdelUser= ' + deluserresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('Security_IAM_PIN_Update_DFX_0103 CloseSession = ' + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('Security_IAM_PIN_Update_DFX_0103 unRegisterInputer='+ data);
done();
})
})
})
})
})
}, function (data) {
})
})
})
} catch (e) {
console.log("Security_IAM_PIN_Update_DFX_0103 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_Delet_DFX_0101', 3, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge = data;
console.info('Security_IAM_PIN_Delet_DFX_0101 publicOpenSession challenge = ' + challenge);
publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) {
let addcredresult101 = data.addCredresult;
console.info('Security_IAM_PIN_Delet_DFX_0101 publicaddCredential= ' + addcredresult101);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let addcredresult101 = data;
console.info('Security_IAM_PIN_Delet_DFX_0101 auth='+ JSON.stringify(addcredresult101));
let token = addcredresult101.authextr.token
publicFC.publicdelUser(UserIDM, token, function (data) {
let deluserresult = data.delUserresult;
console.info('Security_IAM_PIN_Delet_DFX_0101 publicdelUser= ' + deluserresult);
expect(ResultCode.SUCCESS).assertEqual(deluserresult);
publicFC.publicdelUser(UserIDM, token, function (data) {
deluserresult = data.delUserresult;
expect(ResultCode.Authfail).assertEqual(deluserresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('Security_IAM_PIN_Delet_DFX_0101 publicCloseSession data = ' + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('Security_IAM_PIN_Delet_DFX_0101 unRegisterInputer = ' + data);
done();
})
})
})
})
}, function (data) {
})
})
})
} catch (e) {
console.log("Security_IAM_PIN_Delet_DFX_0101 fail " + e);
expect(null).assertFail();
}
})
})
......@@ -126,6 +126,7 @@ function sleep(ms) {
}
describe('userauthTest', function () {
it('Security_IAM_PIN_AddCred_Func_0101', 0, async function (done) {
try {
let registerresult = publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
......@@ -140,7 +141,6 @@ describe('userauthTest', function () {
console.log("testFace Security_IAM_PIN_AddCred_Func_0101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_AddCred_Func_0102', 1, async function (done) {
......@@ -297,41 +297,66 @@ describe('userauthTest', function () {
} catch (e) {
console.log("testaddCredential101 fail " + e);
expect(null).assertFail();
}
}j
})
//
// it('Security_IAM_PIN_AddCred_Func_0105', , async function (done) {
// console.info('testFace Security_IAM_PIN_AddCred_Func_0105 start');
// try {
// publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdata);
// let challenge;
// publicFC.publicOpenSession(UserIDM, function (data) {
// challenge = data;
// console.info("testFace Security_IAM_PIN_AddCred_Func_0105 challenge" + challenge);
// let result1 = null;
// publicFC.publicaddCredential(UserIDM, CredentialInfopinmix, async function (data) {
// result1 = data.addCredresult;
// console.info("testFace Security_IAM_PIN_AddCred_Func_0105 result1" + result1);
//// await sleep(3000);
// }, function (data) {
// });
// let cancelresult = publicFC.publiccancel(UserIDM, challenge);
// console.info("testFace Security_IAM_PIN_AddCred_Func_0105 publiccancel = " + cancelresult);
// expect(ResultCode.SUCCESS).assertEqual(cancelresult);
//// expect(ResultCode.CANCELED).assertEqual(result1);
// publicFC.publicCloseSession(UserIDM, function (data) {
// console.info("testFace Security_IAM_PIN_AddCred_Func_0105 closesession = " + data);
// publicFC.publicunRegisterInputer(PinAuth, function (data) {
// console.info("testFace Security_IAM_PIN_AddCred_Func_0105 unRegist = " + data);
// done();
// })
// })
// })
// } catch (e) {
// console.log("Security_IAM_PIN_AddCred_Func_0105 fail " + e);
// expect(null).assertFail();
// }
// })
it('Security_IAM_PIN_AddCred_Func_0105', 0, async function (done) {
console.info('testFace Security_IAM_PIN_AddCred_Func_0105 start');
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdata);
let challenge;
let cancelresult;
let token;
cancelresult = publicFC.publiccancel(UserIDM, challenge);
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 cancelresult" + cancelresult);
publicFC.publicOpenSession(UserIDM, function (data) {
challenge = data;
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 challenge" + challenge);
let result1 = null;
publicFC.publicaddCredential(UserIDM, CredentialInfopinmix, async function (data) {
result1 = data.addCredresult;
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 result1" + result1);
if(cancelresult == 0){
expect(ResultCode.CANCELED).assertEqual(result1);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 closesession = " + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 unRegist = " + data);
done();
})
})
}else if(cancelresult == 1){
expect(ResultCode.SUCCESS).assertEqual(result1);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
console.info('testFace PIN_AddCred_Func_0105 publicauth'+ JSON.stringify(data));
token = data.authextr.token;
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 token = " + token);
publicFC.publicdelUser(UserIDM, token, function (data) {
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 publicdelUser");
let deluserresult = data.delUserresult;
console.info("testFace PIN_AddCred_Func_0105 deluserresult="+ deluserresult);
publicFC.publicCloseSession(UserIDM, function (data) {
console.info("testFace PIN_AddCred_Func_0105 CloseSession = " + data);
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info("testFace PIN_AddCred_Func_0105 unRegister= " + data);
done();
})
})
}, function (data) {
})
}, function (data) {
})
}
}, function (data) {
});
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 publiccancel = " + cancelresult);
})
} catch (e) {
console.log("Security_IAM_PIN_AddCred_Func_0105 fail " + e);
expect(null).assertFail();
}
})
// it('Security_IAM_PIN_AddCred_Func_0106', 0, async function (done) {
// try {
......@@ -409,7 +434,7 @@ describe('userauthTest', function () {
it('Security_IAM_PIN_Auth_Func_0101', 3, async function (done) {
console.info('testFace Security_IAM_Error_Func_0101 start');
console.info('testFace Security_IAM_PIN_Auth_Func_0101 start');
try {
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata)
publicFC.publicOpenSession(UserIDM, function (data) {
......@@ -578,7 +603,7 @@ describe('userauthTest', function () {
UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
publicFC.publicdelUser(UserIDM, token, function (data) {
let deluserresult = publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0104 delresult = " + delresult);
publicFC.publicCloseSession(UserIDM, function (data) {
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import userAuthNorth from '@ohos.userauthnorth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
let UserAuthKit = userAuthNorth.constructor()
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 = {
User1: 100,
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,
NOT_ENROLLED: 10,
Authfail: 14
}
let GetPropertyType = {
AUTH_SUB_TYPE: 1,
REMAIN_TIMES: 2,
FREEZING_TIME: 3
}
let Inputerdata = new Uint8Array([1, 2, 3, 4, 5, 6]);
let Inputerdatan = new Uint8Array([1, 1, 1, 1, 1, 1]);
let Inputerdatanum = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let Inputerdatanumn = new Uint8Array([1, 1, 1, 1, 1, 1, 1, 1]);
let Inputerdatamix = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]);
let Inputerdatamixn = new Uint8Array([1, 1, 1, 1, 1, 1, 1, 1, 1]);
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: null
}
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));
}
describe('userauthTest', function () {
it('GetVersionTest_Kit_0101', 0, async function (done) {
try {
let getversionresult = null;
getversionresult = UserAuthKit.getVersion();
console.info('GetVersionTest_0101 getversionresult = ' + getversionresult);
expect(false).assertEqual(getversionresult == null);
done();
} catch (e) {
console.log("testFace GetVersionTest_0101 fail " + e);
expect(null).assertFail();
}
})
it('GetAvailabeStatusTest_Kit_0101', 1, async function (done) {
console.info('testFace GetAvailabeStatusTest0101 start');
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
publicFC.publicOpenSession(UserIDM,function(data){
let challenge = data
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix,
function(onresult) {
console.info('testFace GetAvailabeStatusTest0101 addCredresult=' + onresult.addCredresult);
console.log("testFace GetAvailabeStatusTest0101 authUser result = " + onresult.addCredresult);
let Available;
Available = publicFC.publicgetAvailabeStatus(UserAuthKit,AuthType.PIN,AuthTurstLevel.ATL1)
console.info('testFace GetAvailabeStatusTest0101 AvailabeStatus1 = ' + Available);
console.info('testFace GetAvailabeStatusTest0101 ResultCode.SUCCESS = ' + ResultCode.SUCCESS);
expect(ResultCode.SUCCESS).assertEqual(Available);
Available = publicFC.publicgetAvailabeStatus(UserAuthKit,AuthType.PIN,AuthTurstLevel.ATL2)
console.info('testFace GetAvailabeStatusTest0101 AvailabeStatus2 = ' + Available);
console.info('testFace GetAvailabeStatusTest0101 ResultCode.SUCCESS = ' + ResultCode.SUCCESS);
expect(ResultCode.SUCCESS).assertEqual(Available);
Available = publicFC.publicgetAvailabeStatus(UserAuthKit,AuthType.PIN,AuthTurstLevel.ATL3)
console.info('testFace GetAvailabeStatusTest0101 AvailabeStatus3 = ' + Available);
console.info('testFace GetAvailabeStatusTest0101 ResultCode.SUCCESS = ' + ResultCode.SUCCESS);
expect(ResultCode.SUCCESS).assertEqual(Available);
Available = publicFC.publicgetAvailabeStatus(UserAuthKit,AuthType.PIN,AuthTurstLevel.ATL4)
console.info('testFace GetAvailabeStatusTest0101 AvailabeStatus4 = ' + Available);
console.info('testFace GetAvailabeStatusTest0101 ResultCode.SUCCESS = ' + ResultCode.SUCCESS);
expect(ResultCode.SUCCESS).assertEqual(Available);
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function(onresult) {
console.info('testFace GetAvailabeStatusTest0101 publicauth = ' + onresult.authresult);
let token = onresult.authextr.token
publicFC.publicdelUser(UserIDM,token,function(onresult){
console.log("testFace GetAvailabeStatusTest0101 delUser="+ onresult.delUserresult)
publicFC.publicCloseSession(UserIDM,function(data){
console.log("testFace GetAvailabeStatusTest0101 CloseSession= " + data)
publicFC.publicunRegisterInputer(PinAuth,function(data){
done();
})
})
},function(onacquireinfo){
})
}, function(onAcquireInfo) {
}
);
}, function(onAcquireInfo) {
});
})
} catch (e) {
console.log("GetAvailabeStatusTest0101 fail " + e);
expect(null).assertFail();
}
})
it('AuthTest_Kit_0101', 0, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('AuthTest_0101 openSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) {
console.info('AuthTest_0101 addCredential Result1 = ' + JSON.stringify(onresult));
let info101;
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('AuthTest_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('AuthTest_0101 addCredential Result2=' + JSON.stringify(onresult));
addfaceresult = onresult;
console.info('AuthTest_0101 publicaddCredential = ' + addfaceresult.addCredresult);
expect(ResultCode.SUCCESS).assertEqual(addfaceresult.addCredresult);
publicFC.publicauth(UserAuthKit,challenge,AuthType.FACE,10000, async function (data) {
// console.info('testFace AuthTest_0101 onResult = ' + JSON.stringify(data));
let faceauth101 = data;
console.info('AuthTest_0101 publicauth = ' + faceauth101.authresult);
expect(ResultCode.SUCCESS).assertEqual(faceauth101.authresult);
let authresult;
let contextID = await publicFC.publicauth(UserAuthKit,challenge,AuthType.FACE,10000,
function (data) {
console.info('AuthTest_0101 addCredential Result2=' + JSON.stringify(data.authresult));
authresult = data.authresult;
}, function (onacquireinfo) {
})
let cancelresult = publicFC.publicgecancelAuth(UserAuthKit,contextID);
await sleep(100);
if(cancelresult == 1){
console.info('AuthTest_0101 cancel = 1 authresult = ' + authresult);
expect(ResultCode.SUCCESS).assertEqual(authresult);
}else if(cancelresult == 0){
console.info('AuthTest_0101 cancel = 0 authresult = ' + authresult);
console.info('AuthTest_0101 cancel = 0 ResultCode.FAIL = ' + ResultCode.FAIL);
expect(ResultCode.CANCELED).assertEqual(authresult);
}
console.info('testFace AuthTest_0101 onResult = ' + JSON.stringify(data));
await publicFC.publicdelUser(UserIDM,token, function (data) {
console.info('AuthTest_0101 delUser = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('AuthTest_0101 closeSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('AuthTest_0101 unRegister');
done();
})
})
}, function (onacquireinfo) {
})
}, function (onacquireinfo) {
})
}, function (onacquireinfo) {
})
}, function (data) {
})
}, function (onacquireinfo) {
})
})
} catch (e) {
console.log("AuthTest_0101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_Face_Interface_check_AuthTrustLevel_Kit_0101', 0, async function (done) {
console.info('testFace Security_IAM_Face_Interface_check_AuthTrustLevel_0101 start');
expect(10000).assertEqual(userAuthNorth.AuthTrustLevel.ATL1);
expect(20000).assertEqual(userAuthNorth.AuthTrustLevel.ATL2);
expect(30000).assertEqual(userAuthNorth.AuthTrustLevel.ATL3);
expect(40000).assertEqual(userAuthNorth.AuthTrustLevel.ATL4);
console.info('testFace Security_IAM_Face_Interface_check_AuthTrustLevel_0101 end');
done();
})
it('Security_IAM_Face_Interface_check_userauthFaceTipsCode_Kit_0101', 0, async function (done) {
console.info('testFace Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101 start');
expect(1).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_BRIGHT);
expect(2).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_DARK);
expect(3).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_CLOSE);
expect(4).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_FAR);
expect(5).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_HIGH);
expect(6).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_LOW);
expect(7).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_RIGHT);
expect(8).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_LEFT);
expect(9).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_TOO_MUCH_MOTION);
expect(10).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_POOR_GAZE);
expect(11).assertEqual(userAuthNorth.FaceTipsCode.FACE_AUTH_TIP_NOT_DETECTED);
console.info('testFace Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101 end');
done();
})
it('Security_IAM_Face_Interface_check_userauthAuthType_Kit_0101', 0, async function (done) {
console.info('testFace Security_IAM_Face_Interface_check_userauthAuthType_Kit_0101 start');
expect(1).assertEqual(userAuthNorth.AuthType.PIN);
expect(2).assertEqual(userAuthNorth.AuthType.FACE);
console.info('testFace Security_IAM_Face_Interface_check_userauthAuthType_Kit_0101 end');
done();
})
it('Security_IAM_Face_Interface_check_userauthResultCode_Kit_0101', 0, async function (done) {
console.info('testFace Security_IAM_Face_Interface_check_userauthResultCode_0101 start');
expect(0).assertEqual(userAuthNorth.ResultCode.SUCCESS);
expect(1).assertEqual(userAuthNorth.ResultCode.FAIL);
expect(2).assertEqual(userAuthNorth.ResultCode.GENERAL_ERROR);
expect(3).assertEqual(userAuthNorth.ResultCode.CANCELED);
expect(4).assertEqual(userAuthNorth.ResultCode.TIMEOUT);
expect(5).assertEqual(userAuthNorth.ResultCode.TYPE_NOT_SUPPORT);
expect(6).assertEqual(userAuthNorth.ResultCode.TRUST_LEVEL_NOT_SUPPORT);
expect(7).assertEqual(userAuthNorth.ResultCode.BUSY);
expect(8).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS);
expect(9).assertEqual(userAuthNorth.ResultCode.LOCKED);
expect(10).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED);
console.info('testFace Security_IAM_Face_Interface_check_userauthResultCode_0101 end');
done();
})
it('Security_IAM_Face_Interface_check_userauthFingerprintTips_Kit_0101', 0, async function (done) {
console.info('testFace Security_IAM_Face_Interface_check_userauthFingerprintTips_Kit_0101 start');
expect(0).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_TIP_GOOD );
expect(1).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_TIP_IMAGER_DIRTY);
expect(2).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_TIP_INSUFFICIENT);
expect(3).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_TIP_PARTIAL);
expect(4).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_TIP_TOO_FAST);
expect(5).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_TIP_TOO_SLOW);
console.info('testFace Security_IAM_Face_Interface_check_userauthFingerprintTips_Kit_0101 end');
done();
})
})
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import * as publicFC from './Publicfunction-n'
let UserIDM = userIDM.constructor()
let PinAuth = pinAuth.constructor()
let UserAuth = userAuth.constructor()
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 userID = {
User1: 100,
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,
NOT_ENROLLED : 10
}
let Inputerdata = new Uint8Array([1,2,3,4,5,6]);
let CredentialInfopinsix = {
credType: AuthType.PIN,
credSubType: AuthSubType.PIN_SIX,
token: null
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function authcycle(challenge,fcycle){
let finishicon = 0
let token;
for(let i = 0; i < 10; i++){
//未到达10个认证时,完成认证
//闭包方法
(function c(output){
publicFC.publicauth(UserAuth ,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace PIN_Auth_MTBF_0101 auth '+output + '=' + data.authresult);
token = data.authextr.token
if(i == 9){
finishicon = 1
}
},
function(data){
})
})(i)
}
publicFC.publicauth(UserAuth, challenge,AuthType.PIN,AuthTurstLevel.ATL1,
async function (data) {
console.info('testFace PIN_Auth_MTBF_0101 auth11 =' + data.authresult);
if(data.authresult == ResultCode.SUCCESS){
token = data.authextr.token
}
while(finishicon = 0){
await sleep(100);
}
fcycle(token)
},
function(data){
})
}
function authUsercycle(challenge,fcycle){
let finishicon = 0
let token;
for(let i = 0; i < 10; i++){
//未到达10个认证时,完成认证
//闭包方法
(function c(output){
publicFC.publicauthUser(UserAuth ,userID.User1,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
function (data) {
expect(true).assertEqual(data.authresult);
console.info('testFace PIN_Auth_MTBF_0101 auth '+output + '=' + data.authresult);
token = data.authextr.token
if(i == 9){
finishicon = 1
}
},
function(data){
})
})(i)
}
publicFC.publicauthUser(UserAuth, userID.User1,challenge,AuthType.PIN,AuthTurstLevel.ATL1,
async function (data) {
console.info('testFace PIN_Auth_MTBF_0101 auth11 =' + data.authresult);
if(data.authresult == ResultCode.SUCCESS){
token = data.authextr.token
}
while(finishicon = 0){
await sleep(100);
}
fcycle(token)
},
function(data){
})
}
describe('userauthTest', function () {
it('Security_IAM_PIN_Auth_MTBF_0101', 4, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 OpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 addCredential onResult = ' + JSON.stringify(data));
authcycle(challenge,function(data){
publicFC.publicdelUser(UserIDM,data, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 delUser onResult = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 publicCloseSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 publicunRegisterInputer');
done();
})
})
}, function (data) {
})
})
}, function (data) {
})
})
} catch (e) {
console.log("testauthpin101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_Auth_MTBF_0102', 4, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata);
let challenge ;
let finishicon = 0
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 OpenSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 addCredential onResult = ' + JSON.stringify(data));
authUsercycle(challenge,function(data){
publicFC.publicdelUser(UserIDM,data, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 delUser onResult = ' + JSON.stringify(data));
publicFC.publicCloseSession(UserIDM, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 publicCloseSession');
publicFC.publicunRegisterInputer(PinAuth, function (data) {
console.info('testFace PIN_Auth_MTBF_0102 publicunRegisterInputer');
done();
})
})
}, function (data) {
})
})
}, function (data) {
})
})
} catch (e) {
console.log("testauthpin101 fail " + e);
expect(null).assertFail();
}
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册