From 816821fa36083f499539afdcfd1c6cc122fd1145 Mon Sep 17 00:00:00 2001 From: hu-jixiang1 Date: Wed, 22 Jun 2022 10:07:16 +0800 Subject: [PATCH] hujixiang1@huawei.com Signed-off-by: hu-jixiang1 Change-Id: I2c1d6535d8c392e10e7a14c2b1bdb1e002472ab3 --- .../entry/src/main/js/test/List.test.js | 9 - .../src/main/js/test/Publicfunction-n.js | 491 ---------- ...rity_IAM_Coauth_DFX_CallbackJsunit.test.js | 229 ----- ...ity_IAM_Coauth_Func_CallbackJsunit.test.js | 533 ---------- ...curity_IAM_Face_DFX_CallbackJsunit.test.js | 480 --------- ...urity_IAM_Face_Func_CallbackJsunit.test.js | 305 ------ ...y_IAM_Interface_DFX_CallbackJsunit.test.js | 773 --------------- ..._IAM_Interface_Func_CallbackJsunit.test.js | 251 ----- ...ecurity_IAM_PIN_DFX_CallbackJsunit.test.js | 365 ------- ...curity_IAM_PIN_Func_CallbackJsunit.test.js | 925 ------------------ ...ecurity_IAM_PIN_Kit_CallbackJsunit.test.js | 205 +--- 11 files changed, 51 insertions(+), 4515 deletions(-) delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Publicfunction-n.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_DFX_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_Func_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_DFX_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_Func_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_DFX_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_Func_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_DFX_CallbackJsunit.test.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Func_CallbackJsunit.test.js diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js index 30d21e31f..19131de46 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js @@ -13,14 +13,5 @@ * limitations under the License. */ -require('./Security_IAM_PIN_DFX_CallbackJsunit.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') - diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Publicfunction-n.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Publicfunction-n.js deleted file mode 100644 index c6f558fc7..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Publicfunction-n.js +++ /dev/null @@ -1,491 +0,0 @@ -/* - * 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 GetAuthSubType = 0; - let registerresult = PinAuth.registerInputer({ - onGetData: (GetAuthSubType, IInputData) => { - if (GetAuthSubType == 0) { - console.info('testFace faceDemo registerInputer AuthSubType'); - console.info('testFace faceDemo registerInputer AuthSubType111'); - IInputData.onSetData(AuthSubType, Inputerdata) - } else { - IInputData.onSetData(GetAuthSubType, 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} diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_DFX_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_DFX_CallbackJsunit.test.js deleted file mode 100644 index dcf369eb3..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_DFX_CallbackJsunit.test.js +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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_two_1', function () { - - /** - * @tc.name the token from old session is not available in the new session - * @tc.number Security_IAM_Coauth_DFX_0105 - * @tc.size MEDIUM - * @tc.type FUNC - * @tc.level Level3 - */ - 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(); - } - }) - - /** - * @tc.name old challenge is not available in the new session - * @tc.number Security_IAM_Coauth_DFX_0106 - * @tc.size MEDIUM - * @tc.type FUNC - * @tc.level Level2 - */ - 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(); - } - }) -}) \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_Func_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_Func_CallbackJsunit.test.js deleted file mode 100644 index 8925795cf..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Coauth_Func_CallbackJsunit.test.js +++ /dev/null @@ -1,533 +0,0 @@ -/* - * 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 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, - AUTH_FAIL : 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_two_2', function () { - - /* - * @tc.number : Security_IAM_Coauth_Func_0102 - * @tc.name : Can't use old challenge add face in new session - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Coauth_Func_0102', 3, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info('Coauth_Func_0102 publicOpenSession challenge1 = ' + challenge1); - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge2 = data; - console.info('Security_IAM_Coauth_Func_0102 publicOpenSession challenge2 = ' + challenge2); - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - let addcredresult101 = data.addCredresult; - console.info('Security_IAM_Coauth_Func_0102 addcredresult101 = ' + addcredresult101); - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let info101 = data.authresult; - let token2 = data.authextr.token - console.info('Security_IAM_Coauth_Func_0102 publicauth info101 = ' + info101); - publicFC.publicauth(UserAuth, challenge2, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let info1011 = data.authresult; - console.info('Security_IAM_Coauth_Func_0102 publicauth info1011 = ' + info1011); - let token1 = data.authextr.token - publicFC.publicdelUser(UserIDM, token2, function (data) { - let deluserresult = data.delUserresult; - expect(ResultCode.AUTH_FAIL).assertEqual(deluserresult); - publicFC.publicdelUser(UserIDM, token1, function (data) { - console.info('Security_IAM_Coauth_Func_0102 deluserresult ='+ deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('Security_IAM_Coauth_Func_0102 CloseSession = ' + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('Security_IAM_Coauth_Func_0102 unRegister = ' + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }) - } catch (e) { - console.log("testtwochallenge101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Coauth_Func_0105 - * @tc.name : Inquire all credential information with one credential - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_Coauth_Func_0105', 3, async function (done) { - 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 Security_IAM_Coauth_Func_0105 addCredresult = ' + onresult.addCredresult); - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function(onresult) { - console.info('testFace Coauth_Func_0105 addCred onResult = ' + onresult.authresult); - let token = onresult.authextr.token - CredentialInfoface2d.token = token - publicFC.publicaddCredential(UserIDM,CredentialInfopinsix,function(onresult) { - console.info('testFace Coauth_Func_0105 addface onResult = ' + onresult.addCredresult); - publicFC.publicgetAuthInfo(UserIDM,AuthType.PIN,function(data){ - let CredInfo = data; - console.info('testFace Coauth_Func_0105 getAuthInfo = ' + CredInfo[0].authSubType); - expect(AuthSubType.PIN_SIX).assertEqual(CredInfo[0].authSubType); - publicFC.publicdelUser(UserIDM,token,function(onresult){ - console.log("testFace Coauth_Func_0105 delUser = " + onresult.delUserresult) - publicFC.publicCloseSession(UserIDM,function(data){ - console.log("testFace Coauth_Func_0105 CloseSession callback = " + data); - publicFC.publicunRegisterInputer(PinAuth,function(data){ - done(); - }); - }) - },function(onacquireinfo){ - }) - }) - }, function(onAcquireInfo) { - }) - }, function(onAcquireInfo) { - }); - }, function(onAcquireInfo) { - }); - }) - } catch (e) { - console.log("Security_IAM_Coauth_Func_0105 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Coauth_Func_0109 - * @tc.name : Get face availabe status - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Coauth_Func_0109', 3, async function (done) { - 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 Coauth_Func_0109 addCredresult = ' + onresult.addCredresult); - console.log("testFace faceDemo Coauth_Func_0109 authUser = " + onresult.addCredresult); - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, - function(onresult) { - console.info('testFace Coauth_Func_0109 addCred = ' + JSON.stringify(onresult)); - let token = onresult.authextr.token - CredentialInfoface2d.token = token - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d,function(onresult) { - console.info('testFace Coauth_Func_0109 ddCredentialface=' + onresult.authresult); - console.log("testFace Coauth_Func_0109 addface result =" + onresult.addCredresult) - let AvailabeStatus = publicFC.publicgetAvailabeStatus( - UserAuth,AuthType.FACE,AuthTurstLevel.ATL1) - expect(ResultCode.TRUST_LEVEL_NOT_SUPPORT).assertEqual(AvailabeStatus); - AvailabeStatus = publicFC.publicgetAvailabeStatus( - UserAuth,AuthType.FACE,AuthTurstLevel.ATL2) - expect(ResultCode.TRUST_LEVEL_NOT_SUPPORT).assertEqual(AvailabeStatus); - AvailabeStatus = publicFC.publicgetAvailabeStatus( - UserAuth,AuthType.FACE,AuthTurstLevel.ATL3) - expect(ResultCode.TRUST_LEVEL_NOT_SUPPORT).assertEqual(AvailabeStatus); - AvailabeStatus = publicFC.publicgetAvailabeStatus( - UserAuth,AuthType.FACE,AuthTurstLevel.ATL4) - expect(ResultCode.TRUST_LEVEL_NOT_SUPPORT).assertEqual(AvailabeStatus); - publicFC.publicdelUser(UserIDM,token,function(onresult){ - console.log("testFace Coauth_Func_0109 delUser = " + onresult.delUserresult) - publicFC.publicCloseSession(UserIDM,function(data){ - console.log("testFace Coauth_Func_0109 CloseSession callback = " + data) - publicFC.publicunRegisterInputer(PinAuth, function(data){ - done(); - }) - }) - },function(onacquireinfo){ - }) - }, function(onAcquireInfo) { - }) - }, function(onAcquireInfo) { - } - ); - }, function(onAcquireInfo) { - }); - }) - } catch (e) { - console.log("Security_IAM_Coauth_Func_0108 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Coauth_Func_0108 - * @tc.name : Get pin availabe status - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Coauth_Func_0108', 2, async function (done) { - 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 Coauth_Func_0108 addCredresult = ' + onresult.addCredresult); - console.log("testFace Coauth_Func_0108 authUser result = " + onresult.addCredresult); - let AvailabeStatus - AvailabeStatus = publicFC.publicgetAvailabeStatus(UserAuth,AuthType.PIN,AuthTurstLevel.ATL1) - console.info('testFace Security_IAM_Coauth_Func_0108 AvailabeStatus1 = ' + AvailabeStatus); - expect(ResultCode.SUCCESS).assertEqual(AvailabeStatus); - AvailabeStatus = publicFC.publicgetAvailabeStatus(UserAuth,AuthType.PIN,AuthTurstLevel.ATL2) - console.info('testFace Security_IAM_Coauth_Func_0108 AvailabeStatus2 = ' + AvailabeStatus); - expect(ResultCode.SUCCESS).assertEqual(AvailabeStatus); - AvailabeStatus = publicFC.publicgetAvailabeStatus(UserAuth,AuthType.PIN,AuthTurstLevel.ATL3) - console.info('testFace Security_IAM_Coauth_Func_0108 AvailabeStatus3 = ' + AvailabeStatus); - expect(ResultCode.SUCCESS).assertEqual(AvailabeStatus); - AvailabeStatus = publicFC.publicgetAvailabeStatus(UserAuth,AuthType.PIN,AuthTurstLevel.ATL4) - console.info('testFace Security_IAM_Coauth_Func_0108 AvailabeStatus4 = ' + AvailabeStatus); - expect(ResultCode.SUCCESS).assertEqual(AvailabeStatus); - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, - function(onresult) { - console.info('testFace Coauth_Func_0108 addCred onResult = ' + onresult.authresult); - let token = onresult.authextr.token - publicFC.publicdelUser(UserIDM,token,function(onresult){ - console.log("testFace Coauth_Func_0108 delUser result= " + onresult.delUserresult) - publicFC.publicCloseSession(UserIDM,function(data){ - console.log("testFace Coauth_Func_0108 CloseSession callback = " + data) - publicFC.publicunRegisterInputer(PinAuth,function(data){ - done(); - }) - }) - },function(onacquireinfo){ - }) - }, function(onAcquireInfo) { - } - ); - }, function(onAcquireInfo) { - }); - }) - } catch (e) { - console.log("Security_IAM_Coauth_Func_0109 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Coauth_Func_0112 - * @tc.name : Anti violence cracking with four times - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Coauth_Func_0112', 3, async function (done) { - console.info('testFace Security_IAM_Coauth_Func_0112 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_Coauth_Func_0112 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult101 = data.addcredresult; - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth101 = data - console.info("Security_IAM_Coauth_Func_0112 auth1 = " + auth101.authresult); - let token = auth101.authextr.token - console.info("Security_IAM_Coauth_Func_0112 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_Coauth_Func_0112 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdatan), 500) - console.info("Security_IAM_Coauth_Func_0112 challenge2 = " + challenge1); - await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - console.info("Security_IAM_Coauth_Func_0112 authresult1 = " + data.authresult); - let authresult1 = data.authresult - 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.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.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.FAIL).assertEqual(authresult4); - publicFC.publicgetProperty(UserAuth,GetPropertyRequestpin, function(data){ - expect(1).assertEqual(data.remainTimes); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_Coauth_Func_0112 unRegist = " + data); - setTimeout(publicFC.publicRegisterInputer( - PinAuth, AuthSubType.PIN_SIX, Inputerdata), 500) - console.info("Coauth_Func_0112 challenge2 = " + challenge1); - await publicFC.publicauth( - UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult5 = data.authresult - expect(ResultCode.SUCCESS).assertEqual(authresult5); - publicFC.publicdelUser(UserIDM, token, function (data) { - let delresult = data.delUserresult - console.info("Coauth_Func_0112 delresult = " + delresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Coauth_Func_0112 closesession=" + data); - publicFC.publicunRegisterInputer(PinAuth, - function (data) { - console.info("Coauth_Func_0112 unRegist=" + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_Coauth_Func_0112 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Coauth_Func_0113 - * @tc.name : Anti violence cracking with five times - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 0 - */ - it('Security_IAM_Coauth_Func_0113', 3, async function (done) { - console.info('testFace Security_IAM_Coauth_Func_0113 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_Coauth_Func_0113 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult101 = data.addcredresult; - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth101 = data - console.info("Security_IAM_Coauth_Func_0113 auth1 = " + auth101.authresult); - let token = auth101.authextr.token - console.info("Security_IAM_Coauth_Func_0113 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_Coauth_Func_0113 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdatan), 500) - console.info("Security_IAM_Coauth_Func_0113 challenge2 = " + challenge1); - await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult1 = data.authresult - expect(ResultCode.FAIL).assertEqual(authresult1); - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult2 = data.authresult - expect(ResultCode.FAIL).assertEqual(authresult2); - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult3 = data.authresult - expect(ResultCode.FAIL).assertEqual(authresult3); - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult4 = data.authresult - expect(ResultCode.FAIL).assertEqual(authresult4); - publicFC.publicauth( - UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let authresult5 = data.authresult - expect(ResultCode.FAIL).assertEqual(authresult5); - publicFC.publicgetProperty(UserAuth,GetPropertyRequestpin, - function(data){ - expect(0).assertEqual(data.remainTimes); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Coauth_Func_0113 unRegist = " + data); - setTimeout(publicFC.publicRegisterInputer( - PinAuth, AuthSubType.PIN_SIX, Inputerdata), 500) - console.info("Coauth_Func_0113 challenge2 = " + challenge1); - await publicFC.publicauth( - UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - async function (data) { - let authresult6 = data.authresult - expect(ResultCode.LOCKED).assertEqual(authresult6); - publicFC.publicCloseSession(UserIDM, - function (data) { - console.info("closesession = " + data); - publicFC.publicunRegisterInputer( - PinAuth, function (data) { - console.info("unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_Coauth_Func_0113 fail " + e); - expect(null).assertFail(); - } - }) -}) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_DFX_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_DFX_CallbackJsunit.test.js deleted file mode 100644 index 009bd5143..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_DFX_CallbackJsunit.test.js +++ /dev/null @@ -1,480 +0,0 @@ -/* - * 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_two_3', function () { - - /* - * @tc.number : Security_IAM_Face_AddCred_DFX_0103 - * @tc.name : Can't add face with no pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Face_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_Face_AddCred_DFX_0103 challenge = " + challenge) - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - console.info('testFace aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbb'); - console.info('testFace data = ' + data); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let info101 = data; - console.info("Security_IAM_Face_AddCred_DFX_0103 info101 = " + info101); - let token = info101.authextr.token; - console.info("Security_IAM_Face_AddCred_DFX_0103 token = " + token) - CredentialInfoface2d.token = token; - publicFC.publicdelUser(UserIDM, token, function (data) { - let deluserresult = data.delUserresult; - console.info("Security_IAM_Face_AddCred_DFX_0103 deluserresult = " + deluserresult) - publicFC.publicaddCredential(UserIDM, CredentialInfoface2d, function (data) { - let addfaceresult = data.addCredresult - console.info("Security_IAM_Face_AddCred_DFX_0103 addfaceresult = " + addfaceresult); - console.info("Face_AddCred_DFX_0103 addfaceresult = " + typeof(addfaceresult)); - console.info("Face_AddCred_DFX_0103 ResultCode.Authfail = " + ResultCode.Authfail); - console.info("Face_AddCred_DFX_0103 = " + typeof(ResultCode.Authfail)); - expect(ResultCode.FAIL).assertEqual(addfaceresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_Face_AddCred_DFX_0103 closesession = " + data) - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_Face_AddCred_DFX_0103 unRegist = " + data) - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_Face_AddCred_DFX_0103 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_Delet_DFX_0104 - * @tc.name : Delete face with no pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Face_Delet_DFX_0104', 3, async function (done) { - console.info('testFace Security_IAM_Face_Delet_DFX_0104 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data; - console.info("Security_IAM_Face_Delet_DFX_0104 challenge = " + challenge) - publicFC.publicdelCred(UserIDM, "credentialId", "token", function (data) { - console.info("Security_IAM_Face_Delet_DFX_0104 info101 = " + JSON.stringify(data)) - console.info("Security_IAM_Face_Delet_DFX_0104 delCredresult = " + data.delCredresult) - console.info("Security_IAM_Face_Delet_DFX_0104 ResultCode.FAIL = " + ResultCode.GENERAL_ERROR) - expect(ResultCode.GENERAL_ERROR).assertEqual(data.delCredresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_Face_Delet_DFX_0104 closesession = " + data) - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_Face_Delet_DFX_0104 unRegist = " + data) - done(); - }) - }) - }, function (data) { - }) - - }) - - } catch (e) { - console.log("Security_IAM_Face_Delet_DFX_0104 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_Delet_DFX_0105 - * @tc.name : Delete face with no face - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Delet_DFX_0105', 1, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data - console.info("testFace Security_IAM_Face_Delet_DFX_0105 challenge = " + challenge) - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - publicFC.publicdelCred(UserIDM, "credentialId", "token", function (data) { - let info102 = data - console.info("testFace Security_IAM_Face_Delet_DFX_0105 info102 = " + JSON.stringify(data)) - console.info("testFace Security_IAM_Face_Delet_DFX_0105 delCredresult ="+ data.delCredresult); - console.info("testFace Face_Delet_DFX_0105 ResultCode.FAIL = " + ResultCode.GENERAL_ERROR); - expect(ResultCode.GENERAL_ERROR).assertEqual(info102.delCredresult); - publicFC.publicauth(UserAuth, challenge, AuthType.FACE, AuthTurstLevel.ATL1, function (data){ - let info101 = data - console.info("testFace Security_IAM_Face_Delet_DFX_0105 info101 = " + JSON.stringify(data)) - let token = info101.authextr.token - publicFC.publicdelUser(UserIDM, token, function (data) { - let deluserresult = data.delUserresult - console.info("testFace Face_Delet_DFX_0105 deluserresult = " + deluserresult) - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace Security_IAM_Face_Delet_DFX_0105 closesession = " + data) - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace Security_IAM_Face_Delet_DFX_0105 unRegist = " + data) - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - - }, function (data) { - }) - - }, function (data) { - }) - - }) - - } catch (e) { - console.log("Security_IAM_Face_Delet_DFX_0105 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_Auth_DFX_0101 - * @tc.name : Auth face with no pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Face_Auth_DFX_0101', 3, async function (done) { - console.info('testFace Security_IAM_Face_Auth_DFX_0101 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data; - console.info("Security_IAM_Face_Auth_DFX_0101 challenge = " + challenge) - publicFC.publicauth(UserAuth, "challenge", AuthType.FACE, AuthTurstLevel.ATL1, function (data) { - console.info("Security_IAM_Face_Auth_DFX_0101 info101 = " + JSON.stringify(data)) - console.info("Security_IAM_Face_Auth_DFX_0101 delCredresult = " + data.authresult) - console.info("Security_IAM_Face_Auth_DFX_0101 ResultCode.FAIL = " + ResultCode.FAIL) - expect(ResultCode.FAIL).assertEqual(data.authresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_Face_Auth_DFX_0101 closesession = " + data) - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_Face_Auth_DFX_0101 unRegist = " + data) - done(); - }) - }) - }, function (data) { - }) - - }) - - } catch (e) { - console.log("Security_IAM_Face_Auth_DFX_0101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_Auth_DFX_0102 - * @tc.name : Auth face with no face - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Face_Auth_DFX_0102', 2, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data - console.info("Security_IAM_Face_Auth_DFX_0102 challenge = " + JSON.stringify(data)) - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let info101 = data - console.info("Security_IAM_Face_Auth_DFX_0102 info101 = " + JSON.stringify(data)) - let token = info101.authextr.token - CredentialInfoface2d.token = token - console.info("Security_IAM_Face_Auth_DFX_0102 token = " + token) - publicFC.publicauth(UserAuth, challenge, AuthType.FACE, AuthTurstLevel.ATL1, function (data) { - let info102 = data - console.info("Security_IAM_Face_Auth_DFX_0102 info102 = " + JSON.stringify(data)) - console.info("Security_IAM_Face_Auth_DFX_0102 info102.authresult = " + data.authresult) - expect(ResultCode.FAIL).assertEqual(info102.authresult); - publicFC.publicdelUser(UserIDM, token, function (data) { - let deluserresult = data.delUserresult - console.info("Security_IAM_Face_Auth_DFX_0102 deluserresult = " + deluserresult) - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_Face_Auth_DFX_0102 closesession = " + data) - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_Face_Auth_DFX_0102 unRegist = " + data) - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_Face_Auth_DFX_0102 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_AddCred_DFX_0101 - * @tc.name : Can't add face by old token - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 4 - */ - it('Security_IAM_Face_AddCred_DFX_0101', 0, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge2; - challenge2 = data; - let challenge1; - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('Security_IAM_Face_AddCred_DFX_0101 openSession challenge = ' + JSON.stringify(data)); - challenge1 = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (onresult) { - console.info('Face_AddCred_DFX_0101 addCredential Result1 = ' + JSON.stringify(onresult)); - let info101; - let info102; - publicFC.publicauth(UserAuth, challenge2, AuthType.PIN, AuthTurstLevel.ATL1, function (data){ - console.info('Security_IAM_Face_AddCred_DFX_0101 auth= ' + JSON.stringify(data)); - info102 = data; - let token1 = info102.authextr.token; - CredentialInfoface2d.token = token1; - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - console.info('Security_IAM_Face_AddCred_DFX_0101 auth = ' + JSON.stringify(data)); - info101 = data; - let token2 = info101.authextr.token; - let addfaceresult; - publicFC.publicaddCredential(UserIDM, CredentialInfoface2d, function (onresult) { - console.info('Face_AddCred_DFX_0101 addCredential=' + JSON.stringify(onresult)); - console.info('Face_AddCred_DFX_0101 addCredential=' + onresult.addCredresult); - console.info('Face_AddCred_DFX_0101 ResultCode.FAIL=' + ResultCode.FAIL); - addfaceresult = onresult; - expect(ResultCode.FAIL).assertEqual(addfaceresult.addCredresult); - publicFC.publicdelUser(UserIDM, token2, function (data) { - console.info('Face_AddCred_DFX_0101 delUser= ' + JSON.stringify(data)); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('Security_IAM_Face_AddCred_DFX_0101 closeSession'); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('Security_IAM_Face_AddCred_DFX_0101 unRegister'); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }) - } catch (e) { - console.log("Security_IAM_Face_AddCred_DFX_0101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_AddCred_DFX_0101 - * @tc.name : Can't delete face by wrong token - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_Face_Delet_DFX_0101', 2, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata) - let challenge ; - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('Security_IAM_Face_Delet_DFX_0101 openSession challenge = ' + JSON.stringify(data)); - challenge = data; - publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) { - console.info('Face_Delet_DFX_0101 addCredential Result1 = ' + JSON.stringify(onresult)); - let info101; - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) { - console.info('Security_IAM_Face_Delet_DFX_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('Security_IAM_Face_Delet_DFX_0101 addCredential='+ JSON.stringify(onresult)); - addfaceresult = onresult; - let credentialId = addfaceresult.credentialId; - let delcredresult ; - let wrongtoken = token + 'wrong'; - publicFC.publicdelCred(UserIDM,credentialId,wrongtoken, function (data) { - console.info('testFace Face_Delet_DFX_0101 del=' + JSON.stringify(data)); - console.info('testFace Face_Delet_DFX_0101 ResultCode.FAIL=' + ResultCode.GENERAL_ERROR); - delcredresult = data; - expect(ResultCode.GENERAL_ERROR).assertEqual(delcredresult.delCredresult); - publicFC.publicdelUser(UserIDM,token, function (data) { - console.info('Face_Delet_DFX_0101 delUser= ' + JSON.stringify(data)); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('Security_IAM_Face_Delet_DFX_0101 closeSession'); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('Security_IAM_Face_Delet_DFX_0101 unRegister'); - done(); - }) - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }, function (onacquireinfo) { - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }) - } catch (e) { - console.log("Security_IAM_Face_AddCred_Func_0101 fail " + e); - expect(null).assertFail(); - } - }) -}) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_Func_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_Func_CallbackJsunit.test.js deleted file mode 100644 index e1ead9631..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Face_Func_CallbackJsunit.test.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * 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' - -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 : 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 GetPropertyTypearray=new Array(); -GetPropertyTypearray[0]=GetPropertyType.AUTH_SUB_TYPE; -GetPropertyTypearray[1]=GetPropertyType.FREEZING_TIME; -GetPropertyTypearray[2]=GetPropertyType.REMAIN_TIMES; - -let GetPropertyRequestpin = { - authType:AuthType.PIN, - keys:GetPropertyTypearray - } - -let GetPropertyRequestface = { - authType:AuthType.FACE, - keys:GetPropertyTypearray - } - -let CredentialInfopinsix = { - credType: AuthType.PIN, - credSubType: AuthSubType.PIN_SIX, - token:new Uint8Array([1,2,3,4,5,6]) -} - -let CredentialInfopinnum = { - credType: AuthType.PIN, - credSubType: AuthSubType.PIN_NUMBER, - token: null -} - -let CredentialInfopinmix = { - credType: AuthType.PIN, - credSubType: AuthSubType.PIN_MIXED, - token: null -} - -let CredentialInfoface2d = { - credType: AuthType.FACE, - credSubType: AuthSubType.FACE_2D, - token: null -} - -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} - -describe('userauthTest_two_4', function () { - - /* - * @tc.number : Security_IAM_Face_AddCred_DFX_0101 - * @tc.name : Test add face, auth face, authuser face, delete face - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_AddCred_Func_0101', 1, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata) - let challenge ; - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0101 openSession challenge = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) { - console.info('Face_AddCred_Func_0101 addCredential Result1 = ' + JSON.stringify(onresult)); - let info101; - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0101 auth onResult = ' + JSON.stringify(data)); - info101 = data; - let token = info101.authextr.token; - CredentialInfoface2d.token = token; - let addfaceresult; - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) { - console.info('Face_AddCred_Func_0101 addCredential Result2=' + JSON.stringify(onresult)); - addfaceresult = onresult; - expect(ResultCode.FAIL).assertEqual(addfaceresult.addCredresult); - publicFC.publicauth(UserAuth,challenge,AuthType.FACE,AuthTurstLevel.ATL1, function (data) { - console.info('testFace Face_AddCred_Func_0101 onResult = ' + JSON.stringify(data)); - let faceauth101 = data; - expect(ResultCode.FAIL).assertEqual(faceauth101.authresult); - publicFC.publicauthUser( - UserAuth,userID.User1,challenge,AuthType.FACE,AuthTurstLevel.ATL1,function (data) { - console.info('testFace Face_AddCred_Func_0101 onResult= ' + JSON.stringify(data)); - faceauth101 = data; - expect(ResultCode.FAIL).assertEqual(faceauth101.authresult); - publicFC.publicdelUser(UserIDM,token, function (data) { - console.info('Face_AddCred_Func_0101 delUser= ' + JSON.stringify(data)); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0101 closeSession'); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0101 unRegister'); - done(); - }) - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }, function (onacquireinfo) { - }) - }, function (onacquireinfo) { - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }) - } catch (e) { - console.log("Security_IAM_Face_AddCred_Func_0101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_AddCred_Func_0103 - * @tc.name : Cancel add face - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_AddCred_Func_0103', 1, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata) - let challenge ; - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0103 openSession challenge = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) { - console.info('Face_AddCred_Func_0103 addCredential Result1 = ' + JSON.stringify(onresult)); - let info101; - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, async function (data) { - console.info('Security_IAM_Face_AddCred_Func_0103 auth onResult = ' + JSON.stringify(data)); - info101 = data; - let token = info101.authextr.token; - CredentialInfoface2d.token = token; - let addfaceresult; - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (onresult) { - console.info('Face_AddCred_Func_0103 addCredential Result2=' + JSON.stringify(onresult)); - addfaceresult = onresult; - }, function (onacquireinfo) { - }) - let cancelresult = publicFC.publiccancel(UserIDM,challenge); - await sleep(2500); - if(cancelresult == 1){ - console.info('Face_AddCred_Func_0103 cancel1 authresult = ' + addfaceresult.addCredresult); - expect(ResultCode.FAIL).assertEqual(addfaceresult.addCredresult); - }else if(cancelresult == 0){ - console.info('Face_AddCred_Func_0103 cancel0 authresult = ' + addfaceresult.addCredresult); - expect(ResultCode.CANCELED).assertEqual(addfaceresult.addCredresult); - } - await publicFC.publicdelUser(UserIDM,token, function (data) { - console.info('Face_AddCred_Func_0103 delUser= ' + JSON.stringify(data)); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0103 closeSession'); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('Security_IAM_Face_AddCred_Func_0103 unRegister'); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }) - } catch (e) { - console.log("Security_IAM_Face_AddCred_Func_0101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_Face_AddCred_Func_0102 - * @tc.name : Can't add face by wrong token - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_Face_AddCred_Func_0102', 3, async function (done) { - try { - publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata); - let challenge ; - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace Security_IAM_Face_AddCred_Func_0102 publicOpenSession challenge = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (data) { - console.info('testFace Face_AddCred_Func_0102 addCredential= ' + JSON.stringify(data)); - let info101 ; - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) { - console.info('testFace Face_AddCred_Func_0102 publicauth = ' + JSON.stringify(data)); - info101 = data; - let token = info101.authextr.token; - CredentialInfoface2d.token = token; - let addfaceresult ; - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d, function (data) { - console.info('testFace Face_AddCred_Func_0102 addCredential=' + JSON.stringify(data)); - addfaceresult = data; - let credentialId = addfaceresult.credentialId; - let token1 = token + "Wrong Word"; - let delcredresult ; - publicFC.publicdelCred(UserIDM,credentialId,token1, function (data) { - console.info('testFace Face_AddCred_Func_0102 publicdelCred=' + JSON.stringify(data)); - delcredresult = data; - expect(ResultCode.GENERAL_ERROR).assertEqual(delcredresult.delCredresult); - publicFC.publicdelUser(UserIDM,token, function (data) { - console.info('testFace Face_AddCred_Func_0102 delUser= ' + JSON.stringify(data)); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('testFace Face_AddCred_Func_0102 publicCloseSession '); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('testFace Face_AddCred_Func_0102 publicunRegister '); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("testdelface102 fail " + e); - expect(null).assertFail(); - } - }) -}) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_DFX_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_DFX_CallbackJsunit.test.js deleted file mode 100644 index 75fb1ece6..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_DFX_CallbackJsunit.test.js +++ /dev/null @@ -1,773 +0,0 @@ -/* - * 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: 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)); -} - -function inputererror(inputer,done){ - try { - let registerresult = publicFC.publicRegisterInputer(PinAuth, inputer, inputer) - expect(true).assertEqual(registerresult); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace inputererror publicunRegisterInputer unRegist = " + data) - }) - done(); - } catch (e) { - console.log("testFace inputererror fail " + e); - expect(null).assertFail(); - } -} - -function addCredentialerr(inputer,done){ - console.info('testFace addCredentialerr start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace addCredentialerr publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, inputer, function (data) { - console.info('testFace addCredentialerr callback data = ' + JSON.stringify(data)); - let addcredresult101 = data.addCredresult; - console.info("testFace addCredentialerr addcredresult101 = " + addcredresult101); - expect(ResultCode.FAIL).assertEqual(addcredresult101); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace addCredentialerr publicCloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace addCredentialerr unRegister = " + data); - done(); - }) - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("addCredentialerr fail " + e); - expect(null).assertFail(); - } -} - -function autherror(inputer,done){ - console.info('testFace autherror start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace autherror publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - console.info('testFace autherror callback data = ' + JSON.stringify(data)); - let token; - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - console.info('testFace autherror publicauth'); - token = data.authextr.token; - expect(ResultCode.SUCCESS).assertEqual(data.authresult); - console.info("testFace autherror token = " + token); - publicFC.publicauth(UserAuth, challenge, inputer, inputer, function (data) { - expect(ResultCode.TRUST_LEVEL_NOT_SUPPORT).assertEqual(data.authresult); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace autherror publicdelUser"); - let deluserresult = data.delUserresult; - console.info("testFace autherror deluserresult = " + deluserresult); - expect(ResultCode.SUCCESS).assertEqual(deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace autherror publicCloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace autherror unRegister = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("autherror fail " + e); - expect(null).assertFail(); - } -} - -function authusererror(inputer,done){ - console.info('testFace authusererror start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace authusererror publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - console.info('testFace authusererror callback data = ' + JSON.stringify(data)); - let addcredresult101 = data.addCredresult; - console.info("testFace authusererror addcredresult101 = " + addcredresult101); - let token; - console.info('testFace authusererror addSuccess'); - publicFC.publicauthUser(UserAuth, userID.User1, challenge, inputer, inputer, function (data) { - let auth101 = data.authresult - console.info("testFace authusererror auth101 = " + auth101); - if(auth101==ResultCode.FAIL || auth101==ResultCode.TRUST_LEVEL_NOT_SUPPORT){ - console.log("authusererror pass result code = " + auth101); - }else{ - console.log("authusererror fail result code = " + auth101); - expect(null).assertFail(); - } - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1,function (data) { - console.info('testFace authusererror publicauth'); - token = data.authextr.token; - console.info("testFace authusererror token = " + token); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace authusererror publicdelUser"); - let deluserresult = data.delUserresult; - console.info("testFace authusererror deluserresult = " + deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace authusererror publicCloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace authusererror unRegister= " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("authusererror fail " + e); - expect(null).assertFail(); - } -} - -function delusererror(inputer,done){ - console.info('testFace delusererror start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace delusererror publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - console.info('testFace delusererror callback data = ' + JSON.stringify(data)); - let addcredresult101 = data.addCredresult; - console.info("testFace delusererror addcredresult101 = " + addcredresult101); - let token; - console.info('testFace delusererror addSuccess'); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - console.info('testFace delusererror publicauth'); - token = data.authextr.token; - console.info("testFace delusererror token = " + token); - publicFC.publicdelUser(UserIDM, inputer, function (data) { - console.info("testFace delusererror delUserresult1 = " + data.delUserresult); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace delusererror publicdelUser"); - let deluserresult = data.delUserresult; - console.info("testFace delusererror deluserresult2 = " + deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace delusererror publicCloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace delusererror unRegister = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("delusererror fail " + e); - expect(null).assertFail(); - } -} - -function updateerror(inputer,done){ - console.info('testFace updateerror start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data; - console.info("updateerror challenge = " + challenge); - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - let addcredresult101 = data.addcredresult; - console.info("updateerror addcredresult101 = " + addcredresult101); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth101 = data - console.info("updateerror auth101 = " + auth101); - let token = auth101.authextr.token; - CredentialInfopinnum.token = null; - CredentialInfopinnum.credType = null; - CredentialInfopinnum.credSubType = null; - console.info("updateerror token = " + token); - publicFC.publicupdateCred(UserIDM, CredentialInfopinnum, function (data) { - let updateresult = data.updateCredresult; - console.info("updateerror updateresult = " + updateresult); - expect(ResultCode.FAIL).assertEqual(updateresult); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - auth101 = data - console.info("updateerror auth101 = " + auth101); - let token1 = auth101.authextr.token - console.info("updateerror token1 = " + token1); - publicFC.publicdelUser(UserIDM, token1, function (data) { - console.info("updateerror delUser result = " + data.delUserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("updateerror closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("updateerror unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("updateerror fail " + e); - expect(null).assertFail(); - } -} - -function delcrederror(inputer,done){ - try { - publicFC.publicRegisterInputer(PinAuth,AuthSubType.PIN_SIX,Inputerdata) - let challenge ; - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('delcrederror openSession challenge = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM,CredentialInfopinsix, function (onresult) { - console.info('delcrederror addCredential Result1 = ' + JSON.stringify(onresult)); - let info101; - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function (data) { - console.info('delcrederror 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('delcrederror addCredential Result2=' + JSON.stringify(onresult)); - addfaceresult = onresult; - let delcredresult ; - publicFC.publicdelCred(UserIDM, inputer, inputer, function (data) { - console.info('testFace delcrederror del=' + JSON.stringify(data)); - delcredresult = data; - expect(ResultCode.GENERAL_ERROR).assertEqual(delcredresult.delCredresult); - publicFC.publicdelUser(UserIDM,token, function (data) { - console.info('delcrederror delUser= ' + JSON.stringify(data)); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info('delcrederror closeSession'); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info('delcrederror unRegister'); - done(); - }) - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }, function (onacquireinfo) { - }) - }, function (data) { - }) - }, function (onacquireinfo) { - }) - }) - } catch (e) { - console.log("delcrederror fail " + e); - expect(null).assertFail(); - } -} - -function getauthinfoerror(inputer,done){ - 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 getauthinfoerror addCredresult = ' + onresult.addCredresult); - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, - function(onresult) { - console.info( - 'testFace getauthinfoerror addCred onResult = ' + JSON.stringify(onresult)); - let token = onresult.authextr.token - CredentialInfoface2d.token = token - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d,function(onresult) { - console.log("testFace getauthinfoerror addface= " + onresult.addCredresult) - publicFC.publicgetAuthInfo(UserIDM,inputer,function(AsyncCallback) { - console.log("testFace getauthinfoerror getAuthInfo= " + - JSON.stringify(AsyncCallback)) - publicFC.publicdelUser(UserIDM,token,function(onresult){ - let delresult = onresult.delUserresult; - console.log("testFace getauthinfoerror delUser= " + delresult) - publicFC.publicCloseSession(UserIDM,function(data){ - console.log("getauthinfoerror CloseSession= " + data) - publicFC.publicunRegisterInputer(PinAuth,function(data){ - done(); - }) - }) - },function(onacquireinfo){ - }) - }) - }, function(onAcquireInfo) { - }) - }, function(onAcquireInfo) { - }); - }, function(onAcquireInfo) { - }); - }) - } catch (e) { - console.log("getauthinfoerror fail " + e); - expect(null).assertFail(); - } -} - -function getAvailabeStatuserror(inputer,done){ - 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 getAvailabeStatuserror addCredresult = ' + onresult.addCredresult); - console.log("testFace faceDemo getAvailabeStatuserror authUser = " + onresult.addCredresult); - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, - function(onresult) { - console.info('testFace getAvailabeStatuserror addCred = ' + JSON.stringify(onresult)); - let token = onresult.authextr.token - CredentialInfoface2d.token = token - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d,function(onresult) { - console.info('testFace getAvailabeStatuserror addface=' + onresult.authresult); - console.log("testFace getAvailabeStatuserror addface result="+ onresult.addCredresult) - let AvailabeStatus = publicFC.publicgetAvailabeStatus( - UserAuth,inputer,inputer) - console.info('testFace getAvailabeStatuserror addCAvailabeStatusred = ' - + JSON.stringify(AvailabeStatus)); - expect(ResultCode.INVALID_PARAMETERS).assertEqual(AvailabeStatus); - publicFC.publicdelUser(UserIDM,token,function(onresult){ - console.log("testFace getAvailabeStatuserror delUser="+ onresult.delUserresult) - publicFC.publicCloseSession(UserIDM,function(data){ - console.log("testFace getAvailabeStatuserror CloseSession = " + data) - publicFC.publicunRegisterInputer(PinAuth, function(data){ - done(); - }) - }) - },function(onacquireinfo){ - }) - }, function(onAcquireInfo) { - }) - }, function(onAcquireInfo) { - } - ); - }, function(onAcquireInfo) { - }); - }) - } catch (e) { - console.log("getAvailabeStatuserror fail " + e); - expect(null).assertFail(); - } -} - -function getPropertyerror(inputer,done){ - 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 Coauth_Func_0110 addCredresult = ' + onresult.addCredresult); - publicFC.publicauth(UserAuth,challenge,AuthType.PIN,AuthTurstLevel.ATL1, function(onresult) { - console.info('testFace Coauth_Func_0110 addCred onResult = ' + JSON.stringify(onresult)); - let token = onresult.authextr.token - CredentialInfoface2d.token = token - publicFC.publicaddCredential(UserIDM,CredentialInfoface2d,function(onresult) { - console.log("testFace Coauth_Func_0110 ddCredentialface = " + onresult.addCredresult) - GetPropertyRequestface.authType = inputer; - GetPropertyRequestface.keys = inputer; - publicFC.publicgetProperty(UserAuth,GetPropertyRequestface,function(onresult) { - console.log("testFace Coauth_Func_0110 GetPropertyface = " + JSON.stringify(onresult)) - expect(ResultCode.FAIL).assertEqual(onresult.result); - publicFC.publicdelUser(UserIDM,token,function(onresult){ - console.log("testFace Coauth_Func_0110 delUser= " + onresult.delUserresult) - publicFC.publicCloseSession(UserIDM,function(data){ - console.log("testFace Coauth_Func_0110 CloseSession callback = " + data) - publicFC.publicunRegisterInputer(PinAuth, function(data){ - done(); - }) - }) - },function(onacquireinfo){ - }) - }) - }, function(onAcquireInfo) { - }) - }, function(onAcquireInfo) { - }) - }, function(onAcquireInfo) { - }) - }) - } catch (e) { - console.log("Security_IAM_Coauth_Func_0110 fail " + e); - expect(null).assertFail(); - } -} - -describe('userauthTest_two_5', function () { - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0101 - * @tc.name : Test regrsterInputer interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0101', 2, async function (done) { - inputererror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0102 - * @tc.name : Test regrsterInputer interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0102', 2, async function (done) { - inputererror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0103 - * @tc.name : Test addCredential interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0103', 2, async function (done) { - addCredentialerr(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0104 - * @tc.name : Test addCredential interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0104', 2, async function (done) { - addCredentialerr('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0105 - * @tc.name : Test auth interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0105', 2, async function (done) { - autherror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0106 - * @tc.name : Test auth interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0106', 2, async function (done) { - autherror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0107 - * @tc.name : Test authuser interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0107', 2, async function (done) { - authusererror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0108 - * @tc.name : Test authuser interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0108', 2, async function (done) { - authusererror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0109 - * @tc.name : Test getProperty interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0109', 2, async function (done) { - getPropertyerror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0110 - * @tc.name : Test getProperty interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0110', 2, async function (done) { - getPropertyerror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0111 - * @tc.name : Test updateCredential interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0111', 2, async function (done) { - updateerror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0112 - * @tc.name : Test updateCredential interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0112', 2, async function (done) { - updateerror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0113 - * @tc.name : Test deluser interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0113', 2, async function (done) { - delusererror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0114 - * @tc.name : Test deluser interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0114', 2, async function (done) { - delusererror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0115 - * @tc.name : Test delcred interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0115', 2, async function (done) { - delcrederror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0116 - * @tc.name : Test delcred interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0116', 2, async function (done) { - delcrederror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0117 - * @tc.name : Test getauthinfo interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0117', 2, async function (done) { - getauthinfoerror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0118 - * @tc.name : Test delcred interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0118', 2, async function (done) { - getauthinfoerror('Errortest',done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0119 - * @tc.name : Test getAvailabeStatus interface DFX with null - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0119', 2, async function (done) { - getAvailabeStatuserror(null,done); - }) - - /* - * @tc.number : Security_IAM_PIN_Interface_DFX_0120 - * @tc.name : Test getAvailabeStatus interface DFX with string - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Interface_DFX_0120', 2, async function (done) { - getAvailabeStatuserror('Errortest',done); - }) -}) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_Func_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_Func_CallbackJsunit.test.js deleted file mode 100644 index dc6eab949..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_Interface_Func_CallbackJsunit.test.js +++ /dev/null @@ -1,251 +0,0 @@ -/* - * 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_two_6', function () { - - /* - * @tc.number : Security_IAM_Face_Interface_check_IDMAuthSubType_0101 - * @tc.name : InnerKit interface enum AuthSubType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_IDMAuthSubType_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_IDMAuthType_0101 - * @tc.name : InnerKit interface enum AuthType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_IDMAuthType_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_pinauthAuthSubType_0101 - * @tc.name : InnerKit interface enum AuthSubType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthAuthSubType_0101 - * @tc.name : InnerKit interface enum AuthSubType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthAuthSubType_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthAuthTrustLevel_0101 - * @tc.name : InnerKit interface enum AuthTrustLevel - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthAuthTrustLevel_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthAuthType_0101 - * @tc.name : InnerKit interface enum AuthType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthAuthType_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthGetPropertyType_0101 - * @tc.name : InnerKit interface enum GetPropertyType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthGetPropertyType_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthAuthMethod_0101 - * @tc.name : InnerKit interface enum AuthMethod - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthAuthMethod_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthSetPropertyType_0101 - * @tc.name : InnerKit interface enum SetPropertyType - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthSetPropertyType_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthModule_0101 - * @tc.name : InnerKit interface enum Module - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthModule_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthResultCode_0101 - * @tc.name : InnerKit interface enum ResultCode - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthResultCode_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101 - * @tc.name : InnerKit interface enum FaceTipsCode - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthFaceTipsCode_0101', 1, 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(); - }) - - /* - * @tc.number : Security_IAM_Face_Interface_check_userauthFingerprintTips_0101 - * @tc.name : InnerKit interface enum FingerprintTips - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_Face_Interface_check_userauthFingerprintTips_0101', 1, 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(); - }) -}) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_DFX_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_DFX_CallbackJsunit.test.js deleted file mode 100644 index f2b9f28f6..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_DFX_CallbackJsunit.test.js +++ /dev/null @@ -1,365 +0,0 @@ -/* - * 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_two_7', function () { - - /* - * @tc.number : Security_IAM_PIN_AddCred_DFX_0102 - * @tc.name : Add pin after add pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - 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(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_AddCred_DFX_0103 - * @tc.name : Add pin after add pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - 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(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Update_DFX_0101 - * @tc.name : Update pin with no pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Update_DFX_0101', 1, 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(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Update_DFX_0103 - * @tc.name : Update same pin with no error - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Update_DFX_0103', 1, 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(); - } - }) - - - /* - * @tc.number : Security_IAM_PIN_Delet_DFX_0101 - * @tc.name : Can't delete pin wirh no pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Delet_DFX_0101', 1, 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(); - } - }) -}) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Func_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Func_CallbackJsunit.test.js deleted file mode 100644 index 869cbb81c..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Func_CallbackJsunit.test.js +++ /dev/null @@ -1,925 +0,0 @@ -/* - * 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: 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_two_8', function () { - - /* - * @tc.number : Security_IAM_PIN_AddCred_DFX_0102 - * @tc.name : Can't register two inputer. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_PIN_AddCred_Func_0101', 3, async function (done) { - try { - let registerresult = publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - expect(true).assertEqual(registerresult); - registerresult = publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - expect(false).assertEqual(registerresult); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace Security_IAM_PIN_AddCred_Func_0101 publicunRegisterInputer unRegist = " + data) - }) - done(); - } catch (e) { - console.log("testFace Security_IAM_PIN_AddCred_Func_0101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_AddCred_DFX_0102 - * @tc.name : Add, auth, authuser, delete six_pin. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_AddCred_Func_0102', 2, async function (done) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0102 start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0102 publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - console.info('testFace PIN_AddCred_Func_0102 callback data = ' + JSON.stringify(data)); - let addcredresult101 = data.addCredresult; - console.info("testFace PIN_AddCred_Func_0102 addcredresult101 = " + addcredresult101); - expect(ResultCode.SUCCESS).assertEqual(addcredresult101); - let token; - console.info('testFace Security_IAM_PIN_AddCred_Func_0102 addSuccess'); - publicFC.publicauthUser(UserAuth, userID.User1, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let auth101 = data.authresult - console.info("testFace Security_IAM_PIN_AddCred_Func_0102 auth101 = " + auth101); - expect(ResultCode.SUCCESS).assertEqual(auth101); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0102 publicauth'); - token = data.authextr.token; - expect(ResultCode.SUCCESS).assertEqual(data.authresult); - console.info("testFace Security_IAM_PIN_AddCred_Func_0102 token = " + token); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace PIN_AddCred_Func_0102 publicdelUser callback success"); - let deluserresult = data.delUserresult; - console.info("testFace PIN_AddCred_Func_0102 deluserresult = " + deluserresult); - expect(ResultCode.SUCCESS).assertEqual(deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace PIN_AddCred_Func_0102 CloseSession success data =" + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace PIN_AddCred_Func_0102 unRegisterInputer = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("testaddCredential101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_AddCred_Func_0103 - * @tc.name : Add, auth, authuser, delete num_pin. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_AddCred_Func_0103', 2, async function (done) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0103 start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0103 publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - console.info('testFace PIN_AddCred_Func_0103 callback data = ' + JSON.stringify(data)); - let addcredresult101 = data.addCredresult; - console.info("testFace PIN_AddCred_Func_0103 addcredresult101 = " + addcredresult101); - expect(ResultCode.SUCCESS).assertEqual(addcredresult101); - let token; - console.info('testFace Security_IAM_PIN_AddCred_Func_0103 addSuccess'); - publicFC.publicauthUser(UserAuth, userID.User1, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let auth101 = data.authresult - console.info("testFace Security_IAM_PIN_AddCred_Func_0103 auth101 = " + auth101); - expect(ResultCode.SUCCESS).assertEqual(auth101); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0103 publicauth'); - token = data.authextr.token; - expect(ResultCode.SUCCESS).assertEqual(data.authresult); - console.info("testFace Security_IAM_PIN_AddCred_Func_0103 token = " + token); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace Security_IAM_PIN_AddCred_Func_0103 publicdelUser"); - let deluserresult = data.delUserresult; - console.info("testFace PIN_AddCred_Func_0103 deluserresult = " + deluserresult); - expect(ResultCode.SUCCESS).assertEqual(deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace PIN_AddCred_Func_0103 publicCloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace PIN_AddCred_Func_0103 unRegister success = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("testaddCredential101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_AddCred_Func_0104 - * @tc.name : Add, auth, authuser, delete mix_pin. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_AddCred_Func_0104', 1, async function (done) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0104 start'); - try { - let challenge; - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamix); - publicFC.publicOpenSession(UserIDM, function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0104 publicOpenSession data = ' + data); - challenge = data; - publicFC.publicaddCredential(UserIDM, CredentialInfopinmix, function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0104 callback = ' + JSON.stringify(data)); - let addcredresult101 = data.addCredresult; - console.info("testFace PIN_AddCred_Func_0104 addcredresult101 = " + addcredresult101); - expect(ResultCode.SUCCESS).assertEqual(addcredresult101); - let token; - console.info('testFace Security_IAM_PIN_AddCred_Func_0104 addSuccess'); - publicFC.publicauthUser(UserAuth, userID.User1, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let auth101 = data.authresult - console.info("testFace Security_IAM_PIN_AddCred_Func_0104 auth101 = " + auth101); - expect(ResultCode.SUCCESS).assertEqual(auth101); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0104 publicauth'); - token = data.authextr.token; - expect(ResultCode.SUCCESS).assertEqual(data.authresult); - console.info("testFace Security_IAM_PIN_AddCred_Func_0104 token = " + token); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace Security_IAM_PIN_AddCred_Func_0104 publicdelUser callback"); - let deluserresult = data.delUserresult; - console.info("testFace PIN_AddCred_Func_0104 publicdeluserresult = " + deluserresult); - expect(ResultCode.SUCCESS).assertEqual(deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace PIN_AddCred_Func_0104 publicCloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace PIN_AddCred_Func_0104 unRegister success = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("testaddCredential101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_AddCred_Func_0105 - * @tc.name : Cancel add pin. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_PIN_AddCred_Func_0105', 3, async function (done) { - console.info('testFace Security_IAM_PIN_AddCred_Func_0105 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdata); - let challenge; - let cancelresult; - let token; - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 cancelresult" + cancelresult); - publicFC.publicOpenSession(UserIDM, function (data) { - challenge = data; - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 challenge" + challenge); - let result1 = null; - publicFC.publicaddCredential(UserIDM, CredentialInfopinmix, async function (data) { - result1 = data.addCredresult; - cancelresult = publicFC.publiccancel(UserIDM, challenge); - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 result1" + result1); - if(cancelresult == 0){ - expect(ResultCode.CANCELED).assertEqual(result1); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 unRegist = " + data); - done(); - }) - }) - }else if(cancelresult == 1){ - expect(ResultCode.SUCCESS).assertEqual(result1); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - console.info('testFace PIN_AddCred_Func_0105 publicauth'+ JSON.stringify(data)); - token = data.authextr.token; - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 token = " + token); - publicFC.publicdelUser(UserIDM, token, function (data) { - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 publicdelUser"); - let deluserresult = data.delUserresult; - console.info("testFace PIN_AddCred_Func_0105 deluserresult="+ deluserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("testFace PIN_AddCred_Func_0105 CloseSession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("testFace PIN_AddCred_Func_0105 unRegister= " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - } - }, function (data) { - }); - console.info("testFace Security_IAM_PIN_AddCred_Func_0105 publiccancel = " + cancelresult); - }) - } catch (e) { - console.log("Security_IAM_PIN_AddCred_Func_0105 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Auth_Func_0101 - * @tc.name : Pin auth fail six_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Auth_Func_0101', 1, async function (done) { - console.info('testFace Security_IAM_PIN_Auth_Func_0101 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_PIN_Auth_Func_0101 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult101 = data.addcredresult; - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth101 = data - console.info("Security_IAM_PIN_Auth_Func_0101 auth1 = " + auth101.authresult); - let token = auth101.authextr.token - console.info("Security_IAM_PIN_Auth_Func_0101 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Auth_Func_0101 unRegist = " + data); - setTimeout(publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdatan), 500) - console.info("Security_IAM_PIN_Auth_Func_0101 challenge2 = " + challenge1); - await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult = data.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); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0101 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0101 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Auth_Func_0101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Auth_Func_0102 - * @tc.name : Pin auth fail num_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Auth_Func_0102', 1, async function (done) { - console.info('testFace Security_IAM_PIN_Auth_Func_0102 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamix) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_PIN_Auth_Func_0102 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult102 = data.addcredresult; - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth102 = data - console.info("Security_IAM_PIN_Auth_Func_0102 auth102 = " + auth102); - let token = auth102.authextr.token - console.info("Security_IAM_PIN_Auth_Func_0102 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Auth_Func_0102 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamixn), 500) - await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult = data.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); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0102 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0102 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Auth_Func_0102 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Auth_Func_0103 - * @tc.name : Pin auth fail mix_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 3 - */ - it('Security_IAM_PIN_Auth_Func_0103', 3, async function (done) { - console.info('testFace Security_IAM_PIN_Auth_Func_0103 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_PIN_Auth_Func_0103 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult103 = data.addcredresult; - publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth103 = data - console.info("Security_IAM_PIN_Auth_Func_0103 auth103 = " + auth103); - let token = auth103.authextr.token - console.info("Security_IAM_PIN_Auth_Func_0103 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Auth_Func_0103 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanumn), 500) - await publicFC.publicauth(UserAuth, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let authresult = data.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); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0103 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0103 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Auth_Func_0103 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Auth_Func_0104 - * @tc.name : Pin authuser fail six_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Auth_Func_0104', 3, async function (done) { - console.info('testFace Security_IAM_PIN_Auth_Func_0104 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_PIN_Auth_Func_0104 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult101 = data.addcredresult; - publicFC.publicauthUser(UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let auth101 = data - console.info("Security_IAM_PIN_Auth_Func_0104 auth1 = " + auth101.authresult); - let token = auth101.authextr.token - console.info("Security_IAM_PIN_Auth_Func_0104 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Auth_Func_0104 unRegist = " + data); - setTimeout(publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdatan),500) - console.info("Security_IAM_PIN_Auth_Func_0104 challenge2 = " + challenge1); - await publicFC.publicauthUser( - UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let authresult = data.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); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0104 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0104 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Auth_Func_0104 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Auth_Func_0105 - * @tc.name : Pin authuser fail num_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Auth_Func_0105', 1, async function (done) { - console.info('testFace Security_IAM_PIN_Auth_Func_0105 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamix) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_PIN_Auth_Func_0105 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult102 = data.addcredresult; - publicFC.publicauthUser(UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - let auth102 = data - console.info("Security_IAM_PIN_Auth_Func_0105 auth102 = " + auth102); - let token = auth102.authextr.token - console.info("Security_IAM_PIN_Auth_Func_0105 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Auth_Func_0105 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamixn), 500) - await publicFC.publicauthUser( - UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let authresult = data.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); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0105 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0105 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Auth_Func_0105 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Auth_Func_0106 - * @tc.name : Pin authuser fail mix_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 2 - */ - it('Security_IAM_PIN_Auth_Func_0106', 2, async function (done) { - console.info('testFace Security_IAM_PIN_Auth_Func_0106 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge1 = data; - console.info("Security_IAM_PIN_Auth_Func_0106 challenge1 = " + challenge1); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult103 = data.addcredresult; - publicFC.publicauthUser( - UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth103 = data - console.info("Security_IAM_PIN_Auth_Func_0106 auth103 = " + auth103); - let token = auth103.authextr.token - console.info("Security_IAM_PIN_Auth_Func_0106 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Auth_Func_0106 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanumn), 500) - await publicFC.publicauthUser( - UserAuth, userID.User1, challenge1, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let authresult = data.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); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0106 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Auth_Func_0106 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Auth_Func_0103 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Update_Func_0101 - * @tc.name : Update six_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Update_Func_0101', 0, async function (done) { - console.info('testFace Security_IAM_PIN_Update_Func_0101 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data; - console.info("Security_IAM_PIN_Update_Func_0101 challenge = " + challenge); - publicFC.publicaddCredential(UserIDM, CredentialInfopinsix, function (data) { - let addcredresult101 = data.addcredresult; - console.info("Security_IAM_PIN_Update_Func_0101 addcredresult101 = " + addcredresult101); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth101 = data - console.info("Security_IAM_PIN_Update_Func_0101 auth101 = " + auth101); - let token = auth101.authextr.token - console.info("Security_IAM_PIN_Update_Func_0101 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Update_Func_0101 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum), 500) - CredentialInfopinnum.token = token - console.info("PIN_Update_Func_0101 Infopinnum.token = " + CredentialInfopinnum.token); - await publicFC.publicupdateCred(UserIDM, CredentialInfopinnum, function (data) { - let updateresult = data.updateCredresult; - console.info("Security_IAM_PIN_Update_Func_0101 updateresult = " + updateresult); - expect(ResultCode.SUCCESS).assertEqual(updateresult); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - auth101 = data - console.info("Security_IAM_PIN_Update_Func_0101 auth101 = " + auth101); - let token1 = auth101.authextr.token - console.info("Security_IAM_PIN_Update_Func_0101 token1 = " + token1); - publicFC.publicdelUser(UserIDM, token1, function (data) { - console.info("PIN_Update_Func_0101 delUser result = " + data.delUserresult); - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Update_Func_0101 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Update_Func_0101 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("testupdateCredential101 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Update_Func_0102 - * @tc.name : Update num_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('Security_IAM_PIN_Update_Func_0102', 3, async function (done) { - console.info('testFace Security_IAM_PIN_Update_Func_0102 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_NUMBER, Inputerdatanum) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data; - console.info("Security_IAM_PIN_Update_Func_0102 challenge = " + challenge); - publicFC.publicaddCredential(UserIDM, CredentialInfopinnum, function (data) { - let addcredresult102 = data.addcredresult; - console.info("Security_IAM_PIN_Update_Func_0102 addcredresult102 = " + addcredresult102); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, function (data) { - let auth102 = data - console.info("Security_IAM_PIN_Update_Func_0102 auth102 = " + auth102); - let token = auth102.authextr.token - console.info("Security_IAM_PIN_Update_Func_0102 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Update_Func_0102 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamix), 500) - console.info("Security_IAM_PIN_Update_Func_0102 challenge = " + challenge); - 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); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - auth102 = data - console.info("Security_IAM_PIN_Update_Func_0102 auth102 = " + auth102); - let token2 = auth102.authextr.token - console.info("Security_IAM_PIN_Update_Func_0102 token2 = " + token2); - let deluserresult = publicFC.publicdelUser(UserIDM, token2, function (data) { - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Update_Func_0102 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Update_Func_0102 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - - }, function (data) { - }) - }) - } catch (e) { - console.log("Security_IAM_PIN_Update_Func_0102 fail " + e); - expect(null).assertFail(); - } - }) - - /* - * @tc.number : Security_IAM_PIN_Update_Func_0103 - * @tc.name : Update mix_pin - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 4 - */ - it('Security_IAM_PIN_Update_Func_0103', 4, async function (done) { - console.info('testFace Security_IAM_PIN_Update_Func_0103 start'); - try { - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_MIXED, Inputerdatamix) - publicFC.publicOpenSession(UserIDM, function (data) { - let challenge = data; - console.info("Security_IAM_PIN_Update_Func_0103 challenge = " + challenge); - 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) { - let auth103 = data - console.info("Security_IAM_PIN_Update_Func_0103 auth103 = " + auth103); - let token = auth103.authextr.token - console.info("Security_IAM_PIN_Update_Func_0103 token = " + token); - publicFC.publicunRegisterInputer(PinAuth, async function (data) { - console.info("Security_IAM_PIN_Update_Func_0103 unRegist = " + data); - setTimeout( - publicFC.publicRegisterInputer(PinAuth, AuthSubType.PIN_SIX, Inputerdata), 500) - console.info("Security_IAM_PIN_Update_Func_0103 challenge = " + challenge); - 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); - publicFC.publicauth(UserAuth, challenge, AuthType.PIN, AuthTurstLevel.ATL1, - function (data) { - auth103 = data - console.info("Security_IAM_PIN_Update_Func_0103 auth103 = " + auth103); - let token3 = auth103.authextr.token - console.info("Security_IAM_PIN_Update_Func_0103 token3 = " + token3); - publicFC.publicdelUser(UserIDM, token3, function (data) { - publicFC.publicCloseSession(UserIDM, function (data) { - console.info("Security_IAM_PIN_Update_Func_0103 closesession = " + data); - publicFC.publicunRegisterInputer(PinAuth, function (data) { - console.info("Security_IAM_PIN_Update_Func_0103 unRegist = " + data); - done(); - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }, function (data) { - }) - }) - }, function (data) { - }) - }, function (data) { - }) - }) - } catch (e) { - console.log("testupdateCredential103 fail " + e); - expect(null).assertFail(); - } - }) -}) - diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js index a0fdc5dac..5d6e92b0c 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js @@ -13,122 +13,13 @@ * 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_two_9', function () { +describe('userauthTest', function () { /* * @tc.number : Security_IAM_PIN_Kit_Func_0101 @@ -160,56 +51,62 @@ describe('userauthTest_two_9', function () { 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(); } }) + /* + * @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 -- GitLab