提交 1558e44a 编写于 作者: H hu-jixiang1

hujixiang1@huawei.com

Signed-off-by: Nhu-jixiang1 <hujixiang1@huawei.com>
Change-Id: I75d293034a867d21254cafda7956abef6722f3e3
上级 8874f261
......@@ -16,6 +16,9 @@ import("//test/xts/tools/build/suite.gni")
group("useriam") {
testonly = true
if (is_standard_system) {
deps = [ "face_auth/js_api_test/function_test/userauth:ActsUserauthTest" ]
deps = [
"face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
"face_auth/js_api_test/function_test/userauthpart2:ActsUserauthTwoTest",
]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsUserauthTwoTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsUserauthTwoTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "900000",
"package": "com.example.myapplication101",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsUserauthTwoTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ActsUserauthTwoTest.hap->/data/test/ActsUserauthTwoTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap",
"chmod 777 -R data"
]
}
]
}
{
"app": {
"bundleName": "com.example.myapplication101",
"vendor": "example",
"version": {
"code": 12,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication101",
"name": ".MyApplication",
"mainAbility": "com.example.myapplication101.MainAbility",
"deviceType": [
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.myapplication101.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
],
"reqPermissions": [
{
"reason": "reason_manage_face",
"usedScene": {
"ability": ["com.myface.Ability","com.myface.AbilityBackground"],
"when": "always"
},
"name": "ohos.permission.MANAGE_FACE"
},
{
"reason": "reason_access_biometric",
"usedScene": {
"ability": ["com.mybiometric.Ability","com.mybiometric.AbilityBackground"],
"when": "always"
},
"name": "ohos.permission.ACCESS_BIOMETRIC"
}
]
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
import fileio from '@ohos.fileio'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow start')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 35000;
configService.setConfig(this)
require('../../../test/List.test.js')
core.execute()
console.info('onShow end')
},
onReady() {
},
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require("./Security_IAM_PIN_Func_CallbackJsunit.test.js")
require("./Security_IAM_Coauth_Func_CallbackJsunit.test.js")
require("./Security_IAM_Face_Func_CallbackJsunit.test.js")
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from 'deccjsunit/index'
import userIDM from '@ohos.useridm'
import pinAuth from '@ohos.pinauth'
import userAuth from '@ohos.userauth'
let UserIDM = null
let PinAuth = null
let UserAuth = null
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
//同步
function publicRegisterInputer(PinAuth,AuthSubType,Inputerdata){
console.info('testFace publicRegisterInputer in');
try {
console.info('testFace publicRegisterInputer in try');
console.info('testFace publicRegisterInputer PinAuth = ' + PinAuth);
let registerresult = PinAuth.registerInputer({
onGetData: (AuthSubType, IInputData) => {
console.info('testFace faceDemo registerInputer AuthSubType');
console.info('testFace faceDemo registerInputer AuthSubType111');
IInputData.onSetData(AuthSubType, Inputerdata)
}
})
console.log("testFace publicRegisterInputer result is: " + registerresult);
return registerresult;
}
catch (e) {
console.log("testFace publicRegisterInputer fail " + e);
expect(null).assertFail();
}
}
function publicunRegisterInputer(PinAuth,callback){
console.info('testFace publicunRegisterInputer in');
try {
console.info('testFace publicunRegisterInputer in try');
console.info('testFace publicunRegisterInputer PinAuth = ' + PinAuth);
let unRegist = 1;
PinAuth.unregisterInputer();
callback(unRegist)
}
catch (e) {
console.log("testFace publicRegisterInputer 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 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 publicgetAvailabeStatus in');
try {
console.info('testFace publicgetAvailabeStatus in try');
console.info('testFace publicgetAvailabeStatus UserAuth = ' + UserAuth);
let AvailabeStatus = null
AvailabeStatus = UserAuth.getAvailabeStatus(authType, authTrustLevel);
console.info('testFace publicgetAvailabeStatus result = ' + JSON.stringify(AsyncCallback));
return AvailabeStatus
}
catch (e) {
console.log("testFace publicgetAvailabeStatus 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 getallAuthInfo 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 = " + 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 = " + 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}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册