diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js index b18047a204d4b42c6118ba8f5415458b793bdd51..a1f730d383af491f70b48a467819e07e25a4e2cc 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js @@ -120,5 +120,225 @@ describe('userAuthTestExecute', function () { }); console.log("JSAPI_Function_Execute_2100 end"); }) + + /** + * @tc.name execute_authentication_callback_Type_is_null + * @tc.number JSAPI_Function_Execute_3100 + * @tc.size MEDIUM + * @tc.type FUNC + * @tc.level Level2 + */ + it('JSAPI_Function_Execute_3100', 0, function (done) { + console.log("JSAPI_Function_Execute_3100 start"); + const auth = userAuth.getAuthenticator(); + auth.execute("FACE", "S1", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE,S1:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S0", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S0:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S5", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S5:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,/:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("", "", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, /,/:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + try{ + auth.execute("FACE_ONLY", "S1","S1", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S1,S1:" + data); + // INVALID_PARAMETERS(6) + setTimeout(function() { + }, 1); + }); + }catch(e) + { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S1,S1:" + e.code); + } + + try{ + auth.execute("FACE_ONLY", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY" + data); + // INVALID_PARAMETERS(6) + setTimeout(function() { + }, 1); + }); + }catch(e) + { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY" + e.code); + } + + auth.execute("FACE_ONLY", "S1", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S1:" + data); + // NOT ENROLL + expect(data).assertEqual(8); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S2", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S2:" + data); + // NOT ENROLL + expect(data).assertEqual(8); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S3", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S3:" + data); + // NOT ENROLL + expect(data).assertEqual(8); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S4", function(data) { + console.log("JSAPI_Function_Execute_3100 auth.execute, FACE_ONLY,S4:" + data); + // NOT ENROLL + expect(data).assertEqual(8); + setTimeout(function() { + done(); + }, 1); + }); + console.log("JSAPI_Function_Execute_3100 end"); + }) + + + /** + * @tc.name execute_authentication_promise_Type_is_null + * @tc.number JSAPI_Function_Execute_3101 + * @tc.size MEDIUM + * @tc.type FUNC + * @tc.level Level2 + */ + it('JSAPI_Function_Execute_3101', 0, function (done) { + console.log("JSAPI_Function_Execute_3101 start"); + const auth = userAuth.getAuthenticator(); + auth.execute("FACE", "S1").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE,S1:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S0").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S0:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S5").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S5:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,/:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + auth.execute("", "").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,/,/:" + data); + // INVALID_PARAMETERS(6) + expect(data).assertEqual(6); + setTimeout(function() { + }, 1); + }); + + try{ + auth.execute("FACE_ONLY", "S1","S1").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S1,S1:" + data); + // INVALID_PARAMETERS(6) + setTimeout(function() { + }, 1); + }); + }catch(e) + { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S1,S1:" + e.code); + } + + try{ + auth.execute("FACE_ONLY").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY:" + data); + // INVALID_PARAMETERS(6) + setTimeout(function() { + }, 1); + }); + }catch(e) + { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY:" + e.code); + } + + auth.execute("FACE_ONLY", "S1").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S1:" + data); + // NOT ENROLL(8) + expect(data).assertEqual(8); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S2").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S2:" + data); + // NOT ENROLL(8) + expect(data).assertEqual(8); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S3").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S3:" + data); + // NOT ENROLL(8) + expect(data).assertEqual(8); + setTimeout(function() { + }, 1); + }); + + auth.execute("FACE_ONLY", "S4").catch(function(data) { + console.log("JSAPI_Function_Execute_3101 auth.execute,FACE_ONLY,S4:" + data); + // NOT ENROLL(8) + expect(data).assertEqual(8); + setTimeout(function() { + done(); + }, 1); + }); + + console.log("JSAPI_Function_Execute_3101 end"); + }) }) } diff --git a/useriam/face_auth/js_api_test/function_test/userauthnopermission/src/main/js/test/nopermisson.js b/useriam/face_auth/js_api_test/function_test/userauthnopermission/src/main/js/test/nopermisson.js index 3fe3e8eba4f2988533f50e63e4ebbd815cdfe33b..be9730ab5d5bbea8214499e77e6ac95d9161801c 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthnopermission/src/main/js/test/nopermisson.js +++ b/useriam/face_auth/js_api_test/function_test/userauthnopermission/src/main/js/test/nopermisson.js @@ -66,16 +66,13 @@ describe('userAuthTestExecute', function () { * @tc.type FUNC * @tc.level Level2 */ - it('JSAPI_Function_Nopermission_1800', 0, function (done) { + it('JSAPI_Function_Nopermission_1800', 0, function () { console.log("JSAPI_Function_Nopermission_1800 start"); const auth = userAuth.getAuthenticator(); auth.execute("FACE_ONLY", "S1", function(data) { console.log("JSAPI_Function_Nopermission_1800 auth.execute:" + data); // general error expect(data).assertEqual(100); - setTimeout(function() { - done(); - }, 1); }); console.log("JSAPI_Function_Nopermission_1800 end"); }) @@ -115,12 +112,12 @@ describe('userAuthTestExecute', function () { let AvailabeStatus = null AvailabeStatus = UserAuthKit.getAvailableStatus(2, 10000); console.info('testFace Security_IAM_Nopermission_API8_Func_0112,2,10000 result = ' + JSON.stringify(AvailabeStatus)); - // 100:general error - expect(1005).assertEqual(AvailabeStatus); + //201 + expect(201).assertEqual(AvailabeStatus); done() } catch (e) { console.log("Security_IAM_Nopermission_API8_Func_0112 fail " + e.code); - expect(100).assertEqual(e.code); + expect(201).assertEqual(e.code); done() } }) @@ -150,8 +147,8 @@ describe('userAuthTestExecute', function () { onResult: function(result,extraInfo){ console.log("Security_IAM_Nopermission_API8_Func_0103 auth result = " + result); onresult.authresult = result; - //100:general error - expect(1005).assertEqual(result); + //201 + expect(201).assertEqual(result); console.info('Security_IAM_Nopermission_API8_Func_0103 contextID1 = ' + contextID1); let cancelResult = UserAuthKit.cancelAuth(contextID1); console.info('Security_IAM_Nopermission_API8_Func_0103 cancelResult = ' + cancelResult); @@ -166,10 +163,9 @@ describe('userAuthTestExecute', function () { console.info('testFace publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo)); } }); - + done(); }) - /* * @tc.number : Security_IAM_Nopermission_API9_Func_0101 * @tc.name : Kit interface get version @@ -238,7 +234,7 @@ describe('userAuthTestExecute', function () { /* * @tc.number : Security_IAM_Nopermission_API9_Func_0103 - * @tc.name : Kit interface auth & cancel auth + * @tc.name : Kit interface auth * @tc.size : MediumTest * @tc.type : Function * @tc.level : Level 0 @@ -257,7 +253,7 @@ describe('userAuthTestExecute', function () { console.log("authV9 token " + result.token); console.log("authV9 remainAttempts " + result.remainAttempts); console.log("authV9 lockoutDuration " + result.lockoutDuration); - expect(result.result).assertEqual(userAuth.ResultCodeV9.NOT_ENROLLED); + expect(result.result).assertEqual(userAuth.UserAuthResultCode.NOT_ENROLLED); } }); @@ -275,14 +271,6 @@ describe('userAuthTestExecute', function () { expect(e.code).assertEqual(201); } - // cancel auth - try { - authInstance.cancel(); - } catch (e) { - console.log("Security_IAM_Nopermission_API9_Func_0103 cancel fail " + e.code); - expect(e.code).assertEqual(201); - } - // unregister result and tip try { authInstance.off("result"); diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_FUNC_Jsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_FUNC_Jsunit.test.js index f4c679e78fda70b8c4a012478dd1f9b0551473e1..dde5141ba8b01218855e81ff19e29e90cc25d21a 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_FUNC_Jsunit.test.js +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_FUNC_Jsunit.test.js @@ -56,7 +56,7 @@ export default function userauthTest() { userAuthNorth.getAvailableStatus(authType, level[idx1]); } catch (e) { console.log("GetAvailabeStatusTest0102 fail " + 'authType:' + authType + 'trustlevel:' + level[idx1] + 'e.code:' + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.NOT_ENROLLED); done(); } } @@ -112,7 +112,7 @@ export default function userauthTest() { userAuthNorth.getAvailableStatus(invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1); } catch (e) { console.log("GetAvailabeStatusTest0104 authType invalid:" + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.TYPE_NOT_SUPPORT); } } @@ -124,7 +124,7 @@ export default function userauthTest() { userAuthNorth.getAvailableStatus(2, invalidtrustLevel[idx]); } catch (e) { console.log("GetAvailabeStatusTest0104 trustLevel invalid :1 " + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.TRUST_LEVEL_NOT_SUPPORT); } } done() @@ -151,14 +151,14 @@ export default function userauthTest() { authInstance.on("result", { callback: (result) => { console.log("authV9 result " + result.result); - expect(result.result).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED); + expect(result.result).assertEqual(userAuthNorth.UserAuthResultCode.NOT_ENROLLED); } }); //start auth authInstance.start(); } catch (e) { console.log("getAuthInstance/start fail " + e.code + 'authType:' + authType + 'trustlevel:' + level[idx2] + 'e.code:' + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.NOT_ENROLLED); } } done() @@ -226,7 +226,7 @@ export default function userauthTest() { var authInstance = userAuthNorth.getAuthInstance(challenge, invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1); } catch (e) { console.log("getAuthInstance authType invalid : " + "invalidauthType[idx]" + invalidauthType[idx] + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.TYPE_NOT_SUPPORT); } } @@ -238,7 +238,7 @@ export default function userauthTest() { var authInstance = userAuthNorth.getAuthInstance(challenge, 2, invalidtrustLevel[idx]); } catch (e) { console.log("getAuthInstance trustLevel invalid : " + "invalidtrustLevel[idx]" + invalidtrustLevel[idx] + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.TRUST_LEVEL_NOT_SUPPORT); } } done() @@ -262,7 +262,7 @@ export default function userauthTest() { var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); authInstance.on("results", { callback: function (result) { - if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) { + if (result.result != userAuthNorth.UserAuthResultCode.SUCCESS) { console.log("Security_IAM_Func_0106 on result = " + result.result); } } @@ -277,7 +277,7 @@ export default function userauthTest() { var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); authInstance.on("tips", { callback: function (result) { - if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) { + if (result.result != userAuthNorth.UserAuthResultCode.SUCCESS) { console.log("Security_IAM_Func_0106 on result = " + result.result); } } @@ -292,7 +292,7 @@ export default function userauthTest() { var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); authInstance.on("tip", "result", { callback: function (result) { - if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) { + if (result.result != userAuthNorth.UserAuthResultCode.SUCCESS) { console.log("Security_IAM_Func_0106 on result = " + result.result); } } @@ -307,7 +307,7 @@ export default function userauthTest() { var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); authInstance.on("", { callback: function (result) { - if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) { + if (result.result != userAuthNorth.UserAuthResultCode.SUCCESS) { console.log("Security_IAM_Func_0106 on result = " + result.result); } } @@ -365,7 +365,6 @@ export default function userauthTest() { } }) - /* * @tc.number : Security_IAM_Func_0103 * @tc.name : Kit interface auth & cancel auth @@ -387,7 +386,7 @@ export default function userauthTest() { console.log("authV9 token " + result.token); console.log("authV9 remainAttempts " + result.remainAttempts); console.log("authV9 lockoutDuration " + result.lockoutDuration); - expect(result.result).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED); + expect(result.result).assertEqual(userAuthNorth.UserAuthResultCode.NOT_ENROLLED); } }); @@ -409,7 +408,7 @@ export default function userauthTest() { authInstance.cancel(); } catch (e) { console.log("Security_IAM_Func_0103 cancel fail " + e); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.GENERAL_ERROR); } // unregister result and tip @@ -419,7 +418,7 @@ export default function userauthTest() { done(); } catch (e) { console.log("Security_IAM_Func_0103 fail " + e); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.GENERAL_ERROR); done(); } }) @@ -442,7 +441,7 @@ export default function userauthTest() { done(); } catch (e) { console.log("Security_IAM_Func_0108 fail " + e.code); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.GENERAL_ERROR); done(); } }) @@ -464,7 +463,7 @@ export default function userauthTest() { authInstance.cancel(); } catch (e) { console.log("Security_IAM_Func_0109 fail " + e); - expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR); + expect(e.code).assertEqual(userAuthNorth.UserAuthResultCode.GENERAL_ERROR); done(); } }) @@ -556,16 +555,16 @@ export default function userauthTest() { */ it('Security_IAM_Func_0107', 0, async function (done) { console.info('testFace Security_IAM_Func_0107 start'); - expect(12500000).assertEqual(userAuthNorth.ResultCodeV9.SUCCESS); - expect(12500001).assertEqual(userAuthNorth.ResultCodeV9.FAIL); - expect(12500002).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR); - expect(12500003).assertEqual(userAuthNorth.ResultCodeV9.CANCELED); - expect(12500004).assertEqual(userAuthNorth.ResultCodeV9.TIMEOUT); - expect(12500005).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT); - expect(12500006).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT); - expect(12500007).assertEqual(userAuthNorth.ResultCodeV9.BUSY); - expect(12500009).assertEqual(userAuthNorth.ResultCodeV9.LOCKED); - expect(12500010).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED); + expect(12500000).assertEqual(userAuthNorth.UserAuthResultCode.SUCCESS); + expect(12500001).assertEqual(userAuthNorth.UserAuthResultCode.FAIL); + expect(12500002).assertEqual(userAuthNorth.UserAuthResultCode.GENERAL_ERROR); + expect(12500003).assertEqual(userAuthNorth.UserAuthResultCode.CANCELED); + expect(12500004).assertEqual(userAuthNorth.UserAuthResultCode.TIMEOUT); + expect(12500005).assertEqual(userAuthNorth.UserAuthResultCode.TYPE_NOT_SUPPORT); + expect(12500006).assertEqual(userAuthNorth.UserAuthResultCode.TRUST_LEVEL_NOT_SUPPORT); + expect(12500007).assertEqual(userAuthNorth.UserAuthResultCode.BUSY); + expect(12500009).assertEqual(userAuthNorth.UserAuthResultCode.LOCKED); + expect(12500010).assertEqual(userAuthNorth.UserAuthResultCode.NOT_ENROLLED); console.info('testFace Security_IAM_Func_0107 end'); done(); }) diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js index eb38652a3116d056c6abd147a5d24fcc58952681..6ba3032738143698021740c58571dc407d3559cf 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js @@ -18,121 +18,216 @@ import userAuthNorth from '@ohos.userIAM.userAuth' let UserAuthKit = new userAuthNorth.UserAuth() - export default function userauthTest() { -describe('userauthTest', function () { - - /* - * @tc.number : Security_IAM_PIN_Kit_Func_0101 - * @tc.name : Kit interface get version - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 0 - */ - it('Security_IAM_PIN_Kit_Func_0101', 0, async function (done) { - try { - let getversionresult = null; - getversionresult = UserAuthKit.getVersion(); - console.info('GetVersionTest_0101 getversionresult = ' + getversionresult); - expect(false).assertEqual(getversionresult == null); - done(); - } catch (e) { - console.log("testFace GetVersionTest_0101 fail " + e); - expect(null).assertFail(); - } - }) + describe('userauthTest', function () { - /* - * @tc.number : Security_IAM_PIN_Kit_Func_0102 - * @tc.name : Kit interface get AvailabeStatus - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 0 - */ - it('Security_IAM_PIN_Kit_Func_0102', 0, async function (done) { - console.info('testFace GetAvailabeStatusTest0101 start'); - try { - 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_0101 + * @tc.name : Kit interface get version + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 0 + */ + it('Security_IAM_PIN_Kit_Func_0101', 0, async function (done) { + try { + let getversionresult = null; + getversionresult = UserAuthKit.getVersion(); + console.info('GetVersionTest_0101 getversionresult = ' + getversionresult); + expect(getversionresult).assertEqual(0); + done(); + } catch (e) { + console.log("testFace GetVersionTest_0101 fail " + e.code); + expect(null).assertFail(); + } + }) + + /* + * @tc.number : Security_IAM_PIN_Kit_Func_0102 + * @tc.name : Kit interface get AvailabeStatus + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 0 + */ + it('Security_IAM_PIN_Kit_Func_0102', 0, async function (done) { + console.info('testFace Security_IAM_PIN_Kit_Func_0102 start'); + // let authType = [userAuthNorth.UserAuthType.FACE, userAuthNorth.UserAuthType.FINGERPRINT] + let authType = userAuthNorth.UserAuthType.FACE; + let level = [userAuthNorth.AuthTrustLevel.ATL1, userAuthNorth.AuthTrustLevel.ATL2, userAuthNorth.AuthTrustLevel.ATL3, userAuthNorth.AuthTrustLevel.ATL4]; + let availabeStatus; - /* - * @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 = new Uint8Array([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); + for (let idx1 = 0; idx1 < level.length; idx1++) { + try { + console.info('Security_IAM_PIN_Kit_Func_0102 authtype:' + authType+ 'trustlevel:' + level[idx1]) + availabeStatus = UserAuthKit.getAvailableStatus(authType, level[idx1]); + console.info(`Security_IAM_PIN_Kit_Func_0102 ${availabeStatus}`) + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED); + } catch (e) { + console.info(`Security_IAM_PIN_Kit_Func_0102 e ${JSON.stringify(e)}`) + console.log("Security_IAM_PIN_Kit_Func_0102 throw fail " + 'authType:' + authType + 'trustlevel:' + level[idx1] + 'e.code:' + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED); + } 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_0112 + * @tc.name : Kit interface get AvailabeStatus invalid param + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 0 + */ + it('Security_IAM_PIN_Kit_Func_0112', 0, async function (done) { + console.info('testFace Security_IAM_PIN_Kit_Func_0112 start'); + let availabeStatus; + //No AuthType + try { + availabeStatus = UserAuthKit.getAvailableStatus(userAuthNorth.AuthTrustLevel.ATL1); + console.log("getAvailableStatus noAuthType return fail " + availabeStatus); + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } catch (e) { + console.log("getAvailableStatus noAuthType throw fail " + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } - /* - * @tc.number : Security_IAM_PIN_Kit_Func_0107 - * @tc.name : Kit interface enum ResultCode - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 0 - */ - it('Security_IAM_PIN_Kit_Func_0107', 0, async function (done) { - console.info('testFace Security_IAM_PIN_Kit_Func_0107 start'); - expect(0).assertEqual(userAuthNorth.ResultCode.SUCCESS); - expect(1).assertEqual(userAuthNorth.ResultCode.FAIL); - expect(2).assertEqual(userAuthNorth.ResultCode.GENERAL_ERROR); - expect(3).assertEqual(userAuthNorth.ResultCode.CANCELED); - expect(4).assertEqual(userAuthNorth.ResultCode.TIMEOUT); - expect(5).assertEqual(userAuthNorth.ResultCode.TYPE_NOT_SUPPORT); - expect(6).assertEqual(userAuthNorth.ResultCode.TRUST_LEVEL_NOT_SUPPORT); - expect(7).assertEqual(userAuthNorth.ResultCode.BUSY); - expect(8).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); - expect(9).assertEqual(userAuthNorth.ResultCode.LOCKED); - expect(10).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED); - console.info('testFace Security_IAM_PIN_Kit_Func_0107 end'); - done(); - }) + //No AuthTrustLevel + try { + availabeStatus = UserAuthKit.getAvailableStatus(userAuthNorth.UserAuthType.FACE); + console.log("getAvailableStatus AuthTrustLevel return fail " + availabeStatus); + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } catch (e) { + console.log("getAvailableStatus no AuthTrustLevel throw fail " + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } -}) + //No authtype and AuthTrustLevel + try { + availabeStatus = UserAuthKit.getAvailableStatus(); + console.log("getAvailableStatus AuthTrustLevel return fail " + availabeStatus); + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } catch (e) { + console.log("getAvailableStatus no authtype and AuthTrustLevel throw fail " + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } + + //more param 2 + try { + availabeStatus = UserAuthKit.getAvailableStatus(userAuthNorth.UserAuthType.FACE, userAuthNorth.AuthTrustLevel.ATL1, 2); + console.log("getAvailableStatus AuthTrustLevel return fail " + availabeStatus); + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } catch (e) { + console.log("getAvailableStatus more param 2 throw fail " + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + } + + let invalidauthType = [-1, 0, 1, 3, 5] + for (let idx = 0; idx < invalidauthType.length; idx++) { + //authType invalid + try { + console.log("getAvailableStatus authType invalid: " + invalidauthType[idx]); + availabeStatus = UserAuthKit.getAvailableStatus(invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1); + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.TYPE_NOT_SUPPORT); + } catch (e) { + console.log("getAvailableStatus authType invalid throw:" + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.TYPE_NOT_SUPPORT); + } + } + + let invalidtrustLevel = [5000, 15000, 50000] + for (let idx = 0; idx < invalidtrustLevel.length; idx++) { + //trustlevel invalid + try { + console.log("getAvailableStatus trustLevel invalid " + invalidtrustLevel[idx]); + availabeStatus = UserAuthKit.getAvailableStatus(2, invalidtrustLevel[idx]); + expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.TRUST_LEVEL_NOT_SUPPORT); + } catch (e) { + console.log("getAvailableStatus trustLevel invalid throw " + e.code); + expect(e.code).assertEqual(userAuthNorth.ResultCode.TRUST_LEVEL_NOT_SUPPORT); + } + } + done() + }) + + /* + * @tc.number : Security_IAM_PIN_Kit_Func_0113 + * @tc.name : Kit interface auth & cancel auth + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 0 + */ + it('Security_IAM_PIN_Kit_Func_0113', 0, async function (done) { + let contextID1 = null + let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37]) + let onresult = { + authresult: null, + authextr: null, + } + let onacquireinfo = { + authmodule : null, + authacquire : null, + authextr : null + } + + function authPromise(...args){ + return new Promise((res,rej) =>{ + contextID1 = UserAuthKit.auth(args[0], args[1],args[2], { + onResult: function(result,extraInfo){ + console.log(`testFace faceDemo auth result is ${result}, challenge is ${args[0]}, authtype is ${args[1]}, trustlevel is ${args[2]} `); + onresult.authresult = result; + console.log("testFace faceDemo auth extraInfo = " + JSON.stringify(extraInfo)); + onresult.authextr = extraInfo; + console.info('testFace publicauth auth onResult = ' + JSON.stringify(onresult)); + try{ + expect(result).assertEqual(args[3]); + } + catch(e){ + console.log(`public auth error =${e.code}`) + } + console.info('testFace publicauth auth contextID1 = ' + contextID1); + res() + } + }) + }) + } + + await authPromise(challenge, 0, 10000,5) + await authPromise(challenge, 1, 10000,5) + await authPromise(challenge, 3, 20000,5) + await authPromise(challenge, 5, 20000,5) + await authPromise(challenge, 2, 5000,6) + await authPromise(challenge, 4, 15000,6) + await authPromise(challenge, 2, 10000,10) + await authPromise(challenge, 2, 20000,10) + await authPromise(challenge, 2, 30000,10) + await authPromise(challenge, 2, 40000,10) + done() + }) + + /* + * @tc.number : Security_IAM_PIN_Kit_Func_0107 + * @tc.name : Kit interface enum ResultCode + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 0 + */ + it('Security_IAM_PIN_Kit_Func_0107', 0, async function (done) { + console.info('testFace Security_IAM_PIN_Kit_Func_0107 start'); + expect(0).assertEqual(userAuthNorth.ResultCode.SUCCESS); + expect(1).assertEqual(userAuthNorth.ResultCode.FAIL); + expect(2).assertEqual(userAuthNorth.ResultCode.GENERAL_ERROR); + expect(3).assertEqual(userAuthNorth.ResultCode.CANCELED); + expect(4).assertEqual(userAuthNorth.ResultCode.TIMEOUT); + expect(5).assertEqual(userAuthNorth.ResultCode.TYPE_NOT_SUPPORT); + expect(6).assertEqual(userAuthNorth.ResultCode.TRUST_LEVEL_NOT_SUPPORT); + expect(7).assertEqual(userAuthNorth.ResultCode.BUSY); + expect(8).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS); + expect(9).assertEqual(userAuthNorth.ResultCode.LOCKED); + expect(10).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED); + console.info('testFace Security_IAM_PIN_Kit_Func_0107 end'); + done(); + }) + + }) }