提交 33e48552 编写于 作者: H hu-jixiang1 提交者: 胡吉翔

fixed 3ce08cfd from https://gitee.com/hu-jixiang1/xts_acts/pulls/2346

hujixiang
Signed-off-by: Nhu-jixiang1 <hujixiang1@huawei.com>
Change-Id: I0b5de1c498a5a439d0f4b391b12a0be14c2983f6
上级 e97667db
......@@ -64,20 +64,19 @@
],
"reqPermissions": [
{
"reason": "reason_manage_face",
"usedScene": {
"ability": ["com.myface.Ability","com.myface.AbilityBackground"],
"when": "always"
},
"name": "ohos.permission.MANAGE_FACE"
"name": "ohos.permission.ACCESS_BIOMETRIC"
},
{
"reason": "reason_access_biometric",
"usedScene": {
"ability": ["com.mybiometric.Ability","com.mybiometric.AbilityBackground"],
"when": "always"
},
"name": "ohos.permission.ACCESS_BIOMETRIC"
"name": "ohos.permission.USE_USER_IDM"
},
{
"name": "ohos.permission.MANAGE_USER_IDM"
},
{
"name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL"
},
{
"name": "ohos.permission.ACCESS_PIN_AUTH"
}
]
}
......
......@@ -13,10 +13,16 @@
* limitations under the License.
*/
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('./mytest.test.js')
require('./Security_IAM_PIN_Func_CallbackJsunit.test.js')
require('./Security_IAM_PIN_Kit_CallbackJsunit.test.js')
require('./Security_IAM_Face_DFX_CallbackJsunit.test.js')
require('./Security_IAM_Face_Func_CallbackJsunit.test.js')
require('./Security_IAM_Interface_DFX_CallbackJsunit.test.js')
require('./Security_IAM_Interface_Func_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
......@@ -368,6 +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 setProperty inside = ")
console.log("testFace faceDemo setProperty AsyncCallback = " + JSON.stringify(AsyncCallback))
callback(AsyncCallback)
})
......
......@@ -14,9 +14,9 @@
*/
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
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()
......
......@@ -15,9 +15,9 @@
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import userAuth from '@ohos.userAuth'
import userIDM from '@ohos.userIDM'
import pinAuth from '@ohos.pinAuth'
import * as publicFC from './Publicfunction-n'
......@@ -292,8 +292,10 @@ describe('userauthTest', function () {
publicFC.publicgetallAuthInfo(UserIDM,function(AsyncCallback) {
console.log("testFace Coauth_Func_0106 getAuthInfo = " +
JSON.stringify(AsyncCallback))
expect(AuthSubType.PIN_SIX).assertEqual(AsyncCallback[0].authSubType);
expect(AuthSubType.FACE_2D).assertEqual(AsyncCallback[1].authSubType);
expect(AuthSubType.PIN_SIX).assertEqual(AsyncCallback[1].authSubType);
expect(AuthType.PIN).assertEqual(AsyncCallback[1].authType);
expect(AuthSubType.FACE_2D).assertEqual(AsyncCallback[0].authSubType);
expect(AuthType.FACE).assertEqual(AsyncCallback[0].authType);
publicFC.publicdelUser(UserIDM,token,function(onresult){
console.log("testFace Coauth_Func_0106delUser="+ onresult.delUserresult)
publicFC.publicCloseSession(UserIDM,function(data){
......@@ -489,22 +491,22 @@ describe('userauthTest', function () {
function (data) {
console.info("Security_IAM_Coauth_Func_0112 authresult1 = " + data.authresult);
let authresult1 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult1);
expect(ResultCode.FAIL).assertEqual(authresult1);
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
console.info("Security_IAM_Coauth_Func_0112 authresult2 = " + data.authresult);
let authresult2 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult2);
expect(ResultCode.FAIL).assertEqual(authresult2);
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
console.info("Security_IAM_Coauth_Func_0112 authresult3 =" + data.authresult);
let authresult3 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult3);
expect(ResultCode.FAIL).assertEqual(authresult3);
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
console.info("Coauth_Func_0112 authresult4 = " + data.authresult);
let authresult4 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult4);
expect(ResultCode.FAIL).assertEqual(authresult4);
publicFC.publicgetProperty(UserAuth,GetPropertyRequestpin, function(data){
expect(1).assertEqual(data.remainTimes);
publicFC.publicunRegisterInputer(PinAuth, async function (data) {
......@@ -554,6 +556,76 @@ describe('userauthTest', function () {
}
})
it('Security_IAM_Coauth_Func_0122', 0, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
let challenge ;
publicFC.publicOpenSession(UserIDM, function (data) {
console.info('Security_IAM_Coauth_Func_0122 openSession challenge = ' + data);
challenge = data;
publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) {
console.info('Security_IAM_Coauth_Func_0122 addCredential Result1 = ' + JSON.stringify(onresult));
let info101;
publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) {
console.info('Coauth_Func_0122 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('Coauth_Func_0122 addCredential Result2=' + JSON.stringify(onresult));
addfaceresult = onresult;
console.info('Coauth_Func_0122 publicaddCredential = ' + addfaceresult.addCredresult);
expect(ResultCode.SUCCESS).assertEqual(addfaceresult.addCredresult);
publicFC.publicauth(UserAuth,challenge,AuthType.FACE,10000, async function (data) {
// console.info('testFace AuthTest_0101 onResult = ' + JSON.stringify(data));
let faceauth101 = data;
console.info('Coauth_Func_0122 publicauth = ' + faceauth101.authresult);
expect(ResultCode.SUCCESS).assertEqual(faceauth101.authresult);
let authresult;
let contextID = await publicFC.publicauth(UserAuth,challenge,AuthType.FACE,10000,
function (data) {
console.info('Coauth_Func_0122 addCred='+ JSON.stringify(data.authresult));
authresult = data.authresult;
}, function (onacquireinfo) {
})
let cancelresult = publicFC.publicgecancelAuth(UserAuth,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_Coauth_Func_0113', 3, async function (done) {
console.info('testFace Security_IAM_Coauth_Func_0113 start');
try {
......@@ -576,23 +648,23 @@ describe('userauthTest', function () {
await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult1 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult1);
expect(ResultCode.FAIL).assertEqual(authresult1);
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult2 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult2);
expect(ResultCode.FAIL).assertEqual(authresult2);
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult3 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult3);
expect(ResultCode.FAIL).assertEqual(authresult3);
publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult4 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult4);
expect(ResultCode.FAIL).assertEqual(authresult4);
publicFC.publicauth(
UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let authresult5 = data.authresult
expect(ResultCode.AUTH_FAIL).assertEqual(authresult5);
expect(ResultCode.FAIL).assertEqual(authresult5);
publicFC.publicgetProperty(UserAuth,GetPropertyRequestpin,
function(data){
expect(0).assertEqual(data.remainTimes);
......
/*
* 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();
}
})
})
......@@ -14,9 +14,9 @@
*/
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
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()
......
......@@ -14,14 +14,14 @@
*/
import {describe, it, expect} from 'deccjsunit/index'
import userIAM from '@ohos.UserIAM.userAuth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import userAuth from '@ohos.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 = userIAM.constructor()
let UserAuth = userAuth.constructor()
let AuthType = {
PIN : 1,
......
/*
* 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();
}
})
})
......@@ -14,9 +14,9 @@
*/
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import userAuth from '@ohos.userAuth'
import userIDM from '@ohos.userIDM'
import pinAuth from '@ohos.pinAuth'
import * as publicFC from './Publicfunction-n.js'
......@@ -33,7 +33,7 @@ describe('userauthTest', function () {
done();
})
it('Security_IAM_Face_Interface_check_IDMAuthSubType_0101', 0, async function (done) {
it('Security_IAM_Face_Interface_check_IDMAuthType_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);
......
/*
* 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();
}
})
})
......@@ -14,9 +14,9 @@
*/
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
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()
......
......@@ -15,14 +15,14 @@
import {describe, it, expect} from 'deccjsunit/index'
import userAuth from '@ohos.userauth'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
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 UserIDM = new userIDM.UserIdentityManager();
let PinAuth = new pinAuth.PINAuth();
let UserAuth = new userAuth.UserAuth();
let AuthType = {
PIN: 1,
......@@ -307,7 +307,7 @@ describe('userauthTest', function () {
let challenge;
let cancelresult;
let token;
cancelresult = publicFC.publiccancel(UserIDM, challenge);
// cancelresult = publicFC.publiccancel(UserIDM, challenge);
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 cancelresult" + cancelresult);
publicFC.publicOpenSession(UserIDM, function (data) {
challenge = data;
......@@ -315,6 +315,7 @@ describe('userauthTest', function () {
let result1 = null;
publicFC.publicaddCredential(UserIDM, CredentialInfopinmix, async function (data) {
result1 = data.addCredresult;
cancelresult = publicFC.publiccancel(UserIDM, challenge);
console.info("testFace Security_IAM_PIN_AddCred_Func_0105 result1" + result1);
if(cancelresult == 0){
expect(ResultCode.CANCELED).assertEqual(result1);
......@@ -454,7 +455,7 @@ describe('userauthTest', function () {
await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
expect(ResultCode.FAIL).assertEqual(authresult);
publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0101 delresult = " + delresult);
......@@ -503,7 +504,7 @@ describe('userauthTest', function () {
await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
expect(ResultCode.FAIL).assertEqual(authresult);
let deluserresult = publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0102 delresult = " + delresult);
......@@ -552,7 +553,7 @@ describe('userauthTest', function () {
await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1,
function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
expect(ResultCode.FAIL).assertEqual(authresult);
let deluserresult = publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0103 delresult = " + delresult);
......@@ -602,7 +603,7 @@ describe('userauthTest', function () {
await publicFC.publicauthUser(
UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
expect(ResultCode.FAIL).assertEqual(authresult);
let deluserresult = publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0104 delresult = " + delresult);
......@@ -652,7 +653,7 @@ describe('userauthTest', function () {
await publicFC.publicauthUser(
UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
expect(ResultCode.FAIL).assertEqual(authresult);
let deluserresult = publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0105 delresult = " + delresult);
......@@ -702,7 +703,7 @@ describe('userauthTest', function () {
await publicFC.publicauthUser(
UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
let authresult = data.authresult
expect(ResultCode.Authfail).assertEqual(authresult);
expect(ResultCode.FAIL).assertEqual(authresult);
let deluserresult = publicFC.publicdelUser(UserIDM, token, function (data) {
let delresult = data.delUserresult
console.info("Security_IAM_PIN_Auth_Func_0106 delresult = " + delresult);
......@@ -1057,9 +1058,9 @@ describe('userauthTest', function () {
await setTimeout(
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamix), 500)
console.info("Security_IAM_PIN_Update_Func_0102 challenge = " + challenge);
CredentialInfopinnum.token = token
console.info("PIN_Update_Func_0102 Infopinnum.token = " + CredentialInfopinnum.token);
await publicFC.publicupdateCred(UserIDM, CredentialInfopinnum, function (data) {
CredentialInfopinmix.token = token
console.info("PIN_Update_Func_0102 Infopinnum.token = " + CredentialInfopinmix.token);
await publicFC.publicupdateCred(UserIDM, CredentialInfopinmix, function (data) {
let updateresult = data.updateCredresult;
console.info("Security_IAM_PIN_Update_Func_0102 updateresult = " + updateresult);
expect(ResultCode.SUCCESS).assertEqual(updateresult);
......@@ -1103,7 +1104,7 @@ describe('userauthTest', function () {
publicFC.publicOpenSession(UserIDM, function (data) {
let challenge = data;
console.info("Security_IAM_PIN_Update_Func_0103 challenge = " + challenge);
publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) {
publicFC.publicaddCredential(UserIDM, CredentialInfopinmix, function (data) {
let addcredresult103 = data.addcredresult;
console.info("Security_IAM_PIN_Update_Func_0103 addcredresult103 = " + addcredresult103);
publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) {
......@@ -1116,9 +1117,9 @@ describe('userauthTest', function () {
await setTimeout(
publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata), 500)
console.info("Security_IAM_PIN_Update_Func_0103 challenge = " + challenge);
CredentialInfopinnum.token = token
console.info("PIN_Update_Func_0103 Infopinnum.token = " + CredentialInfopinnum.token);
await publicFC.publicupdateCred(UserIDM, CredentialInfopinnum, function (data) {
CredentialInfopinsix.token = token
console.info("PIN_Update_Func_0103 Infopinnum.token = " + CredentialInfopinsix.token);
await publicFC.publicupdateCred(UserIDM, CredentialInfopinsix, function (data) {
let updateresult = data.updateCredresult;
console.info("Security_IAM_PIN_Update_Func_0103 updateresult = " + updateresult);
expect(ResultCode.SUCCESS).assertEqual(updateresult);
......
......@@ -15,10 +15,10 @@
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 userAuth from '@ohos.userAuth'
import userIDM from '@ohos.userIDM'
import pinAuth from '@ohos.pinAuth'
import userAuthNorth from '@ohos.userIAM.userAuth'
import * as publicFC from './Publicfunction-n'
......@@ -130,7 +130,7 @@ function sleep(ms) {
describe('userauthTest', function () {
it('GetVersionTest_Kit_0101', 0, async function (done) {
it('Security_IAM_PIN_Kit_Func_0101', 0, async function (done) {
try {
let getversionresult = null;
getversionresult = UserAuthKit.getVersion();
......@@ -143,7 +143,7 @@ describe('userauthTest', function () {
}
})
it('GetAvailabeStatusTest_Kit_0101', 1, async function (done) {
it('Security_IAM_PIN_Kit_Func_0102', 1, async function (done) {
console.info('testFace GetAvailabeStatusTest0101 start');
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
......@@ -197,7 +197,7 @@ describe('userauthTest', function () {
})
it('AuthTest_Kit_0101', 0, async function (done) {
it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) {
try {
publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata)
let challenge ;
......@@ -267,18 +267,18 @@ it('AuthTest_Kit_0101', 0, async function (done) {
}
})
it('Security_IAM_Face_Interface_check_AuthTrustLevel_Kit_0101', 0, async function (done) {
console.info('testFace Security_IAM_Face_Interface_check_AuthTrustLevel_0101 start');
it('Security_IAM_PIN_Kit_Func_0104', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0104 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');
console.info('testFace Security_IAM_PIN_Kit_Func_0104 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');
it('Security_IAM_PIN_Kit_Func_0105', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0105 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);
......@@ -290,20 +290,20 @@ it('AuthTest_Kit_0101', 0, async function (done) {
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');
console.info('testFace Security_IAM_PIN_Kit_Func_0105 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');
it('Security_IAM_PIN_Kit_Func_0106', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0106 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');
console.info('testFace Security_IAM_PIN_Kit_Func_0106 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');
it('Security_IAM_PIN_Kit_Func_0107', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0107 start');
expect(0).assertEqual(userAuthNorth.ResultCode.SUCCESS);
expect(1).assertEqual(userAuthNorth.ResultCode.FAIL);
expect(2).assertEqual(userAuthNorth.ResultCode.GENERAL_ERROR);
......@@ -315,19 +315,19 @@ it('AuthTest_Kit_0101', 0, async function (done) {
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');
console.info('testFace Security_IAM_PIN_Kit_Func_0107 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');
it('Security_IAM_PIN_Kit_Func_0108', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0108 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');
console.info('testFace Security_IAM_PIN_Kit_Func_0108 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.
先完成此消息的编辑!
想要评论请 注册