提交 41345099 编写于 作者: G gaoxi785

Add permission test cases 0216

Signed-off-by: Ngaoxi785 <gaoxi785@huawei.com>
上级 cbf22139
...@@ -17,8 +17,10 @@ group("osaccount_hap") { ...@@ -17,8 +17,10 @@ group("osaccount_hap") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"actsosaccountpermissiontest:osaccount_permission",
"actsosaccountsystemtest:ActsOsAccountSystemTest", "actsosaccountsystemtest:ActsOsAccountSystemTest",
"actsosaccountthirdpartytest:ActsOsAccountThirdPartyTest", "actsosaccountthirdpartytest:ActsOsAccountThirdPartyTest",
"sceneProject:osaccount_scene",
] ]
} }
} }
# 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")
group("osaccount_permission") {
testonly = true
if (is_standard_system) {
deps = [
"actsosaccountconstrainttest:ActsOsAccountConstraintTest",
"actsosaccountpermissioninteracttest:ActsOsAccountPermissionInteractTest",
"actsosaccountpermissionmanagetest:ActsOsAccountPermissionManageTest",
"actsosaccountpermissionnotest:ActsOsAccountPermissionNoTest",
]
}
}
# 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("ActsOsAccountConstraintTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountConstraintTest"
}
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": "200000",
"package": "com.example.actsosaccountconstrainttest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountConstraintTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountconstrainttest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountconstrainttest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountconstrainttest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
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;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountConstraintTest
</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 file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 20000;
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsOsAccountPermissionSystemNoTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature 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.
*/
import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const EACHTIMEOUT = 2000;
const ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR = 4587523;
const ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR = 4587529;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587571;
describe('ActsOsAccountPermissionTest', function () {
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {
continue;
}
}
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/*
* @tc.number : ActsOsAccountConstraint_0100
* @tc.name : createOsAccount callback
* @tc.desc : failed to create local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0100', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountPermission_0100 end====");
done();
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0200
* @tc.name : createOsAccount promise
* @tc.desc : failed to create local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0200', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], true);
try{
await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], false);
console.debug("====>ActsOsAccountConstraint_0200 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraint_0300
* @tc.name : removeOsAccount callback
* @tc.desc : failed to delete local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0300', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("aaa");
localId = info.localId;
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraint_0300 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0400
* @tc.name : removeOsAccount promise
* @tc.desc : failed to delete local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0400', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("aaa");
localId = info.localId;
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], true);
try{
await AccountManager.removeOsAccount(localId);
}
catch(err){
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], false);
console.debug("====>delete Constraint finish====");
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraint_0400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraint_0500
* @tc.name : activateOsAccount callback
* @tc.desc : switching local users fails after adding constraints
*/
it('ActsOsAccountConstraint_0500', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("aaa");
localId = info.localId;
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraint_0500 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0600
* @tc.name : activateOsAccount promise
* @tc.desc : switching local users fails after adding constraints
*/
it('ActsOsAccountConstraint_0600', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("aaa");
localId = info.localId;
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], true);
try{
await AccountManager.activateOsAccount(localId);
}
catch(err){
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], false);
console.debug("====>delete Constraint finish====");
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraint_0600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraint_0700
* @tc.name : setOsAccountProfilePhoto callback
* @tc.desc : failed to set profile photo for local user after adding constraint
*/
it('ActsOsAccountConstraint_0700', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var photo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMD"+
"AsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF"+
"BQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAALAAwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAA"+
"gEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV"+
"FVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5"+
"ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBU"+
"QdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEh"+
"YaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAP"+
"wD2v4p+OPEXwz+LN3rvivwn4nh0bV9dsP7Oe51nRLOC7EF0kpEkL6psLRLDGsVwFhZkm8ucFljc/R1z8SPiZqBjl0n4SXljb7cPD4g1iwiuA"+
"+TyBbTzoVxtwd+c5yBwT1/hv4W+F/CupalqVjpSy6rqQaO81PUJpL28niLFvJaednkMKljti3bEzhVArQ8H+CtE+H+iro/h7T49J0mORpIbC"+
"3ZvIt9xyUiQnbFGO0aAIMnAGaxlTcqPsnJrrdb7Jfpv1vt1eilap7Syfk/n/nt09NF//9k=";
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("aaa");
localId = info.localId;
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraint_0700 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0800
* @tc.name : setOsAccountProfilePhoto promise
* @tc.desc : failed to set profile photo for local user after adding constraint
*/
it('ActsOsAccountConstraint_0800', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var photo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMD"+
"AsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF"+
"BQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAALAAwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAA"+
"gEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV"+
"FVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5"+
"ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBU"+
"QdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEh"+
"YaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAP"+
"wD2v4p+OPEXwz+LN3rvivwn4nh0bV9dsP7Oe51nRLOC7EF0kpEkL6psLRLDGsVwFhZkm8ucFljc/R1z8SPiZqBjl0n4SXljb7cPD4g1iwiuA"+
"+TyBbTzoVxtwd+c5yBwT1/hv4W+F/CupalqVjpSy6rqQaO81PUJpL28niLFvJaednkMKljti3bEzhVArQ8H+CtE+H+iro/h7T49J0mORpIbC"+
"3ZvIt9xyUiQnbFGO0aAIMnAGaxlTcqPsnJrrdb7Jfpv1vt1eilap7Syfk/n/nt09NF//9k=";
var info = await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("aaa");
localId = info.localId;
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], true);
try{
await AccountManager.setOsAccountProfilePhoto(localId, photo);
}
catch(err){
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], false);
console.debug("====>delete Constraints finish====");
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraint_0800 end====");
done();
}
})
})
\ 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('./Constraint.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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsOsAccountPermissionInteractTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountPermissionInteractTest"
}
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": "60000",
"package": "com.example.actsosaccountpermissioninteracttest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountPermissionInteractTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountpermissioninteracttest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountpermissioninteracttest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountpermissioninteracttest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountPermissionInteractTest
</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 file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsAccountTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature 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.
*/
import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsOsAccountPermissionTest', function () {
/*
* @tc.number : ActsOsAccountPermissionInteract_0100
* @tc.name : isOsAccountActived callback
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0100', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionInteract_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0200
* @tc.name : isOsAccountActived promise
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0200', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isActived = await AccountManager.isOsAccountActived(100);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionInteract_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0300
* @tc.name : isOsAccountVerified callback
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0300', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(100, (err, isVerified)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(err.code).assertEqual(0);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionInteract_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0400
* @tc.name : isOsAccountVerified promise
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0400', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isVerified = await AccountManager.isOsAccountVerified(100);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionInteract_0400 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0500
* @tc.name : queryOsAccountById callback
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0500', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.queryOsAccountById(100, (err, data)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(data.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionInteract_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0600
* @tc.name : queryOsAccountById promise
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0600', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osAccountInfo = await AccountManager.queryOsAccountById(100);
console.debug("====>queryOsAccountById osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(osAccountInfo.localId).assertEqual(100);
expect(osAccountInfo.type.ADMIN).assertEqual(0);
var serialNumberStr = osAccountInfo.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(osAccountInfo.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionInteract_0600 end====");
done();
})
})
\ 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('./Interact.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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsOsAccountPermissionManageTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountPermissionManageTest"
}
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": "60000",
"package": "com.example.actsosaccountpermissionmanagetest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountPermissionManageTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountpermissionmanagetest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountpermissionmanagetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountpermissionmanagetest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountPermissionManageTest
</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 file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsAccountTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature 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('./Manage.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 osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsOsAccountPermissionTest', function () {
/*
* @tc.number : ActsOsAccountPermissionManage_0100
* @tc.name : isOsAccountActived callback
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0100', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionManage_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionManage_0200
* @tc.name : isOsAccountActived promise
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0200', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isActived = await AccountManager.isOsAccountActived(100);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionManage_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionManage_0300
* @tc.name : isOsAccountVerified callback
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0300', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(100, (err, isVerified)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(err.code).assertEqual(0);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionManage_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionManage_0400
* @tc.name : isOsAccountVerified promise
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0400', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isVerified = await AccountManager.isOsAccountVerified(100);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionManage_0400 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionManage_0500
* @tc.name : queryOsAccountById callback
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0500', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.queryOsAccountById(100, (err, data)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(data.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionManage_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionManage_0600
* @tc.name : queryOsAccountById promise
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0600', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osAccountInfo = await AccountManager.queryOsAccountById(100);
console.debug("====>queryOsAccountById osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(osAccountInfo.localId).assertEqual(100);
expect(osAccountInfo.type.ADMIN).assertEqual(0);
var serialNumberStr = osAccountInfo.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(osAccountInfo.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionManage_0600 end====");
done();
})
})
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsOsAccountPermissionNoTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountPermissionNoTest"
}
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": "150000",
"package": "com.example.actsosaccountpermissionnotest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountPermissionNoTest.hap",
"ActsOsAccountScenePermission"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountpermissionnotest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountpermissionnotest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountpermissionnotest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountPermissionNoTest
</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 file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsOsAccountPermissionSystemNoTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature 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('./Permission.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 osAccount from '@ohos.account.osAccount'
import commonevent from '@ohos.commonevent'
import featureAbility from '@ohos.ability.featureability'
import bundle from '@ohos.bundle'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var commonEventSubscribeInfo = {
events: ["osaccount_event_create_permission"]
}
var subscriber;
var receiveLocalId = -1;
const TIMEOUT = 2000;
const TIMEOUTSTART = 10000;
const OSACCOUNTMAXNUMBER = 999;
const ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR = 4587523;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587542;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_CONSTRAINT_ENABLE_ERROR = 4587543;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587545;
const ERR_OSACCOUNT_KIT_GET_CREATED_OS_ACCOUNT_COUNT_ERROR = 4587546;
const ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_ALL_CONSTRAINTS_ERROR = 4587550;
const ERR_OSACCOUNT_KIT_QUERY_CURRENT_OS_ACCOUNT_ERROR = 4587552;
const ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR = 4587553;
const ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR = 4587555;
const ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR = 4587563;
const ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_CONSTRAINTS_ERROR = 4587562;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587571;
const ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR = 4587529;
describe('ActsOsAccountPermissionTest', function () {
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {
continue;
}
}
beforeAll(async function (done) {
console.debug("====>subscriber start====");
function subscriberCallback(err, data){
console.debug("====>subscriberCallback data:" + JSON.stringify(data));
expect(data.event).assertEqual("osaccount_event_create_permission");
receiveLocalId = data.code;
commonevent.unsubscribe(subscriber, unSubscriberCallback);
}
function unSubscriberCallback(err){
console.debug("====>unsubscribe err:" + JSON.stringify(err));
}
commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){
subscriber = data;
commonevent.subscribe(subscriber, subscriberCallback);
console.debug("====>subscribe finish====")
});
sleep(TIMEOUT);
console.debug("====>startAbility start====");
await featureAbility.startAbility(
{
want:
{
deviceId: "",
bundleName: "com.example.actsosaccountscenepermission",
abilityName: "com.example.actsosaccountscenepermission.MainAbility",
action: "action1",
parameters:
{},
},
},
);
sleep(TIMEOUTSTART);
done();
});
afterAll(async function (done) {
console.debug("====>afterAll enter====");
function publishCallback(err){
console.debug("====>publish call back scene err:" + JSON.stringify(err));
}
commonevent.publish("osaccount_event_delete_permission", publishCallback);
sleep(TIMEOUT);
console.debug("====>afterAll finish====");
done();
});
/*
* @tc.number : ActsOsAccountPermission_0100
* @tc.name : setOsAccountConstraints callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0100', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.setOsAccountConstraints(100, ["constraint.cell.broadcasts.set"], true, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_CONSTRAINTS_ERROR);
console.debug("====>ActsOsAccountPermission_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_0200
* @tc.name : setOsAccountConstraints promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0200', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.setOsAccountConstraints(100, ["constraint.cell.broadcasts.set"], true);
}
catch(err){
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_CONSTRAINTS_ERROR);
console.debug("====>ActsOsAccountPermission_0200 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_0300
* @tc.name : createOsAccount callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0300', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err,info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_0400
* @tc.name : createOsAccount promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0400', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_0400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_0500
* @tc.name : queryOsAccountById callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0500', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.queryOsAccountById(100, (err)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR);
console.debug("====>ActsOsAccountPermission_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_0600
* @tc.name : queryOsAccountById promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0600', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.queryOsAccountById(100);
}
catch(err){
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR);
console.debug("====>ActsOsAccountPermission_0600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_0700
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : get the photo of the specified user does not meet the permission
*/
it('ActsOsAccountPermission_0700', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
AccountManager.getOsAccountProfilePhoto(receiveLocalId, (err)=>{
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountPermission_0700 end====");
done();
})
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_0800
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : get the photo of the specified user does not meet the permission
*/
it('ActsOsAccountPermission_0800', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
try{
await AccountManager.getOsAccountProfilePhoto(receiveLocalId);
}
catch(err){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountPermission_0800 end====");
done();
}
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_0900
* @tc.name : setOsAccountProfilePhoto callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_0900', 0, async function(done){
console.debug("====>ActsOsAccountPermission_0900 start====");
var AccountManager = osAccount.getAccountManager();
var photo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMD"+
"AsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF"+
"BQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAALAAwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAA"+
"gEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV"+
"FVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5"+
"ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBU"+
"QdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEh"+
"YaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAP"+
"wD2v4p+OPEXwz+LN3rvivwn4nh0bV9dsP7Oe51nRLOC7EF0kpEkL6psLRLDGsVwFhZkm8ucFljc/R1z8SPiZqBjl0n4SXljb7cPD4g1iwiuA"+
"+TyBbTzoVxtwd+c5yBwT1/hv4W+F/CupalqVjpSy6rqQaO81PUJpL28niLFvJaednkMKljti3bEzhVArQ8H+CtE+H+iro/h7T49J0mORpIbC"+
"3ZvIt9xyUiQnbFGO0aAIMnAGaxlTcqPsnJrrdb7Jfpv1vt1eilap7Syfk/n/nt09NF//9k=";
console.debug("====>get os AccountManager finish====");
AccountManager.setOsAccountProfilePhoto(100, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountPermission_0900 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_1000
* @tc.name : setOsAccountProfilePhoto promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1000', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1000 start====");
var AccountManager = osAccount.getAccountManager();
var photo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMD"+
"AsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF"+
"BQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAALAAwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAA"+
"gEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV"+
"FVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5"+
"ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBU"+
"QdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEh"+
"YaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAP"+
"wD2v4p+OPEXwz+LN3rvivwn4nh0bV9dsP7Oe51nRLOC7EF0kpEkL6psLRLDGsVwFhZkm8ucFljc/R1z8SPiZqBjl0n4SXljb7cPD4g1iwiuA"+
"+TyBbTzoVxtwd+c5yBwT1/hv4W+F/CupalqVjpSy6rqQaO81PUJpL28niLFvJaednkMKljti3bEzhVArQ8H+CtE+H+iro/h7T49J0mORpIbC"+
"3ZvIt9xyUiQnbFGO0aAIMnAGaxlTcqPsnJrrdb7Jfpv1vt1eilap7Syfk/n/nt09NF//9k=";
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.setOsAccountProfilePhoto(100, photo);
}
catch(err){
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountPermission_1000 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1100
* @tc.name : isOsAccountActived callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1100', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
AccountManager.isOsAccountActived(receiveLocalId, (err)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR);
console.debug("====>ActsOsAccountPermission_1100 end====");
done();
})
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1200
* @tc.name : isOsAccountActived promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1200', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
try{
await AccountManager.isOsAccountActived(receiveLocalId);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR);
console.debug("====>ActsOsAccountPermission_1200 end====");
done();
}
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1300
* @tc.name : isOsAccountConstraintEnable callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1300', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountConstraintEnable(100, "constraint.bluetooth", (err)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_CONSTRAINT_ENABLE_ERROR);
console.debug("====>ActsOsAccountPermission_1300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_1400
* @tc.name : isOsAccountConstraintEnable promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1400', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.isOsAccountConstraintEnable(100, "constraint.bluetooth");
}
catch(err){
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_CONSTRAINT_ENABLE_ERROR);
console.debug("====>ActsOsAccountPermission_1400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1500
* @tc.name : isOsAccountVerified callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1500', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != 0){
AccountManager.isOsAccountVerified(receiveLocalId, (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR);
console.debug("====>ActsOsAccountPermission_1500 end====");
done();
})
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1600
* @tc.name : isOsAccountVerified promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1600', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
try{
await AccountManager.isOsAccountVerified(receiveLocalId);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR);
console.debug("====>ActsOsAccountPermission_1600 end====");
done();
}
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1700
* @tc.name : getCreatedOsAccountsCount callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1700', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.getCreatedOsAccountsCount((err)=>{
console.debug("====>getCreatedOsAccountsCount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_CREATED_OS_ACCOUNT_COUNT_ERROR);
console.debug("====>ActsOsAccountPermission_1700 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_1800
* @tc.name : getCreatedOsAccountsCount promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1800', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.getCreatedOsAccountsCount();
}
catch(err){
console.debug("====>getCreatedOsAccountsCount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_CREATED_OS_ACCOUNT_COUNT_ERROR);
console.debug("====>ActsOsAccountPermission_1800 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_1900
* @tc.name : getOsAccountAllConstraints callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_1900', 0, async function(done){
console.debug("====>ActsOsAccountPermission_1900 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.getOsAccountAllConstraints(100, (err)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_ALL_CONSTRAINTS_ERROR);
console.debug("====>ActsOsAccountPermission_1900 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_2000
* @tc.name : getOsAccountAllConstraints promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2000', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2000 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.getOsAccountAllConstraints(100);
}
catch(err){
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_ALL_CONSTRAINTS_ERROR);
console.debug("====>ActsOsAccountPermission_2000 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_2100
* @tc.name : queryCurrentOsAccount callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2100', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.queryCurrentOsAccount((err)=>{
console.debug("====>queryCurrentOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_QUERY_CURRENT_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_2100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_2200
* @tc.name : queryCurrentOsAccount promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2200', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.queryCurrentOsAccount();
}
catch(err){
console.debug("====>queryCurrentOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_QUERY_CURRENT_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_2200 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_2300
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : get current user photo does not meet the permission
*/
it('ActsOsAccountPermission_2300', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.getOsAccountProfilePhoto(100, (err, photo)=>{
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
console.debug("====>getOsAccountProfilePhoto photo:" + photo);
expect(err.code).assertEqual(0);
expect(photo).assertEqual("");
console.debug("====>ActsOsAccountPermission_2300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_2400
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : get current user photo does not meet the permission
*/
it('ActsOsAccountPermission_2400', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var photo = await AccountManager.getOsAccountProfilePhoto(100);
}
catch(err){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getOsAccountProfilePhoto photo:" + photo);
expect(photo).assertEqual("");
console.debug("====>ActsOsAccountPermission_2400 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermission_2500
* @tc.name : isOsAccountActived callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2500', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermission_2500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_2600
* @tc.name : isOsAccountActived promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2600', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isActived = await AccountManager.isOsAccountActived(100);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermission_2600 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermission_2700
* @tc.name : isOsAccountVerified callback
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2700', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(100, (err, isVerified)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(err.code).assertEqual(0);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermission_2700 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_2800
* @tc.name : isOsAccountVerified promise
* @tc.desc : the application call interface does not meet the permissions
*/
it('ActsOsAccountPermission_2800', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isVerified = await AccountManager.isOsAccountVerified(100);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermission_2800 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermission_2900
* @tc.name : activateOsAccount callback
* @tc.desc : activate specified user does not meet the permission
*/
it('ActsOsAccountPermission_2900', 0, async function(done){
console.debug("====>ActsOsAccountPermission_2900 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
AccountManager.activateOsAccount(receiveLocalId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_2900 end====");
done();
})
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_3000
* @tc.name : activateOsAccount promise
* @tc.desc : activate specified user does not meet the permission
*/
it('ActsOsAccountPermission_3000', 0, async function(done){
console.debug("====>ActsOsAccountPermission_3000 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
try{
await AccountManager.activateOsAccount(receiveLocalId);
}
catch(err){
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_3000 end====");
done();
}
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_3100
* @tc.name : removeOsAccount callback
* @tc.desc : remove specified user does not meet the permission
*/
it('ActsOsAccountPermission_3100', 0, async function(done){
console.debug("====>ActsOsAccountPermission_3100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
AccountManager.removeOsAccount(receiveLocalId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_3100 end====");
done();
})
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_3200
* @tc.name : removeOsAccount promise
* @tc.desc : remove specified user does not meet the permission
*/
it('ActsOsAccountPermission_3200', 0, async function(done){
console.debug("====>ActsOsAccountPermission_3200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
if(receiveLocalId != -1){
try{
await AccountManager.removeOsAccount(receiveLocalId);
}
catch(err){
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
console.debug("====>ActsOsAccountPermission_3200 end====");
done();
}
}
else{
console.debug("====>user creation failed====");
expect().assertFail();
done();
}
})
/*
* @tc.number : ActsOsAccountPermission_3300
* @tc.name : isMultiOsAccountEnable callback
* @tc.desc : whether to support multiple user does not meet the permission
*/
it('ActsOsAccountPermission_3300', 0, async function(done){
console.debug("====>ActsOsAccountPermission_3300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isMultiOsAccountEnable((err, data)=>{
console.debug("====>isMultiOsAccountEnable err:" + JSON.stringify(err));
console.debug("====>isMultiOsAccountEnable data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(true);
console.debug("====>ActsOsAccountPermission_3300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_3400
* @tc.name : isMultiOsAccountEnable promise
* @tc.desc : whether to support multiple user does not meet the permission
*/
it('ActsOsAccountPermission_3400', 0, async function(done){
console.debug("====>ActsOsAccountPermission_3400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var data = await AccountManager.isMultiOsAccountEnable();
}
catch(err){
console.debug("====>catch isMultiOsAccountEnable err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isMultiOsAccountEnable data:" + JSON.stringify(data));
expect(data).assertEqual(true);
console.debug("====>ActsOsAccountPermission_3400 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermission_3500
* @tc.name : queryMaxOsAccountNumber callback
* @tc.desc : Query the maximum number of users does not meet the permission
*/
it('ActsOsAccountPermission_3500', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_3500 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryMaxOsAccountNumber((err, data)=>{
console.debug("====>queryMaxOsAccountNumber err:" + JSON.stringify(err));
console.debug("====>queryMaxOsAccountNumber data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(OSACCOUNTMAXNUMBER);
console.debug("====>ActsOsAccountPermission_3500 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountPermission_3600
* @tc.name : queryMaxOsAccountNumber promise
* @tc.desc : Query the maximum number of users does not meet the permission
*/
it('ActsOsAccountPermission_3600', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_3600 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var maxOsAccount = await osAccountManager.queryMaxOsAccountNumber();
console.debug("====>queryMaxOsAccountNumber:" + maxOsAccount);
expect(maxOsAccount).assertEqual(OSACCOUNTMAXNUMBER);
console.debug("====>ActsOsAccountPermission_3600 end====");
done();
});
/*
* @tc.number : ActsOsAccountPermission_3700
* @tc.name : getOsAccountLocalIdFromProcess callback
* @tc.desc : Verify that the user localId obtained from the current process uid does not meet the permission
*/
it('ActsOsAccountPermission_3700', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_3700 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.getOsAccountLocalIdFromProcess((err, localId)=>{
console.debug("====>get localId err: " + JSON.stringify(err));
console.debug("====>localId obtained by process:" + localId);
expect(err.code).assertEqual(0);
expect(localId).assertEqual(100);
console.debug("====>ActsOsAccountPermission_3700 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountPermission_3800
* @tc.name : getOsAccountLocalIdFromProcess promise
* @tc.desc : Verify that the user localId obtained from the current process uid does not meet the permission
*/
it('ActsOsAccountPermission_3800', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_3800 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.debug("====>localId obtained by process:" + localId);
expect(localId).assertEqual(100);
console.debug("====>ActsOsAccountPermission_3800 end====");
done();
});
/*
* @tc.number : ActsOsAccountPermission_3900
* @tc.name : getOsAccountLocalIdFromUid callback
* @tc.desc : Verify that the user localId is obtained by uid does not meet the permission
*/
it('ActsOsAccountPermission_3900', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_3900 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var bundleName = "com.example.actsosaccountpermissionnotest";
var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
var uid = bundleInfo.uid;
console.debug("====>obtained uid:" + uid);
osAccountManager.getOsAccountLocalIdFromUid(uid, (err, localId)=>{
console.debug("====>get localId err: " + JSON.stringify(err));
console.debug("====>localId obtained by uid:" + localId);
expect(err.code).assertEqual(0);
expect(localId).assertEqual(100);
console.debug("====>ActsOsAccountPermission_3900 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountPermission_4000
* @tc.name : getOsAccountLocalIdFromUid promise
* @tc.desc : Verify that the user localId is obtained by uid does not meet the permission
*/
it('ActsOsAccountPermission_4000', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_4000 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var bundleName = "com.example.actsosaccountpermissionnotest";
var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
var uid = bundleInfo.uid;
console.debug("====>obtained uid:" + uid);
var localId = await osAccountManager.getOsAccountLocalIdFromUid(uid);
console.debug("====>localId obtained by uid:" + localId);
expect(localId).assertEqual(100);
console.debug("====>ActsOsAccountPermission_4000 end====");
done();
});
/*
* @tc.number : ActsOsAccountPermission_4100
* @tc.name : getOsAccountTypeFromProcess callback
* @tc.desc : Verify that the user type obtained from the current process uid does not meet the permission
*/
it('ActsOsAccountPermission_4100', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_4100 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.getOsAccountTypeFromProcess((err, accountType)=>{
console.debug("====>get type err: " + JSON.stringify(err));
console.debug("====>type obtained by process:" + JSON.stringify(accountType));
expect(err.code).assertEqual(0);
expect(accountType.ADMIN).assertEqual(0);
console.debug("====>ActsOsAccountPermission_4100 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountPermission_4200
* @tc.name : getOsAccountTypeFromProcess promise
* @tc.desc : Verify that the user type obtained from the current process uid does not meet the permission
*/
it('ActsOsAccountPermission_4200', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_4200 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var accountType = await osAccountManager.getOsAccountTypeFromProcess();
console.debug("====>type obtained by process:" + JSON.stringify(accountType));
expect(accountType.ADMIN).assertEqual(0);
console.debug("====>ActsOsAccountPermission_4200 end====");
done();
});
/*
* @tc.number : ActsOsAccountPermission_4300
* @tc.name : getSerialNumberByOsAccountLocalId callback
* @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber does not meet the
* permission
*/
it('ActsOsAccountPermission_4300', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_4300 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.getSerialNumberByOsAccountLocalId(100, (err, serialNumber)=>{
console.debug("====>ger serialNumber err:" + JSON.stringify(err));
console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" );
expect(err.code).assertEqual(0);
var serialNumberStr = serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
console.debug("====>ger localId err:" + JSON.stringify(err));
console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber);
expect(err.code).assertEqual(0);
expect(localId).assertEqual(100);
console.debug("====>ActsOsAccountPermission_4300 end====");
done();
})
})
});
/*
* @tc.number : ActsOsAccountPermission_4400
* @tc.name : getSerialNumberByOsAccountLocalId promise
* @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber does not meet the
* permission
*/
it('ActsOsAccountPermission_4400', 0, async function (done) {
console.debug("====>ActsOsAccountPermission_4400 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(100);
console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" );
var serialNumberStr = serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
var localId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber);
console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber);
expect(localId).assertEqual(100);
console.debug("====>ActsOsAccountPermission_4400 end====");
done();
});
/*
* @tc.number : ActsOsAccountPermission_4500
* @tc.name : isTestOsAccount callback
* @tc.desc : check whether this OS account is a test OS account does not meet the permission
*/
it('ActsOsAccountPermission_4500', 0, async function(done){
console.debug("====>ActsOsAccountPermission_4500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isTestOsAccount((err, data)=>{
console.debug("====>isTestOsAccount err:" + JSON.stringify(err));
console.debug("====>isTestOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data).assertEqual(false);
console.debug("====>ActsOsAccountPermission_4500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermission_4600
* @tc.name : isTestOsAccount promise
* @tc.desc : check whether this OS account is a test OS account does not meet the permission
*/
it('ActsOsAccountPermission_4600', 0, async function(done){
console.debug("====>ActsOsAccountPermission_4600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var isTest = await AccountManager.isTestOsAccount();
expect(isTest).assertFalse();
console.debug("====>ActsOsAccountPermission_4600 end====");
done();
})
})
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "800000", "test-timeout": "1000000",
"package": "com.example.actsosaccountsystemtest", "package": "com.example.actsosaccountsystemtest",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -20,7 +20,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -20,7 +20,7 @@ describe('ActsOsAccountSystemTest', function () {
/* /*
* @tc.number : ActsOsAccountConstraints_0100 * @tc.number : ActsOsAccountConstraints_0100
* @tc.name : Constraints callback * @tc.name : Constraints callback
* @tc.desc : get 100 local user all constraints * @tc.desc : get constraints for users of the same type as 100 user
*/ */
it('ActsOsAccountConstraints_0100', 0, async function(done){ it('ActsOsAccountConstraints_0100', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0100 start===="); console.debug("====>ActsOsAccountConstraints_0100 start====");
...@@ -30,12 +30,18 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -30,12 +30,18 @@ describe('ActsOsAccountSystemTest', function () {
"constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared", "constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared",
"constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set", "constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth"]; "constraint.bluetooth"];
AccountManager.getOsAccountAllConstraints(100, (err, constraints)=>{ var localId;
AccountManager.createOsAccount("osAccountNameCreate", osAccount.OsAccountType.ADMIN, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err)); console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(constraints.length).assertEqual(adminConstraints.length); expect(constraints.length).assertEqual(adminConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<constraints.length; j++){ for(var j = 0; j<constraints.length; j++){
if(adminConstraints.indexOf(constraints[j]) == -1){ if(adminConstraints.indexOf(constraints[j]) == -1){
failed++; failed++;
...@@ -46,17 +52,20 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -46,17 +52,20 @@ describe('ActsOsAccountSystemTest', function () {
} }
console.debug("====>the number of constraints obtained:" + succeed); console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed); console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){ expect(failed).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
console.debug("====>ActsOsAccountConstraints_0100 end===="); console.debug("====>ActsOsAccountConstraints_0100 end====");
done(); done();
} })
})
}) })
}) })
/* /*
* @tc.number : ActsOsAccountConstraints_0200 * @tc.number : ActsOsAccountConstraints_0200
* @tc.name : Constraints promise * @tc.name : Constraints promise
* @tc.desc : get 100 local user all constraints * @tc.desc : get constraints for users of the same type as 100 user
*/ */
it('ActsOsAccountConstraints_0200', 0, async function(done){ it('ActsOsAccountConstraints_0200', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0200 start===="); console.debug("====>ActsOsAccountConstraints_0200 start====");
...@@ -66,10 +75,15 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -66,10 +75,15 @@ describe('ActsOsAccountSystemTest', function () {
"constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared", "constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared",
"constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set", "constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth"]; "constraint.bluetooth"];
var constraints = await AccountManager.getOsAccountAllConstraints(100); var localId;
var osAccountInfo = await AccountManager.createOsAccount("osAccountNameCreate", osAccount.OsAccountType.ADMIN);
console.debug("====>createOsAccount:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getAccountManager constraints:" + JSON.stringify(constraints)); console.debug("====>getAccountManager constraints:" + JSON.stringify(constraints));
expect(constraints.length).assertEqual(adminConstraints.length); expect(constraints.length).assertEqual(adminConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<constraints.length; j++){ for(var j = 0; j<constraints.length; j++){
if(adminConstraints.indexOf(constraints[j]) == -1){ if(adminConstraints.indexOf(constraints[j]) == -1){
failed++; failed++;
...@@ -80,10 +94,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -80,10 +94,8 @@ describe('ActsOsAccountSystemTest', function () {
} }
console.debug("====>the number of constraints obtained:" + succeed); console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed); console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){ expect(failed).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0100 end===="); await AccountManager.removeOsAccount(localId);
done();
}
console.debug("====>ActsOsAccountConstraints_0200 end===="); console.debug("====>ActsOsAccountConstraints_0200 end====");
done(); done();
}) })
...@@ -743,10 +755,10 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -743,10 +755,10 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set", var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set", "constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use", "constraint.credentials.set","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset", "constraint.vpn.set","constraint.date.time.set","constraint.tethering.config",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile", "constraint.network.reset","constraint.factory.reset","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set"]; "constraint.apps.verify.disable","constraint.cell.broadcasts.set"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{ AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err)); console.debug("====>createOsAccount err:" + JSON.stringify(err));
...@@ -759,7 +771,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -759,7 +771,8 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(allConstraints.length).assertEqual(normalConstraint.length); expect(allConstraints.length).assertEqual(normalConstraint.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(normalConstraint.indexOf(allConstraints[j]) == -1){ if(normalConstraint.indexOf(allConstraints[j]) == -1){
failed++; failed++;
...@@ -801,10 +814,10 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -801,10 +814,10 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set", var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set", "constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use", "constraint.credentials.set","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset", "constraint.vpn.set","constraint.date.time.set","constraint.tethering.config",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile", "constraint.network.reset","constraint.factory.reset","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set"]; "constraint.apps.verify.disable","constraint.cell.broadcasts.set"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL); var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info)); console.debug("====>createOsAccount info:" + JSON.stringify(info));
...@@ -813,7 +826,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -813,7 +826,8 @@ describe('ActsOsAccountSystemTest', function () {
var allConstraints = await AccountManager.getOsAccountAllConstraints(localId); var allConstraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(allConstraints.length).assertEqual(normalConstraint.length); expect(allConstraints.length).assertEqual(normalConstraint.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(normalConstraint.indexOf(allConstraints[j]) == -1){ if(normalConstraint.indexOf(allConstraints[j]) == -1){
failed++; failed++;
...@@ -847,10 +861,9 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -847,10 +861,9 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset", var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset",
"constraint.os.account.create","constraint.add.managed.profile","constraint.apps.verify.disable", "constraint.add.managed.profile","constraint.apps.verify.disable","constraint.cell.broadcasts.set",
"constraint.cell.broadcasts.set","constraint.mobile.networks.set","constraint.control.apps", "constraint.mobile.networks.set","constraint.control.apps","constraint.physical.media","constraint.microphone",
"constraint.physical.media","constraint.microphone","constraint.microphone.unmute","constraint.volume.adjust", "constraint.microphone.unmute","constraint.volume.adjust","constraint.calls.outgoing","constraint.sms.use"];
"constraint.calls.outgoing","constraint.sms.use"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.GUEST, (err, data)=>{ AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.GUEST, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err)); console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data)); console.debug("====>createOsAccount data:" + JSON.stringify(data));
...@@ -862,7 +875,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -862,7 +875,8 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(allConstraints.length).assertEqual(guestConstraints.length); expect(allConstraints.length).assertEqual(guestConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(guestConstraints.indexOf(allConstraints[j]) == -1){ if(guestConstraints.indexOf(allConstraints[j]) == -1){
failed++; failed++;
...@@ -904,10 +918,9 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -904,10 +918,9 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset", var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset",
"constraint.os.account.create","constraint.add.managed.profile","constraint.apps.verify.disable", "constraint.add.managed.profile","constraint.apps.verify.disable","constraint.cell.broadcasts.set",
"constraint.cell.broadcasts.set","constraint.mobile.networks.set","constraint.control.apps", "constraint.mobile.networks.set","constraint.control.apps","constraint.physical.media","constraint.microphone",
"constraint.physical.media","constraint.microphone","constraint.microphone.unmute","constraint.volume.adjust", "constraint.microphone.unmute","constraint.volume.adjust","constraint.calls.outgoing","constraint.sms.use"];
"constraint.calls.outgoing","constraint.sms.use"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.GUEST); var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.GUEST);
console.debug("====>createOsAccount info:" + JSON.stringify(info)); console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP"); expect(info.localName).assertEqual("NameConstraintsP");
...@@ -915,7 +928,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -915,7 +928,8 @@ describe('ActsOsAccountSystemTest', function () {
var allConstraints = await AccountManager.getOsAccountAllConstraints(localId); var allConstraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(allConstraints.length).assertEqual(guestConstraints.length); expect(allConstraints.length).assertEqual(guestConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(guestConstraints.indexOf(allConstraints[j]) == -1){ if(guestConstraints.indexOf(allConstraints[j]) == -1){
failed++; failed++;
......
# 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")
group("osaccount_scene") {
testonly = true
if (is_standard_system) {
deps = [ "actsosaccountscenepermission:ActsOsAccountScenePermission" ]
}
}
# 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_hap("ActsOsAccountScenePermission") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsOsAccountScenePermission"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
}
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",
}
{
"app": {
"bundleName": "com.example.actsosaccountscenepermission",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountscenepermission",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountscenepermission.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
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;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountScenePermission
</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 osaccount from '@ohos.account.osAccount'
import commonevent from '@ohos.commonevent'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
},
onInit() {
this.title = "";
},
onShow() {
var createIocalId;
var commonEventSubscribeInfo = {
events: ["osaccount_event_delete_permission"]
}
var subscriber;
function subscriberCallback(err, data){
console.debug("====>subscriberCallback data:" + JSON.stringify(data));
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.removeOsAccount(createIocalId);
commonevent.unsubscribe(subscriber, unSubscriberCallback);
}
function unSubscriberCallback(err){
console.debug("====>unsubscribe err:" + JSON.stringify(err));
}
commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){
subscriber = data;
commonevent.subscribe(subscriber, subscriberCallback);
console.debug("====>subscribe finish====")
});
async function sceneCreatOsAccount(){
console.debug("====>scene start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var osAccountInfo = await osAccountManager.createOsAccount("osAccountName", osaccount.OsAccountType.NORMAL);
createIocalId = osAccountInfo.localId;
function publishCallback(err){
console.debug("====>publish call back scene err:" + JSON.stringify(err));
}
var commonEventPublishData = {
code: createIocalId,
data: "SUCCESS"
}
commonevent.publish("osaccount_event_create_permission", commonEventPublishData, publishCallback);
}
sceneCreatOsAccount();
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsOsAccountScenePermission"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册