未验证 提交 66e2ec29 编写于 作者: O openharmony_ci 提交者: Gitee

!6572 【OpenHarmony 3.2monthly】useriam代码修改

Merge pull request !6572 from yuanyuhang/monthly1118_1
......@@ -18,6 +18,7 @@ group("useriam") {
if (is_standard_system) {
deps = [
"face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
"face_auth/js_api_test/function_test/userauthnopermission:ActsUserauthnopermissionTest",
"face_auth/js_api_test/function_test/userauthpart2:ActsUserauthTwoTest",
]
}
......
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsUserauthnopermissionTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsUserauthnopermissionTest"
subsystem_name = "useriam"
part_name = "face_auth"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "com.example.myapplication101",
"package-name": "com.example.myapplication101"
},
"kits": [
{
"test-file-name": [
"ActsUserauthnopermissionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ActsUserauthnopermissionTest.hap->/data/test/ActsUserauthnopermissionTest.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": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"tablet",
"default",
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
}
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.Test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* 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.
*/
.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;
}
}
/*
* 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.
*/
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 fileio from '@ohos.fileio'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow start')
},
onReady() {
},
fileSave(caseNum, codeNum, ...code) {
console.log(caseNum + ' fileSave start');
var path = "/data/config.dat"
let fd = fileio.openSync(path, 0o102, 0o666);
var message = caseNum + "\r\n" + codeNum + "\r\n";
for(var i = 0; i < code.length; i++){
message = message + code[i] + "\r\n";
}
fileio.writeSync(fd, message);
fileio.closeSync(fd);
console.log(caseNum + ' fileSave end');
},
fileSaveB(caseNum, code) {
console.log(caseNum + ' fileSave start');
var path = "/data/config.dat"
let fd = fileio.openSync(path, 0o102, 0o666);
var message = code;
fileio.writeSync(fd, message);
fileio.closeSync(fd);
console.log(caseNum + ' fileSave end');
},
saveNull() {
console.log('JSAPI null file faceid.dat start');
var path = "/data/faceId.dat"
let fd = fileio.openSync(path, 0o102, 0o666);
var message = "";
fileio.writeSync(fd, message);
fileio.closeSync(fd);
console.log('JSAPI null file faceid.dat end');
},
}
/*
* 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* 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 userAuthTestNopermission from './nopermisson.js'
export default function testsuite() {
userAuthTestNopermission()
}
/*
* 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 userAuth from '@ohos.userIAM.userAuth'
let UserAuthKit = new userAuth.UserAuth()
var index = require('../MainAbility/pages/index/index.js');
var waitFlag = false;
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/**
* test case
*/
export default function userAuthTestExecute() {
describe('userAuthTestExecute', function () {
beforeEach(function(done) {
let waitTime = 1000;
if (waitFlag) {
waitTime = 30000;
}
setTimeout(function() {
done();
}, waitTime);
})
afterEach(function() {
})
/**
* @tc.name execute_authentication_promise_Type_is_null
* @tc.number JSAPI_Function_Execute_2100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Nopermission_2100', 0, function (done) {
console.log("JSAPI_Function_Nopermission_2100 start");
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S1").catch(function(data) {
console.log("JSAPI_Function_Nopermission_2100 auth.execute:" + data);
// general error
expect(data).assertEqual(100);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Nopermission_2100 end");
})
/**
* @tc.name execute_authentication_callback_Type_is_null
* @tc.number JSAPI_Function_Execute_1800
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Nopermission_1800', 0, function (done) {
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");
})
/*
* @tc.number : Security_IAM_Nopermission_API8_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API8_Func_0101', 0, async function (done) {
try {
let getversionresult = null;
getversionresult = UserAuthKit.getVersion();
console.info('Security_IAM_Nopermission_API8_Func_0101 getversionresult = ' + getversionresult);
//mini version 0
expect(getversionresult).assertEqual(0);
done();
} catch (e) {
console.log("testFace Security_IAM_Nopermission_API8_Func_0101 fail " + e.code);
expect(null).assertFail();
done();
}
})
/*
* @tc.number : Security_IAM_Nopermission_API8_Func_0112
* @tc.name : Kit interface get AvailabeStatus
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API8_Func_0112', 0, async function (done) {
console.info('testFace Security_IAM_Nopermission_API8_Func_0112 start');
try {
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);
done()
} catch (e) {
console.log("Security_IAM_Nopermission_API8_Func_0112 fail " + e.code);
expect(100).assertEqual(e.code);
done()
}
})
/*
* @tc.number : Security_IAM_Nopermission_API8_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API8_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
}
console.log("Security_IAM_Nopermission_API8_Func_0103 2,10000");
contextID1 = UserAuthKit.auth(challenge, userAuth.UserAuthType.FACE,userAuth.AuthTrustLevel.ATL1, {
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);
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);
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_Nopermission_API9_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API9_Func_0101', 0, async function (done) {
try {
let getversionresult = userAuth.getVersion();
console.info('Security_IAM_Nopermission_API9_Func_0101 getversionresult = ' + getversionresult);
// no permission
expect(getversionresult).assertEqual(201);
done();
} catch (e) {
console.log("testFace GetVersionTest_0101 fail " + e.code);
expect(e.code).assertEqual(201);
done();
}
})
/*
* @tc.number : Security_IAM_Nopermisson_Func_0104
* @tc.name : getAvailabeStatus invalid parameters
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermisson_API9_Func_0104', 0, async function (done) {
console.info('testFace Security_IAM_Nopermisson_API9_Func_0104 start');
try {
userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL1);
console.log("Security_IAM_Nopermisson_API9_Func_0104 success " );
done()
} catch (e) {
console.log("Security_IAM_Nopermisson_API9_Func_0104 fail " + e.code);
expect(e.code).assertEqual(201);
done()
}
})
/*
* @tc.number : Security_IAM_Nopermission_API9_Func_0110
* @tc.name : getAuthInstance faceType ATL4
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API9_Func_0110', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuth.UserAuthType.FACE;
let authTrustLevel = userAuth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.log("Security_IAM_Nopermission_API9_Func_0110 FACE ATL1 success");
done();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0110 FACE ATL1 fail" + e.code);
expect(e.code).assertEqual(201);
done();
}
})
/*
* @tc.number : Security_IAM_Nopermission_API9_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API9_Func_0103', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuth.UserAuthType.FACE;
let authTrustLevel = userAuth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuth.getAuthInstance(challenge, authType, authTrustLevel);
// register result and tip
authInstance.on("result", {
callback: (result) => {
console.log("authV9 result " + result.result);
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);
}
});
authInstance.on("tip", {
callback: (result) => {
console.log("authV9 module " + result.module);
console.log("authV9 tip " + result.tip);
}
});
//start auth
authInstance.start();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0103 fail " + e.code);
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");
authInstance.off("tip");
done();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0103 fail " + e.code);
done();
}
})
})
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册