未验证 提交 217802ed 编写于 作者: O openharmony_ci 提交者: Gitee

!7246 【OpenHarmony 4.0.2.2】【安全子系统】useriam用例更新

Merge pull request !7246 from qiaozzzh/01161_1
...@@ -120,5 +120,225 @@ describe('userAuthTestExecute', function () { ...@@ -120,5 +120,225 @@ describe('userAuthTestExecute', function () {
}); });
console.log("JSAPI_Function_Execute_2100 end"); 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");
})
}) })
} }
...@@ -66,16 +66,13 @@ describe('userAuthTestExecute', function () { ...@@ -66,16 +66,13 @@ describe('userAuthTestExecute', function () {
* @tc.type FUNC * @tc.type FUNC
* @tc.level Level2 * @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"); console.log("JSAPI_Function_Nopermission_1800 start");
const auth = userAuth.getAuthenticator(); const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S1", function(data) { auth.execute("FACE_ONLY", "S1", function(data) {
console.log("JSAPI_Function_Nopermission_1800 auth.execute:" + data); console.log("JSAPI_Function_Nopermission_1800 auth.execute:" + data);
// general error // general error
expect(data).assertEqual(100); expect(data).assertEqual(100);
setTimeout(function() {
done();
}, 1);
}); });
console.log("JSAPI_Function_Nopermission_1800 end"); console.log("JSAPI_Function_Nopermission_1800 end");
}) })
...@@ -115,12 +112,12 @@ describe('userAuthTestExecute', function () { ...@@ -115,12 +112,12 @@ describe('userAuthTestExecute', function () {
let AvailabeStatus = null let AvailabeStatus = null
AvailabeStatus = UserAuthKit.getAvailableStatus(2, 10000); AvailabeStatus = UserAuthKit.getAvailableStatus(2, 10000);
console.info('testFace Security_IAM_Nopermission_API8_Func_0112,2,10000 result = ' + JSON.stringify(AvailabeStatus)); console.info('testFace Security_IAM_Nopermission_API8_Func_0112,2,10000 result = ' + JSON.stringify(AvailabeStatus));
// 100:general error //201
expect(1005).assertEqual(AvailabeStatus); expect(201).assertEqual(AvailabeStatus);
done() done()
} catch (e) { } catch (e) {
console.log("Security_IAM_Nopermission_API8_Func_0112 fail " + e.code); console.log("Security_IAM_Nopermission_API8_Func_0112 fail " + e.code);
expect(100).assertEqual(e.code); expect(201).assertEqual(e.code);
done() done()
} }
}) })
...@@ -150,8 +147,8 @@ describe('userAuthTestExecute', function () { ...@@ -150,8 +147,8 @@ describe('userAuthTestExecute', function () {
onResult: function(result,extraInfo){ onResult: function(result,extraInfo){
console.log("Security_IAM_Nopermission_API8_Func_0103 auth result = " + result); console.log("Security_IAM_Nopermission_API8_Func_0103 auth result = " + result);
onresult.authresult = result; onresult.authresult = result;
//100:general error //201
expect(1005).assertEqual(result); expect(201).assertEqual(result);
console.info('Security_IAM_Nopermission_API8_Func_0103 contextID1 = ' + contextID1); console.info('Security_IAM_Nopermission_API8_Func_0103 contextID1 = ' + contextID1);
let cancelResult = UserAuthKit.cancelAuth(contextID1); let cancelResult = UserAuthKit.cancelAuth(contextID1);
console.info('Security_IAM_Nopermission_API8_Func_0103 cancelResult = ' + cancelResult); console.info('Security_IAM_Nopermission_API8_Func_0103 cancelResult = ' + cancelResult);
...@@ -166,10 +163,9 @@ describe('userAuthTestExecute', function () { ...@@ -166,10 +163,9 @@ describe('userAuthTestExecute', function () {
console.info('testFace publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo)); console.info('testFace publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo));
} }
}); });
done();
}) })
/* /*
* @tc.number : Security_IAM_Nopermission_API9_Func_0101 * @tc.number : Security_IAM_Nopermission_API9_Func_0101
* @tc.name : Kit interface get version * @tc.name : Kit interface get version
...@@ -238,7 +234,7 @@ describe('userAuthTestExecute', function () { ...@@ -238,7 +234,7 @@ describe('userAuthTestExecute', function () {
/* /*
* @tc.number : Security_IAM_Nopermission_API9_Func_0103 * @tc.number : Security_IAM_Nopermission_API9_Func_0103
* @tc.name : Kit interface auth & cancel auth * @tc.name : Kit interface auth
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
...@@ -257,7 +253,7 @@ describe('userAuthTestExecute', function () { ...@@ -257,7 +253,7 @@ describe('userAuthTestExecute', function () {
console.log("authV9 token " + result.token); console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts); console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration); 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 () { ...@@ -275,14 +271,6 @@ describe('userAuthTestExecute', function () {
expect(e.code).assertEqual(201); 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 // unregister result and tip
try { try {
authInstance.off("result"); authInstance.off("result");
......
...@@ -56,7 +56,7 @@ export default function userauthTest() { ...@@ -56,7 +56,7 @@ export default function userauthTest() {
userAuthNorth.getAvailableStatus(authType, level[idx1]); userAuthNorth.getAvailableStatus(authType, level[idx1]);
} catch (e) { } catch (e) {
console.log("GetAvailabeStatusTest0102 fail " + 'authType:' + authType + 'trustlevel:' + level[idx1] + 'e.code:' + e.code); 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(); done();
} }
} }
...@@ -112,7 +112,7 @@ export default function userauthTest() { ...@@ -112,7 +112,7 @@ export default function userauthTest() {
userAuthNorth.getAvailableStatus(invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1); userAuthNorth.getAvailableStatus(invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) { } catch (e) {
console.log("GetAvailabeStatusTest0104 authType invalid:" + e.code); 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() { ...@@ -124,7 +124,7 @@ export default function userauthTest() {
userAuthNorth.getAvailableStatus(2, invalidtrustLevel[idx]); userAuthNorth.getAvailableStatus(2, invalidtrustLevel[idx]);
} catch (e) { } catch (e) {
console.log("GetAvailabeStatusTest0104 trustLevel invalid :1 " + e.code); 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() done()
...@@ -151,14 +151,14 @@ export default function userauthTest() { ...@@ -151,14 +151,14 @@ export default function userauthTest() {
authInstance.on("result", { authInstance.on("result", {
callback: (result) => { callback: (result) => {
console.log("authV9 result " + result.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 //start auth
authInstance.start(); authInstance.start();
} catch (e) { } catch (e) {
console.log("getAuthInstance/start fail " + e.code + 'authType:' + authType + 'trustlevel:' + level[idx2] + 'e.code:' + e.code); 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() done()
...@@ -226,7 +226,7 @@ export default function userauthTest() { ...@@ -226,7 +226,7 @@ export default function userauthTest() {
var authInstance = userAuthNorth.getAuthInstance(challenge, invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1); var authInstance = userAuthNorth.getAuthInstance(challenge, invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) { } catch (e) {
console.log("getAuthInstance authType invalid : " + "invalidauthType[idx]" + invalidauthType[idx] + e.code); 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() { ...@@ -238,7 +238,7 @@ export default function userauthTest() {
var authInstance = userAuthNorth.getAuthInstance(challenge, 2, invalidtrustLevel[idx]); var authInstance = userAuthNorth.getAuthInstance(challenge, 2, invalidtrustLevel[idx]);
} catch (e) { } catch (e) {
console.log("getAuthInstance trustLevel invalid : " + "invalidtrustLevel[idx]" + invalidtrustLevel[idx] + e.code); 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() done()
...@@ -262,7 +262,7 @@ export default function userauthTest() { ...@@ -262,7 +262,7 @@ export default function userauthTest() {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("results", { authInstance.on("results", {
callback: function (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); console.log("Security_IAM_Func_0106 on result = " + result.result);
} }
} }
...@@ -277,7 +277,7 @@ export default function userauthTest() { ...@@ -277,7 +277,7 @@ export default function userauthTest() {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("tips", { authInstance.on("tips", {
callback: function (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); console.log("Security_IAM_Func_0106 on result = " + result.result);
} }
} }
...@@ -292,7 +292,7 @@ export default function userauthTest() { ...@@ -292,7 +292,7 @@ export default function userauthTest() {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("tip", "result", { authInstance.on("tip", "result", {
callback: function (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); console.log("Security_IAM_Func_0106 on result = " + result.result);
} }
} }
...@@ -307,7 +307,7 @@ export default function userauthTest() { ...@@ -307,7 +307,7 @@ export default function userauthTest() {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel); var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("", { authInstance.on("", {
callback: function (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); console.log("Security_IAM_Func_0106 on result = " + result.result);
} }
} }
...@@ -365,7 +365,6 @@ export default function userauthTest() { ...@@ -365,7 +365,6 @@ export default function userauthTest() {
} }
}) })
/* /*
* @tc.number : Security_IAM_Func_0103 * @tc.number : Security_IAM_Func_0103
* @tc.name : Kit interface auth & cancel auth * @tc.name : Kit interface auth & cancel auth
...@@ -387,7 +386,7 @@ export default function userauthTest() { ...@@ -387,7 +386,7 @@ export default function userauthTest() {
console.log("authV9 token " + result.token); console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts); console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration); 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() { ...@@ -409,7 +408,7 @@ export default function userauthTest() {
authInstance.cancel(); authInstance.cancel();
} catch (e) { } catch (e) {
console.log("Security_IAM_Func_0103 cancel fail " + 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 // unregister result and tip
...@@ -419,7 +418,7 @@ export default function userauthTest() { ...@@ -419,7 +418,7 @@ export default function userauthTest() {
done(); done();
} catch (e) { } catch (e) {
console.log("Security_IAM_Func_0103 fail " + 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(); done();
} }
}) })
...@@ -442,7 +441,7 @@ export default function userauthTest() { ...@@ -442,7 +441,7 @@ export default function userauthTest() {
done(); done();
} catch (e) { } catch (e) {
console.log("Security_IAM_Func_0108 fail " + e.code); 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(); done();
} }
}) })
...@@ -464,7 +463,7 @@ export default function userauthTest() { ...@@ -464,7 +463,7 @@ export default function userauthTest() {
authInstance.cancel(); authInstance.cancel();
} catch (e) { } catch (e) {
console.log("Security_IAM_Func_0109 fail " + 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(); done();
} }
}) })
...@@ -556,16 +555,16 @@ export default function userauthTest() { ...@@ -556,16 +555,16 @@ export default function userauthTest() {
*/ */
it('Security_IAM_Func_0107', 0, async function (done) { it('Security_IAM_Func_0107', 0, async function (done) {
console.info('testFace Security_IAM_Func_0107 start'); console.info('testFace Security_IAM_Func_0107 start');
expect(12500000).assertEqual(userAuthNorth.ResultCodeV9.SUCCESS); expect(12500000).assertEqual(userAuthNorth.UserAuthResultCode.SUCCESS);
expect(12500001).assertEqual(userAuthNorth.ResultCodeV9.FAIL); expect(12500001).assertEqual(userAuthNorth.UserAuthResultCode.FAIL);
expect(12500002).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR); expect(12500002).assertEqual(userAuthNorth.UserAuthResultCode.GENERAL_ERROR);
expect(12500003).assertEqual(userAuthNorth.ResultCodeV9.CANCELED); expect(12500003).assertEqual(userAuthNorth.UserAuthResultCode.CANCELED);
expect(12500004).assertEqual(userAuthNorth.ResultCodeV9.TIMEOUT); expect(12500004).assertEqual(userAuthNorth.UserAuthResultCode.TIMEOUT);
expect(12500005).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT); expect(12500005).assertEqual(userAuthNorth.UserAuthResultCode.TYPE_NOT_SUPPORT);
expect(12500006).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT); expect(12500006).assertEqual(userAuthNorth.UserAuthResultCode.TRUST_LEVEL_NOT_SUPPORT);
expect(12500007).assertEqual(userAuthNorth.ResultCodeV9.BUSY); expect(12500007).assertEqual(userAuthNorth.UserAuthResultCode.BUSY);
expect(12500009).assertEqual(userAuthNorth.ResultCodeV9.LOCKED); expect(12500009).assertEqual(userAuthNorth.UserAuthResultCode.LOCKED);
expect(12500010).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED); expect(12500010).assertEqual(userAuthNorth.UserAuthResultCode.NOT_ENROLLED);
console.info('testFace Security_IAM_Func_0107 end'); console.info('testFace Security_IAM_Func_0107 end');
done(); done();
}) })
......
...@@ -18,121 +18,216 @@ import userAuthNorth from '@ohos.userIAM.userAuth' ...@@ -18,121 +18,216 @@ import userAuthNorth from '@ohos.userIAM.userAuth'
let UserAuthKit = new userAuthNorth.UserAuth() let UserAuthKit = new userAuthNorth.UserAuth()
export default function userauthTest() { export default function userauthTest() {
describe('userauthTest', function () { describe('userauthTest', function () {
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0101', 0, async function (done) {
try {
let getversionresult = null;
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();
}
})
/* /*
* @tc.number : Security_IAM_PIN_Kit_Func_0102 * @tc.number : Security_IAM_PIN_Kit_Func_0101
* @tc.name : Kit interface get AvailabeStatus * @tc.name : Kit interface get version
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('Security_IAM_PIN_Kit_Func_0102', 0, async function (done) { it('Security_IAM_PIN_Kit_Func_0101', 0, async function (done) {
console.info('testFace GetAvailabeStatusTest0101 start'); try {
try { let getversionresult = null;
let AvailabeStatus = null getversionresult = UserAuthKit.getVersion();
AvailabeStatus = UserAuthKit.getAvailableStatus(userAuthNorth.UserAuthType.FACE, console.info('GetVersionTest_0101 getversionresult = ' + getversionresult);
userAuthNorth.AuthTrustLevel.ATL1); expect(getversionresult).assertEqual(0);
console.info('testFace publicgetAvailableStatus result = ' + JSON.stringify(AvailabeStatus)); done();
expect(6).assertEqual(AvailabeStatus); } catch (e) {
done(); console.log("testFace GetVersionTest_0101 fail " + e.code);
} catch (e) { expect(null).assertFail();
console.log("GetAvailabeStatusTest0101 fail " + e); }
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;
/* for (let idx1 = 0; idx1 < level.length; idx1++) {
* @tc.number : Security_IAM_PIN_Kit_Func_0103 try {
* @tc.name : Kit interface auth & cancel auth console.info('Security_IAM_PIN_Kit_Func_0102 authtype:' + authType+ 'trustlevel:' + level[idx1])
* @tc.size : MediumTest availabeStatus = UserAuthKit.getAvailableStatus(authType, level[idx1]);
* @tc.type : Function console.info(`Security_IAM_PIN_Kit_Func_0102 ${availabeStatus}`)
* @tc.level : Level 0 expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED);
*/ } catch (e) {
it('Security_IAM_PIN_Kit_Func_0103', 0, async function (done) { console.info(`Security_IAM_PIN_Kit_Func_0102 e ${JSON.stringify(e)}`)
let contextID1 = null console.log("Security_IAM_PIN_Kit_Func_0102 throw fail " + 'authType:' + authType + 'trustlevel:' + level[idx1] + 'e.code:' + e.code);
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37]) expect(e.code).assertEqual(userAuthNorth.ResultCode.NOT_ENROLLED);
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(); 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);
}
/* //No AuthTrustLevel
* @tc.number : Security_IAM_PIN_Kit_Func_0107 try {
* @tc.name : Kit interface enum ResultCode availabeStatus = UserAuthKit.getAvailableStatus(userAuthNorth.UserAuthType.FACE);
* @tc.size : MediumTest console.log("getAvailableStatus AuthTrustLevel return fail " + availabeStatus);
* @tc.type : Function expect(availabeStatus).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS);
* @tc.level : Level 0 } catch (e) {
*/ console.log("getAvailableStatus no AuthTrustLevel throw fail " + e.code);
it('Security_IAM_PIN_Kit_Func_0107', 0, async function (done) { expect(e.code).assertEqual(userAuthNorth.ResultCode.INVALID_PARAMETERS);
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 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();
})
})
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册