未验证 提交 72a2fbb0 编写于 作者: O openharmony_ci 提交者: Gitee

!1657 Update account xts case and fix appaccount bug

Merge pull request !1657 from 高曦/master_osaccount_0121
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "3000000",
"test-timeout": "1500000",
"package": "com.example.actsaccountpressure",
"shell-timeout": "60000"
},
......
......@@ -189,7 +189,7 @@ describe('ActsAccountNoPermission', function () {
console.debug("====>ActsAccountNoPermission_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsaccountnopermission";
var selfBundle = "com.example.actsaccounttest";
appAccountManager.addAccount("getAll_callback_nopermission", (err)=>{
console.debug("====>add account 0700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
......@@ -215,7 +215,7 @@ describe('ActsAccountNoPermission', function () {
console.debug("====>ActsAccountNoPermission_0800 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsaccountnopermission";
var selfBundle = "com.example.actsaccounttest";
console.debug("====>add account 0800 start====");
await appAccountManager.addAccount("getAll_promise_nopermission");
console.debug("====>getAllAccounts 0800 start====");
......
......@@ -655,6 +655,8 @@ describe('ActsAccountChangeOnOff', async function () {
expect(data).assertEqual("com.example.actsaccounttest");
}
twiceSign = twiceSign + 1;
setTimeout(async function (){
console.debug("====>off start====");
appAccountManager.off('change', function (){
console.debug("====>off ActsAccountChangeOnOff_1000 finish====");
appAccountManager.deleteAccount("onoff_twice", (err)=>{
......@@ -665,6 +667,7 @@ describe('ActsAccountChangeOnOff', async function () {
done();
});
});
}, 1000)
}
try{
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnFirstCallback);
......
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"test-timeout": "800000",
"package": "com.example.actsosaccountsystemtest",
"shell-timeout": "60000"
},
......
......@@ -16,7 +16,7 @@ import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587571;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587574;
describe('ActsOsAccountSystemTest', function () {
/*
......
/*
* 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('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountConstraints_0100
* @tc.name : Constraints callback
* @tc.desc : get 100 local user all constraints
*/
it('ActsOsAccountConstraints_0100', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var adminConstraints = ["constraint.wifi","constraint.wifi.set","constraint.locale.set",
"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.bluetooth"];
AccountManager.getOsAccountAllConstraints(100, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
expect(constraints.length).assertEqual(adminConstraints.length);
var succeed = 0, failed = 0;
for(var j = 0; j<constraints.length; j++){
if(adminConstraints.indexOf(constraints[j]) == -1){
failed++;
}
else{
succeed++;
}
}
console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){
console.debug("====>ActsOsAccountConstraints_0100 end====");
done();
}
})
})
/*
* @tc.number : ActsOsAccountConstraints_0200
* @tc.name : Constraints promise
* @tc.desc : get 100 local user all constraints
*/
it('ActsOsAccountConstraints_0200', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var adminConstraints = ["constraint.wifi","constraint.wifi.set","constraint.locale.set",
"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.bluetooth"];
var constraints = await AccountManager.getOsAccountAllConstraints(100);
console.debug("====>getAccountManager constraints:" + JSON.stringify(constraints));
expect(constraints.length).assertEqual(adminConstraints.length);
var succeed = 0, failed = 0;
for(var j = 0; j<constraints.length; j++){
if(adminConstraints.indexOf(constraints[j]) == -1){
failed++;
}
else{
succeed++;
}
}
console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){
console.debug("====>ActsOsAccountConstraints_0100 end====");
done();
}
console.debug("====>ActsOsAccountConstraints_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountConstraints_0300
* @tc.name : Constraints callback
* @tc.desc : get 0 local user all constraints
*/
it('ActsOsAccountConstraints_0300', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
AccountManager.getOsAccountAllConstraints(0, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
expect(constraints.length).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountConstraints_0400
* @tc.name : Constraints promise
* @tc.desc : get 0 local user all constraints
*/
it('ActsOsAccountConstraints_0400', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var constraints = await AccountManager.getOsAccountAllConstraints(0);
console.debug("====>getAccountManager constraints:" +JSON.stringify(constraints));
expect(constraints.length).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0400 end====");
done();
})
/*
* @tc.number : ActsOsAccountConstraints_0500
* @tc.name : Constraints callback
* @tc.desc : create and add constraints
*/
it('ActsOsAccountConstraints_0500', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.isOsAccountConstraintEnable(localId, "constraint.location.set", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.setOsAccountConstraints(localId, ["constraint.location.set"], true, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.isOsAccountConstraintEnable(localId, "constraint.location.set", (err, constraint)=>{
console.debug("====>twice isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>twice isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertTrue();
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0500 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_0600
* @tc.name : Constraints promise
* @tc.desc : create and add constraints
*/
it('ActsOsAccountConstraints_0600', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var constraint = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.location.set");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
try{
await AccountManager.setOsAccountConstraints(localId, ["constraint.location.set"], true);
}
catch(err){
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect().assertFail();
done();
}
var constraintTwice = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.location.set");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraintTwice);
expect(constraintTwice).assertTrue();
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_0600 end====");
done();
})
/*
* @tc.number : ActsOsAccountConstraints_0700
* @tc.name : Constraints callback
* @tc.desc : create and delete constraints
*/
it('ActsOsAccountConstraints_0700', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.isOsAccountConstraintEnable(localId, "constraint.bluetooth.set", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertTrue();
AccountManager.setOsAccountConstraints(localId, ["constraint.bluetooth.set"], false, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.isOsAccountConstraintEnable(localId, "constraint.bluetooth.set", (err, constraint)=>{
console.debug("====>twice isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>twice isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0700 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_0800
* @tc.name : Constraints promise
* @tc.desc : create and delete constraints
*/
it('ActsOsAccountConstraints_0800', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var constraint = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.bluetooth.set");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertTrue();
await AccountManager.setOsAccountConstraints(localId, ["constraint.bluetooth.set"], false);
var constraintTwice = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.bluetooth.set");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraintTwice);
expect(constraintTwice).assertFalse();
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_0800 end====");
done();
})
/*
* @tc.number : ActsOsAccountConstraints_0900
* @tc.name : Constraints callback
* @tc.desc : add the same constraints consecutively
*/
it('ActsOsAccountConstraints_0900', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0900 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.isOsAccountConstraintEnable(localId, "constraint.location.set", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.setOsAccountConstraints(localId, ["constraint.location.set"], true, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints :" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
let result = constraints.includes("constraint.location.set");
expect(result).assertTrue();
AccountManager.setOsAccountConstraints(localId, ["constraint.location.set"], true, (err)=>{
console.debug("====>twice setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>twice getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>twice getOsAccountAllConstraints :" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
let result = constraints.includes("constraint.location.set");
expect(result).assertTrue();
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0900 end====");
done();
})
})
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_1000
* @tc.name : Constraints promise
* @tc.desc : add the same constraints consecutively
*/
it('ActsOsAccountConstraints_1000', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1000 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var constraint = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.location.set");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
await AccountManager.setOsAccountConstraints(localId, ["constraint.location.set"], true);
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
let result = constraints.includes("constraint.location.set");
expect(result).assertTrue();
await AccountManager.setOsAccountConstraints(localId, ["constraint.location.set"], true);
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>twice getOsAccountAllConstraints:" + JSON.stringify(constraints));
let result1 = constraints.includes("constraint.location.set");
expect(result1).assertTrue();
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_1000 end====");
done();
})
/*
* @tc.number : ActsOsAccountConstraints_1100
* @tc.name : Constraints callback
* @tc.desc : delete the same constraints consecutively
*/
it('ActsOsAccountConstraints_1100', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.isOsAccountConstraintEnable(localId, "constraint.network.reset", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertTrue();
AccountManager.setOsAccountConstraints(localId, ["constraint.network.reset"], false, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints :" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
var number = 0;
for(var i=0; i < constraints.length; i++){
if(constraints[i] != "constraint.network.reset"){
number++;
}
}
if(number == constraints.length-1){
expect().assertTrue();
}
AccountManager.setOsAccountConstraints(localId, ["constraint.network.reset"], false, (err)=>{
console.debug("====>twice setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>twice getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>twice getOsAccountAllConstraints :" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
var numberTwo = 0;
for(var i=0; i < constraints.length; i++){
if(constraints[i] != "constraint.network.reset"){
numberTwo++;
}
}
if(numberTwo == constraints.length-1){
expect().assertTrue();
}
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_1100 end====");
done();
})
})
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_1200
* @tc.name : Constraints promise
* @tc.desc : delete the same constraints consecutively
*/
it('ActsOsAccountConstraints_1200', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var constraint = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.network.reset");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertTrue();
await AccountManager.setOsAccountConstraints(localId, ["constraint.network.reset"], false);
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
var number = 0;
for(var i=0; i < constraints.length; i++){
if(constraints[i] != "constraint.network.reset"){
number++;
}
}
if(number == constraints.length-1){
expect().assertTrue();
}
await AccountManager.setOsAccountConstraints(localId, ["constraint.network.reset"], false);
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
var numberTwo = 0;
for(var i=0; i < constraints.length; i++){
if(constraints[i] != "constraint.network.reset"){
numberTwo++;
}
}
if(numberTwo == constraints.length-1){
expect().assertTrue();
}
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_1200 end====");
done();
})
/*
* @tc.number : ActsOsAccountConstraints_1300
* @tc.name : Constraints callback
* @tc.desc : to add a constraint not in the constraint list
*/
it('ActsOsAccountConstraints_1300', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
AccountManager.isOsAccountConstraintEnable(100, "constraint.undefined", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.setOsAccountConstraints(100, ["constraint.undefined"], true, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0 ).assertTrue();
console.debug("====>ActsOsAccountConstraints_1300 end====");
done();
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_1400
* @tc.name : Constraints promise
* @tc.desc : to add a constraint not in the constraint list
*/
it('ActsOsAccountConstraints_1400', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var constraint = await AccountManager.isOsAccountConstraintEnable(100, "constraint.undefined");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
try{
await AccountManager.setOsAccountConstraints(100, ["constraint.undefined"], true);
}
catch(err){
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountConstraints_1400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_1500
* @tc.name : Constraints callback
* @tc.desc : to add constraint is empty string and not in constraint list
*/
it('ActsOsAccountConstraints_1500', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
AccountManager.isOsAccountConstraintEnable(100, "", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.setOsAccountConstraints(100, [""], true, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0 ).assertTrue();
console.debug("====>ActsOsAccountConstraints_1500 end====");
done();
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_1600
* @tc.name : Constraints promise
* @tc.desc : to add constraint is empty string and not in constraint list
*/
it('ActsOsAccountConstraints_1600', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var constraint = await AccountManager.isOsAccountConstraintEnable(100, "");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
try{
await AccountManager.setOsAccountConstraints(100, [""], true);
}
catch(err){
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountConstraints_1600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_1700
* @tc.name : Constraints callback
* @tc.desc : to delete a constraint not in the constraint list
*/
it('ActsOsAccountConstraints_1700', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
AccountManager.isOsAccountConstraintEnable(100, "constraint.undefined", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.setOsAccountConstraints(100, ["constraint.undefined"], false, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0 ).assertTrue();
console.debug("====>ActsOsAccountConstraints_1700 end====");
done();
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_1800
* @tc.name : Constraints promise
* @tc.desc : to delete a constraint not in the constraint list
*/
it('ActsOsAccountConstraints_1800', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var constraint = await AccountManager.isOsAccountConstraintEnable(100, "constraint.undefined");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
try{
await AccountManager.setOsAccountConstraints(100, ["constraint.undefined"], false);
}
catch(err){
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountConstraints_1800 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_1900
* @tc.name : Constraints callback
* @tc.desc : add constraints, whether in the constraint list or not in the constraint list
*/
it('ActsOsAccountConstraints_1900', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_1900 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.isOsAccountConstraintEnable(localId, "constraint.device.unmute", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertFalse();
AccountManager.setOsAccountConstraints(localId, ["constraint.device.unmute",
"constraint.undefined"], true, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_1900 end====");
done();
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_2000
* @tc.name : Constraints promise
* @tc.desc : add constraints, whether in the constraint list or not in the constraint list
*/
it('ActsOsAccountConstraints_2000', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2000 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var constraint = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.device.unmute");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
try{
await AccountManager.setOsAccountConstraints(localId, ["constraint.device.unmute",
"constraint.undefined"], true);
}
catch(err){
console.debug("====>setOsAccountConstraints:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_2000 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_2100
* @tc.name : Constraints callback
* @tc.desc : delete constraints, whether in the constraint list or not in the constraint list
*/
it('ActsOsAccountConstraints_2100', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.isOsAccountConstraintEnable(localId, "constraint.cell.broadcasts.set", (err, constraint)=>{
console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.debug("====>isOsAccountConstraintEnable constraint:" + constraint);
expect(err.code).assertEqual(0);
expect(constraint).assertTrue();
AccountManager.setOsAccountConstraints(localId, ["constraint.cell.broadcasts.set",
"constraint.undefined"], false, (err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_2100 end====");
done();
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_2200
* @tc.name : Constraints promise
* @tc.desc : delete constraints, whether in the constraint list or not in the constraint list
*/
it('ActsOsAccountConstraints_2200', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var constraint = await AccountManager.isOsAccountConstraintEnable(localId, "constraint.device.unmute");
console.debug("====>isOsAccountConstraintEnable constraints:" + constraint);
expect(constraint).assertFalse();
try{
await AccountManager.setOsAccountConstraints(localId, ["constraint.device.unmute",
"constraint.undefined"], true);
}
catch(err){
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_2200 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_2300
* @tc.name : Constraints callback
* @tc.desc : create a local user of type normal and get all constraints
*/
it('ActsOsAccountConstraints_2300', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.getOsAccountAllConstraints(localId, (err, allConstraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(err.code).assertEqual(0);
expect(allConstraints.length).assertEqual(normalConstraint.length);
var succeed = 0, failed = 0;
for(var j = 0; j<allConstraints.length; j++){
if(normalConstraint.indexOf(allConstraints[j]) == -1){
failed++;
}
else{
succeed++;
}
}
console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_2300 end====");
done();
})
}else{
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
expect().assertFail();
console.debug("====>ActsOsAccountConstraints_2300 end====");
done();
})
}
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_2400
* @tc.name : Constraints promise
* @tc.desc : create a local user of type normal and get all constraints
*/
it('ActsOsAccountConstraints_2400', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var allConstraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(allConstraints.length).assertEqual(normalConstraint.length);
var succeed = 0, failed = 0;
for(var j = 0; j<allConstraints.length; j++){
if(normalConstraint.indexOf(allConstraints[j]) == -1){
failed++;
}
else{
succeed++;
}
}
console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_2400 end====");
done();
}else{
await AccountManager.removeOsAccount(localId);
expect().assertFail();
console.debug("====>ActsOsAccountConstraints_2400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_2500
* @tc.name : Constraints callback
* @tc.desc : create a local user of type guest and get all constraints
*/
it('ActsOsAccountConstraints_2500', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset",
"constraint.os.account.create","constraint.add.managed.profile","constraint.apps.verify.disable",
"constraint.cell.broadcasts.set","constraint.mobile.networks.set","constraint.control.apps",
"constraint.physical.media","constraint.microphone","constraint.microphone.unmute","constraint.volume.adjust",
"constraint.calls.outgoing","constraint.sms.use"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.GUEST, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.getOsAccountAllConstraints(localId, (err, allConstraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(err.code).assertEqual(0);
expect(allConstraints.length).assertEqual(guestConstraints.length);
var succeed = 0, failed = 0;
for(var j = 0; j<allConstraints.length; j++){
if(guestConstraints.indexOf(allConstraints[j]) == -1){
failed++;
}
else{
succeed++;
}
}
console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_2500 end====");
done();
})
}else{
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
expect().assertFail();
console.debug("====>ActsOsAccountConstraints_2500 end====");
done();
})
}
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_2600
* @tc.name : Constraints promise
* @tc.desc : create a local user of type guest and get all constraints
*/
it('ActsOsAccountConstraints_2600', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset",
"constraint.os.account.create","constraint.add.managed.profile","constraint.apps.verify.disable",
"constraint.cell.broadcasts.set","constraint.mobile.networks.set","constraint.control.apps",
"constraint.physical.media","constraint.microphone","constraint.microphone.unmute","constraint.volume.adjust",
"constraint.calls.outgoing","constraint.sms.use"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.GUEST);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
var allConstraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(allConstraints.length).assertEqual(guestConstraints.length);
var succeed = 0, failed = 0;
for(var j = 0; j<allConstraints.length; j++){
if(guestConstraints.indexOf(allConstraints[j]) == -1){
failed++;
}
else{
succeed++;
}
}
console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_2600 end====");
done();
}else{
await AccountManager.removeOsAccount(localId);
expect().assertFail();
console.debug("====>ActsOsAccountConstraints_2600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_2700
* @tc.name : Constraints callback
* @tc.desc : get all constrain information of non-existing local users
*/
it('ActsOsAccountConstraints_2700', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var nonExistentLocalId = 1000;
AccountManager.getOsAccountAllConstraints(nonExistentLocalId, (err)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountConstraints_2700 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountConstraints_2800
* @tc.name : Constraints promise
* @tc.desc : get all constrain information of non-existing local users
*/
it('ActsOsAccountConstraints_2800', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var nonExistentLocalId = 1000;
try{
await AccountManager.getOsAccountAllConstraints(nonExistentLocalId);
}
catch(err){
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountConstraints_2800 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraints_2900
* @tc.name : Constraints callback
* @tc.desc : create a normal type local user,add all constraints and delete two constraints
*/
it('ActsOsAccountConstraints_2900', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_2900 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var addallConstraints = ["constraint.wifi","constraint.wifi.set","constraint.locale.set",
"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.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set","constraint.mobile.networks.set",
"constraint.control.apps","constraint.physical.media","constraint.microphone","constraint.microphone.unmute",
"constraint.volume.adjust","constraint.calls.outgoing","constraint.sms.use","constraint.fun",
"constraint.windows.create","constraint.system.error.dialogs","constraint.cross.profile.copy.paste",
"constraint.beam.outgoing","constraint.wallpaper","constraint.safe.boot",
"constraint.parent.profile.app.linking","constraint.audio.record","constraint.camera.use",
"constraint.os.account.background.run","constraint.data.roam","constraint.os.account.set.icon",
"constraint.wallpaper.set","constraint.oem.unlock","constraint.device.unmute","constraint.password.unified",
"constraint.autofill","constraint.content.capture","constraint.content.suggestions",
"constraint.os.account.start","constraint.location.set","constraint.airplane.mode.set",
"constraint.brightness.set","constraint.share.into.profile","constraint.ambient.display",
"constraint.screen.timeout.set","constraint.print","constraint.private.dns.set"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("NameConstraintsC");
localId = data.localId;
AccountManager.setOsAccountConstraints(localId, addallConstraints, true,(err)=>{
console.debug("====>setOsAccountConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
expect(constraints.length).assertEqual(63);
AccountManager.setOsAccountConstraints(localId, ["constraint.print",
"constraint.private.dns.set"], false, (err)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
expect(err.code).assertEqual(0);
expect(constraints.length).assertEqual(61);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_2900 end====");
done();
})
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraints_3000
* @tc.name : Constraints promise
* @tc.desc : create a normal type local user,add all constraints and delete two constraints
*/
it('ActsOsAccountConstraints_3000', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_3000 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var addallConstraints = ["constraint.wifi","constraint.wifi.set","constraint.locale.set",
"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.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set","constraint.mobile.networks.set",
"constraint.control.apps","constraint.physical.media","constraint.microphone","constraint.microphone.unmute",
"constraint.volume.adjust","constraint.calls.outgoing","constraint.sms.use","constraint.fun",
"constraint.windows.create","constraint.system.error.dialogs","constraint.cross.profile.copy.paste",
"constraint.beam.outgoing","constraint.wallpaper","constraint.safe.boot",
"constraint.parent.profile.app.linking","constraint.audio.record","constraint.camera.use",
"constraint.os.account.background.run","constraint.data.roam","constraint.os.account.set.icon",
"constraint.wallpaper.set","constraint.oem.unlock","constraint.device.unmute","constraint.password.unified",
"constraint.autofill","constraint.content.capture","constraint.content.suggestions",
"constraint.os.account.start","constraint.location.set","constraint.airplane.mode.set",
"constraint.brightness.set","constraint.share.into.profile","constraint.ambient.display",
"constraint.screen.timeout.set","constraint.print","constraint.private.dns.set"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP");
localId = info.localId;
await AccountManager.setOsAccountConstraints(localId, addallConstraints, true);
console.debug("====>add allConstraints finish====");
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getAccountManager constraints:" +JSON.stringify(constraints));
expect(constraints.length).assertEqual(63);
await AccountManager.setOsAccountConstraints(localId, ["constraint.print",
"constraint.private.dns.set"], false);
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getAccountManager constraints:" +JSON.stringify(constraints));
expect(constraints.length).assertEqual(61);
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraints_3000 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 osaccount from '@ohos.account.osaccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const ERR_OS_ACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR = 4587526;
const ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR = 4587532;
const ERR_OSACCOUNT_KIT_LOCAL_NAME_EMPTY_ERROR = 4587581;
const ERR_OSACCOUNT_KIT_CANNOT_DELETE_ID_ERROR = 4587584;
describe('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountCreate_0100
* @tc.name : createOsAccount callback
* @tc.desc : Authenticate to create a local user of type normal
*/
it('ActsOsAccountCreate_0100', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
osAccountManager.createOsAccount("osAccountNameCreateA", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
createIdStr = createIocalId.toString();
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameCreateA");
osAccountManager.queryAllCreatedOsAccounts((err, data)=>{
console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertTrue();
if (dataMap.has(createIdStr)) {
let OsAccountInfo = dataMap.get(createIdStr);
console.debug("====>query all local users containing: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("osAccountNameCreateA");
expect(OsAccountInfo.type.NORMAL).assertEqual(1);
expect(OsAccountInfo.isActived).assertFalse();
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountCreate_0100 end====");
done();
})
}
})
});
});
/*
* @tc.number : ActsOsAccountCreate_0200
* @tc.name : createOsAccount promise
* @tc.desc : Authenticate to create a local user of type normal
*/
it('ActsOsAccountCreate_0200', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
var osAccount = await osAccountManager.createOsAccount("osAccountNameCreateB", osaccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccount));
createIocalId = osAccount.localId;
createIdStr = createIocalId.toString();
expect(osAccount.localName).assertEqual("osAccountNameCreateB");
var data = await osAccountManager.queryAllCreatedOsAccounts();
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertTrue();
if (dataMap.has(createIdStr)) {
let OsAccountInfo = dataMap.get(createIdStr);
console.debug("====>query all local users containing: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("osAccountNameCreateB");
expect(OsAccountInfo.type.NORMAL).assertEqual(1);
expect(OsAccountInfo.isActived).assertFalse();
}
await osAccountManager.removeOsAccount(createIocalId);
console.debug("====>ActsOsAccountCreate_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountCreate_0300
* @tc.name : createOsAccount callback
* @tc.desc : Authenticate to create a local user of type guest
*/
it('ActsOsAccountCreate_0300', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
osAccountManager.createOsAccount("osAccountNameCreateC", osaccount.OsAccountType.GUEST, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
createIdStr = createIocalId.toString();
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameCreateC");
osAccountManager.queryAllCreatedOsAccounts((err, data)=>{
console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertTrue();
if (dataMap.has(createIdStr)) {
let OsAccountInfo = dataMap.get(createIdStr);
console.debug("====>query all local users containing: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("osAccountNameCreateC");
expect(OsAccountInfo.type.GUEST).assertEqual(2);
expect(OsAccountInfo.isActived).assertFalse();
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountCreate_0300 end====");
done();
})
}
})
});
});
/*
* @tc.number : ActsOsAccountCreate_0400
* @tc.name : createOsAccount promise
* @tc.desc : Authenticate to create a local user of type guest
*/
it('ActsOsAccountCreate_0400', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
var osAccount = await osAccountManager.createOsAccount("osAccountNameCreateD", osaccount.OsAccountType.GUEST);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccount));
createIocalId = osAccount.localId;
createIdStr = createIocalId.toString();
expect(osAccount.localName).assertEqual("osAccountNameCreateD");
var data = await osAccountManager.queryAllCreatedOsAccounts();
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertTrue();
if (dataMap.has(createIdStr)) {
let OsAccountInfo = dataMap.get(createIdStr);
console.debug("====>query all local users containing: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("osAccountNameCreateD");
expect(OsAccountInfo.type.GUEST).assertEqual(2);
expect(OsAccountInfo.isActived).assertFalse();
}
await osAccountManager.removeOsAccount(createIocalId);
console.debug("====>ActsOsAccountCreate_0400 end====");
done();
});
/*
* @tc.number : ActsOsAccountCreate_0500
* @tc.name : createOsAccount callback
* @tc.desc : Authenticate to create a local user of type admin
*/
it('ActsOsAccountCreate_0500', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
osAccountManager.createOsAccount("osAccountNameCreateE", osaccount.OsAccountType.ADMIN, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
createIdStr = createIocalId.toString();
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameCreateE");
osAccountManager.queryAllCreatedOsAccounts((err, data)=>{
console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertTrue();
if (dataMap.has(createIdStr)) {
let OsAccountInfo = dataMap.get(createIdStr);
console.debug("====>query all local users containing: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("osAccountNameCreateE");
expect(OsAccountInfo.type.ADMIN).assertEqual(0);
expect(OsAccountInfo.isActived).assertFalse();
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountCreate_0500 end====");
done();
})
}
})
});
});
/*
* @tc.number : ActsOsAccountCreate_0600
* @tc.name : createOsAccount promise
* @tc.desc : Authenticate to create a local user of type admin
*/
it('ActsOsAccountCreate_0600', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
var osAccount = await osAccountManager.createOsAccount("osAccountNameCreateF", osaccount.OsAccountType.ADMIN);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccount));
createIocalId = osAccount.localId;
createIdStr = createIocalId.toString();
expect(osAccount.localName).assertEqual("osAccountNameCreateF");
var data = await osAccountManager.queryAllCreatedOsAccounts();
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertTrue();
if (dataMap.has(createIdStr)) {
let OsAccountInfo = dataMap.get(createIdStr);
console.debug("====>query all local users containing: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("osAccountNameCreateF");
expect(OsAccountInfo.type.ADMIN).assertEqual(0);
expect(OsAccountInfo.isActived).assertFalse();
}
await osAccountManager.removeOsAccount(createIocalId);
console.debug("====>ActsOsAccountCreate_0600 end====");
done();
});
/*
* @tc.number : ActsOsAccountCreate_0700
* @tc.name : createOsAccount callback
* @tc.desc : Verify that the created user name is empty
*/
it('ActsOsAccountCreate_0700', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0700 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.createOsAccount("", osaccount.OsAccountType.ADMIN, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_LOCAL_NAME_EMPTY_ERROR);
console.debug("====>ActsOsAccountCreate_0700 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountCreate_0800
* @tc.name : createOsAccount promise
* @tc.desc : Verify that the created user name is empty
*/
it('ActsOsAccountCreate_0800', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0800 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.createOsAccount("", osaccount.OsAccountType.ADMIN);
}catch(err){
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_LOCAL_NAME_EMPTY_ERROR);
console.debug("====>ActsOsAccountCreate_0800 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountCreate_0900
* @tc.name : removeOsAccount callback
* @tc.desc : Authenticate to delete the specified local user
*/
it('ActsOsAccountCreate_0900', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_0900 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
osAccountManager.createOsAccount("osAccountNameCreateG", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
createIdStr = createIocalId.toString();
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameCreateG");
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.queryAllCreatedOsAccounts((err, data)=>{
console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertFalse();
console.debug("====>ActsOsAccountCreate_0900 end====");
done();
})
})
});
});
/*
* @tc.number : ActsOsAccountCreate_1000
* @tc.name : removeOsAccount promise
* @tc.desc : Authenticate to delete the specified local user
*/
it('ActsOsAccountCreate_1000', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1000 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var createIdStr;
let dataMap = new Map();
var osAccount = await osAccountManager.createOsAccount("osAccountNameCreateH", osaccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccount));
createIocalId = osAccount.localId;
createIdStr = createIocalId.toString();
expect(osAccount.localName).assertEqual("osAccountNameCreateH");
await osAccountManager.removeOsAccount(createIocalId);
console.debug("====>remove localId: " + createIocalId);
var data = await osAccountManager.queryAllCreatedOsAccounts();
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
for (let i = 0, len = data.length; i < len; i++) {
console.debug("====>contain localId:" + data[i].localId);
dataMap.set(data[i].localId.toString(), data[i])
}
expect(dataMap.has("100")).assertTrue();
expect(dataMap.has(createIdStr)).assertFalse();
console.debug("====>ActsOsAccountCreate_1000 end====");
done();
});
/*
* @tc.number : ActsOsAccountCreate_1100
* @tc.name : removeOsAccount callback
* @tc.desc : Verify duplicate removal of the same local user
*/
it('ActsOsAccountCreate_1100', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
osAccountManager.createOsAccount("osAccountNameCreateI", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameCreateI");
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
console.debug("====>ActsOsAccountCreate_1100 end====");
done();
})
})
});
});
/*
* @tc.number : ActsOsAccountCreate_1200
* @tc.name : removeOsAccount promise
* @tc.desc : Verify duplicate removal of the same local user
*/
it('ActsOsAccountCreate_1200', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
var osAccount = await osAccountManager.createOsAccount("osAccountNameCreateA", osaccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccount));
createIocalId = osAccount.localId;
expect(osAccount.localName).assertEqual("osAccountNameCreateA");
await osAccountManager.removeOsAccount(createIocalId);
console.debug("====>remove localId: " + createIocalId);
try{
await osAccountManager.removeOsAccount(createIocalId);
}catch(err){
console.debug("====>remove localId: " + createIocalId + " err: " + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
console.debug("====>ActsOsAccountCreate_1200 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountCreate_1300
* @tc.name : removeOsAccount callback
* @tc.desc : Validation cannot delete 0 user
*/
it('ActsOsAccountCreate_1300', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId = 0;
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CANNOT_DELETE_ID_ERROR);
console.debug("====>ActsOsAccountCreate_1300 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountCreate_1400
* @tc.name : removeOsAccount promise
* @tc.desc : Validation cannot delete 0 user
*/
it('ActsOsAccountCreate_1400', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId = 0;
try{
await osAccountManager.removeOsAccount(localId);
}catch(err){
console.debug("====>remove localId: " + localId + " err: " + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CANNOT_DELETE_ID_ERROR);
console.debug("====>ActsOsAccountCreate_1400 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountCreate_1500
* @tc.name : removeOsAccount callback
* @tc.desc : Validation cannot delete 100 user
*/
it('ActsOsAccountCreate_1500', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId = 100;
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CANNOT_DELETE_ID_ERROR);
console.debug("====>ActsOsAccountCreate_1500 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountCreate_1600
* @tc.name : removeOsAccount promise
* @tc.desc : Validation cannot delete 100 user
*/
it('ActsOsAccountCreate_1600', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId = 100;
try{
await osAccountManager.removeOsAccount(localId);
}catch(err){
console.debug("====>remove localId: " + localId + " err: " + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CANNOT_DELETE_ID_ERROR);
console.debug("====>ActsOsAccountCreate_1600 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountCreate_1700
* @tc.name : createOsAccount callback
* @tc.desc : Authentication failed to create user with parameter type not matching
*/
it('ActsOsAccountCreate_1700', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1700 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.createOsAccount("osAccountNameCreateA", -1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(err.code).assertEqual(ERR_OS_ACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountCreate_1700 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountCreate_1800
* @tc.name : createOsAccount promise
* @tc.desc : Authentication failed to create user with parameter type not matching
*/
it('ActsOsAccountCreate_1800', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1800 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.createOsAccount("osAccountNameCreateA", -1);
}catch(err){
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OS_ACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountCreate_1800 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountCreate_1900
* @tc.name : createOsAccount callback
* @tc.desc : Authentication failed to create user with parameter type mismatch
*/
it('ActsOsAccountCreate_1900', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_1900 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.createOsAccount("osAccountNameCreateA", 3, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(err.code).assertEqual(ERR_OS_ACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountCreate_1900 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountCreate_2000
* @tc.name : createOsAccount promise
* @tc.desc : Authentication failed to create user with parameter type mismatch
*/
it('ActsOsAccountCreate_2000', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_2000 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.createOsAccount("osAccountNameCreateA", 3);
}catch(err){
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OS_ACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountCreate_2000 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountCreate_2100
* @tc.name : createOsAccount
* @tc.desc : Verify that the user localId can be reused and the user serialNumber is not
*/
it('ActsOsAccountCreate_2100', 0, async function (done) {
console.debug("====>ActsOsAccountCreate_2100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var OsAccountInfo = await osAccountManager.createOsAccount("nameCreateSerial", osaccount.OsAccountType.NORMAL);
console.debug("====>first createOsAccount OsAccountInfo:" + JSON.stringify(OsAccountInfo));
console.debug("====>createTime: " + OsAccountInfo.createTime);
console.debug("====>lastLoginTime: " + OsAccountInfo.lastLoginTime);
console.debug("====>serialNumber: " + OsAccountInfo.serialNumber);
console.debug("====>domainInfo: " + OsAccountInfo.domainInfo);
var localIdFir = OsAccountInfo.localId;
var serialNumFir = OsAccountInfo.serialNumber;
expect(OsAccountInfo.localName).assertEqual("nameCreateSerial");
console.debug("====>remove os account start====");
await osAccountManager.removeOsAccount(localIdFir);
var accountInfoSec = await osAccountManager.createOsAccount("nameCreateSerial", osaccount.OsAccountType.NORMAL);
console.debug("====>second createOsAccount OsAccountInfo:" + JSON.stringify(accountInfoSec));
var localIdSec = accountInfoSec.localId;
var serialNumSec = accountInfoSec.serialNumber;
console.debug("====>first create localId: " + localIdFir + " second create localId: " + localIdSec);
console.debug("====>first create serialNumber: " + serialNumFir + " second serialNumber: " + serialNumSec);
expect(localIdFir).assertEqual(localIdSec);
var serialNumAdd = serialNumFir + 1;
expect(serialNumAdd).assertEqual(serialNumSec);
console.debug("====>ActsOsAccountCreate_2100 end====");
done();
});
})
\ No newline at end of file
......@@ -15,3 +15,7 @@
require('./Query.test.js')
require('./Activate.test.js')
require('./OnOff.test.js')
require('./Set.test.js')
require('./Constraints.test.js')
require('./Photo.test.js')
require('./Create.test.js')
\ No newline at end of file
......@@ -25,47 +25,6 @@ describe('ActsOsAccountSystemTest', function () {
}
}
/*
* @tc.number : ActsOsAccountOnOff_0100
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that the activating type subscription can receive user switching
*/
it('ActsOsAccountOnOff_0100', 0, async function (done) {
console.debug("====>ActsOsAccountOnOff_0100 start====");
var osAccountManager = osaccount.getAccountManager();
var localId;
console.debug("====>get AccountManager finish====");
function onCallback(receiveLocalId){
console.debug("====>receive localId:" + receiveLocalId);
if(receiveLocalId == localId){
osAccountManager.off("activating", "osAccountOnOffNameA", offCallback);
}
}
function removeCallback(err){
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountOnOff_0100 end====");
done();
}
function offCallback(){
console.debug("====>off enter")
osAccountManager.removeOsAccount(localId, removeCallback);
}
osAccountManager.on("activating", "osAccountOnOffNameA", onCallback);
sleep(TIMEOUT);
osAccountManager.createOsAccount("osAccountNameA", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameA");
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0200
* @tc.name : Subscribe and unsubscribing local multi-user
......@@ -271,6 +230,7 @@ describe('ActsOsAccountSystemTest', function () {
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount errcode:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
sleep(TIMEOUT);
setTimeout(()=>{
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
......@@ -759,4 +719,56 @@ describe('ActsOsAccountSystemTest', function () {
}, TIMEOUT);
});
/*
* @tc.number : ActsOsAccountOnOff_2000
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Authenticate switch back after switching user subscription receives two callbacks
*/
it('ActsOsAccountOnOff_2000', 0, async function (done) {
console.debug("====>ActsOsAccountOnOff_2000 start====");
var osAccountManager = osaccount.getAccountManager();
var localId;
var enterSign = 0;
var localHundredId = 100;
console.debug("====>get AccountManager finish====");
function onCallback(receiveLocalId){
console.debug("====>receive localId:" + receiveLocalId);
if(receiveLocalId == localId){
enterSign = enterSign + 1;
}
if(receiveLocalId == localHundredId){
enterSign = enterSign + 1;
osAccountManager.off("activate", "osAccountOnOffNameQ", offCallback);
}
}
function offCallback(){
console.debug("====>off enter")
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>the enterSign is: " + enterSign);
expect(enterSign).assertEqual(2);
console.debug("====>ActsOsAccountOnOff_2000 end====");
done();
})
}
osAccountManager.on("activate", "osAccountOnOffNameQ", onCallback);
sleep(TIMEOUT);
osAccountManager.createOsAccount("osAccountNameQ", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameQ");
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.activateOsAccount(localHundredId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
});
});
});
})
})
\ 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 TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR = 4587558;
describe('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountProfilePhoto_0100
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify that the newly created user photo is an empty string
*/
it('ActsOsAccountProfilePhoto_0100', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
osAccountManager.createOsAccount("osAccountNameIdSerialC", osaccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>create os account err: " + JSON.stringify(err));
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("osAccountNameIdSerialC");
localId = data.localId;
osAccountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
console.debug("====>get photo:" + photo + " by localId: " + localId);
expect(err.code).assertEqual(0);
expect(photo).assertEqual("");
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountProfilePhoto_0100 end====");
done();
})
})
})
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0200
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify that the newly created user photo is an empty string
*/
it('ActsOsAccountProfilePhoto_0200', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var data = await osAccountManager.createOsAccount("osAccountNameIdSerialD", osaccount.OsAccountType.NORMAL);
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data));
expect(data.localName).assertEqual("osAccountNameIdSerialD");
localId = data.localId;
var photo = await osAccountManager.getOsAccountProfilePhoto(localId);
console.debug("====>get photo:" + photo + " by localId: " + localId);
expect(photo).assertEqual("");
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountProfilePhoto_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0300
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify to ger the photo of the user that does not exist
*/
it('ActsOsAccountProfilePhoto_0300', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var nonExistentId = 1000;
osAccountManager.getOsAccountProfilePhoto(nonExistentId, (err)=>{
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountProfilePhoto_0300 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0400
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify to get the photo of the user that does not exist
*/
it('ActsOsAccountProfilePhoto_0400', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var nonExistentId = 1000;
try{
await osAccountManager.getOsAccountProfilePhoto(nonExistentId);
}catch(err){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountProfilePhoto_0400 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0500
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify to get photo with parameter type mismatch
*/
it('ActsOsAccountProfilePhoto_0500', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localIdStr = "100";
function gerPhotoCallback(err, data){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.getOsAccountProfilePhoto(localIdStr, gerPhotoCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountProfilePhoto_0500 end====");
done();
}, TIMEOUT);
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0600
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify to the get photo with parameter type mismatch
*/
it('ActsOsAccountProfilePhoto_0600', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localIdStr = "100";
var data = await osAccountManager.getOsAccountProfilePhoto(localIdStr);
expect(data).assertEqual(null);
console.debug("====>ActsOsAccountProfilePhoto_0600 end====");
done();
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0700
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify to get photo with parameter undefined
*/
it('ActsOsAccountProfilePhoto_0700', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0700 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var undefinedId = undefined;
function gerPhotoCallback(err, data){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.getOsAccountProfilePhoto(undefinedId,gerPhotoCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountProfilePhoto_0700 end====");
done();
}, TIMEOUT);
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0800
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify to get photo with parameter undefined
*/
it('ActsOsAccountProfilePhoto_0800', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0800 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var undefinedId = undefined;
var data = await osAccountManager.getOsAccountProfilePhoto(undefinedId);
expect(data).assertEqual(null);
console.debug("====>ActsOsAccountProfilePhoto_0800 end====");
done();
});
})
\ No newline at end of file
......@@ -17,7 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 1000;
const OSACCOUNTMAXNUMBER = 999;
const ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR = 4587554;
const ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR = 4587556;
describe('ActsOsAccountSystemTest', function () {
/*
......
/*
* 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 TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_NAME_ERROR = 4587564;
const ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR = 4587566;
describe('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountSet_0100
* @tc.name : setOsAccountName callback
* @tc.desc : Set the local name of the os account based on the localId
*/
it('ActsOsAccountSet_0100', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0100 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
osAccountManager.createOsAccount("osAccountNameSetA", osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameSetA");
osAccountManager.setOsAccountName(localId, "Abc", (err)=>{
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.queryOsAccountById(localId, (err, info)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("Abc");
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountSet_0100 end====");
done();
})
})
})
})
})
/*
* @tc.number : ActsOsAccountSet_0200
* @tc.name : setOsAccountName promise
* @tc.desc : Set the local name of the os account based on the localId
*/
it('ActsOsAccountSet_0200', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0200 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var osAccountInfo = await osAccountManager.createOsAccount("osAccountNameSetB", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(osAccountInfo.localName).assertEqual("osAccountNameSetB");
await osAccountManager.setOsAccountName(localId, "Abc");
var getInfo = await osAccountManager.queryOsAccountById(localId);
console.debug("====>queryOsAccountById info:" + JSON.stringify(getInfo));
expect(getInfo.localName).assertEqual("Abc");
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountSet_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_0300
* @tc.name : setOsAccountName callback
* @tc.desc : Authentication failed to set local name for 0 user
*/
it('ActsOsAccountSet_0300', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0300 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.setOsAccountName(0, "Abc", (err)=>{
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_NAME_ERROR);
console.debug("====>ActsOsAccountSet_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountSet_0400
* @tc.name : setOsAccountName promise
* @tc.desc : Authentication failed to set local name for 0 user
*/
it('ActsOsAccountSet_0400', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0400 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.setOsAccountName(0, "Abc");
}
catch(err){
console.debug("====>catch setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_NAME_ERROR);
console.debug("====>ActsOsAccountSet_0400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountSet_0500
* @tc.name : setOsAccountName callback
* @tc.desc : Authentication failed to set local name for -1 user
*/
it('ActsOsAccountSet_0500', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0500 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.setOsAccountName(-1, "Abc", (err)=>{
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_NAME_ERROR);
console.debug("====>ActsOsAccountSet_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountSet_0600
* @tc.name : setOsAccountName promise
* @tc.desc : Authentication failed to set local name for -1 user
*/
it('ActsOsAccountSet_0600', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0600 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.setOsAccountName(-1, "Abc");
}
catch(err){
console.debug("====>catch setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_NAME_ERROR);
console.debug("====>ActsOsAccountSet_0600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountSet_0700
* @tc.name : setOsAccountName callback
* @tc.desc : Authentication failed to set local name for "100" user
*/
it('ActsOsAccountSet_0700', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0700 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
function funcSetNameCallback(err){
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.setOsAccountName("100", "Abc", funcSetNameCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountSet_0700 end====");
done();
}, TIMEOUT);
})
/*
* @tc.number : ActsOsAccountSet_0800
* @tc.name : setOsAccountName promise
* @tc.desc : Authentication failed to set local name for "100" user
*/
it('ActsOsAccountSet_0800', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0800 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var result = await osAccountManager.setOsAccountName("100", "Abc");
console.debug("====>catch setOsAccountName err:" + JSON.stringify(result));
expect(result).assertEqual(null);
console.debug("====>ActsOsAccountSet_0800 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_0900
* @tc.name : setOsAccountName callback
* @tc.desc : Authentication failed to set local name for undefined user
*/
it('ActsOsAccountSet_0900', 0, async function (done) {
console.debug("====>ActsOsAccountSet_0900 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
function funcSetNameCallback(err){
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.setOsAccountName(undefined, "Abc", funcSetNameCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountSet_0900 end====");
done();
}, TIMEOUT);
})
/*
* @tc.number : ActsOsAccountSet_1000
* @tc.name : setOsAccountName promise
* @tc.desc : Authentication failed to set local name for undefined user
*/
it('ActsOsAccountSet_1000', 0, async function (done) {
console.debug("====>ActsOsAccountSet_1000 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var result = await osAccountManager.setOsAccountName(undefined, "Abc");
console.debug("====>catch setOsAccountName err:" + JSON.stringify(result));
expect(result).assertEqual(null);
console.debug("====>ActsOsAccountSet_1000 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_1100
* @tc.name : setOsAccountName callback
* @tc.desc : Verify that the same username is set repeatedly
*/
it('ActsOsAccountSet_1100', 0, async function(done){
console.debug("====>ActsOsAccountSet_1100 start====");
var osAccountManager = osAccount.getAccountManager();
var localId;
osAccountManager.createOsAccount('localName_callback', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("localName_callback");
localId = data.localId;
osAccountManager.setOsAccountName(localId, "localName_callback", (err)=>{
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.setOsAccountName(localId, "localName_callback", (err)=>{
console.debug("====>twice setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.queryOsAccountById(localId, (err,info)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" +JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("localName_callback");
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountSet_1100 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountSet_1200
* @tc.name : setOsAccountName promise
* @tc.desc : Verify that the same username is set repeatedly
*/
it('ActsOsAccountSet_1200', 0, async function (done) {
console.debug("====>ActsOsAccountSet_1200 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
try{
var info = await osAccountManager.createOsAccount("localName_promise", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>catch createOsAccount err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("localName_promise");
localId = info.localId
try{
await osAccountManager.setOsAccountName(localId, "localName_promise");
}
catch(err){
console.debug("====>catch setOsAccountName err:" + JSON.stringify(err));
expect().assertFail();
done();
}
try{
await osAccountManager.setOsAccountName(localId, "localName_promise");
}
catch(err){
console.debug("====>catch twice setOsAccountName err:" + JSON.stringify(err));
expect().assertFail();
done();
}
try{
var info = await osAccountManager.queryOsAccountById(localId);
}
catch(err){
console.debug("====>catch queryOsAccountById err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>queryOsAccountById info:" + JSON.stringify(info));
expect(info.localName).assertEqual("localName_promise");
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountSet_1200 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_1300
* @tc.name : setOsAccountName callback
* @tc.desc : Verify repeated settings with different username
*/
it('ActsOsAccountSet_1300', 0, async function(done){
console.debug("====>ActsOsAccountSet_1300 start====");
var osAccountManager = osAccount.getAccountManager();
var localId;
osAccountManager.createOsAccount('localName_callback', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("localName_callback");
localId = data.localId;
osAccountManager.setOsAccountName(localId, "localName_callback", (err)=>{
console.debug("====>setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.setOsAccountName(localId, "localName_callbackTwice", (err)=>{
console.debug("====>twice setOsAccountName err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.queryOsAccountById(localId, (err,info)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" +JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("localName_callbackTwice");
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountSet_1300 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountSet_1400
* @tc.name : setOsAccountName promise
* @tc.desc : Verify repeated settings with different username
*/
it('ActsOsAccountSet_1400', 0, async function (done) {
console.debug("====>ActsOsAccountSet_1400 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
try{
var info = await osAccountManager.createOsAccount("localName_promise", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>catch createOsAccount err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("localName_promise");
localId = info.localId
try{
await osAccountManager.setOsAccountName(localId, "localName_promise");
}
catch(err){
console.debug("====>catch setOsAccountName err:" + JSON.stringify(err));
expect().assertFail();
done();
}
try{
await osAccountManager.setOsAccountName(localId, "localName_promiseTwice");
}
catch(err){
console.debug("====>catch setOsAccountName err:" + JSON.stringify(err));
expect().assertFail();
done();
}
try{
var info = await osAccountManager.queryOsAccountById(localId);
}
catch(err){
console.debug("====>catch twice queryOsAccountById err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>queryOsAccountById info:" + JSON.stringify(info));
expect(info.localName).assertEqual("localName_promiseTwice");
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountSet_1400 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_1500
* @tc.name : setOsAccountName callback
* @tc.desc : create and set profile photo the base64 image converted from png image
*/
it('ActsOsAccountSet_1500', 0, async function(done){
console.debug("====>ActsOsAccountSet_1500 start====");
var osAccountManager = osAccount.getAccountManager();
var localId;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
osAccountManager.createOsAccount('localNamePhotoPng_callback', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("localNamePhotoPng_callback");
localId = data.localId;
osAccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.queryOsAccountById(localId, (err,info)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" +JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.photo).assertEqual(photo);
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountSet_1500 end====");
done();
})
})
})
})
})
/*
* @tc.number : ActsOsAccountSet_1600
* @tc.name : setOsAccountName promise
* @tc.desc : create and set profile photo the base64 image converted from png image
*/
it('ActsOsAccountSet_1600', 0, async function (done) {
console.debug("====>ActsOsAccountSet_1600 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
try{
var info = await osAccountManager.createOsAccount("localPhotoPng_promise", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>catch createOsAccount err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("localPhotoPng_promise");
localId = info.localId
try{
await osAccountManager.setOsAccountProfilePhoto(localId, photo);
}
catch(err){
console.debug("====>catch setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
try{
var info = await osAccountManager.queryOsAccountById(localId);
}
catch(err){
console.debug("====>catch queryOsAccountById err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>queryOsAccountById info:" + JSON.stringify(info));
expect(info.photo).assertEqual(photo);
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountSet_1600 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_1700
* @tc.name : setOsAccountName callback
* @tc.desc : create and set profile photo the base64 image converted from jpg image
*/
it('ActsOsAccountSet_1700', 0, async function(done){
console.debug("====>ActsOsAccountSet_1700 start====");
var osAccountManager = osAccount.getAccountManager();
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="
osAccountManager.createOsAccount('localNamePhotoJpg_callback', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("localNamePhotoJpg_callback");
localId = data.localId;
osAccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.queryOsAccountById(localId, (err,info)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" +JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.photo).assertEqual(photo);
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountSet_1700 end====");
done();
})
})
})
})
})
/*
* @tc.number : ActsOsAccountSet_1800
* @tc.name : setOsAccountName promise
* @tc.desc : create and set profile photo the base64 image converted from jpg image
*/
it('ActsOsAccountSet_1800', 0, async function (done) {
console.debug("====>ActsOsAccountSet_1800 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get 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="
try{
var info = await osAccountManager.createOsAccount("localPhotoJpg_promise", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>catch createOsAccount err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("localPhotoJpg_promise");
localId = info.localId
try{
await osAccountManager.setOsAccountProfilePhoto(localId, photo);
}
catch(err){
console.debug("====>catch setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
try{
var info = await osAccountManager.queryOsAccountById(localId);
}
catch(err){
console.debug("====>catch queryOsAccountById err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>queryOsAccountById info:" + JSON.stringify(info));
expect(info.photo).assertEqual(photo);
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountSet_1800 end====");
done();
})
/*
* @tc.number : ActsOsAccountSet_1900
* @tc.name : setOsAccountName callback
* @tc.desc : set 0 local user profile photo the base64 image converted from png image
*/
it('ActsOsAccountSet_1900', 0, async function (done) {
console.debug("====>ActsOsAccountSet_1900 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
osAccountManager.setOsAccountProfilePhoto(0, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_1900 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountSet_2000
* @tc.name : setOsAccountName promise
* @tc.desc : set 0 local user profile photo the base64 image converted from png image
*/
it('ActsOsAccountSet_2000', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2000 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
try{
await osAccountManager.setOsAccountProfilePhoto(0, photo);
}
catch(err){
console.debug("====>catch setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2000 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountSet_2100
* @tc.name : setOsAccountName callback
* @tc.desc : set 0 local user profile photo the base64 image converted from jpg image
*/
it('ActsOsAccountSet_2100', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2100 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
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="
osAccountManager.setOsAccountProfilePhoto(0, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountSet_2200
* @tc.name : setOsAccountName promise
* @tc.desc : set 0 local user profile photo the base64 image converted from jpg image
*/
it('ActsOsAccountSet_2200', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2200 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
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="
try{
await osAccountManager.setOsAccountProfilePhoto(0, photo);
}
catch(err){
console.debug("====>catch setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2200 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountSet_2300
* @tc.name : setOsAccountName callback
* @tc.desc : set the specified local profile photo to "bbb"
*/
it('ActsOsAccountSet_2300', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2300 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.setOsAccountProfilePhoto(100, "bbb", (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountSet_2400
* @tc.name : setOsAccountName promise
* @tc.desc : set the specified local profile photo to "bbb"
*/
it('ActsOsAccountSet_2400', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2400 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.setOsAccountProfilePhoto(100, "bbb");
}
catch(err){
console.debug("====>catch setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountSet_2500
* @tc.name : setOsAccountName callback
* @tc.desc : set the specified local profile photo to ""
*/
it('ActsOsAccountSet_2500', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2500 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.setOsAccountProfilePhoto(100, "", (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountSet_2600
* @tc.name : setOsAccountName promise
* @tc.desc : set the specified local profile photo to ""
*/
it('ActsOsAccountSet_2600', 0, async function (done) {
console.debug("====>ActsOsAccountSet_2600 start====");
var osAccountManager = osAccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.setOsAccountProfilePhoto(100, "");
}
catch(err){
console.debug("====>catch setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_SET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountSet_2600 end====");
done();
}
})
})
\ No newline at end of file
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "100000",
"test-timeout": "200000",
"package": "com.example.actsosaccountthirdpartytest",
"shell-timeout": "60000"
},
......
......@@ -35,6 +35,7 @@ export default {
core.init()
const configService = core.getDefaultService('config')
this.timeout = 8000;
configService.setConfig(this)
require('../../../test/List.test')
......
......@@ -13,3 +13,4 @@
* limitations under the License.
*/
require('./OsAccountIs.test.js')
require('./OsAccountGet.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 bundle from '@ohos.bundle'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_LOCAL_ID_FROM_UID_ERROR = 4587551;
describe('ActsOsAccountThirdPartyTest', function () {
/*
* @tc.number : ActsOsAccountGetIdFormUid_0100
* @tc.name : getOsAccountLocalIdFromUid callback
* @tc.desc : Verify that the user localId is obtained by uid
*/
it('ActsOsAccountGetIdFormUid_0100', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormUid_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var bundleName = "com.example.actsosaccountthirdpartytest";
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(0);
console.debug("====>ActsOsAccountGetIdFormUid_0100 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountGetIdFormUid_0200
* @tc.name : getOsAccountLocalIdFromUid promise
* @tc.desc : Verify that the user localId is obtained by uid
*/
it('ActsOsAccountGetIdFormUid_0200', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormUid_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var bundleName = "com.example.actsosaccountthirdpartytest";
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(0);
console.debug("====>ActsOsAccountGetIdFormUid_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountGetIdFormUid_0300
* @tc.name : getOsAccountLocalIdFromUid callback
* @tc.desc : Authentication failed to query user by uid -1
*/
it('ActsOsAccountGetIdFormUid_0300', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormUid_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var incorrectUid = -1;
osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{
console.debug("====>get localId err: " + JSON.stringify(err));
console.debug("====>localId obtained by uid:" + localId);
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_LOCAL_ID_FROM_UID_ERROR);
expect(localId).assertEqual(0);
console.debug("====>ActsOsAccountGetIdFormUid_0300 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountGetIdFormUid_0400
* @tc.name : getOsAccountLocalIdFromUid promise
* @tc.desc : Authentication failed to query user by uid -1
*/
it('ActsOsAccountGetIdFormUid_0400', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormUid_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var incorrectUid = -1;
try{
await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid);
}catch(err){
console.debug("====>get localId by uid err:" +JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_LOCAL_ID_FROM_UID_ERROR);
console.debug("====>ActsOsAccountGetIdFormUid_0400 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountGetIdFormUid_0500
* @tc.name : getOsAccountLocalIdFromUid callback
* @tc.desc : Authentication failed to query user by uid 2147483648
*/
it('ActsOsAccountGetIdFormUid_0500', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormUid_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var incorrectUid = 2147483648;
osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{
console.debug("====>get localId err: " + JSON.stringify(err));
console.debug("====>localId obtained by uid:" + localId);
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_LOCAL_ID_FROM_UID_ERROR);
expect(localId).assertEqual(0);
console.debug("====>ActsOsAccountGetIdFormUid_0500 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountGetIdFormUid_0600
* @tc.name : getOsAccountLocalIdFromUid promise
* @tc.desc : Authentication failed to query user by uid 2147483648
*/
it('ActsOsAccountGetIdFormUid_0600', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormUid_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var incorrectUid = 2147483648;
try{
await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid);
}catch(err){
console.debug("====>get localId by uid err:" +JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_LOCAL_ID_FROM_UID_ERROR);
console.debug("====>ActsOsAccountGetIdFormUid_0600 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountGetIdFormProcess_0100
* @tc.name : getOsAccountLocalIdFromProcess callback
* @tc.desc : Verify that the user localId obtained from the current process uid
*/
it('ActsOsAccountGetIdFormProcess_0100', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormProcess_0100 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(0);
console.debug("====>ActsOsAccountGetIdFormProcess_0100 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountGetIdFormProcess_0200
* @tc.name : getOsAccountLocalIdFromProcess promise
* @tc.desc : Verify that the user localId obtained from the current process uid
*/
it('ActsOsAccountGetIdFormProcess_0200', 0, async function (done) {
console.debug("====>ActsOsAccountGetIdFormProcess_0200 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(0);
console.debug("====>ActsOsAccountGetIdFormProcess_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountGetTypeFormProcess_0100
* @tc.name : getOsAccountTypeFromProcess callback
* @tc.desc : Verify that the user type obtained from the current process uid
*/
it('ActsOsAccountGetTypeFormProcess_0100', 0, async function (done) {
console.debug("====>ActsOsAccountGetTypeFormProcess_0100 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("====>ActsOsAccountGetTypeFormProcess_0100 end====");
done();
});
});
/*
* @tc.number : ActsOsAccountGetTypeFormProcess_0200
* @tc.name : getOsAccountTypeFromProcess promise
* @tc.desc : Verify that the user type obtained from the current process uid
*/
it('ActsOsAccountGetTypeFormProcess_0200', 0, async function (done) {
console.debug("====>ActsOsAccountGetTypeFormProcess_0200 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("====>ActsOsAccountGetTypeFormProcess_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountLocalIdSerial_0100
* @tc.name : getSerialNumberByOsAccountLocalId callback
* @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber
*/
it('ActsOsAccountLocalIdSerial_0100', 0, async function (done) {
console.debug("====>ActsOsAccountLocalIdSerial_0100 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("====>ActsOsAccountLocalIdSerial_0100 end====");
done();
})
})
});
/*
* @tc.number : ActsOsAccountLocalIdSerial_0200
* @tc.name : getSerialNumberByOsAccountLocalId promise
* @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber
*/
it('ActsOsAccountLocalIdSerial_0200', 0, async function (done) {
console.debug("====>ActsOsAccountLocalIdSerial_0200 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("====>ActsOsAccountLocalIdSerial_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountLocalIdSerial_0300
* @tc.name : getOsAccountLocalIdBySerialNumber callback
* @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber
*/
it('ActsOsAccountLocalIdSerial_0300', 0, async function (done) {
console.debug("====>ActsOsAccountLocalIdSerial_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.getSerialNumberByOsAccountLocalId(0, (err, serialNumber)=>{
console.debug("====>ger serialNumber err:" + JSON.stringify(err));
console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" );
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("00000000");
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(0);
console.debug("====>ActsOsAccountLocalIdSerial_0300 end====");
done();
})
})
});
/*
* @tc.number : ActsOsAccountLocalIdSerial_0400
* @tc.name : getOsAccountLocalIdBySerialNumber promise
* @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber
*/
it('ActsOsAccountLocalIdSerial_0400', 0, async function (done) {
console.debug("====>ActsOsAccountLocalIdSerial_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(0);
console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" );
var serialNumberStr = serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000000");
var localId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber);
console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber);
expect(localId).assertEqual(0);
console.debug("====>ActsOsAccountLocalIdSerial_0400 end====");
done();
});
/*
* @tc.number : ActsOsAccountLocalIdSerial_0500
* @tc.name : getSerialNumberByOsAccountLocalId callback
* @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the
* serialNumber
*/
it('ActsOsAccountLocalIdSerial_0500', 0, async function (done) {
console.debug("====>ActsOsAccountLocalIdSerial_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
osAccountManager.createOsAccount("osAccountNameIdSerialA", osaccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>create os account err: " + JSON.stringify(err));
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("osAccountNameIdSerialA");
localId = data.localId;
osAccountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId);
expect(err.code).assertEqual(0);
osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, getlocalId)=>{
console.debug("====>ger localId err:" + JSON.stringify(err));
console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber);
expect(err.code).assertEqual(0);
expect(getlocalId).assertEqual(localId);
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountLocalIdSerial_0500 end====");
done();
})
})
})
})
});
/*
* @tc.number : ActsOsAccountLocalIdSerial_0600
* @tc.name : getOsAccountLocalIdBySerialNumber promise
* @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the
* serialNumber
*/
it('ActsOsAccountLocalIdSerial_0600', 0, async function (done) {
console.debug("====>ActsOsAccountLocalIdSerial_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var OsAccountInfo = await osAccountManager.createOsAccount("accountIdSerialB", osaccount.OsAccountType.NORMAL);
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("accountIdSerialB");
localId = OsAccountInfo.localId;
var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(localId);
console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId);
var getlocalId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber);
console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber);
expect(getlocalId).assertEqual(localId);
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountLocalIdSerial_0600 end====");
done();
});
/*
* @tc.number : ActsOsAccountGetCount_0100
* @tc.name : getCreatedOsAccountsCount callback
* @tc.desc : Verify to obtain the number os all os accounts created
*/
it('ActsOsAccountGetCount_0100', 0, async function (done) {
console.debug("====>ActsOsAccountGetCount_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var obtainCount = 0;
var localIdFir;
var localIdSec;
osAccountManager.getCreatedOsAccountsCount((err, data)=>{
console.debug("====>obtains the number of all os accounts created err:" + JSON.stringify(err));
console.debug("====>obtains the number of all os accounts created data:" + data);
expect(err.code).assertEqual(0);
obtainCount = data;
osAccountManager.createOsAccount("osAccountNameIdSerialE", osaccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>create first os account err: " + JSON.stringify(err));
console.debug("====>create first os account OsAccountInfo: " + JSON.stringify(data));
localIdFir = data.localId;
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("osAccountNameIdSerialE");
osAccountManager.createOsAccount("osAccountIdSerialF", osaccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>create second os account err: " + JSON.stringify(err));
console.debug("====>create second os account OsAccountInfo: " + JSON.stringify(data));
localIdSec = data.localId;
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("osAccountIdSerialF");
osAccountManager.getCreatedOsAccountsCount((err, count)=>{
console.debug("====>obtains the number of all os accounts created err:" + JSON.stringify(err));
console.debug("====>obtains the number of all os accounts created count:" + count);
expect(err.code).assertEqual(0);
count = count - 2;
expect(count).assertEqual(obtainCount);
osAccountManager.removeOsAccount(localIdFir, (err)=>{
console.debug("====>remove localId: " + localIdFir + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.getCreatedOsAccountsCount((err, data)=>{
console.debug("====>obtains the number accounts created err:" + JSON.stringify(err));
console.debug("====>obtains the number accounts created data:" + data);
expect(err.code).assertEqual(0);
data = data - 1;
expect(data).assertEqual(obtainCount);
osAccountManager.removeOsAccount(localIdSec, (err)=>{
console.debug("====>remove localId: " + localIdSec + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountGetCount_0100 end====");
done();
})
})
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountGetCount_0200
* @tc.name : getCreatedOsAccountsCount promise
* @tc.desc : Verify to obtain the number os all os accounts created
*/
it('ActsOsAccountGetCount_0200', 0, async function (done) {
console.debug("====>ActsOsAccountGetCount_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var obtainCount = await osAccountManager.getCreatedOsAccountsCount();
console.debug("====>obtains the number of all os accounts created:" + obtainCount);
var osAccountFir = await osAccountManager.createOsAccount("osAccountIdSerialG", osaccount.OsAccountType.NORMAL);
console.debug("====>create first os account OsAccountInfo: " + JSON.stringify(osAccountFir));
var localIdFir = osAccountFir.localId;
expect(osAccountFir.localName).assertEqual("osAccountIdSerialG");
var osAccountSec = await osAccountManager.createOsAccount("osAccountIdSerialH", osaccount.OsAccountType.NORMAL);
console.debug("====>create second os account OsAccountInfo: " + JSON.stringify(osAccountSec));
var localIdSec = osAccountSec.localId;
expect(osAccountSec.localName).assertEqual("osAccountIdSerialH");
var countFir = await osAccountManager.getCreatedOsAccountsCount();
console.debug("====>obtains the number of all os accounts created count:" + countFir);
countFir = countFir - 2;
expect(countFir).assertEqual(obtainCount);
await osAccountManager.removeOsAccount(localIdFir);
console.debug("====>remove localId: " + localIdFir);
var countSec = await osAccountManager.getCreatedOsAccountsCount();
console.debug("====>obtains the number accounts created count:" + countSec);
countSec = countSec - 1;
expect(countSec).assertEqual(obtainCount);
await osAccountManager.removeOsAccount(localIdSec);
console.debug("====>remove localId: " + localIdSec);
console.debug("====>ActsOsAccountGetCount_0200 end====");
done();
})
})
\ No newline at end of file
......@@ -16,8 +16,8 @@ import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587543;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587546;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587545;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587548;
describe('ActsOsAccountThirdPartyTest', function () {
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册