未验证 提交 174fd5f1 编写于 作者: O openharmony_ci 提交者: Gitee

!3679 release3.1 useriam js用例删除只保存kit相关用例

Merge pull request !3679 from 胡吉翔/release3.10622
......@@ -13,16 +13,6 @@
* limitations under the License.
*/
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')
/*
* Copyright (C) 2022 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 userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import userAuth from '@ohos.userauth'
let UserIDM = null
let PinAuth = null
let UserAuth = null
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
//同步
function publicRegisterInputer(PinAuth,AuthSubType,Inputerdata){
console.info('testFace publicRegisterInputer in');
try {
console.info('testFace publicRegisterInputer in try');
console.info('testFace publicRegisterInputer PinAuth = ' + PinAuth);
let registerresult = PinAuth.registerInputer({
onGetData: (AuthSubType, IInputData) => {
console.info('testFace faceDemo registerInputer AuthSubType');
console.info('testFace faceDemo registerInputer AuthSubType111');
IInputData.onSetData(AuthSubType, Inputerdata)
}
})
console.log("testFace publicRegisterInputer result is: " + registerresult);
return registerresult;
}
catch (e) {
console.log("testFace publicRegisterInputer fail " + e);
expect(null).assertFail();
}
}
function publicunRegisterInputer(PinAuth,callback){
console.info('testFace publicunRegisterInputer in');
try {
console.info('testFace publicunRegisterInputer in try');
console.info('testFace publicunRegisterInputer PinAuth = ' + PinAuth);
let unRegist = 1;
PinAuth.unregisterInputer();
callback(unRegist)
}
catch (e) {
console.log("testFace unpublicRegisterInputer fail " + e);
expect(null).assertFail();
}
}
function publicOpenSession(UserIDM,callback){
console.info('testFace publicOpenSession in');
try {
console.info('testFace publicOpenSession in try');
console.info('testFace faceDemo UserIDM = ' + UserIDM);
let challenge = null
UserIDM.openSession( function(data){
try{
console.log("testFace before get challenge");
console.log("testFace + " + data);
challenge = data;
console.log("testFace end ");
console.log("testFace after get challenge");
callback(challenge);
expect(true).assertEqual(challenge != null);
}
catch(e) {
console.info('testFace faceDemo openSession error = ' + JSON.stringify(e));
}
});
}
catch (e) {
console.log("testFace publicOpenSession fail " + e);
console.log(e);
expect(null).assertFail();
}
}
function publicCloseSession(UserIDM,callback){
console.info('testFace publicCloseSession in');
try {
console.info('testFace publicCloseSession in try');
console.info('testFace publicCloseSession UserIDM = ' + UserIDM);
let closesession = 0;
UserIDM.closeSession();
callback(closesession);
}
catch (e) {
console.log("testFace publicCloseSession fail " + e);
expect(null).assertFail();
}}
async function publicaddCredential(UserIDM,CredentialInfo,callback1,callback2){
console.info('testFace publicaddCredential in');
try {
console.info('testFace publicaddCredential in try');
let onresult = {
addCredresult: null,
credentialId: null,
}
let onAcquireInfo = {
addCredmodule : null,
addCredacquire : null,
addCredextr : null
}
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)
onresult.addCredresult= result;
if(extraInfo != undefined) {
onresult.credentialId = extraInfo.credentialId
} else {
onresult.credentialId = null;
}
callback1(onresult)
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('testFace publicaddCredential onAcquireInfo in');
onAcquireInfo.addCredmodule = modulea;
onAcquireInfo.addCredacquire = acquire;
onAcquireInfo.addCredextr = extr;
console.info('testFace publicaddCredential onAcquireInfo =' + JSON.stringify(onAcquireInfo));
console.info(modulea);
callback2(onAcquireInfo)
},
})
}
catch (e) {
console.log("testFace publicaddCredential fail " + e);
expect(null).assertFail();
}
}
function publicupdateCred(UserIDM,CredentialInfo,callback1,callback2){
console.info('testFace publicupdateCred in');
try {
console.info('testFace publicupdateCred in try');
console.info('testFace publicupdateCred UserIDM = ' + UserIDM);
let onresult = {
updateCredresult: null,
CredentialId: null,
}
let onacquireinfo = {
updateCredmodule : null,
updateCredacquire : null,
updateCredextr : null
}
UserIDM.updateCredential(CredentialInfo, {
onResult: function(result,extraInfo){
console.log("testFace faceDemo updateCredential result = " + result)
onresult.updateCredresult = result
console.log("testFace faceDemo updateCredential credentialId = " + extraInfo.credentialId)
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.info('testFace publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult));
callback1(onresult)
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('testFace publicupdateCred updateCredential onAcquireInfo in ');
onacquireinfo.updateCredmodule = modulea
onacquireinfo.updateCredacquire = acquire
onacquireinfo.updateCredextr = extr
console.info('testFace public updateCredential onacquireinfo = ' + JSON.stringify(onacquireinfo));
console.log("testFace faceDemo updateCredential module = " + modulea)
callback2(onacquireinfo)
}
})
}
catch (e) {
console.log("testFace publicupdateCred fail " + e);
expect(null).assertFail();
}
}
//同步
function publiccancel(UserIDM,challenge){
console.info('testFace publiccancel in');
try {
console.info('testFace publiccancel in try');
console.info('testFace publiccancel UserIDM = ' + UserIDM);
let cancelresult = UserIDM.cancel(challenge)
console.log("testFace cancelresult is " + cancelresult);
return cancelresult
}
catch (e) {
console.log("testFace publiccancel fail " + e);
expect(null).assertFail();
}
}
function publicdelUser(UserIDM,token,callback1,callback2){
console.info('testFace publicdelUser in');
try {
console.info('testFace publicdelUser in try');
console.info('testFace publicdelUser UserIDM = ' + UserIDM);
let onresult = {
delUserresult: null,
CredentialId: null,
}
let onacquireinfo = {
delUsermodule : null,
delUseracquire : null,
delUserextr : null
}
UserIDM.delUser(token, {
onResult: function(result,extraInfo){
console.log("testFace faceDemo delUser result = " + result)
onresult.delUserresult = result
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.info('testFace publicdelUser delUser = ' + JSON.stringify(onresult));
callback1(onresult)
},
onAcquireInfo:function (modulea,acquire,extr){
console.log("testFace faceDemo delUser onAcquireInfo in ");
onacquireinfo.delUsermodule = modulea
onacquireinfo.delUseracquire = acquire
onacquireinfo.delUserextr = extr
console.log("testFace faceDemo delUser onAcquireInfo = " + JSON.stringify(onacquireinfo));
callback2(onacquireinfo)
}
})
}
catch (e) {
console.log("testFace publicdelUser fail " + e);
expect(null).assertFail();
}
}
function publicdelCred(UserIDM,credentialId,token,callback1,callback2){
console.info('testFace publicdelCred in');
try {
console.info('testFace publicdelCred in try');
console.info('testFace publicdelCred UserIDM = ' + UserIDM);
let onresult = {
delCredresult: null,
CredentialId: null,
}
let onacquireinfo = {
delCredmodule : null,
delCredacquire : null,
delCredextr : null
}
UserIDM.delCred(credentialId, token,{
onResult: function(result,extraInfo){
console.log("testFace faceDemo delCred result = " + result)
onresult.delCredresult = result
console.log("testFace faceDemo delCred extraInfo = " + extraInfo)
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.log("testFace faceDemo delCred onresult = " + JSON.stringify(onresult));
callback1(onresult)
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('testFace publicdelCred delCred onAcquireInfo in');
onacquireinfo.delCredmodule = modulea
onacquireinfo.delCredacquire = acquire
onacquireinfo.delCredextr = extr
console.log("testFace faceDemo delCred module = " + modulea);
console.log("testFace faceDemo delCred onacquireinfo = " + JSON.stringify(onacquireinfo));
callback2(onacquireinfo)
}
})
}
catch (e) {
console.log("testFace publicdelCred fail " + e);
expect(null).assertFail();
}
}
function publicgetAuthInfo(UserIDM,authType,callback){
console.info('testFace publicgetAuthInfo in');
try {
console.info('testFace publicgetAuthInfo in try');
console.info('testFace publicgetAuthInfo UserIDM = ' + UserIDM);
UserIDM.getAuthInfo(authType, function (AsyncCallback) {
console.log("testFace faceDemo getAuthInfo AsyncCallback = " + JSON.stringify(AsyncCallback))
callback(AsyncCallback)
})
}
catch (e) {
console.log("testFace publicgetAuthInfo fail " + e);
expect(null).assertFail();
}
}
function publicgetallAuthInfo(UserIDM,callback){
console.info('testFace publicgetallAuthInfo in');
try {
console.info('testFace publicgetallAuthInfo in try');
console.info('testFace publicgetallAuthInfo UserIDM = ' + UserIDM);
UserIDM.getAuthInfo(function (AsyncCallback) {
console.log("testFace faceDemo getallAuthInfo AsyncCallback = " + JSON.stringify(AsyncCallback))
callback(AsyncCallback)
})
}
catch (e) {
console.log("testFace publicgetallAuthInfo fail " + e);
expect(null).assertFail();
}
}
//同步
function publicgetAvailabeStatus(UserAuth,authType,authTrustLevel){
console.info('testFace publicgetAvailableStatus in');
try {
console.info('testFace publicgetAvailableStatus in try');
console.info('testFace publicgetAvailableStatus UserAuth = ' + UserAuth);
let AvailabeStatus = null
AvailabeStatus = UserAuth.getAvailableStatus(authType, authTrustLevel);
console.info('testFace publicgetAvailableStatus result = ' + JSON.stringify(AvailabeStatus));
return AvailabeStatus
}
catch (e) {
console.log("testFace publicgetAvailableStatus fail " + e);
expect(null).assertFail();
}
}
function publicgetProperty(UserAuth,GetPropertyRequest,callback){
console.info('testFace publicgetProperty in');
try {
console.info('testFace publicgetProperty in try');
console.info('testFace publicgetProperty UserAuth = ' + UserAuth);
UserAuth.getProperty(GetPropertyRequest,function (AsyncCallback) {
console.log("testFace faceDemo getallAuthInfo AsyncCallback = " + JSON.stringify(AsyncCallback))
callback(AsyncCallback)
})
}
catch (e) {
console.log("testFace publicgetProperty fail " + e);
expect(null).assertFail();
}
}
function publicsetProperty(UserAuth,SetPropertyRequest,callback){
console.info('testFace publicsetProperty in');
try {
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)
})
}
catch (e) {
console.log("testFace publicsetProperty fail " + e);
expect(null).assertFail();
}
}
function publicauth(UserAuth,challenge,authType,authTrustLevel,callback1,callback2){
console.info('testFace publicauth in');
try {
console.info('testFace publicauth in try');
console.info('testFace publicauth UserAuth = ' + UserAuth);
let onresult = {
authresult: null,
authextr: null,
}
let onacquireinfo = {
authmodule : null,
authacquire : null,
authextr : null
}
let contextID1 = null
contextID1 = UserAuth.auth(challenge, authType,authTrustLevel,{
onResult: function(result,extraInfo){
console.log("testFace faceDemo auth result = " + result)
onresult.authresult = result
console.log("testFace faceDemo auth extraInfo = " + JSON.stringify(extraInfo));
onresult.authextr = extraInfo;
console.info('testFace publicauth auth onResult = ' + JSON.stringify(onresult));
callback1(onresult)
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('faceTest publicauth auth onAcquireInfo in');
onacquireinfo.authmodule = modulea;
onacquireinfo.authacquire = acquire;
onacquireinfo.authextr = extr;
console.log("testFace faceDemo auth module = " + JSON.stringify(modulea));
console.info('testFace publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo));
callback2(onacquireinfo)
}
});
console.info('testFace publicauth auth contextID1 = ' + contextID1);
return contextID1
}
catch (e) {
console.log("testFace publicauth fail " + e);
expect(null).assertFail();
}
}
function publicauthUser(UserAuth,userID,challenge,authType,authTrustLevel,callback1,callback2){
console.info('testFace publicauthUser in');
try {
console.info('testFace publicauthUser in try');
console.info('testFace publicauthUser UserAuth = ' + UserAuth);
let onresult = {
authresult: null,
authextr: null,
}
let onacquireinfo = {
authmodule : null,
authacquire : null,
authextr : null
}
let contextID1 = null
contextID1 = UserAuth.authUser(userID, challenge, authType, authTrustLevel, {
onResult: function(result,extraInfo){
console.log("testFace faceDemo authUser result = " + result)
onresult.authresult = result
console.log("testFace faceDemo authUser authextr = " + JSON.stringify(extraInfo))
onresult.authextr = extraInfo;
console.info('testFace publicauthUser authUser onResult = ' + JSON.stringify(onresult));
callback1(onresult)
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('testFace publicauthUser authUser onAcquireInfo in');
onacquireinfo.authmodule = modulea
onacquireinfo.authacquire = acquire
onacquireinfo.authextr = extr
console.log("testFace faceDemo authUser module = " + JSON.stringify(modulea));
console.info('testFace publicauthUser authUser onacquireinfo = ' + JSON.stringify(onacquireinfo));
callback2(onacquireinfo)
}
})
console.info('testFace publicauthUser authUser contextID1 = ' + contextID1);
return contextID1
}
catch (e) {
console.log("testFace publicauthUser fail " + e);
expect(null).assertFail();
}
}
//同步
function publicgecancelAuth(UserAuth,contextID){
console.info('testFace publicgecancelAuth in');
try {
console.info('testFace publicgecancelAuth in try');
console.info('testFace publicgecancelAuth UserAuth = ' + UserAuth);
let cancelAuthresult = null
cancelAuthresult = UserAuth.cancelAuth(contextID)
console.info('testFace publicgecancelAuth cancelAuth cancelAuthresult = ' + cancelAuthresult);
return cancelAuthresult
}
catch (e) {
console.log("testFace publiccancelAuth fail " + e);
expect(null).assertFail();
}
}
export{publicRegisterInputer, publicgetallAuthInfo,
publicunRegisterInputer, publicOpenSession, publicCloseSession,
publicaddCredential, publicupdateCred, publiccancel, publicdelUser,
publicdelCred, publicgetAuthInfo, publicgetAvailabeStatus, publicgetProperty,
publicsetProperty, publicauth, publicauthUser, publicgecancelAuth}
/*
* Copyright (C) 2022 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 = new userIDM.UserIdentityManager();
let PinAuth = new pinAuth.PINAuth();
let UserAuth = new userAuth.UserAuth();
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_two1', 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) 2022 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_two5', 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_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);
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) 2022 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 = new userIDM.UserIdentityManager();
let PinAuth = new pinAuth.PINAuth();
let UserAuth = new userAuth.UserAuth();
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_two6', 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();
}
})
})
......@@ -13,123 +13,21 @@
* 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.userIAM.userAuth'
import * as publicFC from './Publicfunction-n'
let UserIDM = new userIDM.UserIdentityManager();
let PinAuth = new pinAuth.PINAuth();
let UserAuth = new userAuth.UserAuth();
let UserAuthKit = new userAuthNorth.UserAuth()
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_two8', function () {
describe('userauthTest', function () {
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0101', 0, async function (done) {
try {
let getversionresult = null;
......@@ -143,130 +41,79 @@ describe('userauthTest_two8', function () {
}
})
it('Security_IAM_PIN_Kit_Func_0102', 1, async function (done) {
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0102
* @tc.name : Kit interface get AvailabeStatus
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0102', 0, 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) {
});
})
let AvailabeStatus = null
AvailabeStatus = UserAuthKit.getAvailableStatus(userAuthNorth.UserAuthType.FACE,
userAuthNorth.AuthTrustLevel.ATL1);
console.info('testFace publicgetAvailableStatus result = ' + JSON.stringify(AvailabeStatus));
expect(6).assertEqual(AvailabeStatus);
done();
} catch (e) {
console.log("GetAvailabeStatusTest0101 fail " + e);
expect(null).assertFail();
}
})
it('Security_IAM_PIN_Kit_Func_0103', 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(2000);
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();
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) {
let contextID1 = null
let challenge = [253, 19, 58, 160, 67, 200, 247, 37]
let onresult = {
authresult: null,
authextr: null,
}
let onacquireinfo = {
authmodule : null,
authacquire : null,
authextr : null
}
contextID1 = UserAuthKit.auth(challenge, userAuthNorth.UserAuthType.FACE,userAuthNorth.AuthTrustLevel.ATL1, {
onResult: function(result,extraInfo){
console.log("testFace faceDemo auth result = " + result);
onresult.authresult = result;
console.log("testFace faceDemo auth extraInfo = " + JSON.stringify(extraInfo));
onresult.authextr = extraInfo;
console.info('testFace publicauth auth onResult = ' + JSON.stringify(onresult));
expect(1).assertEqual(result);
console.info('testFace publicauth auth contextID1 = ' + contextID1);
let cancelResult = UserAuthKit.cancelAuth(contextID1);
console.info('testFace publicauth cancelResult = ' + cancelResult);
done();
},
onAcquireInfo: function (modulea,acquire,extr){
console.info('faceTest publicauth auth onAcquireInfo in');
onacquireinfo.authmodule = modulea;
onacquireinfo.authacquire = acquire;
onacquireinfo.authextr = extr;
console.log("testFace faceDemo auth module = " + JSON.stringify(modulea));
console.info('testFace publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo));
}
});
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0104
* @tc.name : Kit interface enum AuthTrustLevel
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
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);
......@@ -277,6 +124,13 @@ it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) {
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0105
* @tc.name : Kit interface enum FaceTips
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
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.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT);
......@@ -294,6 +148,13 @@ it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) {
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0106
* @tc.name : Kit interface enum UserAuthType
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0106', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0106 start');
expect(2).assertEqual(userAuthNorth.UserAuthType.FACE);
......@@ -302,6 +163,13 @@ it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) {
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0107
* @tc.name : Kit interface enum ResultCode
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
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);
......@@ -319,6 +187,13 @@ it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) {
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0108
* @tc.name : Kit interface enum FingerprintTips
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
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_AUTH_TIP_GOOD);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册