diff --git a/account/OsAccountTest_js/src/main/config.json b/account/OsAccountTest_js/src/main/config.json index fd7e2fd62b1434e72b956a90bca72172dddb67f6..bd9e2e06733e59b5d543f8d7576084f4d15c8423 100644 --- a/account/OsAccountTest_js/src/main/config.json +++ b/account/OsAccountTest_js/src/main/config.json @@ -18,7 +18,7 @@ "mainAbility": ".MainAbility", "srcPath":"", "deviceType": [ - "default", + "default", "phone" ], "distro": { @@ -37,6 +37,10 @@ { "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", "reason": "ceshi" + }, + { + "name": "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS", + "reason": "ceshi" } ], "abilities": [ diff --git a/account/OsAccountTest_js/src/main/js/test/ActsDSGetSet.test.js b/account/OsAccountTest_js/src/main/js/test/ActsDSGetSet.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7758e1912a22be12894de701facfae2dbc6180ca --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/test/ActsDSGetSet.test.js @@ -0,0 +1,297 @@ +/* + * 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. + */ + +// @ts-nocheck +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, done } from '@ohos/hypium' + +import account from '@ohos.account.distributedAccount' +const LOGININFO = { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" +} +const LOGOUTINFO = { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGOUT" +} +export default function ActsDAGetSetTest() { + describe('ActsDAGetSetTest', function () { + beforeEach(function () { + }) + afterEach(function () { + }) + + /** + * @tc.number ActsDistributedAccountDeviceId_0100 + * @tc.name Test query the distribruted id by callback. + * @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality by callback. + */ + it('ActsDistributedAccountDeviceId_0100', 0, async function(done){ + console.log("====>test query distribtued id start"); + const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; //'12345'sha256的值 + const accountAbility = account.getDistributedAccountAbility(); + accountAbility.setOsAccountDistributedInfo(LOGININFO, (err)=>{ + console.log("====>set distributedInfo err:" + JSON.stringify(err)); + accountAbility.getOsAccountDistributedInfo((err, distributedInfo)=>{ + console.log("====>get distributedInfo err:" + JSON.stringify(err)); + console.log("====>get distributedInfo:" + JSON.stringify(distributedInfo)); + expect(distributedInfo.name).assertEqual('ZhangSan'); + expect(distributedInfo.id).assertEqual(distributedId); + accountAbility.setOsAccountDistributedInfo(LOGOUTINFO, (err)=>{ + console.debug('====>ActsDistributedAccountDeviceId_0100 logout_result:'+ JSON.stringify(err)) + expect(err).assertEqual(null) + console.log("====>test query distribtued id end"); + done(); + }) + }) + }) + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0100 + * @tc.name Test distributedAccount.getDistributedAccountAbility. + * @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality. + */ + it('account_getDistributedAccountAbility_test', 0, async function (done) { + var ret = false; + const accountAbility = account.getDistributedAccountAbility() + console.debug("====>account_getDistributedAccountAbility_test result:" + JSON.stringify(accountAbility)) + if(accountAbility !== null){ + ret = true; + } + expect(ret).assertTrue() + done(); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0200 + * @tc.name Test distributedAccount.getOsAccountDistributedInfo. + * @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality. + */ + it('account_getOsAccountDistributedInfo_test001', 0, async function (done) { + let accountAbility = account.getDistributedAccountAbility() + accountAbility.getOsAccountDistributedInfo().then(function (data) { + console.debug('====>account_getOsAccountDistributedInfo_test001 data:' + JSON.stringify(data)) + expect(data.name).assertEqual('ohosAnonymousName') + expect(data.id).assertEqual('ohosAnonymousUid') + done(); + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0300 + * @tc.name Test distributedAccount.getOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality by callback. + */ + it('account_getOsAccountDistributedInfo_test002', 0, async function (done) { + let accountAbility = account.getDistributedAccountAbility() + accountAbility.getOsAccountDistributedInfo(function (err, data) { + console.debug('====>account_getOsAccountDistributedInfo_test002 err:' + JSON.stringify(err)) + console.debug('====>account_getOsAccountDistributedInfo_test002 data:' + JSON.stringify(data)) + expect(err).assertEqual(null) + expect(data.name).assertEqual('ohosAnonymousName') + expect(data.id).assertEqual('ohosAnonymousUid') + done(); + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0400 + * @tc.name Test distributedAccount.setOsAccountDistributedInfo. + * @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality. + */ + it('account_setOsAccountDistributedInfo_test001', 0, async function (done) { + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:{} + }; + accountAbility.setOsAccountDistributedInfo(obj).then(function () { + accountAbility.getOsAccountDistributedInfo(function (data) { + console.debug('====>account_setOsAccountDistributedInfo_test001 data:' + JSON.stringify(data)) + expect(data.name).assertEqual('ZhangSan') + expect(data.id).assertEqual('12345') + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOUT' + }; + accountAbility.setOsAccountDistributedInfo(obj).then(function (err) { + expect(err).assertEqual(null) + }); + }); + }); + accountAbility.getOsAccountDistributedInfo(function (data) { + console.debug('====>account_setOsAccountDistributedInfo_test001 get data:' + JSON.stringify(data)) + expect(data).assertEqual(null) + done(); + }) + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0500 + * @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback. + */ + it('account_setOsAccountDistributedInfo_test002', 0, async function (done) { + var accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:{} + }; + accountAbility.setOsAccountDistributedInfo(obj, function () { + accountAbility.getOsAccountDistributedInfo(function (err, data) { + console.debug("====>account_setOsAccountDistributedInfo_test002 data:" + JSON.stringify(data)) + expect(data.name).assertEqual('ZhangSan') + expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5') + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOUT' + }; + accountAbility.setOsAccountDistributedInfo(obj).then(function (data) { + expect(data).assertEqual(null) + done(); + }); + }); + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0300 + * @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback. + */ + it('account_setOsAccountDistributedInfo_test003', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.TOKEN_INVALID', + scalableData:{} + }; + accountAbility.setOsAccountDistributedInfo(obj, function (result) { + console.debug("====>account_setOsAccountDistributedInfo_test003 update_err:" + JSON.stringify(result)) + accountAbility.getOsAccountDistributedInfo(obj).then(function (data) { + console.debug("====>account_setOsAccountDistributedInfo_test003 data:" + JSON.stringify(data)) + expect(data.name).assertNull() + done(); + }) + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0500 + * @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback. + */ + it('account_setOsAccountDistributedInfo_test004', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:{} + }; + accountAbility.setOsAccountDistributedInfo(obj, function (err) { + console.debug("====>account_setOsAccountDistributedInfo_test004 update_err:" + JSON.stringify(err)) + accountAbility.getOsAccountDistributedInfo(function (err, data) { + console.debug("====>account_setOsAccountDistributedInfo_test004 query_err:" + JSON.stringify(err)) + console.debug("====>account_setOsAccountDistributedInfo_test004 query_data:" + JSON.stringify(data)) + expect(data.name).assertEqual('ZhangSan') + expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5') + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOFF' + }; + accountAbility.setOsAccountDistributedInfo(obj).then(function (result) { + expect(err).assert(null) + done(); + }); + }); + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0600 + * @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback. + */ + it('account_setOsAccountDistributedInfo_test005', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:{age:'12'} + }; + accountAbility.setOsAccountDistributedInfo(obj, function (err) { + console.debug("====>account_setOsAccountDistributedInfo_test005 update_err:" + JSON.stringify(err)) + accountAbility.getOsAccountDistributedInfo(function (err, data) { + console.debug("====>account_setOsAccountDistributedInfo_test005 query_err:" + JSON.stringify(err)) + console.debug("====>account_setOsAccountDistributedInfo_test005 query_data:" + JSON.stringify(data)) + expect(data.scalableData.age).assertEqual('12') + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOFF' + }; + accountAbility.setOsAccountDistributedInfo(obj).then(function (result) { + expect(err).assert(null) + done(); + }); + }); + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0700 + * @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback. + */ + it('account_setOsAccountDistributedInfo_test006', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:{age:'12'} + }; + accountAbility.setOsAccountDistributedInfo(obj, function (err) { + console.debug("====>account_setOsAccountDistributedInfo_test006 update_err:" + JSON.stringify(err)) + accountAbility.getOsAccountDistributedInfo(function (err, data) { + console.debug("====>account_setOsAccountDistributedInfo_test006 query_err:" + JSON.stringify(err)) + console.debug("====>account_setOsAccountDistributedInfo_test006 query_data:" + JSON.stringify(data)) + expect(data.scalableData.age).assertEqual('12') + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOFF' + }; + accountAbility.setOsAccountDistributedInfo(obj).then(function (result) { + expect(err).assert(null) + done(); + }); + }); + }); + }) + }) +} diff --git a/account/OsAccountTest_js/src/main/js/test/List.test.js b/account/OsAccountTest_js/src/main/js/test/List.test.js index 90369e959345b4af6b635a17fd0a32efcb042cf3..f536b6e8b56e948a94e3c184e30dc5f116ed15c2 100755 --- a/account/OsAccountTest_js/src/main/js/test/List.test.js +++ b/account/OsAccountTest_js/src/main/js/test/List.test.js @@ -13,7 +13,9 @@ * limitations under the License. */ import AccountTest from './OsAccount.test.js' +import ActsDAGetSetTest from './ActsDSGetSet.test.js' export default function testsuite() { AccountTest() + ActsDAGetSetTest() } \ No newline at end of file diff --git a/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js b/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js index 72b910a1219bb36c609744905a1814c08308005f..d94d89f05efb1e35793fac5aad395febd5cc259c 100755 --- a/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js +++ b/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js @@ -14,9 +14,19 @@ */ // @ts-nocheck -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, done } from '@ohos/hypium' import account from '@ohos.account.distributedAccount' +const LOGININFO = { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" +} +const LOGOUTINFO = { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGOUT" +} export default function AccountTest() { describe('AccountTest', function () { beforeEach(function () { @@ -29,24 +39,25 @@ export default function AccountTest() { * @tc.name Test query the distribruted id by callback. * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback. */ - it('ActsDistributedAccountDeviceId_0100', 0, async function(done){ - console.log("test query distribtued id start"); - const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; + it('ActsDistributedAccountDeviceId_0100', 0, async function(done){ + console.log("====>test query distribtued id start"); + const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; //'12345'sha256的值 const accountAbility = account.getDistributedAccountAbility(); - accountAbility.updateOsAccountDistributedInfo( - { - name: 'ZhangSan', - id: '12345', - event: "Ohos.account.event.LOGIN" - }, (err)=>{ - console.log("update distributedInfo err:" + JSON.stringify(err)); + accountAbility.updateOsAccountDistributedInfo(LOGININFO, (err)=>{ + console.log("====>update distributedInfo err:" + JSON.stringify(err)); accountAbility.queryOsAccountDistributedInfo((err, distributedInfo)=>{ - console.log("query distributedInfo err:" + JSON.stringify(err)); - console.log("query distributedInfo:" + JSON.stringify(distributedInfo)); + console.log("====>query distributedInfo err:" + JSON.stringify(err)); + console.log("====>query distributedInfo:" + JSON.stringify(distributedInfo)); expect(distributedInfo.name).assertEqual('ZhangSan'); expect(distributedInfo.id).assertEqual(distributedId); - console.log("test query distribtued id end"); - done(); + console.debug('success') + accountAbility.updateOsAccountDistributedInfo(LOGOUTINFO, (err)=>{ + console.debug('====>ActsDistributedAccountDeviceId_0100 logout_result:'+ JSON.stringify(err)) + expect(err).assertEqual(undefined) + console.log("====>test query distribtued id end"); + done(); + }) + }) }) }) @@ -56,13 +67,15 @@ export default function AccountTest() { * @tc.name Test distributedAccount.getDistributedAccountAbility. * @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality. */ - it('account_getDistributedAccountAbility_test', 0, function () { + it('account_getDistributedAccountAbility_test', 0, async function (done) { var ret = false; const accountAbility = account.getDistributedAccountAbility() + console.debug("====>account_getDistributedAccountAbility_test result:" + JSON.stringify(accountAbility)) if(accountAbility !== null){ ret = true; } expect(ret).assertTrue() + done(); }) /** @@ -70,10 +83,13 @@ export default function AccountTest() { * @tc.name Test distributedAccount.queryOsAccountDistributedInfo. * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality. */ - it('account_queryOsAccountDistributedInfo_test001', 0, function () { - const accountAbility = account.getDistributedAccountAbility() + it('account_queryOsAccountDistributedInfo_test001', 0, async function (done) { + let accountAbility = account.getDistributedAccountAbility() accountAbility.queryOsAccountDistributedInfo().then(function (data) { - expect(data.name).assertEqual('anonymous') + console.debug('====>account_queryOsAccountDistributedInfo_test001 data:' + JSON.stringify(data)) + expect(data.name).assertEqual('ohosAnonymousName') + expect(data.id).assertEqual('ohosAnonymousUid') + done(); }); }) @@ -82,10 +98,15 @@ export default function AccountTest() { * @tc.name Test distributedAccount.queryOsAccountDistributedInfo by callback. * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback. */ - it('account_queryOsAccountDistributedInfo_test002', 0, function () { - const accountAbility = account.getDistributedAccountAbility() - accountAbility.queryOsAccountDistributedInfo(function (data) { - expect(data.name).assertEqual('anonymous') + it('account_queryOsAccountDistributedInfo_test002', 0, async function (done) { + let accountAbility = account.getDistributedAccountAbility() + accountAbility.queryOsAccountDistributedInfo(function (err, data) { + console.debug('====>account_queryOsAccountDistributedInfo_test002 err:' + JSON.stringify(err)) + console.debug('====>account_queryOsAccountDistributedInfo_test002 data:' + JSON.stringify(data)) + expect(err).assertEqual(undefined) + expect(data.name).assertEqual('ohosAnonymousName') + expect(data.id).assertEqual('ohosAnonymousUid') + done(); }); }) @@ -94,18 +115,18 @@ export default function AccountTest() { * @tc.name Test distributedAccount.updateOsAccountDistributedInfo. * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality. */ - it('account_updateOsAccountDistributedInfo_test001', 0, function () { + it('account_updateOsAccountDistributedInfo_test001', 0, async function (done) { const accountAbility = account.getDistributedAccountAbility() - let data = null + let data = null let obj = { id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN', scalableData:data }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertTrue() + accountAbility.updateOsAccountDistributedInfo(obj).then(function () { accountAbility.queryOsAccountDistributedInfo(function (data) { + console.debug('====>account_updateOsAccountDistributedInfo_test001 data:' + JSON.stringify(data)) expect(data.name).assertEqual('ZhangSan') expect(data.id).assertEqual('12345') let obj = { @@ -113,13 +134,15 @@ export default function AccountTest() { name: 'ZhangSan', event: 'Ohos.account.event.LOGOUT' }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertTrue() + accountAbility.updateOsAccountDistributedInfo(obj).then(function (err) { + expect(err).assertEqual(undefined) }); }); }); accountAbility.queryOsAccountDistributedInfo(function (data) { - execpt(data).assertNull() + + expect(data).assertEqual(undefined) + done(); }) }) @@ -128,34 +151,32 @@ export default function AccountTest() { * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. */ - it('account_updateOsAccountDistributedInfo_test002', 0, function () { - let data = null - const accountAbility = account.getDistributedAccountAbility() + it('account_updateOsAccountDistributedInfo_test002', 0, async function (done) { + var accountAbility = account.getDistributedAccountAbility() let obj = { id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN', - scalableData:data + scalableData:{} }; - accountAbility.updateOsAccountDistributedInfo(obj, function (result) { - expect(result).assertTrue() - accountAbility.queryOsAccountDistributedInfo(function (data) { + accountAbility.updateOsAccountDistributedInfo(obj, function () { + accountAbility.queryOsAccountDistributedInfo(function (err, data) { + console.debug("====>account_updateOsAccountDistributedInfo_test002 data:" + JSON.stringify(data)) expect(data.name).assertEqual('ZhangSan') - expect(data.id).assertEqual('12345') - const accountAbility = account.getDistributedAccountAbility() + expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5') let obj = { id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGOUT' - }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertTrue() + accountAbility.updateOsAccountDistributedInfo(obj).then(function (data) { + expect(data).assertEqual(undefined) + done(); }); }); }); }) - + /** * @tc.number SUB_Account_distributedAccount_JS_API_0300 * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. @@ -163,7 +184,7 @@ export default function AccountTest() { */ it('account_updateOsAccountDistributedInfo_test003', 0, function () { const accountAbility = account.getDistributedAccountAbility() - let data = null + let data = null let obj = { id: '12345', name: 'ZhangSan', @@ -171,13 +192,15 @@ export default function AccountTest() { scalableData:data }; accountAbility.updateOsAccountDistributedInfo(obj, function (result) { - expect(result).assertTrue() + console.debug("====>account_updateOsAccountDistributedInfo_test003 update_err:" + JSON.stringify(result)) accountAbility.queryOsAccountDistributedInfo(obj).then(function (data) { - except(data.name).assertNull() + console.debug("====>account_updateOsAccountDistributedInfo_test003 data:" + JSON.stringify(data)) + expect(data.name).assertNull() + done(); }) }); }) - + /** * @tc.number SUB_Account_distributedAccount_JS_API_0500 * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. @@ -185,27 +208,27 @@ export default function AccountTest() { */ it('account_updateOsAccountDistributedInfo_test004', 0, function () { const accountAbility = account.getDistributedAccountAbility() - let data = null let obj = { id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN', - scalableData:data + scalableData:{} }; - accountAbility.updateOsAccountDistributedInfo(obj, function (result) { - expect(result).assertTrue() - accountAbility.queryOsAccountDistributedInfo(function (data) { + accountAbility.updateOsAccountDistributedInfo(obj, function (err) { + console.debug("====>account_updateOsAccountDistributedInfo_test004 update_err:" + JSON.stringify(err)) + accountAbility.queryOsAccountDistributedInfo(function (err, data) { + console.debug("====>account_updateOsAccountDistributedInfo_test004 query_err:" + JSON.stringify(err)) + console.debug("====>account_updateOsAccountDistributedInfo_test004 query_data:" + JSON.stringify(data)) expect(data.name).assertEqual('ZhangSan') - expect(data.id).assertEqual('12345') - const accountAbility = account.getDistributedAccountAbility() + expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5') let obj = { id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGOFF' - }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertNull() + accountAbility.updateOsAccountDistributedInfo(obj).then(function (err) { + expect(err).assert(undefined) + done(); }); }); }); diff --git a/account/appaccount/BUILD.gn b/account/appaccount/BUILD.gn index c5a5c0d20fcb1ab04ab69bee51dd9a30833d7a76..da882415beb0810f7066572c0e1ca186a4aa0a4a 100644 --- a/account/appaccount/BUILD.gn +++ b/account/appaccount/BUILD.gn @@ -17,11 +17,15 @@ group("appaccount_hap") { testonly = true if (is_standard_system) { deps = [ + "actsaccountoperatetest:ActsAccountOperateTest", "actsaccounttest:ActsAccountTest", "actsaccounttstest:ActsAccountTsTest", + "actsgetaccountsbyowner:ActsGetAccountsByOwnerTest", "actsgetallaccounts:ActsGetAllAccountsTest", + "actssetcheckdatasyncenable:ActsSetCheckDataSyncEnableTest", "actssetchecksyncenable:ActsSetCheckSyncEnableTest", "getallaccessibleaccounts:accessibleaccounts", + "getallaccounts:getallaccounts", "sceneProject:appaccount_scene", ] } diff --git a/account/appaccount/actsaccountoperatetest/BUILD.gn b/account/appaccount/actsaccountoperatetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7d6557649cb401f47bd8564cdceb2c85815497c6 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAccountOperateTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAccountOperateTest" + subsystem_name = "account" + part_name = "os_account" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/account/appaccount/actsaccountoperatetest/Test.json b/account/appaccount/actsaccountoperatetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c6afc90a1442e21df7de5225c05d43340d401f62 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/Test.json @@ -0,0 +1,24 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "3000000", + "bundle-name": "com.example.actsaccountoperatetest", + "package-name": "com.example.actsaccountoperatetest", + "shell-timeout": "3000000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAccountOperateTest.hap", + "ActsAccountSceneAppAccess.hap", + "ActsAccountSceneOnOff.hap", + "ActsAccountOauthtoken.hap", + "ActsAccountAuthenticator.hap", + "ActsAccountTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/actsaccountoperatetest/signature/openharmony_sx.p7b b/account/appaccount/actsaccountoperatetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/account/appaccount/actsaccountoperatetest/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/actsaccountoperatetest/src/main/config.json b/account/appaccount/actsaccountoperatetest/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..90decaf4ca3dcfc820f4417689d909f3c10b0efb --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/config.json @@ -0,0 +1,114 @@ +{ + "app": { + "bundleName": "com.example.actsaccountoperatetest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccountoperatetest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/app.js b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/i18n/en-US.json b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/i18n/zh-CN.json b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,24 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f7fa13538134ab88f502a6d53885f46df315d7bf --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,20 @@ + + +
+ + {{title}} + +
diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8ed88c0000318e63c673f4aeb94d9da35cd6e6 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,27 @@ +/* + * 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. + */ +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + onInit() { + this.title = "ActsAccountOpertaeTest"; + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/app.js b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..d635763164434febf9a294f7be8ae2c3241161d3 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,49 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actsaccountoperatetest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/AccountCredential.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/AccountCredential.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9341297651bec0aad4df9f94e9c1c6dd92a72d3b --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/AccountCredential.test.js @@ -0,0 +1,677 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +const EACHTIMEOUT = 500; +export default function ActsAppAccountCredential() { + describe('ActsAppAccountCredential', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + done(); + }) + + /* + * @tc.number : ActsAppAccountCredential_0100 + * @tc.name : The correct calls setAssociatedData and getCredential get the credential + * @tc.desc : The setCredential setting credential is called when the forwarding parameters + * are correct, and then getCredential is called for the credential(callback) + */ + it('ActsAppAccountCredential_0100', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0100", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_0100", "credentialType1", "credential1",(err)=>{ + console.debug("====>ActsAppAccountCredential_0100 setCredential:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential("account_name_0100", "credentialType1", (err,data)=>{ + console.debug("====>getCredential 0100 err:" + JSON.stringify(err)); + console.debug("====>getCredential 0100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("credential1"); + appAccountManager.removeAccount("account_name_0100", (err)=>{ + console.debug("====>delete Account 0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_0100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_0200 + * @tc.name : The correct calls setCredential and getCredential get the credential + * @tc.desc : The setAssociatedData setting credential is called when the forwarding parameters + * are correct, and then getCredential is called for the credential(promise) + */ + it('ActsAppAccountCredential_0200', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add accountActsAppAccountCredential_0200 start===="); + await appAccountManager.createAccount("account_name_0200"); + console.debug("====>setCredential ActsAppAccountCredential_0200 start===="); + try{ + await appAccountManager.setCredential("account_name_0200", "credentialType2", "credential2"); + } + catch(err){ + console.error("setCredential ActsAppAccountCredential_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getCredential ActsAppAccountCredential_0200 start===="); + try{ + var data = await appAccountManager.getCredential("account_name_0200", "credentialType2"); + } + catch(err){ + console.error("getCredential ActsAppAccountCredential_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getCredential ActsAppAccountCredential_0200 data:" + JSON.stringify(data)); + expect(data).assertEqual("credential2"); + console.debug("====>delete account ActsAppAccountCredential_0200 start===="); + appAccountManager.removeAccount("account_name_0200") + console.debug("====>ActsAppAccountCredential_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAppAccountCredential_0300 + * @tc.name : Whether getAssociatedData can get the correct value when calling setCredential two times + * @tc.desc : When the first setCredential is called and the second setCredential + * is called,the setting of the credential is different if the call getCredential + * can get the second credential(callback) + */ + it('ActsAppAccountCredential_0300', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0300",(err)=>{ + console.debug("====>add account ActsAppAccountCredential_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_0300", "credentialType3", "credential3",(err)=>{ + console.debug("====>setCredential first time 0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_0300", "credentialType3", "newcredential3",(err)=>{ + console.debug("====>setCredential second time 0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential("account_name_0300", "credentialType3", (err, data)=>{ + console.debug("====>getCredential 0300 err:" + JSON.stringify(err)); + console.debug("====>getCredential 0300 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("newcredential3"); + appAccountManager.removeAccount("account_name_0300", (err)=>{ + console.debug("====>delete Account 0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_0300 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_0400 + * @tc.name : Whether getAssociatedData can get the correct value when calling setCredential two times + * @tc.desc : When the first setCredential is called and the second setCredential + * is called,the setting of the credential is different if the call getCredential + * can get the second credential(promise) + */ + it('ActsAppAccountCredential_0400', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_0400 start===="); + await appAccountManager.createAccount("account_name_0400"); + try{ + await appAccountManager.setCredential("account_name_0400", "credentialType4", "credential4"); + await appAccountManager.setCredential("account_name_0400", "credentialType4", "newcredential4") + } + catch(err){ + console.error("setCredential ActsAppAccountCredential_0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getCredential("account_name_0400", "credentialType4"); + } + catch(err){ + console.error("getCredential ActsAppAccountCredential_0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAppAccountCredential_0400 getCredential data:" + JSON.stringify(data)); + expect(data).assertEqual("newcredential4"); + console.debug("====>delete account ActsAppAccountCredential_0400 start===="); + appAccountManager.removeAccount("account_name_0400") + console.debug("====>ActsAppAccountCredential_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsAppAccountCredential_0500 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is null + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming credential is null(callback) + */ + it('ActsAppAccountCredential_0500', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0500",(err)=>{ + console.debug("====>add account ActsAppAccountCredential_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_0500", "credentialType5", "", (err)=>{ + console.debug("====>setCredential ActsAppAccountCredential_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential("account_name_0500", "credentialType5", (err,data)=>{ + console.debug("====>getCredential ActsAppAccountCredential_0500 err:" + JSON.stringify(err)); + console.debug("====>getCredential ActsAppAccountCredential_0500 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(""); + appAccountManager.removeAccount("account_name_0500", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_0500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_0600 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is null + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming credential is null(promise) + */ + it('ActsAppAccountCredential_0600', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_0600 start===="); + await appAccountManager.createAccount("account_name_0600"); + console.debug("====>setCredential ActsAppAccountCredential_0600 start===="); + await appAccountManager.setCredential("account_name_0600", "credentialType6", ""); + console.debug("====>getCredential ActsAppAccountCredential_0600 start===="); + var data = await appAccountManager.getCredential("account_name_0600", "credentialType6"); + console.debug("====>getCredential ActsAppAccountCredential_0600 data" + JSON.stringify(data)); + expect(data).assertEqual(""); + console.debug("====>delete account ActsAppAccountCredential_0600 start===="); + await appAccountManager.removeAccount("account_name_0600"); + console.debug("====>ActsAppAccountCredential_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsAppAccountCredential_0700 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is null(callback) + */ + it('ActsAppAccountCredential_0700', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0700", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_0700", "", "credential7", (err)=>{ + console.debug("====>setCredential ActsAppAccountCredential_0700 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("account_name_0700", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_0700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_0800 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is null(promise) + */ + it('ActsAppAccountCredential_0800', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ccountActsAppAccountCredential_0800 start===="); + await appAccountManager.createAccount("account_name_0800"); + try{ + await appAccountManager.setCredential("account_name_0800", "", "credential8"); + } + catch(err){ + console.debug("====>setCredential ActsAppAccountCredential_0800 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_0800 start===="); + appAccountManager.removeAccount("account_name_0800"); + console.debug("====>ActsAppAccountCredential_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAppAccountCredential_0900 + * @tc.name : getCredential getting value is called when the argument is wrong + * @tc.desc : Call getCredential getting credential when the incoming parameter type is wrong(callback) + */ + it('ActsAppAccountCredential_0900', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0900", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential("account_name_0900", "", (err)=>{ + console.debug("====>getCredential ActsAppAccountCredential_0900 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("account_name_0900", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_0900 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_1000 + * @tc.name : getCredential getting value is called when the argument is wrong + * @tc.desc : Call getCredential getting credential when the incoming parameter type is wrong(promise) + */ + it('ActsAppAccountCredential_1000', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_1000 start===="); + await appAccountManager.createAccount("account_name_1000"); + try{ + await appAccountManager.getCredential("account_name_1000",""); + } + catch(err){ + console.debug("====>getCredential ActsAppAccountCredential_1000 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_1000 start===="); + await appAccountManager.removeAccount("account_name_1000"); + console.debug("====>ActsAppAccountCredential_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAppAccountCredential_1100 + * @tc.name : setAssociatedData setting credential is called when the argument is sapce + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is space + * then use getCredential getting the credential(callback) + */ + it('ActsAppAccountCredential_1100', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1100",(err)=>{ + console.debug("====>add account ActsAppAccountCredential_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_1100", " ", "credential11",(err)=>{ + console.debug("====>setCredential ActsAppAccountCredential_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential("account_name_1100", " ", (err, data)=>{ + console.debug("====>getCredential 1100 err:" + JSON.stringify(err)); + console.debug("====>getCredential 1100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("credential11"); + appAccountManager.removeAccount("account_name_1100", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_1100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_1200 + * @tc.name : setAssociatedData setting credential is called when the argument is sapce + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is space + * then use getCredential getting the credential(promise) + */ + it('ActsAppAccountCredential_1200', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_1200 start===="); + await appAccountManager.createAccount("account_name_1200"); + console.debug("====>setCredential ActsAppAccountCredential_1200 start===="); + await appAccountManager.setCredential("account_name_1200", " ", "credential12"); + console.debug("====>getCredential ActsAppAccountCredential_1200 start===="); + var data = await appAccountManager.getCredential("account_name_1200", " "); + console.debug("====>getCredential ActsAppAccountCredential_1200 data" + JSON.stringify(data)); + expect(data).assertEqual("credential12"); + console.debug("====>delete account ActsAppAccountCredential_1200 start===="); + await appAccountManager.removeAccount("account_name_1200"); + console.debug("====>ActsAppAccountCredential_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsAppAccountCredential_1300 + * @tc.name : setAssociatedData setting credential is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter name is null(callback) + */ + it('ActsAppAccountCredential_1300', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1300",(err)=>{ + console.debug("====>add account ActsAppAccountCredential_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("", "credentialType13", "credential13", (err)=>{ + console.debug("====>setCredential ActsAppAccountCredential_1300 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("account_name_1300", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_1300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_1400 + * @tc.name : setAssociatedData setting credential is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter name is null(promise) + */ + it('ActsAppAccountCredential_1400', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_1400 start===="); + await appAccountManager.createAccount("account_name_1400"); + try{ + await appAccountManager.setCredential("", "credentialType14", "credential14"); + } + catch(err){ + console.debug("====>setCredential ActsAppAccountCredential_1400 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_1400 start===="); + await appAccountManager.removeAccount("account_name_1400"); + console.debug("====>ActsAppAccountCredential_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAppAccountCredential_1500 + * @tc.name : Get it directly without setting credential callback + * @tc.desc : Call getCredential directly to get credential without calling setCredential + */ + it('ActsAppAccountCredential_1500', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1500", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential("account_name_1500", "credentialType15", (err)=>{ + console.debug("====>getCredential ActsAppAccountCredential_1500 err:" + JSON.stringify(err)); + expect(err.code == 12300019).assertEqual(true); + appAccountManager.removeAccount("account_name_1500", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_1500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_1600 + * @tc.name : Get it directly without setting credential promise + * @tc.desc : Call getCredential directly to get credential without calling setCredential + */ + it('ActsAppAccountCredential_1600', 0, async function (done) { + console.debug("cActsAppAccountCredential_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_1600 start===="); + await appAccountManager.createAccount("account_name_1600"); + try{ + await appAccountManager.getCredential("account_name_1600", "credentialType16"); + } + catch(err){ + console.debug("====>getCredential ActsAppAccountCredential_1600 err:" + JSON.stringify(err)); + expect(err.code == 12300019).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_1600 start===="); + await appAccountManager.removeAccount("account_name_1600"); + console.debug("====>ActsAppAccountCredential_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAppAccountCredential_1700 + * @tc.name : setCredential setting credential is called when the argument is wrong callback + * @tc.desc : Call setCredential setting credential when the incoming parameter credential is wrong + */ + it('ActsAppAccountCredential_1700', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1700 start===="); + var CREDENTIALOVERSIZE = "K" + for(var i = 0;i < 256;i++) + CREDENTIALOVERSIZE = CREDENTIALOVERSIZE + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1700", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_1700", "credentialType17", CREDENTIALOVERSIZE, (err)=>{ + console.debug("====>CREDENTIALOVERSIZE.length:" + JSON.stringify(CREDENTIALOVERSIZE.length)); + expect(CREDENTIALOVERSIZE.length).assertEqual(1025); + console.debug("====>setCredential ActsAppAccountCredential_1700 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("account_name_1700", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_1700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_1800 + * @tc.name : setCredential setting credential is called when the argument is wrong promise + * @tc.desc : Call setCredential setting credential when the incoming parameter credential is wrong + */ + it('ActsAppAccountCredential_1800', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1800 start===="); + var bigStr = "K" + for(var i = 0;i < 256;i++) + bigStr = bigStr + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_1800 start===="); + await appAccountManager.createAccount("account_name_1800"); + try{ + await appAccountManager.setCredential("account_name_1800", "credentialType18", bigStr); + } + catch(err){ + console.debug("====>bigStr.length:" + JSON.stringify(bigStr.length)); + expect(bigStr.length).assertEqual(1025); + console.debug("====>setCredential ActsAppAccountCredential_1800 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_1800 start===="); + await appAccountManager.removeAccount("account_name_1800"); + console.debug("====>ActsAppAccountCredential_1800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAppAccountCredential_1900 + * @tc.name : setCredential setting credential is called when the argument is wrong + * @tc.desc : Call setCredential setting type when the incoming parameter credential is wrong(callback) + */ + it('ActsAppAccountCredential_1900', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_1900 start===="); + var CREDENTIALTYPEOVERSIZE = "K" + for(var i = 0;i < 256;i++) + CREDENTIALTYPEOVERSIZE = CREDENTIALTYPEOVERSIZE + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1900", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential("account_name_1900", CREDENTIALTYPEOVERSIZE, "credential19", (err)=>{ + console.debug("====>CREDENTIALTYPEOVERSIZE.length:" + JSON.stringify(CREDENTIALTYPEOVERSIZE.length)); + expect(CREDENTIALTYPEOVERSIZE.length).assertEqual(1025); + console.debug("====>setCredential ActsAppAccountCredential_1900 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("account_name_1900", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAppAccountCredential_1900 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_2000 + * @tc.name : setCredential setting credential is called when the argument is wrong + * @tc.desc : Call setCredential setting type when the incoming parameter credential is wrong(promise) + */ + it('ActsAppAccountCredential_2000', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_2000 start===="); + var CREDENTIALTYPEOVERSIZE = "K" + for(var i = 0;i < 256;i++) + CREDENTIALTYPEOVERSIZE=CREDENTIALTYPEOVERSIZE+"K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_2000 start===="); + await appAccountManager.createAccount("account_name_2000"); + try{ + await appAccountManager.setCredential("account_name_2000", CREDENTIALTYPEOVERSIZE , "credential20"); + } + catch(err){ + console.debug("====>CREDENTIALTYPEOVERSIZE.length:" + JSON.stringify(CREDENTIALTYPEOVERSIZE.length)); + expect(CREDENTIALTYPEOVERSIZE.length).assertEqual(1025); + console.debug("====>setCredential ActsAppAccountCredential_2000 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_2000 start===="); + await appAccountManager.removeAccount("account_name_2000"); + console.debug("====>ActsAppAccountCredential_2000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAppAccountCredential_2100 + * @tc.name : setCredential setting credential is called when the argument is wrong + * @tc.desc : Call setCredential setting name when the incoming parameter name is wrong(callback) + */ + it('ActsAppAccountCredential_2100', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_2100 start===="); + var NAMEOVERSIZE = "n" + for(var i = 0;i < 256;i++) + NAMEOVERSIZE = NAMEOVERSIZE + "name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_2100", (err)=>{ + console.debug("====>add account ActsAppAccountCredential_2100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential(NAMEOVERSIZE, "credentialType21", "credential21", (err)=>{ + console.debug("====>setCredential ActsAppAccountCredential_2100 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("account_name_2100", (err)=>{ + console.debug("====>delete Account ActsAppAccountCredential_2100 err:" + JSON.stringify(err)); + console.debug("====>ActsAppAccountCredential_2100 end===="); + expect(err).assertEqual(null); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAppAccountCredential_2200 + * @tc.name : setCredential setting credential is called when the argument is wrong + * @tc.desc : Call setCredential setting name when the incoming parameter name is wrong(promise) + */ + it('ActsAppAccountCredential_2200', 0, async function (done) { + console.debug("====>ActsAppAccountCredential_2200 start===="); + var NAMEOVERSIZE ="n" + for(var i=0;i<256;i++) + NAMEOVERSIZE=NAMEOVERSIZE+"name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAppAccountCredential_2200 start===="); + try{ + await appAccountManager.createAccount("account_name_2200"); + } + catch(err){ + console.debug("====>add account ActsAppAccountCredential_2200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setCredential ActsAppAccountCredential_2200 start===="); + try{ + await appAccountManager.setCredential(NAMEOVERSIZE, "credentialType22", "credential22"); + } + catch(err){ + console.debug("====>setCredential ActsAppAccountCredential_2200 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAppAccountCredential_2200 start===="); + await appAccountManager.removeAccount("account_name_2200"); + console.debug("====>ActsAppAccountCredential_2200 end===="); + done(); + } + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/AccountManager.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/AccountManager.test.js new file mode 100644 index 0000000000000000000000000000000000000000..cd5d686762b6d517f50f98875399aa3f72513160 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/AccountManager.test.js @@ -0,0 +1,95 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +export default function ActsAccountManager() { + describe('ActsAccountManager', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountManager_0100 + * @tc.name : createAppAccountManager + * @tc.desc : Create two application account module objects, one object adds an application account, + * the other object deletes the application account + */ + it('ActsAccountManager_0100', 0, async function (done) { + console.debug("====>ActsAccountManager_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var appAccountManagerTwo = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("creatappaccount_name_first", (err)=>{ + console.debug("====>add account ActsAccountManager_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManagerTwo.removeAccount("creatappaccount_name_first", (err)=>{ + console.debug("====>delete Account ActsAccountManager_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountManager_0100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountManager_0200 + * @tc.name : createAppAccountManager + * @tc.desc : Create two application account module objects, one object adds application accounts and + * sets additional information, and the other object can obtain additional information of + * the application account + */ + it('ActsAccountManager_0200', 0, async function (done) { + console.debug("====>ActsAccountManager_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + var appAccountManagerTwo = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("creatappaccount_name_second", (err)=>{ + console.debug("====>add account ActsAccountManager_0200 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManagerTwo.setAccountExtraInfo("creatappaccount_name_second", "creatappaccount_extra", (err)=>{ + console.debug("====>setAccountExtraInfo err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountExtraInfo("creatappaccount_name_second", (err, data)=>{ + console.debug("====>getAccountExtraInfo err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("creatappaccount_extra"); + appAccountManagerTwo.removeAccount("creatappaccount_name_second", (err)=>{ + console.debug("====>delete Account err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountManager_0200 end===="); + done(); + }); + }); + }); + }); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/AuthToken.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/AuthToken.test.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f456992fde22f3338e8a58f7c035f09adabf2a --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/AuthToken.test.js @@ -0,0 +1,3423 @@ +/* + * 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 account from '@ohos.account.appAccount' +import resmgr from '@ohos.resourceManager' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + + +const TIMEOUT = 1000; +const EACHTIMEOUT = 500; +const LENGTHLIMIT = 512; +const TOKENLENGTHLIMIT = 1024; +const AUTHTYPELENGTHLIMIT = 1024; +const OWNERLENGTHLIMIT = 1024; + +const OWNERSELF = "com.example.actsaccountoperatetest"; +export default function ActsAccountAuthToken() { + describe('ActsAccountAuthToken', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + beforeEach(async function (done) { + console.debug("====>beforeAll enter===="); + await sleep(EACHTIMEOUT); + done(); + }); + + /* + * @tc.number : testGetEntriesString101 + * @tc.name : Use getEntries get the value by mixing the string key + * @tc.desc : Mixed strings value can be obtained correctly + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 1 + */ + + + it('ActsAccountAuthToken_9100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountAuthToken_9100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType1","test_token1",(err)=>{ + console.debug("====>ActsAccountAuthToken_9100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_9100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_tokenTest_name","authType1","other_app_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_9100 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType2","test_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_9100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_9100 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9100 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(2); + appAccountManager.deleteAuthToken("account_tokenTest_name",OWNERSELF,"authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_9100 deleteAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_9100 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9100 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(2); + appAccountManager.removeAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_9100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_9100 end===="); + done(); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_9100 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9100 getAuthToken data:" + data); + expect(err.code==12300003).assertEqual(true); + console.debug("====>ActsAccountAuthToken_9100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_9000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountAuthToken_9000 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_9000 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_9000 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9000 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("test_token"); + appAccountManager.setAuthTokenVisibility("account_tokenTest_name","authType","other_app_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_9000 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_9000 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_9000 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("other_app_bundleName"); + appAccountManager.deleteAuthToken("account_tokenTest_name",OWNERSELF,"authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_9000 deleteAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_9000 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9000 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(1); + expect(ArrayData[0].authType).assertEqual("authType"); + expect(ArrayData[0].token).assertEqual(""); + appAccountManager.setAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,false,(err)=>{ + console.debug("====>ActsAccountAuthToken_9000 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_9000 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9000 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_9000 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_9000 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + + it('ActsAccountAuthToken_7100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_7100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7100 createAccount start===="); + appAccountManager.createAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_7100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType1","test_token1",(err)=>{ + console.debug("====>ActsAccountAuthToken_7100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_7100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType2","test_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_7100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_7100 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7100 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(2); + expect(ArrayData[0].authType).assertEqual("authType1"); + expect(ArrayData[0].token).assertEqual("test_token2"); + expect(ArrayData[1].authType).assertEqual("authType2"); + expect(ArrayData[1].token).assertEqual("test_token2"); + appAccountManager.deleteAuthToken("account_tokenTest_name",OWNERSELF,"authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_7100 deleteAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_7100 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7100 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(1); + expect(ArrayData[0].authType).assertEqual("authType2"); + expect(ArrayData[0].token).assertEqual("test_token2"); + appAccountManager.removeAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_7100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_7100 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7100 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_7200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_7200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountAuthToken_7200 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7200 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_7200 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7200 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("test_token"); + appAccountManager.getAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_7200 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7200 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_7200 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7200 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_7300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_7300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7300 createAccount start===="); + appAccountManager.createAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_7300 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7300 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_7300 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7300 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("test_token"); + appAccountManager.checkAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_7300 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7300 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.setAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,false,(err)=>{ + console.debug("====>ActsAccountAuthToken_7300 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_7300 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7300 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.deleteAuthToken("account_tokenTest_name",OWNERSELF,"authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7300 deleteAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_7300 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7300 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_7400', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountAuthToken_7400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7400 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountAuthToken_7400 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_limit","authType","callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7400 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_authType_limit",OWNERSELF,limitAuthType,"callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7400 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountAuthToken_7400 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7400 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_7500', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountAuthToken_7500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7500 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_limit"); + console.debug("====>ActsAccountAuthToken_7500 getAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_authType_limit",OWNERSELF,limitAuthType,"promise_authType_limit_token"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_7500 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_7500 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_limit"); + console.debug("====>ActsAccountAuthToken_7500 end===="); + done(); + } + }); + + + + it('ActsAccountAuthToken_7600', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountAuthToken_7600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7600 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountAuthToken_7600 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_limit",limitAuthType,"callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7600 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_authType_limit",OWNERSELF,limitAuthType,"callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7600 getAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountAuthToken_7600 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7600 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_7700', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountAuthToken_7700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7700 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_limit") + console.debug("====>ActsAccountAuthToken_7700 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_authType_limit",limitAuthType,"promise_authType_limit_token"); + console.debug("====>ActsAccountAuthToken_7700 deleteAuthToken start===="); + await appAccountManager.deleteAuthToken("account_promise_authType_limit",OWNERSELF,limitAuthType,"promise_authType_limit_token") + console.debug("====>ActsAccountAuthToken_7700 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_limit") + console.debug("====>ActsAccountAuthToken_7700 end===="); + done(); + + }); + + + + it('ActsAccountAuthToken_7800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_7800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7800 createAccount start===="); + appAccountManager.createAccount("account_callback_empty_authType",(err)=>{ + console.debug("====>ActsAccountAuthToken_7800 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_empty_authType","authType","callback_empty_authType_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7800 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_empty_authType",OWNERSELF,"","callback_empty_authType_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_7800 deleteAuthToken err:" + JSON.stringify(err)); + expect(err.code == 12400004).assertEqual(true); + appAccountManager.getAuthToken("account_callback_empty_authType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_7800 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_7800 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_empty_authType_token"); + appAccountManager.removeAccount("account_callback_empty_authType",(err)=>{ + console.debug("====>ActsAccountAuthToken_7800 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_7800 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_7900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_7900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7900 createAccount start===="); + await appAccountManager.createAccount("account_promise_empty_authType"); + console.debug("====>ActsAccountAuthToken_7900 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_empty_authType","authType","promise_empty_authType_token"); + console.debug("====>ActsAccountAuthToken_7900 deleteAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_empty_authType",OWNERSELF,"","promise_empty_authType_token"); + }catch(err){ + console.debug('====>ActsAccountAuthToken_7900 deleteAuthToken err:' + JSON.stringify(err)) + expect(err.code == 12400004).assertEqual(true); + console.debug("====>ActsAccountAuthToken_7900 getAuthToken start===="); + var data = await appAccountManager.getAuthToken("account_promise_empty_authType",OWNERSELF,"authType"); + expect(data).assertEqual("promise_empty_authType_token"); + console.debug("====>ActsAccountAuthToken_7900 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_empty_authType"); + console.debug("====>ActsAccountAuthToken_7900 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_8000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8000 createAccount start===="); + appAccountManager.createAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountAuthToken_8000 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token1",(err)=>{ + console.debug("====>ActsAccountAuthToken_8000 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token2",(err)=>{ + console.debug("====>ActsAccountAuthToken_8000 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_8000 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8000 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setSameAuthType_token2"); + appAccountManager.deleteAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType","callback_setSameAuthType_token1",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_8000 deleteAuthToken err:" + JSON.stringify(err)); + expect(err.code == 12400004).assertEqual(true); + appAccountManager.removeAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountAuthToken_8000 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8000 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_8100', 0, async function (done) { + var limitName = ''; + for(var i = 0;i < LENGTHLIMIT + 1; i++){ + limitName += 'c'; + } + console.debug("====>ActsAccountAuthToken_8100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8100 getAllAuthTokens start===="); + appAccountManager.getAllAuthTokens(limitName, OWNERSELF).then((ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8100 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(ArrayData.length).assertEqual(0); + console.debug("====>ActsAccountAuthToken_8100 ===="); + done(); + }).catch((err)=>{ + expect(err.code!=0).assertEqual(true); + done(); + }) + }); + + it('ActsAccountAuthToken_8200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8200 getAllAuthTokens start===="); + appAccountManager.getAllAuthTokens("", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8200 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8200 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_8200 ===="); + done(); + }); + }); + + it('ActsAccountAuthToken_8300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8300 getAllAuthTokens start===="); + appAccountManager.getAllAuthTokens("acount_no_setToken", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8300 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8300 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8300 end===="); + done(); + }); + }); + + + + it('ActsAccountAuthToken_8400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8400 createAccount start===="); + appAccountManager.createAccount("acount_no_setToken",(err)=>{ + console.debug("====>ActsAccountAuthToken_8400 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("acount_no_setToken", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8400 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8400 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(0); + appAccountManager.removeAccount("acount_no_setToken",(err)=>{ + console.debug("====>ActsAccountAuthToken_8400 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8400 end===="); + done(); + }); + }); + }); + }); + + + + it('ActsAccountAuthToken_8500', 0, async function (done) { + var limitName = ''; + for(var i = 0;i < LENGTHLIMIT; i++){ + limitName += 'c'; + } + console.debug("====>ActsAccountAuthToken_8500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8500 createAccount start===="); + appAccountManager.createAccount(limitName,(err)=>{ + console.debug("====>ActsAccountAuthToken_8500 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken(limitName,"authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_8500 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens(limitName, OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8500 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8500 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err).assertEqual(null); + expect(ArrayData.length).assertEqual(1); + expect(ArrayData[0].authType).assertEqual("authType"); + expect(ArrayData[0].token).assertEqual("test_token"); + appAccountManager.removeAccount(limitName,(err)=>{ + console.debug("====>ActsAccountAuthToken_8500 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8500 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_8600', 0, async function (done) { + var limitOwner = ''; + for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ + limitOwner += 'c'; + } + console.debug("====>ActsAccountAuthToken_8600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8600 createAccount start===="); + appAccountManager.createAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8600 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_callback_getAllAuthTokens_test",limitOwner,(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8600 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8600 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData).assertEqual(null); + appAccountManager.removeAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8600 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8600 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_8700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8700 createAccount start===="); + appAccountManager.createAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_callback_getAllAuthTokens_test","",(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8700 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8700 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData).assertEqual(null); + appAccountManager.removeAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8700 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_8800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8800 createAccount start===="); + appAccountManager.createAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8800 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_callback_getAllAuthTokens_test","invalid_owner",(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8800 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8800 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData).assertEqual(null); + appAccountManager.removeAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8800 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8800 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountAuthToken_8900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_8900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_8900 createAccount start===="); + appAccountManager.createAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAuthTokens("account_callback_getAllAuthTokens_test"," ",(err,ArrayData)=>{ + console.debug("====>ActsAccountAuthToken_8900 getAllAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_8900 getAllAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData).assertEqual(null); + appAccountManager.removeAccount("account_callback_getAllAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountAuthToken_8900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_8900 end===="); + done(); + }); + }); + }); + }); + + + + + it('ActsAccountAuthToken_0100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0100 createAccount start===="); + appAccountManager.createAccount("account_callback_normal",(err)=>{ + console.debug("====>ActsAccountAuthToken_0100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_normal","authType","callback_normal_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_0100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_normal",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_0100 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_0100 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_normal_token"); + appAccountManager.checkAuthTokenVisibility("account_callback_normal","authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_0100 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_0100 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.deleteAuthToken("account_callback_normal",OWNERSELF,"authType","callback_normal_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_0100 deleteAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("account_callback_normal",(err)=>{ + console.debug("====>ActsAccountAuthToken_0100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_0100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_0200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0200 createAccount start===="); + await appAccountManager.createAccount("account_promise_normal"); + console.debug("====>ActsAccountAuthToken_0200 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_normal","authType","promise_normal_token"); + console.debug("====>ActsAccountAuthToken_0200 getAuthToken start===="); + var data1 = await appAccountManager.getAuthToken("account_promise_normal",OWNERSELF,"authType"); + console.debug("====>getAuthToken ActsAccountAuthToken_0200 data:" + data1); + expect(data1).assertEqual("promise_normal_token"); + console.debug("====>ActsAccountAuthToken_0200 checkAuthTokenVisibility start===="); + var state = await appAccountManager.checkAuthTokenVisibility("account_promise_normal","authType",OWNERSELF); + console.debug("====>checkAuthTokenVisibility ActsAccountAuthToken_0200 state:" + state); + expect(state).assertEqual(true); + console.debug("====>ActsAccountAuthToken_0200 deleteAuthToken start===="); + await appAccountManager.deleteAuthToken("account_promise_normal",OWNERSELF,"authType","promise_normal_token"); + console.debug("====>ActsAccountAuthToken_0200 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_normal"); + console.debug("====>ActsAccountAuthToken_0200 end===="); + done(); + }); + + + + + it('ActsAccountAuthToken_0300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0300 getAuthToken start===="); + appAccountManager.createAccount("account_callback_noSetToken",(err)=>{ + console.debug("====>ActsAccountAuthToken_0300 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_noSetToken",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_0300 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_0300 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_noSetToken",(err)=>{ + console.debug("====>ActsAccountAuthToken_0300 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_0300 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountAuthToken_0400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0400 createAccount start===="); + await appAccountManager.createAccount("account_promise_noSetToken"); + console.debug("====>ActsAccountAuthToken_0400 getAuthToken start===="); + try{ + await appAccountManager.getAuthToken("account_promise_noSetToken",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_0400 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_0400 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_noSetToken"); + console.debug("====>ActsAccountAuthToken_0400 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_0500', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0500 getAuthToken start===="); + appAccountManager.getAuthToken("noAdd_account_callback",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_0500 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_0500 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + done(); + }); + }); + + it('ActsAccountAuthToken_0600', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0600 getAuthToken start===="); + try{ + await appAccountManager.getAuthToken("noAdd_account_promise",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_0600 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_0600 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_0700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0700 createAccount start===="); + appAccountManager.createAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountAuthToken_0700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_0700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_0700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_0700 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_0700 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setSameAuthType_token"); + appAccountManager.setAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_DiffToken",(err)=>{ + console.debug("====>ActsAccountAuthToken_0700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_0700 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_0700 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setSameAuthType_DiffToken"); + appAccountManager.removeAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountAuthToken_0700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_0700 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + + + + + it('ActsAccountAuthToken_0800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_0800 createAccount start===="); + await appAccountManager.createAccount("account_promise_setSameAuthType"); + console.debug("====>ActsAccountAuthToken_0800 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_token"); + console.debug("====>ActsAccountAuthToken_0800 repeat setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_token"); + var data1 = await appAccountManager.getAuthToken("account_promise_setSameAuthType",OWNERSELF,"authType"); + console.debug("====>getAuthToken ActsAccountAuthToken_0800 data:" + data1); + expect(data1).assertEqual("promise_setSameAuthType_token"); + console.debug("====>ActsAccountAuthToken_0800 repeat set diffToken setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_DiffToken"); + var data2 = await appAccountManager.getAuthToken("account_promise_setSameAuthType",OWNERSELF,"authType"); + console.debug("====>getAuthToken ActsAccountAuthToken_0800 data:" + data2); + expect(data2).assertEqual("promise_setSameAuthType_DiffToken"); + console.debug("====>ActsAccountAuthToken_0800 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_setSameAuthType"); + console.debug("====>ActsAccountAuthToken_0800 end===="); + done(); + }); + + + + it('ActsAccountAuthToken_0900', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_setDiff", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setDiff","authType1","callback_setDiff_token1",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setDiff","authType2","callback_setDiff_token2",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setDiff",OWNERSELF,"authType1", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_0900 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_0900 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setDiff_token1"); + appAccountManager.getAuthToken("account_callback_setDiff",OWNERSELF,"authType2", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_0900 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_0900 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setDiff_token2"); + appAccountManager.removeAccount("account_callback_setDiff", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_0900 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + + it('ActsAccountAuthToken_1000', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_1000 createAccount start===="); + await appAccountManager.createAccount("account_promise_setDiff"); + console.debug("====>setAuthToken ActsAccountAuthToken_1000 start===="); + await appAccountManager.setAuthToken("account_promise_setDiff","aythType1","promise_setDiff_token1"); + console.debug("====>setAuthToken ActsAccountAuthToken_1000 start===="); + await appAccountManager.setAuthToken("account_promise_setDiff","aythType2","promise_setDiff_token2"); + + console.debug("====>getAuthToken ActsAccountAuthToken_1000 start===="); + var data1 = await appAccountManager.getAuthToken("account_promise_setDiff",OWNERSELF,"aythType1"); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1000 data:" + data1); + expect(data1).assertEqual("promise_setDiff_token1"); + console.debug("====>getAuthToken ActsAccountAuthToken_1000 start===="); + var data2 = await appAccountManager.getAuthToken("account_promise_setDiff",OWNERSELF,"aythType2"); + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1000 data:" + data2); + expect(data2).assertEqual("promise_setDiff_token2"); + + console.debug("====>deleteAuthToken ActsAccountAuthToken_1000 start===="); + await appAccountManager.deleteAuthToken("account_promise_setDiff",OWNERSELF,"aythType1","promise_setDiff_token1"); + console.debug("====>deleteAuthToken ActsAccountAuthToken_1000 start===="); + await appAccountManager.deleteAuthToken("account_promise_setDiff",OWNERSELF,"aythType2","promise_setDiff_token2"); + console.debug("====>ActsAccountAuthToken_1000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_setDiff"); + console.debug("====>ActsAccountAuthToken_1000 end===="); + done(); + }); + + + + it('ActsAccountAuthToken_1100', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setDeleteGet","old_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setDeleteGet","new_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1100 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setDeleteGet_token"); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1100 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setDeleteGet_token"); + appAccountManager.deleteAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>deleteAuthToken deleteOld ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1100 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1100 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("callback_setDeleteGet_token"); + appAccountManager.deleteAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>deleteAuthToken deleteNew ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1100 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1100 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_1100 end===="); + done(); + }); + }); + }) + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_1200', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_1200 createAccount start===="); + await appAccountManager.createAccount("account_promise_setDeleteGet"); + + console.debug("====>setAuthToken setOld ActsAccountAuthToken_1200 start===="); + await appAccountManager.setAuthToken("account_promise_setDeleteGet","old_authType","promise_setDeleteGet_token"); + console.debug("====>setAuthToken setNew ActsAccountAuthToken_1200 start===="); + await appAccountManager.setAuthToken("account_promise_setDeleteGet","new_authType","promise_setDeleteGet_token"); + + console.debug("====>getAuthToken ActsAccountAuthToken_1200 start===="); + var data1BeforeDel = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType"); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 data1BeforeDel:" + data1BeforeDel); + expect(data1BeforeDel).assertEqual("promise_setDeleteGet_token"); + console.debug("====>getAuthToken ActsAccountAuthToken_1200 start===="); + var data2BeforeDel = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType"); + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1200 data2BeforeDel:" + data2BeforeDel); + expect(data2BeforeDel).assertEqual("promise_setDeleteGet_token"); + + console.debug("====>deleteAuthToken deleteOld ActsAccountAuthToken_1200 start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType","promise_setDeleteGet_token"); + } + catch(err){ + console.debug("====>deleteAuthToken ActsAccountAuthToken_1200 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + } + + console.debug("====>getAuthToken ActsAccountAuthToken_1200 start===="); + try{ + var data1AfterDel = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType",); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 data1_AfterDel:" + data1AfterDel); + expect().assertFail(); + } + catch(err){ + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + } + console.debug("====>getAuthToken ActsAccountAuthToken_1200 start===="); + try{ + var data2AfterDel = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType",); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 data2_AfterDel:" + data2AfterDel); + expect(data2AfterDel).assertEqual("promise_setDeleteGet_token"); + } + catch(err){ + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1200 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + } + console.debug("====>deleteAuthToken deleteNew ActsAccountAuthToken_1200 start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType","promise_setDeleteGet_token"); + } + catch(err){ + console.debug("====>deleteAuthToken ActsAccountAuthToken_1200 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + } + + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 start===="); + try{ + var data1AgainDel = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType",); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 data1_AgainDel:" + data1AgainDel); + expect().assertFail(); + } + catch(err){ + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + } + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1200 start===="); + try{ + var data2AgainDel = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType",); + console.debug("====>getAuthToken getOld ActsAccountAuthToken_1200 data2_AgainDel:" + data2AgainDel); + expect().assertFail(); + } + catch(err){ + console.debug("====>getAuthToken getNew ActsAccountAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + } + await appAccountManager.removeAccount("account_promise_setDeleteGet"); + console.debug("====>ActsAccountAuthToken_1200 end===="); + done(); + + }); + + + it('ActsAccountAuthToken_1300', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setDeleteGet","authType","account_callback_setDeleteGet_token",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_setDeleteGet",OWNERSELF,"authType","account_callback_setDeleteGet_token",(err)=>{ + console.debug("====>deleteAuthToken ActsAccountAuthToken_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setDeleteGet",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_1300 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_1300 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_1300 end===="); + done(); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_1400', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_1400 createAccount start===="); + await appAccountManager.createAccount("account_promise_setDeleteGet"); + console.debug("====>setAuthToken ActsAccountAuthToken_1400 start===="); + await appAccountManager.setAuthToken("account_promise_setDeleteGet","authType","promise_setDeleteGet_token"); + console.debug("====>deleteAuthToken ActsAccountAuthToken_1400 start===="); + await appAccountManager.deleteAuthToken("account_promise_setDeleteGet",OWNERSELF,"authType","promise_setDeleteGet_token"); + console.debug("====>getAuthToken ActsAccountAuthToken_1400 start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_setDeleteGet",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>getAuthToken ActsAccountAuthToken_1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>getAuthToken ActsAccountAuthToken_1400 data:" + data); + console.debug("====>ActsAccountAuthToken_1400 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_setDeleteGet"); + console.debug("====>ActsAccountAuthToken_1400 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_1500', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setAuthToken("account_callback_accountNotExit","authType","account_callback_accountNotExit_token", (err)=>{ + console.debug("====>setAuthToken ActsAccountAuthToken_1500 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_1500 end===="); + done(); + }); + }); + + it('ActsAccountAuthToken_1600', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>setAuthToken ActsAccountAuthToken_1600 start===="); + try{ + await appAccountManager.setAuthToken("account_promise_accountNotExit","authType","account_promise_accountNotExit_token"); + } + catch(err){ + console.debug("====>setAuthToken ActsAccountAuthToken_1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_1600 end===="); + done(); + } + }); + + + + it('ActsAccountAuthToken_1700', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteAuthToken("account_callback_accountNotExit",OWNERSELF,"authType","account_callback_accountNotExit_token", (err)=>{ + console.debug("====>deleteAuthToken ActsAccountAuthToken_1700 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_1700 end===="); + done(); + }); + }); + + it('ActsAccountAuthToken_1800', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>deleteAuthToken ActsAccountAuthToken_1800 start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_accountNotExit",OWNERSELF,"authType","account_promise_accountNotExit_token"); + } + catch(err){ + console.debug("====>deleteAuthToken ActsAccountAuthToken_1800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_1800 end===="); + done(); + } + }); + + + + it('ActsAccountAuthToken_1900', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ + console.debug("====>deleteAuthToken ActsAccountAuthToken_1900 err:" + JSON.stringify(err)); + appAccountManager.getAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_1900 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_1900 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_1900 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_2000', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_2000 createAccount start===="); + await appAccountManager.createAccount("account_promise_noExitToken"); + console.debug("====>deleteAuthToken ActsAccountAuthToken_2000 start===="); + await appAccountManager.deleteAuthToken("account_promise_noExitToken",OWNERSELF,"aythType","test_token").catch((err)=>{ + console.debug("====>deleteAuthToken ActsAccountAuthToken_2000 err:" + JSON.stringify(err)); + }); + console.debug("====>getAuthToken ActsAccountAuthToken_2000 start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_noExitToken",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>getAuthToken ActsAccountAuthToken_2000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_2000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_noExitToken"); + console.debug("====>ActsAccountAuthToken_2000 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_2100', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_repeatDelete","authType","",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ + console.debug("====>deleteAuthToken first ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + appAccountManager.getAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken first ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken first ActsAccountAuthToken_2100 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ + console.debug("====>deleteAuthToken second ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + appAccountManager.getAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken second ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken second ActsAccountAuthToken_2100 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_2100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_2100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + + + + it('ActsAccountAuthToken_2200', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_2200 createAccount start===="); + await appAccountManager.createAccount("account_promise_repeatDelete"); + console.debug("====>setAuthToken ActsAccountAuthToken_2200 start===="); + await appAccountManager.setAuthToken("account_promise_repeatDelete","aythType","promise_repeatDelete_token"); + console.debug("====>deleteAuthToken first ActsAccountAuthToken_2200 start===="); + await appAccountManager.deleteAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); + try{ + console.debug("====>deleteAuthToken second ActsAccountAuthToken_2200 start===="); + await appAccountManager.deleteAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); + expect().assertFail() + }catch(err){ + expect(err.code == 12400004).assertEqual(true); + console.debug("====>deleteAuthToken second ActsAccountAuthToken_2200 err:" + JSON.stringify(err)); + } + try{ + console.debug("====>getAuthToken ActsAccountAuthToken_2200 start===="); + var data = await appAccountManager.getAuthToken("account_promise_repeatDelete",OWNERSELF,"authType"); + expect().assertFail() + } + catch(err){ + console.debug("====>getAuthToken ActsAccountAuthToken_2200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_2200 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_repeatDelete"); + console.debug("====>ActsAccountAuthToken_2200 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_2300', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_setEmptyToken", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_setEmptyToken","authType","",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_setEmptyToken",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2300 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_2300 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_setEmptyToken", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_2300 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_2400', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_2400 createAccount start===="); + await appAccountManager.createAccount("account_promise_setEmptyToken"); + console.debug("====>setAuthToken ActsAccountAuthToken_2400 start===="); + await appAccountManager.setAuthToken("account_promise_setEmptyToken","aythType",""); + console.debug("====>getAuthToken ActsAccountAuthToken_2400 start===="); + try{ + await appAccountManager.getAuthToken("account_promise_setEmptyToken","authType",limitToken); + } + catch(err){ + console.debug("====>getAuthToken ActsAccountAuthToken_2400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_2400 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_setEmptyToken"); + console.debug("====>ActsAccountAuthToken_2400 end===="); + done(); + } + }); + + + + it('ActsAccountAuthToken_2500', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_spaceToken", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_spaceToken","authType"," ",(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_spaceToken",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2500 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_2500 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual(" "); + appAccountManager.removeAccount("account_callback_spaceToken", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_2500 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_2600', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_2600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_2600 createAccount start===="); + await appAccountManager.createAccount("account_promise_spaceToken"); + console.debug("====>setAuthToken ActsAccountAuthToken_2600 start===="); + await appAccountManager.setAuthToken("account_promise_spaceToken","aythType"," "); + console.debug("====>getAuthToken ActsAccountAuthToken_2600 start===="); + var data = await appAccountManager.getAuthToken("account_promise_spaceToken",OWNERSELF,"aythType"); + expect(data).assertEqual(" "); + console.debug("====>ActsAccountAuthToken_2600 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_spaceToken"); + console.debug("====>ActsAccountAuthToken_2600 end===="); + done(); + }); + + + + it('ActsAccountAuthToken_2700', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT + 1; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountAuthToken_2700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_exceed_limitToken", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_2700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_exceed_limitToken","authType",limitToken,(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2700 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_exceed_limitToken", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_2700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_2700 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_2800', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT + 1; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountAuthToken_2800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_2800 createAccount start===="); + await appAccountManager.createAccount("account_promise_exceed_limitToken"); + console.debug("====>setAuthToken ActsAccountAuthToken_2800 start===="); + try{ + await appAccountManager.setAuthToken("account_promise_exceed_limitToken","authType",limitToken); + } + catch(err){ + console.debug("====>setAuthToken ActsAccountAuthToken_2800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_2800 removeAccount start===="); + appAccountManager.removeAccount("account_promise_exceed_limitToken"); + console.debug("====>ActsAccountAuthToken_2800 end===="); + done(); + } + }); + + + it('ActsAccountAuthToken_2900', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountAuthToken_2900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_limitToken", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_2900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_limitToken","authType",limitToken,(err)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_limitToken",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_2900 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_2900 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual(limitToken); + appAccountManager.removeAccount("account_callback_limitToken", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_2900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_2900 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_3000', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountAuthToken_3000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3000 createAccount start===="); + await appAccountManager.createAccount("account_promise_limitToken"); + console.debug("====>setAuthToken ActsAccountAuthToken_3000 start===="); + await appAccountManager.setAuthToken("account_promise_limitToken","authType",limitToken); + console.debug("====>getAuthToken ActsAccountAuthToken_3000 start===="); + var data = await appAccountManager.getAuthToken("account_promise_limitToken",OWNERSELF,"authType"); + expect(data).assertEqual(limitToken); + console.debug("====>ActsAccountAuthToken_3000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_limitToken"); + console.debug("====>ActsAccountAuthToken_3000 end===="); + done(); + }); + + + it('ActsAccountAuthToken_3100', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_3100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_3100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_limitAuthType",limitAuthType,"account_callback_limitAuthType_token",(err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_3100 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_3100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_3100 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_3200', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_3400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3400 createAccount start===="); + await appAccountManager.createAccount("account_promise_exceed_limitAuthType"); + console.debug("====>setAuthToken ActsAccountAuthToken_3400 start===="); + try{ + await appAccountManager.setAuthToken("account_promise_exceed_limitAuthType",limitAuthType,"account_promise_limitAuthType_token"); + } + catch(err){ + console.debug("====>setAuthToken ActsAccountAuthToken_3400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_3400 removeAccount start===="); + appAccountManager.removeAccount("account_promise_exceed_limitAuthType"); + console.debug("====>ActsAccountAuthToken_3400 end===="); + done(); + } + }); + + + + it('ActsAccountAuthToken_3300', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_3300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>createAccount ActsAccountAuthToken_3300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_limitAuthType","com.example.actsaccounttest",limitAuthType, (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_3300 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_3300 data:" + data); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>removeAccount ActsAccountAuthToken_3300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_3300 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountAuthToken_3400', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_3400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3400 createAccount start===="); + await appAccountManager.createAccount("account_promise_limitAuthType"); + console.debug("====>getAuthToken ActsAccountAuthToken_3400 start===="); + try{ + await appAccountManager.getAuthToken("account_promise_limitAuthType",OWNERSELF,limitAuthType); + } + catch(err){ + console.debug("====>getAuthToken ActsAccountAuthToken_3400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_3400 removeAccount start===="); + appAccountManager.removeAccount("account_promise_limitAuthType"); + console.debug("====>ActsAccountAuthToken_3400 end===="); + done(); + } + }); + + + + /* + * @tc.number : ActsAccountAuthToken_2700 + * @tc.name : Test auth token in callback form + * @tc.desc : 设置一个authType长度刚好为限制长度的token 查询 + */ + it('ActsAccountAuthToken_3500', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_3500 start===="); + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT; i++) { + limitAuthType += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3500 create finish===="); + appAccountManager.createAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>add account ActsAccountAuthToken_3500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_limitAuthType",limitAuthType,"account_callback_limitAuthType_token", (err)=>{ + console.debug("====>setAuthToken ActsAccountAuthToken_3500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_limitAuthType","com.example.actsaccountoperatetest",limitAuthType, (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_3500 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_3500 data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("account_callback_limitAuthType_token"); + appAccountManager.removeAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>delete Account ActsAccountAuthToken_3500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_3500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAuthToken_2800 + * @tc.name : Test auth token in promise form + * @tc.desc : 设置一个authType长度刚好为限制长度的token + */ + + /* + * @tc.number : ActsAccountAuthToken_2900 + * @tc.name : Test auth token in callback form + * @tc.desc : Clear token parameter name is an empty string + */ + //测试 删除一个账号名为空的token callback方式 + it('ActsAccountAuthToken_4100', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4100 create finish===="); + appAccountManager.deleteAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ + console.debug("====>clearauthToken ActsAccountAuthToken_4100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAuthToken_3000 + * @tc.name : Test auth token in promise form + * @tc.desc : Clear token parameter name is an empty string + */ + //测试 删除一个账号名为空的token promise方式 + it('ActsAccountAuthToken_4200', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4200 create finish===="); + console.debug("====>clearauthToken ActsAccountAuthToken_4200 start===="); + try{ + await appAccountManager.deleteAuthToken("","com.example.actsaccounttest","authType","account_notExist_token"); + } + catch(err){ + console.debug("====>deleteAuthToken ActsAccountAuthToken_4200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAuthToken_3100 + * @tc.name : Test auth token in callback form + * @tc.desc : The clear token parameter name is a space string + */ + it('ActsAccountAuthToken_4300', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4300 create finish===="); + appAccountManager.deleteAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ + console.debug("====>clearauthToken ActsAccountAuthToken_4300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAuthToken_3200 + * @tc.name : Test auth token in promise form + * @tc.desc : The clear token parameter name is a space string + */ + it('ActsAccountAuthToken_4400', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4400 create finish===="); + console.debug("====>clearauthToken ActsAccountAuthToken_4400 start===="); + try{ + await appAccountManager.deleteAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token"); + } + catch(err){ + console.debug("====>deleteAuthToken ActsAccountAuthToken_4400 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAuthToken_3300 + * @tc.name : Test auth token in callback form + * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters + */ + it('ActsAccountAuthToken_4500', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4500 start===="); + var nameLimit = ''; + for (let i = 0; i < LENGTHLIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4500 create finish===="); + appAccountManager.deleteAuthToken(nameLimit,"com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ + console.debug("====>clearauthToken ActsAccountAuthToken_4500 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAuthToken_3400 + * @tc.name : Test auth token in promise form + * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters + */ + it('ActsAccountAuthToken_4600', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4600 start===="); + var nameLimit = ''; + for (let i = 0; i < LENGTHLIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4600 create finish===="); + console.debug("====>deleteAuthToken ActsAccountAuthToken_4600 start===="); + try{ + await appAccountManager.deleteAuthToken(nameLimit,"com.example.actsaccounttest","authType","account_notExist_token"); + } + catch(err){ + console.debug("====>deleteAuthToken ActsAccountAuthToken_4600 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4600 end===="); + done(); + } + }); + + //查询无效包名owner(为其他字符串时)账号的token callback方式 + it('ActsAccountAuthToken_4700', 0, async function(done) { + console.debug("====>ActsAccountAuthToken_4700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4700 create finish===="); + appAccountManager.createAccount("account_callback_invalid_owner", (err)=>{ + console.debug("====>add account ActsAccountAuthToken_4700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_invalid_owner","invalid_owner","authType", (err, data)=>{ + console.debug("====>getAuthToken ActsAccountAuthToken_4700 err:" + JSON.stringify(err)); + console.debug("====>getAuthToken ActsAccountAuthToken_4700 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_invalid_owner", (err)=>{ + console.debug("====>delete account ActsAccountAuthToken_4700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_4700 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_3600', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_3600 start===="); + var limitAuthType = ''; + for (var i = 0; i < AUTHTYPELENGTHLIMIT; i++) { + limitAuthType += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3600 createAccount start===="); + await appAccountManager.createAccount("account_promise_limitAuthType"); + console.debug("====>ActsAccountAuthToken_3600 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_limitAuthType",limitAuthType,"account_promise_limitAuthType_token"); + console.debug("====>ActsAccountAuthToken_3600 getAuthToken start===="); + var data = await appAccountManager.getAuthToken("account_promise_limitAuthType",OWNERSELF,limitAuthType); + expect(data).assertEqual("account_promise_limitAuthType_token"); + console.debug("====>ActsAccountAuthToken_3600 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_limitAuthType"); + console.debug("====>ActsAccountAuthToken_3600 end===="); + done(); + }); + + + it('ActsAccountAuthToken_3700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_3700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3700 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_3700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_empty","","account_callback_authType_empty_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_3700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_authType_empty",OWNERSELF,"",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_3700 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_3700 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("account_callback_authType_empty_token"); + appAccountManager.removeAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_3700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_3700 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_3800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_3800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3800 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountAuthToken_3800 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_authType_empty","","account_promise_authType_empty_token"); + console.debug("====>ActsAccountAuthToken_3800 getAuthToken start===="); + var data = await appAccountManager.getAuthToken("account_promise_authType_empty",OWNERSELF,""); + expect(data).assertEqual("account_promise_authType_empty_token"); + console.debug("====>ActsAccountAuthToken_3800 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountAuthToken_3800 end===="); + done(); + }); + + it('ActsAccountAuthToken_3900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_3900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_3900 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_3900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_space"," ","account_callback_authType_space_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_3900 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_authType_space",OWNERSELF," ",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_3900 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_3900 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("account_callback_authType_space_token"); + appAccountManager.removeAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_3900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_3900 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_4000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_4000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4000 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_space"); + console.debug("====>ActsAccountAuthToken_4000 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_authType_space"," ","account_promise_authType_space_token"); + console.debug("====>ActsAccountAuthToken_4000 getAuthToken start===="); + var data = await appAccountManager.getAuthToken("account_promise_authType_space",OWNERSELF," "); + expect(data).assertEqual("account_promise_authType_space_token"); + console.debug("====>ActsAccountAuthToken_4000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_space"); + console.debug("====>ActsAccountAuthToken_4000 end===="); + done(); + }); + + + it('ActsAccountAuthToken_4800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_4800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4800 createAccount start===="); + await appAccountManager.createAccount("account_promise_invalid_owner"); + console.debug("====>ActsAccountAuthToken_4800 getAuthToken start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_invalid_owner","invalid_owner","authType"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_4800 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_4800 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_invalid_owner"); + console.debug("====>ActsAccountAuthToken_4800 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_4900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_4900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_4900 createAccount start===="); + appAccountManager.createAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_4900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_owner_empty","","authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_4900 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_4900 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_4900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_4900 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountAuthToken_5000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5000 createAccount start===="); + await appAccountManager.createAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountAuthToken_5000 getAuthToken start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_owner_empty","","authType"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_5000 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_5000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountAuthToken_5000 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_5100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5100 createAccount start===="); + appAccountManager.createAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_5100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_owner_space"," ","authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_5100 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_5100 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_5100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_5100 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountAuthToken_5200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5200 createAccount start===="); + await appAccountManager.createAccount("account_callback_owner_space"); + console.debug("====>ActsAccountAuthToken_5200 getAuthToken start===="); + try{ + var data = await appAccountManager.getAuthToken("account_callback_owner_space"," ","authType"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_5200 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_5200 removeAccount start===="); + await appAccountManager.removeAccount("account_callback_owner_space"); + console.debug("====>ActsAccountAuthToken_5200 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_5300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5300 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_invalid",(err)=>{ + console.debug("====>ActsAccountAuthToken_5300 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_invalid","authType","account_callback_authType_invalid_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_5300 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_authType_invalid",OWNERSELF,"invalid_authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_5300 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_5300 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_authType_invalid",(err)=>{ + console.debug("====>ActsAccountAuthToken_5300 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_5300 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_5400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5400 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_invalid"); + console.debug("====>ActsAccountAuthToken_5400 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_authType_invalid","authType","account_promise_authType_invalid_token"); + console.debug("====>ActsAccountAuthToken_5400 getAuthToken start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_authType_invalid",OWNERSELF,"invalid_authType"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_5400 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_5400 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_invalid"); + console.debug("====>ActsAccountAuthToken_5400 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_5500', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5500 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_5500 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_empty","authType","account_callback_authType_empty_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_5500 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_authType_empty",OWNERSELF,"",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_5500 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_5500 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_5500 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_5500 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_5600', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5600 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountAuthToken_5600 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_authType_empty","authType","account_promise_authType_empty_token"); + console.debug("====>ActsAccountAuthToken_5600 getAuthToken start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_authType_empty",OWNERSELF,""); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_5600 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_5600 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountAuthToken_5600 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_5700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5700 createAccount start===="); + appAccountManager.createAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_5700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_authType_space","authType","account_callback_authType_space_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_5700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_callback_authType_space",OWNERSELF," ",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_5700 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_5700 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_5700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_5700 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_5800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5800 createAccount start===="); + await appAccountManager.createAccount("account_promise_authType_space"); + console.debug("====>ActsAccountAuthToken_5800 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_authType_space","authType","account_promise_authType_space_token"); + console.debug("====>ActsAccountAuthToken_5800 getAuthToken start===="); + try{ + var data = await appAccountManager.getAuthToken("account_promise_authType_space",OWNERSELF," "); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_5800 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_5800 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_authType_space"); + console.debug("====>ActsAccountAuthToken_5800 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_5900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_5900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_5900 createAccount start===="); + appAccountManager.createAccount("account_callback_owner_invalid",(err)=>{ + console.debug("====>ActsAccountAuthToken_5900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_owner_invalid","authType","account_callback_owner_invalid_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_5900 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_owner_invalid","invalid_owner","authType","account_callback_owner_invalid_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_5900 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_owner_invalid",(err)=>{ + console.debug("====>ActsAccountAuthToken_5900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_5900 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_6000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_6000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6000 createAccount start===="); + await appAccountManager.createAccount("account_promise_owner_invalid"); + console.debug("====>ActsAccountAuthToken_6000 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_owner_invalid","authType","account_promise_owner_invalid_token"); + console.debug("====>ActsAccountAuthToken_6000 getAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_owner_invalid","invalid_owner","authType","account_promise_owner_invalid_token"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_6000 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_6000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_owner_invalid"); + console.debug("====>ActsAccountAuthToken_6000 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_6100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_6100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6100 createAccount start===="); + appAccountManager.createAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_6100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_owner_empty","authType","account_callback_owner_empty_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_6100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_owner_empty","","authType","account_callback_owner_empty_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_6100 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountAuthToken_6100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_6100 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_6200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_6200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6200 createAccount start===="); + await appAccountManager.createAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountAuthToken_6200 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_owner_empty","authType","account_promise_owner_empty_token"); + console.debug("====>ActsAccountAuthToken_6200 getAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_owner_empty","","authType","account_promise_owner_empty_token"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_6200 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_6200 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountAuthToken_6200 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_6300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_6300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6300 createAccount start===="); + appAccountManager.createAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_6300 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_owner_space","authType","account_callback_owner_space_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_6300 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_owner_space"," ","authType","account_callback_owner_space_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_6300 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_6300 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_6300 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_6400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_6400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6400 createAccount start===="); + await appAccountManager.createAccount("account_promise_owner_space"); + console.debug("====>ActsAccountAuthToken_6400 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_owner_space","authType","account_promise_owner_space_token"); + console.debug("====>ActsAccountAuthToken_6400 getAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_owner_space"," ","authType","account_promise_owner_space_token"); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_6400 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_6400 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_owner_space"); + console.debug("====>ActsAccountAuthToken_6400 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_6500', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT + 1; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountAuthToken_6500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6500 createAccount start===="); + appAccountManager.createAccount("account_callback_token_exceedLimit",(err)=>{ + console.debug("====>ActsAccountAuthToken_6500 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_token_exceedLimit",OWNERSELF,"authType",limitToken,(err)=>{ + console.debug("====>ActsAccountAuthToken_6500 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_callback_token_exceedLimit",(err)=>{ + console.debug("====>ActsAccountAuthToken_6500 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_6500 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountAuthToken_6600', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT + 1; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountAuthToken_6600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6600 createAccount start===="); + await appAccountManager.createAccount("account_promise_token_exceedLimit"); + console.debug("====>ActsAccountAuthToken_6600 deleteAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_token_exceedLimit",OWNERSELF,"authType",limitToken); + } + catch(err){ + console.debug("====>ActsAccountAuthToken_6600 getAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_6600 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_token_exceedLimit"); + console.debug("====>ActsAccountAuthToken_6600 end===="); + done(); + } + }); + + it('ActsAccountAuthToken_6700', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountAuthToken_6700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6700 createAccount start===="); + appAccountManager.createAccount("account_callback_token_limit",(err)=>{ + console.debug("====>ActsAccountAuthToken_6700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_token_limit","authType",limitToken,(err)=>{ + console.debug("====>ActsAccountAuthToken_6700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_token_limit",OWNERSELF,"authType",limitToken,(err)=>{ + console.debug("====>ActsAccountAuthToken_6700 getAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("account_callback_token_limit",(err)=>{ + console.debug("====>ActsAccountAuthToken_6700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_6700 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_6800', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountAuthToken_6800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6800 createAccount start===="); + await appAccountManager.createAccount("account_promise_token_limit"); + console.debug("====>ActsAccountAuthToken_6800 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_token_limit","authType",limitToken); + console.debug("====>ActsAccountAuthToken_6800 deleteAuthToken start===="); + await appAccountManager.deleteAuthToken("account_promise_token_limit",OWNERSELF,"authType",limitToken); + console.debug("====>ActsAccountAuthToken_6800 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_token_limit"); + console.debug("====>ActsAccountAuthToken_6800 end===="); + done(); + }); + + it('ActsAccountAuthToken_6900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_6900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_6900 createAccount start===="); + appAccountManager.createAccount("account_callback_delete_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_6900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_callback_delete_space","authType","account_callback_delete_space_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_6900 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.deleteAuthToken("account_callback_delete_space", OWNERSELF,"authType", "",(err)=>{ + console.debug("====>ActsAccountAuthToken_6900 deleteAuthToken err:" + JSON.stringify(err)); + expect(err.code == 12400004).assertEqual(true) + appAccountManager.getAuthToken("account_callback_delete_space", OWNERSELF, "authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_6900 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_6900 getAuthToken data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("account_callback_delete_space_token"); + appAccountManager.removeAccount("account_callback_delete_space",(err)=>{ + console.debug("====>ActsAccountAuthToken_6900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_6900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_7000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_7000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountAuthToken_7000 createAccount start===="); + await appAccountManager.createAccount("account_promise_delete_space"); + console.debug("====>ActsAccountAuthToken_7000 setAuthToken start===="); + await appAccountManager.setAuthToken("account_promise_delete_space","authType","account_promise_delete_space_token"); + console.debug("====>ActsAccountAuthToken_7000 deleteAuthToken start===="); + try{ + await appAccountManager.deleteAuthToken("account_promise_delete_space",OWNERSELF,"authType",""); + expect().assertFail(); + done(); + }catch(err){ + expect(err.code == 12400004).assertEqual(true) + console.debug("====>ActsAccountAuthToken_7000 getAuthToken start===="); + var data = await appAccountManager.getAuthToken("account_promise_delete_space",OWNERSELF,"authType"); + expect(data).assertEqual("account_promise_delete_space_token"); + console.debug("====>ActsAccountAuthToken_7000 removeAccount start===="); + await appAccountManager.removeAccount("account_promise_delete_space"); + console.debug("====>ActsAccountAuthToken_7000 end===="); + done(); + } + + + }); + + it('ActsAccountAuthToken_9200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthCallback("test_sessionId").then(()=>{ + expect().assertFail(); + done(); + }) + .catch((err)=>{ + console.debug("====>ActsAccountAuthToken_9200 getAuthCalback err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true) + done(); + }) + }); + + it('ActsAccountAuthToken_9300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthCallback("").then(()=>{ + expect().assertFail(); + done(); + }) + .catch((err)=>{ + console.debug("====>ActsAccountAuthToken_9300 getAuthCalback err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true) + done(); + }) + }); + + it('ActsAccountAuthToken_9400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthCallback(" ").then(()=>{ + expect().assertFail(); + done(); + }) + .catch((err)=>{ + console.debug("====>ActsAccountAuthToken_9400 getAuthCalback err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true) + done(); + }) + }); + + it('ActsAccountAuthToken_9500', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.queryAuthenticatorInfo(OWNERSELF,(err)=>{ + console.debug("====>ActsAccountAuthToken_9500 queryAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_9600', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.queryAuthenticatorInfo("",(err)=>{ + console.debug("====>ActsAccountAuthToken_9600 queryAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_9700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.queryAuthenticatorInfo(" ",(err)=>{ + console.debug("====>ActsAccountAuthToken_9700 queryAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_9800', 0, async function (done) { + var limiOwner = ''; + for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ + limiOwner += 't'; + } + console.debug("====>ActsAccountAuthToken_9800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.queryAuthenticatorInfo(limiOwner,(err)=>{ + console.debug("====>ActsAccountAuthToken_9800 queryAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_9900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_9900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err,)=>{ + console.debug("====>ActsAccountAuthToken_9900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","authType","test_BundleName",true).then(()=>{ + appAccountManager.getAuthToken("account_setAuthTokenVisibility_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_9900 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_9900 getAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_9900 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_9900 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_BundleName"); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_9900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_9900 end===="); + done(); + }); + }); + }); + }).catch((err)=>{ + expect(err).assertEqual(null); + done(); + }) + }); + }); + + it('ActsAccountAuthToken_10000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err,)=>{ + console.debug("====>ActsAccountAuthToken_10000 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10000 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + try{ + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","authType","test_BundleName","true",(err)=>{ + expect().assertFail(); + done(); + }); + }catch(err){ + expect(err.code == 401).assertEqual(true); + console.debug("====>ActsAccountAuthToken_10000 setAuthTokenVisibility err:" + JSON.stringify(err)); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10000 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10000 end===="); + done(); + }); + } + + }); + }); + }); + + it('ActsAccountAuthToken_10100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + try{ + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","authType","test_BundleName","invalid_string",(err)=>{ + console.debug("====>ActsAccountAuthToken_10100 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(err){ + console.debug("====>ActsAccountAuthToken_10100 setAuthTokenVisibility throw_err:" + JSON.stringify(err)); + expect(err.code == 401).assertEqual(true); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10100 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10100 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10100 end===="); + done(); + }); + }); + } + }); + }); + }); + + it('ActsAccountAuthToken_10200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10200 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10200 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","authType","",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10200 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code==12300002).assertEqual(true); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10200 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10200 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_10300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10300 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10300 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","authType"," ",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10300 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10300 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10300 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual(" "); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10300 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10300 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_10400', 0, async function (done) { + var limitBundleName = ''; + for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ + limitBundleName += 't'; + } + console.debug("====>ActsAccountAuthToken_10400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10400 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10400 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","authType",limitBundleName,true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10400 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10400 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10400 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_10500', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10500 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10500 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10500 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10500 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10500 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10500 getAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10500 getAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10500 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10500 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_10600', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10600 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10600 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name"," ","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10600 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name"," ",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10600 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10600 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10600 getAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10600 getAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10600 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10600 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountAuthToken_10700', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_10700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name",limitAuthType,"test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10700 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10700 getAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10700 getAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_10800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10800 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_setAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_10800 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_setAuthTokenVisibility_name","invalid_authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10800 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","invalid_authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10800 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10800 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.getAuthList("account_setAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_10800 getAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10800 getAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_setAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_10800 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_10800 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_10900', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_10900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setAuthTokenVisibility("","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_10900 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setAuthTokenVisibility(" ","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_11000 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11100', 0, async function (done) { + var limitName = ''; + for(var i = 0; i < LENGTHLIMIT + 1; i++){ + limitName += 't'; + } + console.debug("====>ActsAccountAuthToken_11100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setAuthTokenVisibility(limitName,"authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_11100 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setAuthTokenVisibility("no_add_account","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_11200 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkAuthTokenVisibility("","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11300 checkAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkAuthTokenVisibility(" ","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11400 checkAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11500', 0, async function (done) { + var limitName = ''; + for(var i = 0; i < LENGTHLIMIT + 1; i++){ + limitName += 't'; + } + console.debug("====>ActsAccountAuthToken_11500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkAuthTokenVisibility(limitName,"authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11500 checkAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11600', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkAuthTokenVisibility("no_add_account","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11600 checkAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountAuthToken_11700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_11700 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_11700 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11700 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_11700 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(false); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11700 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_11700 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_11700 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_11700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_11800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_11800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_11800 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_11800 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name"," ","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11800 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_11800 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(false); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name"," ",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11800 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_11800 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_11800 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_11800 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_11900', 0, async function (done) { + var limitAuthType =''; + for(var i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_11900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_11900 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_11900 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name",limitAuthType,"test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11900 checkAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name",limitAuthType,OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_11900 checkAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_11900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_11900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12000 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12000 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","invalid_authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_12000 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12000 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(false); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","invalid_authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_12000 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12000 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12000 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12000 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","authType","",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_12100 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12100 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12100 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12200 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12200 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","authType"," ",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_12200 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12200 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(false); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12200 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12200 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12300', 0, async function (done) { + var limitBundleName = ''; + for(var i = 0; i < OWNERLENGTHLIMIT + 1; i++){ + limitBundleName += 't'; + } + console.debug("====>ActsAccountAuthToken_12300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12300 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_checkAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12300 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_checkAuthTokenVisibility_name","authType",limitBundleName,(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_12300 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12300 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err.code!=0).assertEqual(true); + appAccountManager.removeAccount("account_checkAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12300 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12300 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_testgetAuthList_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12400 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_testgetAuthList_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12400 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_testgetAuthList_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_12400 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_testgetAuthList_name","",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_12400 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12400 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_testgetAuthList_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12400 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12400 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12500', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_testgetAuthList_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12500 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_testgetAuthList_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12500 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_testgetAuthList_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_12500 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_testgetAuthList_name"," ",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_12500 getAuthList err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12500 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.removeAccount("account_testgetAuthList_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12500 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12500 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12600', 0, async function (done) { + var limitAuthType =''; + for(var i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 't'; + } + console.debug("====>ActsAccountAuthToken_12600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_testgetAuthList_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12600 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_testgetAuthList_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_12600 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthTokenVisibility("account_testgetAuthList_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_12600 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthList("account_testgetAuthList_name",limitAuthType,(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_12600 getAuthList err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountAuthToken_12600 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray).assertEqual(null); + appAccountManager.removeAccount("account_testgetAuthList_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_12600 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_12600 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_12700', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthList("","authType").then((dataArray)=>{ + console.debug("====>ActsAccountAuthToken_12700 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + done(); + }).catch((err)=>{ + expect(err.code!=0).assertEqual(true); + done(); + }) + }); + + it('ActsAccountAuthToken_12800', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_12800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthList(" ","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_12800 getAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12800 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray).assertEqual(null); + done(); + }); + }); + + it('ActsAccountAuthToken_12900', 0, async function (done) { + var limitName = ''; + for(var i = 0; i < LENGTHLIMIT + 1; i++){ + limitName += 't'; + } + console.debug("====>ActsAccountAuthToken_12900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthList(limitName,"authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_12900 getAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_12900 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray).assertEqual(null); + done(); + }); + }); + + it('ActsAccountAuthToken_13000', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_13000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthList("no_add_account","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_13000 getAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13000 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray).assertEqual(null); + done(); + }); + }); + + it('ActsAccountAuthToken_13100', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_13100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountAuthToken_13100 createAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountAuthToken_13100 setAuthToken err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountAuthToken_13100 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13100 getAuthToken stateBack:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual("test_token"); + appAccountManager.checkAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_13100 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13100 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(false); + appAccountManager.getAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_13100 getAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13100 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err).assertEqual(null); + expect(dataArray.length).assertEqual(0); + appAccountManager.setAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountAuthToken_13100 setAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountAuthToken_13100 checkAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13100 checkAuthTokenVisibility stateBack:" + stateBack); + expect(err).assertEqual(null); + expect(stateBack).assertEqual(true); + appAccountManager.getAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountAuthToken_13100 getAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13100 getAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err).assertEqual(null); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.removeAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountAuthToken_13100 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountAuthToken_13100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountAuthToken_13200', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_13200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.queryAuthenticatorInfo("com.example.actsaccountOauthtoken",(err,dataInfo)=>{ + console.debug("====>ActsAccountAuthToken_13200 queryAuthenticatorInfo err:" + JSON.stringify(err)); + console.debug("====>ActsAccountAuthToken_13200 queryAuthenticatorInfo dataInfo:" + JSON.stringify(dataInfo)); + expect(err).assertEqual(null); + expect(isNaN(dataInfo.iconId)).assertFalse(); + expect(isNaN(dataInfo.labelId)).assertFalse(); + done(); + }); + }); + + it('ActsAccountAuthToken_13300', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_13300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.auth("authenticate_test_account","com.example.actsaccountOauthtoken","authType",{},{ + onResult: (resultCode, resultData)=>{ + console.debug("====>ActsAccountAuthToken_13300 authenticate resultCode:" + JSON.stringify(resultCode)); + console.debug("====>ActsAccountAuthToken_13300 authenticate resultData:" + JSON.stringify(resultData)); + expect(resultCode.code).assertEqual(0); + expect(resultData.name).assertEqual("authenticate_test_account"); + expect(resultData.authType).assertEqual("authType"); + expect(resultData.token).assertEqual("serviceApp/authenticate/Token"); + done(); + }, + onRequestRedirected: null + }); + done(); + }); + + it('ActsAccountAuthToken_13400', 0, async function (done) { + console.debug("====>ActsAccountAuthToken_13400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccountImplicitly("com.example.actsaccountOauthtoken",{},{ + onResult: (resultCode, resultData) =>{ + console.debug("====>ActsAccountAuthToken_13400 authenticate resultCode:" + JSON.stringify(resultCode)); + console.debug("====>ActsAccountAuthToken_13400 authenticate resultData:" + JSON.stringify(resultData)); + expect(resultCode.code).assertEqual(0); + expect(resultData.name).assertEqual("authenticate_test_account"); + expect(resultData.authType).assertEqual("authType"); + expect(resultData.token).assertEqual("serviceApp/authenticate/Token"); + done(); + }, + onRequestRedirected: (request) =>{ + console.debug("====>ActsAccountAuthToken_13400 onRequestRedirected request:" + JSON.stringify(request)); + let abilityStartSetting = { + want:request + } + featureAbility.startAbility(abilityStartSetting, (err, result)=>{ + console.debug("====>ActsAccountAuthToken_13400 onRequestRedirected err:" + JSON.stringify(err)); + }); + done(); + } + }); + done(); + }); + }) +} diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/Authenticator.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/Authenticator.test.js new file mode 100644 index 0000000000000000000000000000000000000000..cc2ea38938a45f89a98424f41bc74f51d5438957 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/Authenticator.test.js @@ -0,0 +1,725 @@ +/* + * 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 account from '@ohos.account.appAccount' +import featureAbility from '@ohos.ability.featureAbility' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const NAMELIMIT = 512; +const LENGTHLIMIT = 1024; +const name = 'zhangsan' +const owner = 'com.example.accountauthenticator' +const createAccountOptions = {customData:{age:'12'}} +export default function ActsAccountAppAccess() { + describe('ActsAccountAuthenticator', function () { + + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + beforeAll(async function (done) { + done(); + }); + /* + * @tc.number : ActsAccountCheckAccountLabels_0100 + * @tc.name : Check Account Labels callback form + * @tc.desc : + */ + it('ActsAccountCheckAccountLabels_0100', 0, async function (done) { + console.debug("====>ActsAccountCheckAccountLabels_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>start finish===="); + appAccountManager.createAccount(name, createAccountOptions, (err)=>{ + console.debug("====>ActsAccountCheckAccountLabels_0100 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAccountLabels(name, owner, ['level4'], (err, data)=>{ + console.debug("====>ActsAccountCheckAccountLabels_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAccountLabels_0100 data:" + JSON.stringify(data)); + appAccountManager.removeAccount(name, (err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0100 removeAccount_err:" + JSON.stringify(err)) + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAccountLabels_0100 end===="); + done(); + }) + }); + }); + }); + + + /* + * @tc.number : ActsAccountCheckAccountLabels_0200 + * @tc.name : Check Account Labels callback form + * @tc.desc : + */ + + it('ActsAccountCheckAccountLabels_0200', 0, async function (done) { + console.debug("====>ActsAccountCheckAccountLabels_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>start finish===="); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountCheckAccountLabels_0200 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAccountLabels(name, owner, ['20-30'], (err, data)=>{ + console.debug("====>ActsAccountCheckAccountLabels_0200 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAccountLabels_0200 data:" + JSON.stringify(data)); + appAccountManager.removeAccount(name, (err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0200 removeAccount_err:" + JSON.stringify(err)) + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAccountLabels_0200 end===="); + done(); + }) + }); + }); + }); + + /* + * @tc.number : ActsAccountCheckAccountLabels_0300 + * @tc.name : Check Account Labels callback form + * @tc.desc : + */ + + it('ActsAccountCheckAccountLabels_0300', 0, async function (done) { + console.debug("====>ActsAccountCheckAccountLabels_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>start finish===="); + appAccountManager.createAccount('CheckAccountLabels_0300', (err)=>{ + console.debug("====>ActsAccountCheckAccountLabels_0300 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAccountLabels('CheckAccountLabels_0300', owner, ['male'], (err, data)=>{ + console.debug("====>ActsAccountCheckAccountLabels_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAccountLabels_0300 data:" + JSON.stringify(data)); + expect(data).assertEqual(false) + appAccountManager.removeAccount("CheckAccountLabels_0300", (err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0300 removeAccount_err:" + JSON.stringify(err)) + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAccountLabels_0300 end===="); + done(); + }) + + }); + }); + + }); + + /* + * @tc.number : ActsAccountCheckAccountLabels_0400 + * @tc.name : Check Account Labels promise form + * @tc.desc : + */ + + it('ActsAccountCheckAccountLabels_0400', 0, async function (done) { + console.debug("====>ActsAccountCheckAccountLabels_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + await appAccountManager.createAccount(name, createAccountOptions).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0400 add_account_success"); + appAccountManager.checkAccountLabels(name, owner, ['level4']).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0400 data:" + JSON.stringify(data)); + appAccountManager.removeAccount(name).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0400 delete_account_success"); + done(); + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0400 delete_account_err"); + }); + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0400 err:" + JSON.stringify(err)) + expect().assertFail(); + done(); + }) + }).catch((err) => { + console.debug("====>ActsAccountCheckAccountLabels_0400 add_account_err:" + JSON.stringify(err)) + expect().assertFail(); + done(); + }) + }); + + /* + * @tc.number : ActsAccountCheckAccountLabels_0500 + * @tc.name : Check Account Labels promise form + * @tc.desc : + */ + + it('ActsAccountCheckAccountLabels_0500', 0, async function (done) { + console.debug("====>ActsAccountCheckAccountLabels_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + await appAccountManager.createAccount(name, createAccountOptions).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0500 add_account_success"); + appAccountManager.checkAccountLabels(name, owner, ['20-30']).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0500 data:" + JSON.stringify(data)); + expect(account.Constants.KEY_REQUIRED_LABELS).assertEqual('requiredLabels') + expect(account.Constants.KEY_BOOLEAN_RESULT).assertEqual('booleanResult') + appAccountManager.removeAccount(name).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_success"); + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_err"); + }); + done() + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0500 err:" + JSON.stringify(err)) + expect(typeof(err) != undefined).assertTrue(); + done(); + }) + }).catch((err) => { + console.debug("====>ActsAccountCheckAccountLabels_0500 add_account_err:" + JSON.stringify(err)) + expect().assertFail(); + done(); + }) + }); + + /* + * @tc.number : ActsAccountCheckAccountLabels_0600 + * @tc.name : Check Account Labels promise form + * @tc.desc : + */ + + it('ActsAccountCheckAccountLabels_0600', 0, async function (done) { + console.debug("====>ActsAccountCheckAccountLabels_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + await appAccountManager.createAccount('CheckAccountLabels_0600', createAccountOptions).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0600 add_account_success:" + JSON.stringify(data)); + appAccountManager.checkAccountLabels('CheckAccountLabels_0600', owner, ['male']).then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0600 data:" + JSON.stringify(data)); + appAccountManager.removeAccount('CheckAccountLabels_0600').then((data) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_success"); + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_err"); + }); + done() + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAccountLabels_0600 err:" + JSON.stringify(err)) + expect().assertFail(); + done(); + }) + }).catch((err) => { + console.debug("====>ActsAccountCheckAccountLabels_0600 add_account_err:" + JSON.stringify(err)) + expect().assertFail(); + done(); + }) + }); + + /* + * @tc.number : ActsAccountCheckAppAccess_0100 + * @tc.name : Check App Access callback form + * @tc.desc : + */ + + it('ActsAccountCheckAppAccess_0100', 0, async function (done) { + console.debug("====>ActsAccountCheckAppAccess_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountCheckAppAccess_0100 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAppAccess(name, owner, (err, data)=>{ + console.debug("====>ActsAccountCheckAppAccess_0100 first_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCheckAppAccess_0100 first_data:" + JSON.stringify(data)); + expect(data).assertEqual(false) + appAccountManager.setAppAccess(name, owner, true, (err, data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0100 enableAppAccess_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAppAccess(name, owner, (err, data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0100 second_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(data).assertEqual(true) + appAccountManager.setAppAccess(name, owner, false, (err, data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0100 disableAppAccount_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkAppAccess(name, owner,(err, data)=>{ + console.debug("====>ActsAccountCheckAppAccess_0100 third_err:" + JSON.stringify(err)) + expect(err).assertEqual(null) + expect(data).assertEqual(false) + try { + appAccountManager.removeAccount(name) + console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_err') + expect().assertFail() + } + }) + + }) + }) + }) + }); + }); + }); + + + /* + * @tc.number : ActsAccountCheckAppAccess_0200 + * @tc.name : Check App Access promise form + * @tc.desc : + */ + + it('ActsAccountCheckAppAccess_0200', 0, async function (done) { + console.debug("====>ActsAccountCheckAppAccess_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount(name, createAccountOptions).then((data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 add_account_success:"); + appAccountManager.checkAppAccess(name, owner).then((data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 first_data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + appAccountManager.setAppAccess(name, owner, true).then((data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 enableAppAccess_success"); + appAccountManager.checkAppAccess(name, owner).then((data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 second_data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + appAccountManager.setAppAccess(name, owner, false).then((data)=>{ + console.debug("====>ActsAccountCheckAppAccess_0200 disabAppAccess_data:" + JSON.stringify(data)); + appAccountManager.checkAppAccess(name, owner).then((data) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 third_data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + try{ + appAccountManager.removeAccount(name) + console.debug('====>ActsAccountCheckAppAccess_0200 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_err') + expect().assertFail() + } + }).catch((err)=>{ + console.debug("====>ActsAccountCheckAppAccess_0200 third_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 disableAppAccess_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 second_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err)=>{ + console.debug("====>ActsAccountCheckAppAccess_0200 enableAppAccess_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err) =>{ + console.debug("====>ActsAccountCheckAppAccess_0200 first_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err) => { + console.debug("====>ActsAccountCheckAppAccess_0200 createAccount_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + + }); + + + /* + * @tc.number : ActsAccountDeleteAccountCredential_0100 + * @tc.name : Delete Account Credential callback form + * @tc.desc : + */ + + it('ActsAccountDeleteAccountCredential_0100', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccountCredential_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>start finish===="); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountDeleteAccountCredential_0100 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setCredential(name, "PIN", "credential1", (err)=>{ + console.debug("====>ActsAccountDeleteAccountCredential_0100 setAccountCredential_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getCredential(name, "PIN", (err, data) =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0100 getAccountCredential_err:" + JSON.stringify(err)) + expect(err).assertEqual(null); + console.debug("====>ActsAccountDeleteAccountCredential_0100 getAccountCredential_success:" + JSON.stringify(data)); + appAccountManager.deleteAccountCredential(name, "PIN", (err, data)=>{ + console.debug("====>ActsAccountDeleteAccountCredential_0100 deleteAccountCredential_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(data).assertEqual(undefined); + console.debug("====>ActsAccountDeleteAccountCredential_0100 deleteAccountCredential_data:" + JSON.stringify(data)); + try{ + appAccountManager.removeAccount(name) + console.debug('====>ActsAccountDeleteAccountCredential_0100 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountDeleteAccountCredential_0100 removeAccount_err') + expect().assertFail() + done(); + } + }) + }) + }); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccountCredential_0200 + * @tc.name : Delete Account Credential promise form + * @tc.desc : + */ + + it('ActsAccountDeleteAccountCredential_0200', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccountCredential_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount(name, createAccountOptions).then((data) =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 add_account_success"); + appAccountManager.setCredential(name, "PIN", "credential2").then(() =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 setAccountCredential_success"); + appAccountManager.getCredential(name, "PIN").then((data) =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 getAccountCredential_data:" + JSON.stringify(data)); + appAccountManager.deleteAccountCredential(name, "PIN").then((data) =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 data:" + JSON.stringify(data)); + try{ + appAccountManager.removeAccount(name) + console.debug('====>ActsAccountDeleteAccountCredential_0200 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountDeleteAccountCredential_0200 removeAccount_err') + expect().assertFail() + } + }).catch((err) =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err)=>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 getAccountCredential_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err) =>{ + console.debug("====>ActsAccountDeleteAccountCredential_0200 setAccountCredential_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }).catch((err) => { + console.debug("====>ActsAccountDeleteAccountCredential_0200 createAccount_err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }); + + /* + * @tc.number : ActsAccountVerifyCredential_0100 + * @tc.name : Verify Credential callback form, options + * @tc.desc : + */ + + it('ActsAccountVerifyCredential_0100', 0, async function (done) { + console.debug("====>ActsAccountVerifyCredential_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var options = {credentialType: "PIN", credential: "123456"} + console.debug("====>start finish===="); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountVerifyCredential_0100 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.verifyCredential(name, owner, options, { + onResult: async (resultCode, resultData)=>{ + console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultcode:" + JSON.stringify(resultCode)); + expect(resultCode).assertEqual(0) + console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultData:" + JSON.stringify(resultData)); + expect(resultData.booleanResult).assertEqual(true) + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountVerifyCredential_0100 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountVerifyCredential_0100 removeAccount_err') + expect().assertFail() + } + done(); + }, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_onRequestContinued") + } + }); + }); + }); + + /* + * @tc.number : ActsAccountVerifyCredential_0200 + * @tc.name : Verify Credential callback form + * @tc.desc : + */ + + it('ActsAccountVerifyCredential_0200', 0, async function (done) { + console.debug("====>ActsAccountVerifyCredential_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>start finish===="); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountVerifyCredential_0200 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.verifyCredential(name, owner, { + onResult: async (resultCode, resultData)=>{ + console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultcode:" + JSON.stringify(resultCode)); + expect(resultCode).assertEqual(0) + console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultData:" + JSON.stringify(resultData)); + expect(resultData.booleanResult).assertEqual(false) + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_err') + expect().assertFail() + } + done(); + }, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_onRequestContinued") + } + }); + }); + }); + + /* + * @tc.number : ActsAccountSetAuthenticatorProperties_0100 + * @tc.name : Verify Credential callback form, options + * @tc.desc : + */ + + it('ActsAccountSetAuthenticatorProperties_0100', 0, async function (done) { + console.debug("====>ActsAccountSetAuthenticatorProperties_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var options = {credentialType: "PIN", credential: "123456"} + console.debug("====>start finish===="); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountSetAuthenticatorProperties_0100 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthenticatorProperties(owner, options, { + onResult: async (resultCode, resultData)=>{ + console.debug("====>ActsAccountSetAuthenticatorProperties_0100 setAuthenticatorProperties_resultcode:" + JSON.stringify(resultCode)); + expect(resultCode).assertEqual(10016) + console.debug("====>ActsAccountSetAuthenticatorProperties_0100 setAuthenticatorProperties_resultData:" + JSON.stringify(resultData)); + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountSetAuthenticatorProperties_0100 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountSetAuthenticatorProperties_0100 removeAccount_err') + expect().assertFail() + } + done(); + }, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountSetAuthenticatorProperties_0100 verifyCredential_onRequestContinued") + } + }); + }); + }); + + /* + * @tc.number : ActsAccountSetAuthenticatorProperties_0200 + * @tc.name : Verify Credential callback form + * @tc.desc : + */ + + it('ActsAccountSetAuthenticatorProperties_0200', 0, async function (done) { + console.debug("====>ActsAccountSetAuthenticatorProperties_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>start finish===="); + appAccountManager.createAccount(name, (err)=>{ + console.debug("====>ActsAccountSetAuthenticatorProperties_0200 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAuthenticatorProperties(owner, { + onResult: async (resultCode, resultData)=>{ + console.debug("====>ActsAccountSetAuthenticatorProperties_0200 setAuthenticatorProperties_resultcode:" + JSON.stringify(resultCode)); + expect(resultCode).assertEqual(10016) + console.debug("====>ActsAccountSetAuthenticatorProperties_0200 setAuthenticatorProperties_resultData:" + JSON.stringify(resultData)); + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountSetAuthenticatorProperties_0200 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountSetAuthenticatorProperties_0200 removeAccount_err') + expect().assertFail() + } + done(); + }, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountSetAuthenticatorProperties_0200 verifyCredential_onRequestContinued") + } + }); + }); + }); + + /* + * @tc.number : ActsAccountSelectAccountByOptions_0100 + * @tc.name : Verify Credential callback form + * @tc.desc : + */ + + it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) { + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.accountauthenticator", + abilityName: "com.example.accountauthenticator.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ) + await sleep(1000) + console.debug("====>ActsAccountSelectAccountByOptions_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var select_options = {allowedAccounts:[{"name":name,"owner":owner}]} + console.debug("====>start finish===="); + appAccountManager.createAccount(name, async (err)=>{ + console.debug("====>ActsAccountSelectAccountByOptions_0100 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + try { + var data = await appAccountManager.selectAccountsByOptions(select_options) + console.debug("====>ActsAccountSelectAccountByOptions_0100 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(1) + } catch(err) { + console.debug("====>ActsAccountSelectAccountByOptions_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null) + } + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountSelectAccountByOptions_0100 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountSelectAccountByOptions_0100 removeAccount_err') + expect().assertFail() + done(); + } + }); + }); + + /* + * @tc.number : ActsAccountSelectAccountByOptions_0100 + * @tc.name : Verify Credential callback form + * @tc.desc : + */ + + it('ActsAccountSelectAccountByOptions_0200', 0, async function (done) { + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.accountauthenticator", + abilityName: "com.example.accountauthenticator.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ) + await sleep(1000) + console.debug("====>ActsAccountSelectAccountByOptions_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + var select_options = {allowedOwners: [owner]} + console.debug("====>start finish===="); + appAccountManager.createAccount(name, async (err)=>{ + console.debug("====>ActsAccountSelectAccountByOptions_0200 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + try { + var data = await appAccountManager.selectAccountsByOptions(select_options) + console.debug("====>ActsAccountSelectAccountByOptions_0200 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(3) + } catch(err) { + console.debug("====>ActsAccountSelectAccountByOptions_0200 err:" + JSON.stringify(err)); + expect(err).assertEqual(null) + } + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountSelectAccountByOptions_0200 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountSelectAccountByOptions_0200 removeAccount_err') + expect().assertFail() + done(); + } + }); + }); + + + /* + * @tc.number : ActsAccountSelectAccountByOptions_0100 + * @tc.name : Verify Credential callback form + * @tc.desc : + */ + + it('ActsAccountSelectAccountByOptions_0300', 0, async function (done) { + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.accountauthenticator", + abilityName: "com.example.accountauthenticator.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ) + await sleep(1500) + console.debug("====>ActsAccountSelectAccountByOptions_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + var options = {requiredLabels: ["male", "30-40"]} + console.debug("====>start finish===="); + appAccountManager.createAccount(name, async (err)=>{ + console.debug("====>ActsAccountSelectAccountByOptions_0300 add_account_err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + try { + var data = await appAccountManager.selectAccountsByOptions(options) + console.debug("====>ActsAccountSelectAccountByOptions_0300 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(1) + } catch(err) { + console.debug("====>ActsAccountSelectAccountByOptions_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null) + } + try{ + await appAccountManager.removeAccount(name) + console.debug('====>ActsAccountSelectAccountByOptions_0300 removeAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountSelectAccountByOptions_0300 removeAccount_err') + expect().assertFail() + done(); + } + }); + }); + + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/ChangeOnOff.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/ChangeOnOff.js new file mode 100644 index 0000000000000000000000000000000000000000..860b0b8edf16f601bb07a61070116164fb491a3a --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/ChangeOnOff.js @@ -0,0 +1,450 @@ +/* + * 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 account from '@ohos.account.appAccount' +import commonevent from '@ohos.commonEvent' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +export default function ActsAccountOnOff() { + describe('ActsAccountOnOff', async function () { + + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + beforeAll(async function (done) { + done(); + }); + + async function testInit(){ + console.debug("====>startAbility start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountsceneonoff", + abilityName: "com.example.actsaccountsceneonoff.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + await sleep(TIMEOUT); + } + + /* + * @tc.number : ActsAccountOnOff_0300 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the credential + */ + it('ActsAccountOnOff_0300', 0, async function (done) { + testInit(); + console.debug("====>ActsAccountOnOff_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountOnOff_0300 start"); + await appAccountManager.createAccount("onoff_setcredential"); + console.debug("====>enableAppAccess ActsAccountOnOff_0300 start"); + await appAccountManager.setAppAccess("onoff_setcredential", "com.example.actsaccountsceneonoff", true); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0300 err:" + JSON.stringify(err)); + } + function removeAccountCallback(err){ + console.debug("====>delete account 0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0300 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_setcredential"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.removeAccount("onoff_setcredential", removeAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setCredential start===="); + try{ + await appAccountManager.setCredential("onoff_setcredential", "credentialType", "credential"); + } + catch(err){ + console.error("====>setCredential fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setCredential finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_setcredential"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountOnOff_0300 finish====") + }); + + var commonEventPublishData = { + code: 9 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0300===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountOnOff_0400 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to delete + * authorized account + */ + it('ActsAccountOnOff_0400', 0, async function (done) { + testInit(); + console.debug("====>ActsAccountOnOff_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountOnOff_0400 start"); + await appAccountManager.createAccount("onoff_removeFir"); + console.debug("====>add second account ActsAccountOnOff_0400 start"); + await appAccountManager.createAccount("onoff_removeSec"); + console.debug("====>enableAppAccess first ActsAccountOnOff_0400 start"); + await appAccountManager.setAppAccess("onoff_removeFir", "com.example.actsaccountsceneonoff", true); + console.debug("====>enableAppAccess second ActsAccountOnOff_0400 start"); + await appAccountManager.setAppAccess("onoff_removeSec", "com.example.actsaccountsceneonoff", true); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0400 err:" + JSON.stringify(err)); + } + function removeAccountCallback(err){ + console.debug("====>remove account 0400 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0400 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_remove_another"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.removeAccount("onoff_removeFir", removeAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>removeAccount start===="); + try{ + await appAccountManager.removeAccount("onoff_removeSec"); + } + catch(err){ + console.error("====>removeAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>removeAccount finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_remove_another"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountOnOff_0400 finish====") + }); + + var commonEventPublishData = { + code: 10 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0400===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountOnOff_0500 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to delete + * the only authorized account + */ + it('ActsAccountOnOff_0500', 0, async function (done) { + testInit(); + console.debug("====>ActsAccountOnOff_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountOnOff_0500 start"); + await appAccountManager.createAccount("onoff_remove"); + console.debug("====>enableAppAccess ActsAccountOnOff_0500 start"); + await appAccountManager.setAppAccess("onoff_remove", "com.example.actsaccountsceneonoff", true); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0500 err:" + JSON.stringify(err)); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0500 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_remove"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + done(); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>removeAccount start===="); + try{ + await appAccountManager.removeAccount("onoff_remove"); + } + catch(err){ + console.error("====>removeAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>removeAccount finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_remove"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountOnOff_0500 finish====") + }); + + var commonEventPublishData = { + code: 11 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0500===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountOnOff_0600 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to cancel + * authorized account + */ + it('ActsAccountOnOff_0600', 0, async function (done) { + testInit(); + console.debug("====>ActsAccountOnOff_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountOnOff_0600 start"); + await appAccountManager.createAccount("onoff_disableFir"); + console.debug("====>add second account ActsAccountOnOff_0600 start"); + await appAccountManager.createAccount("onoff_disableSec"); + console.debug("====>enableAppAccess first ActsAccountOnOff_0600 start"); + await appAccountManager.setAppAccess("onoff_disableFir", "com.example.actsaccountsceneonoff", true); + console.debug("====>enableAppAccess second ActsAccountOnOff_0600 start"); + await appAccountManager.setAppAccess("onoff_disableSec", "com.example.actsaccountsceneonoff", true); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0600 err:" + JSON.stringify(err)); + } + function removeAccountCallback(err){ + console.debug("====>remove first account 0600 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("onoff_disableSec", (err)=>{ + console.debug("====>remove second account 0600 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + done(); + }); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0600 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_set_another_disable"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.removeAccount("onoff_disableFir", removeAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>disableAppAccess start===="); + try{ + await appAccountManager.setAppAccess("onoff_disableSec", "com.example.actsaccountsceneonoff", false); + } + catch(err){ + console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_set_another_disable"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountOnOff_0600 finish====") + }); + + var commonEventPublishData = { + code: 12 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0600===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountOnOff_0700 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to cancel + * the only authorized account + */ + it('ActsAccountOnOff_0700', 0, async function (done) { + testInit(); + console.debug("====>ActsAccountOnOff_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountOnOff_0700 start"); + await appAccountManager.createAccount("onoff_disable"); + console.debug("====>enableAppAccess ActsAccountOnOff_0700 start"); + await appAccountManager.setAppAccess("onoff_disable", "com.example.actsaccountsceneonoff", true); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0700 err:" + JSON.stringify(err)); + } + function removeAccountCallback(err){ + console.debug("====>delete account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0700 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_set_disable"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.removeAccount("onoff_disable", removeAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>disableAppAccess start===="); + try{ + await appAccountManager.setAccess("onoff_disable", "com.example.actsaccountsceneonoff", false); + } + catch(err){ + console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_set_disable"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountOnOff_0700 finish====") + }); + + var commonEventPublishData = { + code: 13 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0700===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + + /* + * @tc.number : ActsAccountOnOff_0900 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Receiving account information after adding two accounts to the app, subscribing to itself, + * and changing one of the associatal data + */ + it('ActsAccountOnOff_0900', 0, async function (done) { + console.debug("====>ActsAccountOnOff_0900 start===="); + let dataMap = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountOnOff_0900 start"); + await appAccountManager.createAccount("onoff_self_first"); + console.debug("====>add second account ActsAccountOnOff_0900 start"); + await appAccountManager.createAccount("onoff_self_second"); + console.debug("====>on ActsAccountOnOff_0900 start"); + function changeOnCallback(data){ + console.debug("====>receive change 0900 data:" + JSON.stringify(data)); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("onoff_self_first")).assertTrue(); + if (dataMap.has("onoff_self_first")) { + let data = dataMap.get("onoff_self_first"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountoperatetest"); + } + expect(dataMap.has("onoff_self_second")).assertTrue(); + if (dataMap.has("onoff_self_second")) { + let data = dataMap.get("onoff_self_second"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountoperatetest"); + } + appAccountManager.off('accountChange', function (){ + console.debug("====>off ActsAccountOnOff_0900 finish===="); + appAccountManager.removeAccount("onoff_self_first", (err)=>{ + console.debug("====>delete first account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("onoff_self_second", (err)=>{ + console.debug("====>delete second account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountOnOff_0900 end===="); + done(); + }); + }); + }); + } + try{ + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountOnOff_0900 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setCustomData start===="); + try{ + await appAccountManager.setCustomData("onoff_self_second", "change_key", "change_value"); + } + catch(err){ + console.error("====>setCustomData fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/CreateAccount.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/CreateAccount.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4a6d48f991e207fd3d7b0779182a4db05342756e --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/CreateAccount.test.js @@ -0,0 +1,659 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const NAMELIMIT = 512; +const LENGTHLIMIT = 1024; +const ERR_PARAMETER_CHECK_FAILD =401 +const ERR_INVALID_PARAMETER = 12300002 +const ERR_ACCOUNT_EXIST = 12300008 +const createAccountOptions = {customData:{age:'12'}} //k and v length 1024 ,k and v size 1024 +const createAccountOptionsDiff = {customData:{sex:'male'}} +export default function ActsAccountCreateAccount() { + describe('ActsAccountCreateAccount', function () { + + /* + * @tc.number : ActsAccountCreateAccount_0100 + * @tc.name : Add account callback form + * @tc.desc : Add account in callback form without additional information + */ + it('ActsAccountCreateAccount_0100', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_callback_first", (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("account_name_callback_first", (err)=>{ + console.debug("====>delete Account ActsAccountCreateAccount_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCreateAccount_0100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_0200 + * @tc.name : Add account promise form + * @tc.desc : Add account in promise form without additional information + */ + it('ActsAccountCreateAccount_0200', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account start===="); + try{ + await appAccountManager.createAccount("account_name_promise_first"); + } + catch(err){ + console.error("====>add account fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account start===="); + await appAccountManager.removeAccount("account_name_promise_first"); + console.debug("====>ActsAccountCreateAccount_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCreateAccount_0300 + * @tc.name : Add account callback form + * @tc.desc : Add account in callback form with additional information + */ + it('ActsAccountCreateAccount_0300', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_callback_second", createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("account_name_callback_second", (err)=>{ + console.debug("====>delete Account ActsAccountCreateAccount_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCreateAccount_0300 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_0400 + * @tc.name : Add account promise form + * @tc.desc : Add account in promise form with additional information + */ + it('ActsAccountCreateAccount_0400', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account start===="); + try{ + await appAccountManager.createAccount("account_name_promise_second", createAccountOptions); + } + catch(err){ + console.error("====>add account fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account start===="); + await appAccountManager.removeAccount("account_name_promise_second"); + console.debug("====>ActsAccountCreateAccount_0400 end===="); + done(); + }); + + + /* + * @tc.number : ActsAccountCreateAccount_0500 + * @tc.name : Add account callback form + * @tc.desc : Repeatedly add the same name account and the same additional information + */ + it('ActsAccountCreateAccount_0500', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_name_callback_third", createAccountOptions, (err)=>{ + console.debug("====>add account first time ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("account_name_callback_third", createAccountOptions, (err)=>{ + console.debug("====>add account second time ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_EXIST); + appAccountManager.removeAccount("account_name_callback_third", (err)=>{ + console.debug("====>delete Account ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCreateAccount_0500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_0600 + * @tc.name : Add account promise form + * @tc.desc : Repeatedly add the same name account and the same additional information + */ + it('ActsAccountCreateAccount_0600', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account for the first time ActsAccountCreateAccount_0600===="); + await appAccountManager.createAccount("account_name_promise_third", createAccountOptions); + console.debug("====>add account for the second time ActsAccountCreateAccount_0600 start===="); + try{ + await appAccountManager.createAccount("account_name_promise_third", createAccountOptions); + } + catch(err){ + console.debug("====>add account for the second time 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_EXIST); + await appAccountManager.removeAccount("account_name_promise_third"); + console.debug("====>ActsAccountCreateAccount_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_0700 + * @tc.name : Add account callback form + * @tc.desc : The account name exceeds the length limit of 512 characters + */ + it('ActsAccountCreateAccount_0700', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0700 start===="); + var limitAccountName = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + limitAccountName += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount(limitAccountName, createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountCreateAccount_0700 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_0800 + * @tc.name : Add account promise form + * @tc.desc : The account name exceeds the length limit of 512 characters + */ + it('ActsAccountCreateAccount_0800', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0800 start===="); + var limitAccountName = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + limitAccountName += 'n'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.createAccount(limitAccountName, createAccountOptions); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>add account ActsAccountCreateAccount_0800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountCreateAccount_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_0900 + * @tc.name : Add account callback form + * @tc.desc : Additional information exceeds the length limit of 1024 characters + */ + it('ActsAccountCreateAccount_0900', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_0900 start===="); + var limitAccountExtra = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitAccountExtra += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_name_callback_fifth", {customData:{age:limitAccountExtra}}, (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountCreateAccount_0900 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_1000 + * @tc.name : Add account promise form + * @tc.desc : Additional information exceeds the length limit of 1024 characters + */ + it('ActsAccountCreateAccount_1000', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1000 start===="); + var limitAccountExtra = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitAccountExtra += 'e'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.createAccount("account_name_promise_fifth", {customData:{[limitAccountExtra]:'12'}}); + } + catch(err){ + console.debug("====>add account ActsAccountCreateAccount_1000 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountCreateAccount_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_1100 + * @tc.name : Add account callback form + * @tc.desc : The account name is an empty string + */ + it('ActsAccountCreateAccount_1100', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("", createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountCreateAccount_1100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_1200 + * @tc.name : Add account promise form + * @tc.desc : The account name is an empty string + */ + it('ActsAccountCreateAccount_1200', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1200 start===="); + console.debug("====>ActsAccountCreateAccount_1200 add account start===="); + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.createAccount("", createAccountOptions); + } + catch(err){ + console.debug("====>add account ActsAccountCreateAccount_1200 err:"+ JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountCreateAccount_1200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_1300 + * @tc.name : Add account callback form + * @tc.desc : Additional information is an empty string + */ + it('ActsAccountCreateAccount_1300', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + try{ + appAccountManager.createAccount("account_name_callback_seventh", "", (err)=>{ + expect().assertFail(); + done(); + }); + }catch(err){ + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountCreateAccount_1300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_1400 + * @tc.name : Add account promise form + * @tc.desc : Additional information is an empty string + */ + it('ActsAccountCreateAccount_1400', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountCreateAccount_1400 start===="); + try{ + await appAccountManager.createAccount("account_name_promise_seventh", ""); + } + catch(err){ + console.error("====>add account ActsAccountCreateAccount_1400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + } + console.debug("====>delete account ActsAccountCreateAccount_1400 start===="); + await appAccountManager.removeAccount("account_name_promise_seventh"); + done(); + }); + + /* + * @tc.number : ActsAccountCreateAccount_1500 + * @tc.name : Add account callback form + * @tc.desc : The account name is a special character such as a space + */ + it('ActsAccountCreateAccount_1500', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + try{ + appAccountManager.createAccount(specialStr, createAccountOptions, (err)=>{ + expect(err.code == 12300002).assertEqual(true); + console.debug("====>ActsAccountCreateAccount_1500 end===="); + done(); + }); + }catch(err){ + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_1600 + * @tc.name : Add account promise form + * @tc.desc : The account name is a special character such as a space + */ + it('ActsAccountCreateAccount_1600', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + try{ + await appAccountManager.createAccount(specialStr, createAccountOptions); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>add Account ActsAccountCreateAccount_1600 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>ActsAccountCreateAccount_1600 end===="); + done(); + } + }); + + + /* + * @tc.number : ActsAccountCreateAccount_1700 + * @tc.name : Add account callback form + * @tc.desc : The account name is a special string + */ + it('ActsAccountCreateAccount_1700', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + appAccountManager.createAccount(specialStr, createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount(specialStr, (err)=>{ + console.debug("====>delete Account ActsAccountCreateAccount_1700 err" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCreateAccount_1700 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_1800 + * @tc.name : Add account promise form + * @tc.desc : The account name is a special string + */ + it('ActsAccountCreateAccount_1800', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + console.debug("====>add account ActsAccountCreateAccount_1800===="); + try{ + await appAccountManager.createAccount(specialStr, createAccountOptions); + } + catch(err){ + console.error("====>add Account ActsAccountCreateAccount_1800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountCreateAccount_1800===="); + await appAccountManager.removeAccount(specialStr); + console.debug("====>ActsAccountCreateAccount_1800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCreateAccount_1900 + * @tc.name : Add account callback form + * @tc.desc : Additional information is a special character such as a space + */ + it('ActsAccountCreateAccount_1900', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + try{ + appAccountManager.createAccount("account_name_callback_tenth", specialStr, (err)=>{ + expect().assertFail(); + done(); + }); + }catch(err){ + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountCreateAccount_1900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_2000 + * @tc.name : Add account promise form + * @tc.desc : Additional information is a special character such as a space + */ + it('ActsAccountCreateAccount_2000', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + console.debug("====>add account ActsAccountCreateAccount_2000===="); + try{ + await appAccountManager.createAccount("account_name_promise_tenth", specialStr); + } + catch(err){ + console.error("====>add Account ActsAccountCreateAccount_2000 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + } + console.debug("====>delete account ActsAccountCreateAccount_2000===="); + await appAccountManager.removeAccount("account_name_promise_tenth"); + console.debug("====>ActsAccountCreateAccount_2000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCreateAccount_2100 + * @tc.name : Add account callback form + * @tc.desc : Additional information is a special string + */ + it('ActsAccountCreateAccount_2100', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2100 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + try{ + appAccountManager.createAccount("account_extraInfo_callback_eleventh", specialStr, (err)=>{ + expect().assertFail(); + done(); + }); + }catch(err){ + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountCreateAccount_2100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_2200 + * @tc.name : Add account promise form + * @tc.desc : Additional information is a special string + */ + it('ActsAccountCreateAccount_2200', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2200 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + console.debug("====>add account ActsAccountCreateAccount_2200===="); + try{ + await appAccountManager.createAccount("account_extraInfo_promise_eleventh", specialStr); + } + catch(err){ + console.error("====>add Account ActsAccountCreateAccount_2200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + } + console.debug("====>delete account ActsAccountCreateAccount_2200===="); + await appAccountManager.removeAccount("account_extraInfo_promise_eleventh"); + console.debug("====>ActsAccountCreateAccount_2200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCreateAccount_2300 + * @tc.name : Add account callback form + * @tc.desc : Repeatedly add accounts with the same name and different additional information + */ + it('ActsAccountCreateAccount_2300', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("account_name_callback_same", createAccountOptions, (err)=>{ + console.debug("====>add account first time ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("account_name_callback_same", createAccountOptionsDiff, (err)=>{ + console.debug("====>add account second time ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(12300008); + appAccountManager.removeAccount("account_name_callback_same", (err)=>{ + console.debug("====>delete Account ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCreateAccount_2300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_2400 + * @tc.name : Add account promise form + * @tc.desc : Repeatedly add accounts with the same name and different additional information + */ + it('ActsAccountCreateAccount_2400', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account for the first time ActsAccountCreateAccount_2400===="); + await appAccountManager.createAccount("account_name_promise_same", createAccountOptions); + console.debug("====>add account for the second time ActsAccountCreateAccount_2400===="); + try{ + await appAccountManager.createAccount("account_name_promise_same", createAccountOptionsDiff); + } + catch(err){ + console.debug("====>add account for the second time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(12300008); + appAccountManager.removeAccount("account_name_promise_same"); + console.debug("====>ActsAccountCreateAccount_2400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_2500 + * @tc.name : Add account callback form + * @tc.desc : The account name reaches the limit of 512 characters + */ + it('ActsAccountCreateAccount_2500', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2500 start===="); + var limitName = ''; + for (var i = 0; i < NAMELIMIT; i++) { + limitName += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount(limitName, createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountCreateAccount_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount(limitName, (err)=>{ + console.debug("====>delete Account ActsAccountCreateAccount_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCreateAccount_2500 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountCreateAccount_2600 + * @tc.name : Add account promise form + * @tc.desc : The account name reaches the limit of 512 characters + */ + it('ActsAccountCreateAccount_2600', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2600 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountCreateAccount_2600 start===="); + try{ + await appAccountManager.createAccount(nameLimit, createAccountOptions); + } + catch(err){ + console.error("====>add account ActsAccountCreateAccount_2600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountCreateAccount_2600 start===="); + await appAccountManager.removeAccount(nameLimit); + console.debug("====>ActsAccountCreateAccount_2600 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCreateAccount_2700 + * @tc.name : Add account callback form + * @tc.desc : Additional information reaches the limit of 1024 characters + */ + it('ActsAccountCreateAccount_2700', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2700 start===="); + var limitExtra = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + limitExtra += 't'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + appAccountManager.createAccount("account_extra_callback_limit", limitExtra, (err)=>{ + expect().assertFail(); + done(); + }); + }catch(err){ + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountCreateAccount_2700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCreateAccount_2800 + * @tc.name : Add account promise form + * @tc.desc : Additional information reaches the limit of 1024 characters + */ + it('ActsAccountCreateAccount_2800', 0, async function (done) { + console.debug("====>ActsAccountCreateAccount_2800 start===="); + var extraLimit = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + extraLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.createAccount("account_extra_promise_limit", extraLimit); + } + catch(err){ + console.error("====>add account ActsAccountCreateAccount_2800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + } + console.debug("====>delete account ActsAccountCreateAccount_2800 start===="); + appAccountManager.removeAccount("account_extra_promise_limit"); + console.debug("====>ActsAccountCreateAccount_2800 end===="); + done(); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/CustomData.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/CustomData.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8807b36060b5a4b6d0b1bbc2e2932af619ba6a33 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/CustomData.test.js @@ -0,0 +1,1195 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +const EACHTIMEOUT = 500; +export default function ActsAccountCustomData() { + describe('ActsAccountCustomData', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + done(); + }) + + /* + * @tc.number : ActsAccountCustomData_0100 + * @tc.name : The correct calls setAssociatedData and getAssociatedData get the value + * @tc.desc : The setAssociatedData setting valueis called when the forwarding parameters + * are correct, and then getAssociatedData is called for the value(callback) + */ + it('ActsAccountCustomData_0100', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0100",(err)=>{ + console.debug("====>add accountActsAccountCustomData_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_0100", "key1", "value1", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_0100", "key1", (err, data)=>{ + console.debug("====>getAssociatedData 0100 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("value1"); + appAccountManager.removeAccount("account_name_0100", (err)=>{ + console.debug("====>delete Account 0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_0100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_0200 + * @tc.name : The correct calls setAssociatedData and getAssociatedData get the value + * @tc.desc : The setAssociatedData setting value is called when the forwarding parameters + * are correct, and then getAssociatedData is called for the value(promise) + */ + it('ActsAccountCustomData_0200', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_0200 start===="); + try{ + await appAccountManager.createAccount("account_name_0200"); + } + catch(err){ + console.error("====>add Account ActsAccountCustomData_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAssociatedData ActsAccountCustomData_0200 start===="); + try{ + await appAccountManager.setAssociatedData("account_name_0200", "key2", "value2"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountCustomData_0200 start===="); + try{ + var data = await appAccountManager.getAssociatedData("account_name_0200", "key2"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountCustomData_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountCustomData_0200 data:" + JSON.stringify(data)); + expect(data).assertEqual("value2"); + console.debug("====>delete account ActsAccountCustomData_0200 start===="); + try{ + await appAccountManager.removeAccount("account_name_0200"); + } + catch(err){ + console.error("====>delete account 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_0300 + * @tc.name : Get it directly without setting value + * @tc.desc : Call getAssociatedData directly to get value without calling setAssociatedData(callback) + */ + it('ActsAccountCustomData_0300', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0300", (err)=>{ + console.debug("====>add account ActsAccountCustomData_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_0300", "key3", (err, data)=>{ + console.debug("====>getAssociatedData 0300 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0300 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + appAccountManager.removeAccount("account_name_0300", (err)=>{ + console.debug("====>delete Account 0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_0300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_0400 + * @tc.name : Get it directly without setting value + * @tc.desc : Call getAssociatedData directly to get value without calling setAssociatedData(promise) + */ + it('ActsAccountCustomData_0400', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_0400 start===="); + try{ + await appAccountManager.createAccount("account_name_0400"); + } + catch(err){ + console.error("====>add Account ActsAccountCustomData_0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.getAssociatedData("account_name_0400", "key4"); + console.error("====>getAssociatedData fail ActsAccountCustomData_0400===="); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>getAssociatedData ActsAccountCustomData_0400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_0400 start===="); + try{ + await appAccountManager.removeAccount("account_name_0400"); + } + catch(err){ + console.error("====>delete account 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_0500 + * @tc.name : Call getAssociatedData to get value when passing in the error parameter + * @tc.desc : After calling setAssociatedData setting value correctly, + * call the getAssociatedData of the pass error to check if you get the value(callback) + */ + it('ActsAccountCustomData_0500', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0500",(err)=>{ + console.debug("====>add account ActsAccountCustomData_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_0500", "key5", "value5", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_0500", "keyerr", (err, data)=>{ + console.debug("====>getAssociatedData 0500 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0500 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + appAccountManager.removeAccount("account_name_0500", (err)=>{ + console.debug("====>delete Account 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_0500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_0600 + * @tc.name : Call getAssociatedData to get value when passing in the error parameter + * @tc.desc : After calling setAssociatedData setting value correctly, + * call the getAssociatedData of the pass error to check if you get the value(promise) + */ + it('ActsAccountCustomData_0600', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_0600 start===="); + try{ + await appAccountManager.createAccount("account_name_0600"); + } + catch(err){ + console.error("====>add Account ActsAccountCustomData_0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.setAssociatedData("account_name_0600", "key6", "value6"); + try{ + var data = await appAccountManager.getAssociatedData("account_name_0600", "keyerr"); + } + catch(err){ + console.debug("====>getAssociatedData 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_0600 start===="); + try{ + await appAccountManager.removeAccount("account_name_0600"); + } + catch(err){ + console.error("====>delete account 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_0700 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is different if the call getAssociatedData + * can get the second value(callback) + */ + it('ActsAccountCustomData_0700', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0700",(err)=>{ + console.debug("====>add account ActsAccountCustomData_0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_0700", "key7", "value7", (err)=>{ + console.debug("====>setAssociatedDatafir first time 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_0700", "key7", "newvalue7", (err)=>{ + console.debug("====>setAssociatedDatafir second time 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_0700", "key7", (err, data)=>{ + console.debug("====>getAssociatedData 0700 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0700 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("newvalue7"); + appAccountManager.removeAccount("account_name_0700", (err)=>{ + console.debug("====>delete Account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_0700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_0800 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is different if the call getAssociatedData + * can get the second value(promise) + */ + it('ActsAccountCustomData_0800', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + try{ + await appAccountManager.createAccount("account_name_0800"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_0800","key8","value8"); + await appAccountManager.setAssociatedData("account_name_0800","key8","newvalue8"); + }catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAssociatedData("account_name_0800", "key8"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountCustomData_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountCustomData_0800 data:" + JSON.stringify(data)); + expect(data).assertEqual("newvalue8"); + console.debug("====>delete account ActsAccountCustomData_0800 start===="); + try{ + await appAccountManager.removeAccount("account_name_0800"); + } + catch(err){ + console.error("====>delete account 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_0900 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is same if the call getAssociatedData + * can get the second value(callback) + */ + it('ActsAccountCustomData_0900', 0, async function (done) { + console.debug("====>ActsAccountCustomData_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_0900",(err)=>{ + console.debug("====>add account ActsAccountCustomData_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_0900", "key9", "value9", (err)=>{ + console.debug("====>setAssociatedData first time 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_0900", "key9", "value9", (err)=>{ + console.debug("====>setAssociatedData second time 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_0900", "key9", (err, data)=>{ + console.debug("====>getAssociatedData 0900 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0900 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("value9"); + appAccountManager.removeAccount("account_name_0900", (err)=>{ + console.debug("====>delete Account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_0900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_1000 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is same if the call getAssociatedData + * can get the second value(promise) + */ + it('ActsAccountCustomData_1000', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>createAccount ActsAccountCustomData_1000 start===="); + try{ + await appAccountManager.createAccount("account_name_1000"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1000", "key10", "value10"); + await appAccountManager.setAssociatedData("account_name_1000", "key10", "value10"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAssociatedData("account_name_1000", "key10"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountCustomData_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData 1000 data:" + JSON.stringify(data)); + expect(data).assertEqual("value10"); + console.debug("====>delete account ActsAccountCustomData_1000 start===="); + try{ + await appAccountManager.removeAccount("account_name_1000"); + } + catch(err){ + console.error("====>delete account 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_1100 + * @tc.name : Call multiple setAssociatedData calls multiple times getAssociatedData gets the value separately + * @tc.desc : Call setAssociatedData setting value again after calling setAssociatedData setting + * different value, and then call getAssociatedData twice to get the set value(callback) + */ + it('ActsAccountCustomData_1100', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1100",(err)=>{ + console.debug("====>add account ActsAccountCustomData_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_1100", "key11_first", "value11_first", (err)=>{ + console.debug("====>setAssociatedData first time 1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_1100", "key11_second", "value11_second", (err)=>{ + console.debug("====>setAssociatedData second time 1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_1100", "key11_first", (err,data)=>{ + console.debug("====>getAssociatedData key11_first 1100 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData key11_first 1100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("value11_first"); + appAccountManager.getAssociatedData("account_name_1100", "key11_second", (err,data)=>{ + console.debug("====>getAssociatedData key11_second 1100 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData key11_second 1100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("value11_second"); + appAccountManager.removeAccount("account_name_1100", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + }); + console.debug("====>ActsAccountCustomData_1100 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_1200 + * @tc.name : Call multiple setAssociatedData calls multiple times getAssociatedData gets the value separately + * @tc.desc : Call setAssociatedData setting value again after calling setAssociatedData setting + * different value, and then call getAssociatedData twice to get the set value(promise) + */ + it('ActsAccountCustomData_1200', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>createAccount ActsAccountCustomData_1200 start===="); + try{ + await appAccountManager.createAccount("account_name_1200"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1200", "key12_first", "value12_first"); + await appAccountManager.setAssociatedData("account_name_1200", "key12_second", "value12_second"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var dataFir = await appAccountManager.getAssociatedData("account_name_1200", "key12_first"); + var dataSec = await appAccountManager.getAssociatedData("account_name_1200", "key12_second"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountCustomData_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_1200 getAssociatedData dataFir:" + JSON.stringify(dataFir)); + expect(dataFir).assertEqual("value12_first"); + console.debug("====>ActsAccountCustomData_1200 getAssociatedData dataSec:" + JSON.stringify(dataSec)); + expect(dataSec).assertEqual("value12_second"); + console.debug("====>delete account ActsAccountCustomData_1200 start===="); + try{ + await appAccountManager.removeAccount("account_name_1200"); + } + catch(err){ + console.error("====>delete account 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_1300 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter KEY is wrong(callback) + */ + it('ActsAccountCustomData_1300', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1300", (err)=>{ + console.debug("====>add account ActsAccountCustomData_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_1300", "", "value13", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.removeAccount("account_name_1300", (err)=>{ + console.debug("====>delete account ActsAccountCustomData_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_1300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_1400 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter KEY is wrong(promise) + */ + it('ActsAccountCustomData_1400', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_1400 start===="); + try{ + await appAccountManager.createAccount("account_name_1400"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1400", "", "value14"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountCustomData_1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_1400 start===="); + try{ + await appAccountManager.removeAccount("account_name_1400"); + } + catch(err){ + console.error("====>delete account 1400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_1500 + * @tc.name : setAssociatedData setting key is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting key when the incoming parameter KEY is wrong(callback) + */ + it('ActsAccountCustomData_1500', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1500 start===="); + var keyOverSize = "K" + for(var i = 0;i < 256;i++) + keyOverSize = keyOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1500", (err)=>{ + console.debug("====>add account ActsAccountCustomData_1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>1500 keyOverSize.length:" + JSON.stringify(keyOverSize.length)); + expect(keyOverSize.length).assertEqual(1025); + appAccountManager.setAssociatedData("account_name_1500", keyOverSize, "value15", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_1500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.removeAccount("account_name_1500", (err)=>{ + console.debug("====>delete account ActsAccountCustomData_1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_1500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_1600 + * @tc.name : setAssociatedData setting key is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting key when the incoming parameter KEY is wrong(promise) + */ + it('ActsAccountCustomData_1600', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1600 start===="); + var keyOverSize = "K" + for(var i=0;i<256;i++) + keyOverSize = keyOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + expect(keyOverSize.length).assertEqual(1025); + console.debug("====>add account ActsAccountCustomData_1600 start===="); + try{ + await appAccountManager.createAccount("account_name_1600"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_1600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1600", keyOverSize, "value16"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountCustomData_1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_1600 start===="); + try{ + await appAccountManager.removeAccount("account_name_1600"); + } + catch(err){ + console.error("====>delete account 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_1700 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming key is a space(callback) + */ + it('ActsAccountCustomData_1700', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1700", (err)=>{ + console.debug("====>add account ActsAccountCustomData_1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_1700", " ", "value17", (err)=>{ + console.debug("====>ActsAccountCustomData_1700 setAssociatedData:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_1700", " ", (err, data)=>{ + console.debug("====>getAssociatedData 1700 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 1700 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual("value17"); + appAccountManager.removeAccount("account_name_1700", (err)=>{ + console.debug("====>delete Account 1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_1700 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_1800 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming key is a space(promise) + */ + it('ActsAccountCustomData_1800', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_1800 start===="); + try{ + await appAccountManager.createAccount("account_name_1800"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_1800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.setAssociatedData("account_name_1800", " ", "value18"); + try{ + var data = await appAccountManager.getAssociatedData("account_name_1800", " "); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountCustomData_1800 data:" + JSON.stringify(data)); + expect(data).assertEqual("value18"); + console.debug("====>delete account ActsAccountCustomData_1800 start===="); + try{ + await appAccountManager.removeAccount("account_name_1800"); + } + catch(err){ + console.error("====>delete account 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_1800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_1900 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is null(callback) + */ + it('ActsAccountCustomData_1900', 0, async function (done) { + console.debug("====>ActsAccountCustomData_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_1900", (err)=>{ + console.debug("====>add account ActsAccountCustomData_1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_1900", "key19", "", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_1900", "key19", (err, data)=>{ + console.debug("====>getAssociatedData 1900 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 1900 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(""); + appAccountManager.removeAccount("account_name_1900", (err)=>{ + console.debug("====>delete Account 1900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_1900 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_2000 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is null(promise) + */ + it('ActsAccountCustomData_2000', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_2000 start===="); + try{ + await appAccountManager.createAccount("account_name_2000"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_2000", "key20", ""); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAssociatedData("account_name_2000", "key20"); + } + catch(err){ + console.error("====>getAssociatedData 2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountCustomData_2000 data:" + JSON.stringify(data)); + expect(data).assertEqual(""); + console.debug("====>delete account ActsAccountCustomData_2000 start===="); + try{ + await appAccountManager.removeAccount("account_name_2000"); + } + catch(err){ + console.error("====>delete account 2000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_2000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_2100 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter value is wrong(callback) + */ + it('ActsAccountCustomData_2100', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2100 start===="); + var valueOverSize = "K" + for(var i = 0;i < 256;i++) + valueOverSize = valueOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_2100",(err)=>{ + console.debug("====>add account ActsAccountCustomData_2100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(valueOverSize.length).assertEqual(1025); + appAccountManager.setAssociatedData("account_name_2100", "key21", valueOverSize, (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_2100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.removeAccount("account_name_2100", (err)=>{ + console.debug("====>delete Account ActsAccountCustomData_2100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_2100 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_2200 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter value is wrong(promise) + */ + it('ActsAccountCustomData_2200', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2200 start===="); + var valueOverSize = "K" + for(var i = 0;i < 256;i++) + valueOverSize = valueOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + expect(valueOverSize.length).assertEqual(1025); + try{ + await appAccountManager.createAccount("account_name_2200"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_2200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_2200", "key22", valueOverSize); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountCustomData_2200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_2200 start===="); + try{ + await appAccountManager.removeAccount("account_name_2200"); + } + catch(err){ + console.error("====>delete account 2200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_2200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_2300 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is a space(callback) + */ + it('ActsAccountCustomData_2300', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_2300", (err)=>{ + console.debug("====>add account ActsAccountCustomData_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_2300", "key23", " ", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAssociatedData("account_name_2300", "key23", (err, data)=>{ + console.debug("====>getAssociatedData 2300 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 2300 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(" "); + appAccountManager.removeAccount("account_name_2300", (err)=>{ + console.debug("====>delete Account 2300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_2300 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_2400 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is a space(promise) + */ + it('ActsAccountCustomData_2400', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCustomData_2400 start===="); + try{ + await appAccountManager.createAccount("account_name_2400"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_2400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.setAssociatedData("account_name_2400", "key24", " "); + try{ + var data = await appAccountManager.getAssociatedData("account_name_2400", "key24"); + } + catch(err){ + console.error("====>getAssociatedData 2400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData 2400 err:" + JSON.stringify(data)); + expect(data).assertEqual(" "); + console.debug("====>delete account ActsAccountCustomData_2400 start===="); + try{ + await appAccountManager.removeAccount("account_name_2400"); + } + catch(err){ + console.error("====>delete account 2400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_2400 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCustomData_2500 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is null(callback) + */ + it('ActsAccountCustomData_2500', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_2500", (err)=>{ + console.debug("====>add account ActsAccountCustomData_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("", "key25", "value25", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_2500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.removeAccount("account_name_2500", (err)=>{ + console.debug("====>delete Account ActsAccountCustomData_2500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_2500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_2600 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is null(promise) + */ + it('ActsAccountCustomData_2600', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>ActsAccountCustomData_2600 createAccount start===="); + try{ + await appAccountManager.createAccount("account_name_2600"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_2600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("", "key26", "value26"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountCustomData_2600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_2600 start===="); + try{ + await appAccountManager.removeAccount("account_name_2600"); + } + catch(err){ + console.error("====>delete account 2600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_2600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_2700 + * @tc.name : setAssociatedData setting name is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting name when the incoming parameter name is wrong(callback) + */ + it('ActsAccountCustomData_2700', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2700 start===="); + var nameOverSize = "n" + for(var i = 0;i < 256;i++) + nameOverSize = nameOverSize+"name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_2700",(err)=>{ + console.debug("====>add account ActsAccountCustomData_2700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(nameOverSize.length).assertEqual(1025); + appAccountManager.setAssociatedData(nameOverSize, "key27", "value27", (err)=>{ + console.debug("====>ActsAccountCustomData_2700 setAssociatedData:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.removeAccount("account_name_2700", (err)=>{ + console.debug("====>delete Account ActsAccountCustomData_2700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_2700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_2800 + * @tc.name : setAssociatedData setting name is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting name when the incoming parameter name is wrong(promise) + */ + it('ActsAccountCustomData_2800', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2800 start===="); + var nameOverSize = "n" + for(var i = 0;i < 256;i++) + nameOverSize = nameOverSize + "name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + expect(nameOverSize.length).assertEqual(1025); + console.debug("====>add account ActsAccountCustomData_2800 start===="); + try{ + await appAccountManager.createAccount("account_name_2800"); + } + catch(err){ + console.error("====>add account ActsAccountCustomData_2800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData(nameOverSize, "key28", "value28"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountCustomData_2800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCustomData_2800 start===="); + try{ + await appAccountManager.removeAccount("account_name_2800"); + } + catch(err){ + console.error("====>delete account 2800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCustomData_2800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCustomData_2900 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is a space(callback) + */ + it('ActsAccountCustomData_2900', 0, async function (done) { + console.debug("====>ActsAccountCustomData_2900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount(" ", (err)=>{ + console.debug("====>add account ActsAccountCustomData_2900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.setAssociatedData(" ", "key29", "value29", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_2900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.getAssociatedData(" ", "key29", (err, data)=>{ + console.debug("====>getAssociatedData 2900 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 2900 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(null); + console.debug("====>ActsAccountCustomData_2900 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCustomData_3000 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is a space(promise) + */ + it('ActsAccountCustomData_3000', 0, async function (done) { + console.debug("====>ActsAccountCustomData_3000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + try{ + await appAccountManager.createAccount(" "); + } + catch(err){ + console.debug("====>add account ActsAccountCustomData_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + try{ + await appAccountManager.setAssociatedData(" ", "key30", "value30"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountCustomData_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + try{ + await appAccountManager.getAssociatedData(" ", "key30"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountCustomData_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountCustomData_3000 end===="); + done(); + } + } + } + }) + + + /* + * @tc.number : ActsAccountCustomData_3100 + * @tc.name : The correct calls setAssociatedData and getAssociatedData get the value + * @tc.desc : The setAssociatedData setting valueis called when the forwarding parameters + * are correct, and then getAssociatedData is called for the value(callback) + */ + it('ActsAccountCustomData_3100', 0, async function (done) { + console.debug("====>ActsAccountCustomData_3100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_name_3100",(err)=>{ + console.debug("====>add ActsAccountCustomData_3100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAssociatedData("account_name_3100", "key31", "value31", (err)=>{ + console.debug("====>setAssociatedData ActsAccountCustomData_3100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + var result = appAccountManager.getAssociatedDataSync("account_name_3100", "key31") + console.debug("====>getAssociatedData ActsAccountCustomData_3100 result:" + JSON.stringify(result)); + expect(result).assertEqual("value31"); + appAccountManager.removeAccount("account_name_3100", (err)=>{ + console.debug("====>delete Account 0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountCustomData_3100 end===="); + done(); + }); + }); + }); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/ErrCode.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/ErrCode.test.js new file mode 100644 index 0000000000000000000000000000000000000000..884450494fa485d030d39b010313f1b8585b0360 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/ErrCode.test.js @@ -0,0 +1,3309 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +const STRCOUNT = 1025; +const EACHTIMEOUT = 500; +export default function ActsAccountErrCode() { + describe('ActsAccountErrCode', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + done(); + }) + + /* + * @tc.number : ActsAccountErrCode_0100 + * @tc.name : createAccount callback + * @tc.desc : test the number of parameters does not match (需要的参数顺序正确,后面有多余的,不报错) + */ + it('ActsAccountErrCode_0100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0100 creat finish===="); + try { + appAccountManager.createAccount("test_account_name", {"test_key":"test_extrainfo"}, (err)=>{ + console.debug("====>ActsAccountErrCode_0100 create account callback err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("test_account_name", (err)=>{ + console.debug("====>ActsAccountErrCode_0100 delete Account err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountErrCode_0100 end===="); + done(); + }); + }, "test_more_param") + } catch(err) { + console.debug("====>ActsAccountErrCode_0100 create account catch err:" + JSON.stringify(err)); + expect().assertFail(); + console.debug("====>ActsAccountErrCode_0100 end===="); + done(); + } + + }); + + /* + * @tc.number : ActsAccountErrCode_0200 + * @tc.name : createAccount callback + * @tc.desc : test the number of parameters does not match(需要的参数顺序中有多余类型参数) + */ + it('ActsAccountErrCode_0200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0200 creat finish===="); + try { + appAccountManager.createAccount("test_account_name", {"test_key":"test_extrainfo"}, "test_more_param", (err)=>{ + console.debug("====>ActsAccountErrCode_0200 create account callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_0200 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0200 end===="); + done(); + } + + }); + + /* + * @tc.number : ActsAccountErrCode_0300 + * @tc.name : createAccount callback + * @tc.desc : test the number of parameters does not match(需要的参数数量少于预期) + */ + it('ActsAccountErrCode_0300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0300 creat finish===="); + try { + appAccountManager.createAccount((err)=>{ + console.debug("====>ActsAccountErrCode_0300 create account callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_0300 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0400 + * @tc.name : createAccount callback + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_0400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0400 creat finish===="); + try { + appAccountManager.createAccount(123456, {"test_key":"test_extrainfo"}, (err)=>{ + console.debug("====>ActsAccountErrCode_0400 create account callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_0400 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0500 + * @tc.name : createAccount callback + * @tc.desc : test the type of parameters does not match(extrainfo不匹配) + */ + it('ActsAccountErrCode_0500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0500 creat finish===="); + try { + appAccountManager.createAccount("test_account_name", " ", (err)=>{ + console.debug("====>ActsAccountErrCode_0500 create account callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_0500 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0510 + * @tc.name : createAccount callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_0510', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0510 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0510 creat finish===="); + try { + appAccountManager.createAccount(123456, {"test_key":"test_extrainfo"}, 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_0510 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0510 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0600 + * @tc.name : createAccount promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_0600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0600 creat finish===="); + try { + appAccountManager.createAccount(); + } catch(err) { + console.debug("====>ActsAccountErrCode_0600 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0610 + * @tc.name : createAccount promise + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_0610', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0610 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0610 creat finish===="); + try { + appAccountManager.createAccount(123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_0610 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0610 end===="); + done(); + } + }); + + //createAccountImplicitly + /* + * @tc.number : ActsAccountErrCode_0700 + * @tc.name : createAccountImplicitly callback + * @tc.desc : test the number of parameters does not match(extrainfo不匹配) + */ + it('ActsAccountErrCode_0700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0700 creat finish===="); + try { + appAccountManager.createAccountImplicitly({ + onResult: (resultCode, resultData)=>{ + console.debug("====>ActsAccountErrCode_0700 authenticate resultCode:" + JSON.stringify(resultCode)); + console.debug("====>ActsAccountErrCode_0700 authenticate resultData:" + JSON.stringify(resultData)); + done(); + }, + onRequestRedirected: null + }); + } catch(err) { + console.debug("====>ActsAccountErrCode_0700 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0800 + * @tc.name : createAccountImplicitly callback + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_0800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0800 creat finish===="); + try { + appAccountManager.createAccountImplicitly(123456, {}, { + onResult: null, + onRequestRedirected: null + }); + } catch(err) { + console.debug("====>ActsAccountErrCode_0800 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0810 + * @tc.name : createAccountImplicitly callback + * @tc.desc : test the type of parameters does not match(options不匹配) + */ + it('ActsAccountErrCode_0810', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0810 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0810 creat finish===="); + try { + appAccountManager.createAccountImplicitly("test_owner", "test_options", { + onResult: null, + onRequestRedirected: null + }); + } catch(err) { + console.debug("====>ActsAccountErrCode_0810 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0810 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_0820 + * @tc.name : createAccountImplicitly callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_0820', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0820 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0820 creat finish===="); + var options = {authType: "test_authType"}; + try { + appAccountManager.createAccountImplicitly("test_owner", options, 1233); + } catch(err) { + console.debug("====>ActsAccountErrCode_0820 create account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0820 end===="); + done(); + } + }); + + //removeAccount + /* + * @tc.number : ActsAccountErrCode_0900 + * @tc.name : removeAccount callback + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_0900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0900 creat finish===="); + try { + appAccountManager.removeAccount(123456, (err)=>{ + console.debug("====>ActsAccountErrCode_0900 remove account callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_0900 remove account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0900 end===="); + done(); + } + }); + + //removeAccount + /* + * @tc.number : ActsAccountErrCode_0910 + * @tc.name : removeAccount callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_0910', 0, async function (done) { + console.debug("====>ActsAccountErrCode_0910 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_0910 creat finish===="); + try { + appAccountManager.removeAccount("test_name", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_0910 remove account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_0910 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1000 + * @tc.name : removeAccount callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_1000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1000 creat finish===="); + try { + appAccountManager.removeAccount((err)=>{ + console.debug("====>ActsAccountErrCode_1000 remove account callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_1000 remove account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1100 + * @tc.name : removeAccount promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_1100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1100 creat finish===="); + try { + appAccountManager.removeAccount(123456) + } catch(err) { + console.debug("====>ActsAccountErrCode_1100 remove account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1200 + * @tc.name : removeAccount callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_1200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1200 creat finish===="); + try { + appAccountManager.removeAccount(); + } catch(err) { + console.debug("====>ActsAccountErrCode_1200 remove account catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1200 end===="); + done(); + } + }); + + //setAppAccess + /* + * @tc.number : ActsAccountErrCode_1300 + * @tc.name : setAppAccess callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_1300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1300 creat finish===="); + try { + appAccountManager.setAppAccess((err)=>{ + console.debug("====>ActsAccountErrCode_1300 setAppAccess callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_1300 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1400 + * @tc.name : setAppAccess callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_1400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1400 creat finish===="); + try { + appAccountManager.setAppAccess(123456, "test_owner", false, (err)=>{ + console.debug("====>ActsAccountErrCode_1400 setAppAccess callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_1400 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1410 + * @tc.name : setAppAccess callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_1410', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1410 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1410 creat finish===="); + try { + appAccountManager.setAppAccess("test_name", "test_owner", false, 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_1410 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1410 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1500 + * @tc.name : setAppAccess promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_1500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1500 creat finish===="); + try { + appAccountManager.setAppAccess(); + } catch(err) { + console.debug("====>ActsAccountErrCode_1500 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1600 + * @tc.name : setAppAccess promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_1600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1600 creat finish===="); + try { + appAccountManager.setAppAccess(123456, "test_owner", false); + } catch(err) { + console.debug("====>ActsAccountErrCode_1600 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1610 + * @tc.name : setAppAccess promise + * @tc.desc : test the type of parameters does not match(bundlename不匹配) + */ + it('ActsAccountErrCode_1610', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1610 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1610 creat finish===="); + try { + appAccountManager.setAppAccess("test_name", 12345, false); + } catch(err) { + console.debug("====>ActsAccountErrCode_1610 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1610 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1620 + * @tc.name : setAppAccess promise + * @tc.desc : test the type of parameters does not match(isAccessible不匹配) + */ + it('ActsAccountErrCode_1620', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1620 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1620 creat finish===="); + try { + appAccountManager.setAppAccess("test_name", "test_owner", "123"); + } catch(err) { + console.debug("====>ActsAccountErrCode_1620 setAppAccess catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1620 end===="); + done(); + } + }); + + //checkDataSyncEnabled + /* + * @tc.number : ActsAccountErrCode_1700 + * @tc.name : checkDataSyncEnabled callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_1700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1700 creat finish===="); + try { + appAccountManager.checkDataSyncEnabled((err, data)=>{ + console.debug("====>ActsAccountErrCode_1700 checkDataSyncEnabled callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_1700 checkDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1800 + * @tc.name : checkDataSyncEnabled callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_1800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1800 creat finish===="); + try { + appAccountManager.checkDataSyncEnabled(123456, (err, data)=>{ + console.debug("====>ActsAccountErrCode_1800 checkDataSyncEnabled callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_1800 checkDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1810 + * @tc.name : checkDataSyncEnabled callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_1810', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1810 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1810 creat finish===="); + try { + appAccountManager.checkDataSyncEnabled("test_name", 123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_1810 checkDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1810 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_1900 + * @tc.name : checkDataSyncEnabled promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_1900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_1900 creat finish===="); + try { + appAccountManager.checkDataSyncEnabled(); + } catch(err) { + console.debug("====>ActsAccountErrCode_1900 checkDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_1900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2000 + * @tc.name : checkDataSyncEnabled promise + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_2000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2000 creat finish===="); + try { + appAccountManager.checkDataSyncEnabled(123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_2000 checkDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2000 end===="); + done(); + } + }); + + //setCredential + /* + * @tc.number : ActsAccountErrCode_2100 + * @tc.name : setCredential callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_2100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2100 creat finish===="); + try { + appAccountManager.setCredential((err)=>{ + console.debug("====>ActsAccountErrCode_2100 setCredential callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_2100 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2200 + * @tc.name : setCredential callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_2200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2200 creat finish===="); + try { + appAccountManager.setCredential(123456, "test_credential_type", "test_credential", (err)=>{ + console.debug("====>ActsAccountErrCode_2200 setCredential callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_2200 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2210 + * @tc.name : setCredential callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_2210', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2210 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2210 creat finish===="); + try { + appAccountManager.setCredential("test_name", "test_credential_type", "test_credential", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_2210 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2210 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2300 + * @tc.name : setCredential promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_2300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2300 creat finish===="); + try { + appAccountManager.setCredential(); + } catch(err) { + console.debug("====>ActsAccountErrCode_2300 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2400 + * @tc.name : setCredential promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_2400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2400 creat finish===="); + try { + appAccountManager.setCredential(123456, "test_credential_type", "test_credential"); + } catch(err) { + console.debug("====>ActsAccountErrCode_2400 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2410 + * @tc.name : setCredential promise + * @tc.desc : test the type of parameters does not match(credentialType不匹配) + */ + it('ActsAccountErrCode_2410', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2410 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2410 creat finish===="); + try { + appAccountManager.setCredential("test_name", 12345, "test_credential"); + } catch(err) { + console.debug("====>ActsAccountErrCode_2410 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2410 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2420 + * @tc.name : setCredential promise + * @tc.desc : test the type of parameters does not match(credential不匹配) + */ + it('ActsAccountErrCode_2420', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2420 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2420 creat finish===="); + try { + appAccountManager.setCredential("test_name", "test_credential_type", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_2420 setCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2420 end===="); + done(); + } + }); + + //setDataSyncEnabled + /* + * @tc.number : ActsAccountErrCode_2500 + * @tc.name : setDataSyncEnabled callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_2500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2500 creat finish===="); + try { + appAccountManager.setDataSyncEnabled((err)=>{ + console.debug("====>ActsAccountErrCode_2500 setDataSyncEnabled callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_2500 setDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2600 + * @tc.name : setDataSyncEnabled callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_2600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2600 creat finish===="); + try { + appAccountManager.setDataSyncEnabled(123456, false, (err)=>{ + console.debug("====>ActsAccountErrCode_2600 setDataSyncEnabled callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_2600 setDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2610 + * @tc.name : setDataSyncEnabled callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_2610', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2610 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2610 creat finish===="); + try { + appAccountManager.setDataSyncEnabled("test_name", false, 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_2610 setDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2610 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2700 + * @tc.name : setDataSyncEnabled promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_2700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2700 creat finish===="); + try { + appAccountManager.setDataSyncEnabled(); + } catch(err) { + console.debug("====>ActsAccountErrCode_2700 setDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2800 + * @tc.name : setDataSyncEnabled promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_2800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2800 creat finish===="); + try { + appAccountManager.setDataSyncEnabled(123456, false); + } catch(err) { + console.debug("====>ActsAccountErrCode_2800 setDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_2810 + * @tc.name : setDataSyncEnabled promise + * @tc.desc : test the type of parameters does not match(isEnable不匹配) + */ + it('ActsAccountErrCode_2810', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2810 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2810 creat finish===="); + try { + appAccountManager.setDataSyncEnabled("test_name", "false"); + } catch(err) { + console.debug("====>ActsAccountErrCode_2810 setDataSyncEnabled catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2810 end===="); + done(); + } + }); + + //setCustomData + /* + * @tc.number : ActsAccountErrCode_2900 + * @tc.name : setCustomData callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_2900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_2900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_2900 creat finish===="); + try { + appAccountManager.setCustomData((err)=>{ + console.debug("====>ActsAccountErrCode_2900 setCustomData callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_2900 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_2900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3000 + * @tc.name : setCustomData callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_3000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3000 creat finish===="); + try { + appAccountManager.setCustomData(123456, "test_key", "test_value", (err)=>{ + console.debug("====>ActsAccountErrCode_3000 setCustomData callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_3000 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3010 + * @tc.name : setCustomData callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_3010', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3010 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3010 creat finish===="); + try { + appAccountManager.setCustomData("test_name", "test_key", "test_value", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_3010 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3010 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3100 + * @tc.name : setCustomData promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_3100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3100 creat finish===="); + try { + appAccountManager.setCustomData(); + } catch(err) { + console.debug("====>ActsAccountErrCode_3100 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3200 + * @tc.name : setCustomData promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_3200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3200 creat finish===="); + try { + appAccountManager.setCustomData(123456, "test_key", "test_value"); + } catch(err) { + console.debug("====>ActsAccountErrCode_3200 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3210 + * @tc.name : setCustomData promise + * @tc.desc : test the type of parameters does not match(key不匹配) + */ + it('ActsAccountErrCode_3210', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3210 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3210 creat finish===="); + try { + appAccountManager.setCustomData("test_name", 12345, "test_value"); + } catch(err) { + console.debug("====>ActsAccountErrCode_3210 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3210 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3220 + * @tc.name : setCustomData promise + * @tc.desc : test the type of parameters does not match(value不匹配) + */ + it('ActsAccountErrCode_3220', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3220 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3220 creat finish===="); + try { + appAccountManager.setCustomData("test_name", "test_key", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_3220 setCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3220 end===="); + done(); + } + }); + + //getAllAccounts + /* + * @tc.number : ActsAccountErrCode_3300 + * @tc.name : getAllAccounts callback + * @tc.desc : test the type of parameters does not match + */ + + //getAccountsByOwner + /* + * @tc.number : ActsAccountErrCode_3500 + * @tc.name : getAccountsByOwner callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_3500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3500 creat finish===="); + try { + appAccountManager.getAccountsByOwner((err, data)=>{ + console.debug("====>ActsAccountErrCode_3500 getAccountsByOwner callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_3500 getAccountsByOwner catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3600 + * @tc.name : getAccountsByOwner callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_3600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3600 creat finish===="); + try { + appAccountManager.getAccountsByOwner(123456, (err, data)=>{ + console.debug("====>ActsAccountErrCode_3600 getAccountsByOwner callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_3600 getAccountsByOwner catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3610 + * @tc.name : getAccountsByOwner callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_3610', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3610 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3610 creat finish===="); + try { + appAccountManager.getAccountsByOwner("test_owner", 1234) + } catch(err) { + console.debug("====>ActsAccountErrCode_3610 getAccountsByOwner catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3610 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3700 + * @tc.name : getAccountsByOwner promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_3700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3700 creat finish===="); + try { + appAccountManager.getAccountsByOwner(); + } catch(err) { + console.debug("====>ActsAccountErrCode_3700 getAccountsByOwner catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_3800 + * @tc.name : getAccountsByOwner promise + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_3800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3800 creat finish===="); + try { + appAccountManager.getAccountsByOwner(123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_3800 getAccountsByOwner catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3800 end===="); + done(); + } + }); + + //getCredential + /* + * @tc.number : ActsAccountErrCode_3900 + * @tc.name : getCredential callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_3900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_3900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_3900 creat finish===="); + try { + appAccountManager.getCredential((err, data)=>{ + console.debug("====>ActsAccountErrCode_3900 getCredential callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_3900 getCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_3900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4000 + * @tc.name : getCredential callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_4000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4000 creat finish===="); + try { + appAccountManager.getCredential(123456, "test_credential_type", (err, data)=>{ + console.debug("====>ActsAccountErrCode_4000 getCredential callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_4000 getCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4010 + * @tc.name : getCredential callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_4010', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4010 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4010 creat finish===="); + try { + appAccountManager.getCredential("test_name", "test_credential_type", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_4010 getCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4010 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4100 + * @tc.name : getCredential promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_4100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4100 creat finish===="); + try { + appAccountManager.getCredential(); + } catch(err) { + console.debug("====>ActsAccountErrCode_4100 getCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4200 + * @tc.name : getCredential promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_4200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4200 creat finish===="); + try { + appAccountManager.getCredential(123456, "test_credential_type"); + } catch(err) { + console.debug("====>ActsAccountErrCode_4200 getCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4210 + * @tc.name : getCredential promise + * @tc.desc : test the type of parameters does not match(credentialType不匹配) + */ + it('ActsAccountErrCode_4210', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4210 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4210 creat finish===="); + try { + appAccountManager.getCredential("test_name", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_4210 getCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4210 end===="); + done(); + } + }); + + //getCustomData + /* + * @tc.number : ActsAccountErrCode_4300 + * @tc.name : getCustomData callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_4300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4300 creat finish===="); + try { + appAccountManager.getCustomData((err, data)=>{ + console.debug("====>ActsAccountErrCode_4300 getCustomData callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_4300 getCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4400 + * @tc.name : getCustomData callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_4400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4400 creat finish===="); + try { + appAccountManager.getCustomData(123456, "test_key", (err, data)=>{ + console.debug("====>ActsAccountErrCode_4400 getCustomData callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_4400 getCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4410 + * @tc.name : getCustomData callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_4410', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4410 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4410 creat finish===="); + try { + appAccountManager.getCustomData("test_name", "test_key", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_4410 getCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4410 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4500 + * @tc.name : getCustomData promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_4500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4500 creat finish===="); + try { + appAccountManager.getCustomData(); + } catch(err) { + console.debug("====>ActsAccountErrCode_4500 getCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4600 + * @tc.name : getCustomData promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_4600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4600 creat finish===="); + try { + appAccountManager.getCustomData(123456, "test_key"); + } catch(err) { + console.debug("====>ActsAccountErrCode_4600 getCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4610 + * @tc.name : getCustomData promise + * @tc.desc : test the type of parameters does not match(key不匹配) + */ + it('ActsAccountErrCode_4610', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4610 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4610 creat finish===="); + try { + appAccountManager.getCustomData("test_name", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_4610 getCustomData catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4610 end===="); + done(); + } + }); + + + //getCustomDataSync + /* + * @tc.number : ActsAccountErrCode_4700 + * @tc.name : getCustomDataSync + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_4700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4700 creat finish===="); + try { + appAccountManager.getCustomDataSync(123456, "test_key"); + } catch(err) { + console.debug("====>ActsAccountErrCode_4700 getCustomDataSync catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4710 + * @tc.name : getCustomDataSync + * @tc.desc : test the type of parameters does not match(key不匹配) + */ + it('ActsAccountErrCode_4710', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4710 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4710 creat finish===="); + try { + appAccountManager.getCustomDataSync("test_name", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_4710 getCustomDataSync catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4710 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4800 + * @tc.name : getCustomDataSync + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_4800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4800 creat finish===="); + try { + appAccountManager.getCustomDataSync(); + } catch(err) { + console.debug("====>ActsAccountErrCode_4800 getCustomDataSync catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_4800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_4900 + * @tc.name : getCustomDataSync + * @tc.desc : test service error + */ + it('ActsAccountErrCode_4900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_4900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_4900 creat finish===="); + try { + appAccountManager.getCustomDataSync("test_no_account", "test_key"); + } catch(err) { + console.debug("====>ActsAccountErrCode_4900 getCustomDataSync catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(12300003); + console.debug("====>ActsAccountErrCode_4900 end===="); + done(); + } + }); + + //auth + /* + * @tc.number : ActsAccountErrCode_5000 + * @tc.name : auth callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_5000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5000 creat finish===="); + try { + appAccountManager.auth("test_name"); + } catch(err) { + console.debug("====>ActsAccountErrCode_5000 auth catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5100 + * @tc.name : auth callback + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_5100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5100 creat finish===="); + try { + appAccountManager.auth(12346, "test_owner", "test_authtype", { + onResult: null, + onRequestRedirected: null + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5100 auth catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5110 + * @tc.name : auth callback + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_5110', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5110 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5110 creat finish===="); + try { + appAccountManager.auth("test_name", 12346, "test_authtype", { + onResult: null, + onRequestRedirected: null + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5110 auth catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5110 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5120 + * @tc.name : auth callback + * @tc.desc : test the type of parameters does not match(authtype不匹配) + */ + it('ActsAccountErrCode_5120', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5120 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5120 creat finish===="); + try { + appAccountManager.auth("test_name", "test_owner", 123456, { + onResult: null, + onRequestRedirected: null + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5120 auth catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5120 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5130 + * @tc.name : auth callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_5130', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5130 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5130 creat finish===="); + try { + appAccountManager.auth("test_name", "test_owner", 123456, "callback"); + } catch(err) { + console.debug("====>ActsAccountErrCode_5130 auth catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5130 end===="); + done(); + } + }); + + //getAuthToken + /* + * @tc.number : ActsAccountErrCode_5200 + * @tc.name : getAuthToken callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_5200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5200 creat finish===="); + try { + appAccountManager.getAuthToken((err, data)=>{ + console.debug("====>ActsAccountErrCode_5200 getAuthToken callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5200 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5300 + * @tc.name : getAuthToken callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_5300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5300 creat finish===="); + try { + appAccountManager.getAuthToken("test_name", "test_owner", 12345, (err, data)=>{ + console.debug("====>ActsAccountErrCode_5300 getAuthToken callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5300 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5310 + * @tc.name : getAuthToken callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_5310', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5310 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5310 creat finish===="); + try { + appAccountManager.getAuthToken("test_name", "test_owner", "test_authType", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_5310 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5310 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5400 + * @tc.name : getAuthToken promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_5400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5400 creat finish===="); + try { + var authToken = appAccountManager.getAuthToken(); + } catch(err) { + console.debug("====>ActsAccountErrCode_5400 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5500 + * @tc.name : getAuthToken promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_5500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5500 creat finish===="); + try { + var authToken = appAccountManager.getAuthToken(12345, "test_owner", "test_authtype"); + } catch(err) { + console.debug("====>ActsAccountErrCode_5500 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5510 + * @tc.name : getAuthToken promise + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_5510', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5510 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5510 creat finish===="); + try { + var authToken = appAccountManager.getAuthToken("test_name", 12345, "test_authType"); + } catch(err) { + console.debug("====>ActsAccountErrCode_5510 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5510 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5520 + * @tc.name : getAuthToken promise + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_5520', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5520 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5520 creat finish===="); + try { + var authToken = appAccountManager.getAuthToken("test_name", "test_owner", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_5520 getAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5520 end===="); + done(); + } + }); + + //setAuthToken + /* + * @tc.number : ActsAccountErrCode_5600 + * @tc.name : setAuthToken callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_5600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5600 creat finish===="); + try { + appAccountManager.setAuthToken((err)=>{ + console.debug("====>ActsAccountErrCode_5600 setAuthToken callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5600 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5700 + * @tc.name : setAuthToken callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_5700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5700 creat finish===="); + try { + appAccountManager.setAuthToken("test_name", 123456, "test_token", (err)=>{ + console.debug("====>ActsAccountErrCode_5700 setAuthToken callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_5700 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5710 + * @tc.name : setAuthToken callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_5710', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5710 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5710 creat finish===="); + try { + appAccountManager.setAuthToken("test_name", "test_authType", "test_token", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_5710 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5710 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5400 + * @tc.name : setAuthToken promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_5800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5800 creat finish===="); + try { + appAccountManager.setAuthToken(); + } catch(err) { + console.debug("====>ActsAccountErrCode_5800 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5900 + * @tc.name : setAuthToken promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_5900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5900 creat finish===="); + try { + appAccountManager.setAuthToken(12345, "test_authType", "test_token"); + } catch(err) { + console.debug("====>ActsAccountErrCode_5900 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5910 + * @tc.name : setAuthToken promise + * @tc.desc : test the type of parameters does not match(authType不匹配) + */ + it('ActsAccountErrCode_5910', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5910 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5910 creat finish===="); + try { + appAccountManager.setAuthToken("test_name", 123456, "test_token"); + } catch(err) { + console.debug("====>ActsAccountErrCode_5910 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5910 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_5920 + * @tc.name : setAuthToken promise + * @tc.desc : test the type of parameters does not match(token不匹配) + */ + it('ActsAccountErrCode_5920', 0, async function (done) { + console.debug("====>ActsAccountErrCode_5920 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_5920 creat finish===="); + try { + appAccountManager.setAuthToken("test_name", "test_authType", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_5920 setAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_5920 end===="); + done(); + } + }); + + //deleteAuthToken + /* + * @tc.number : ActsAccountErrCode_6000 + * @tc.name : deleteAuthToken callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_6000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6000 creat finish===="); + try { + appAccountManager.deleteAuthToken((err)=>{ + console.debug("====>ActsAccountErrCode_6000 deleteAuthToken callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_6000 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6100 + * @tc.name : deleteAuthToken callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6100 creat finish===="); + try { + appAccountManager.deleteAuthToken("test_name", "test_owner", 123456, "test_token", (err)=>{ + console.debug("====>ActsAccountErrCode_6100 deleteAuthToken callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_6100 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6110 + * @tc.name : deleteAuthToken callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6110', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6110 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6110 creat finish===="); + try { + appAccountManager.deleteAuthToken("test_name", "test_owner", "test_authType", "test_token", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_6110 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6110 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6200 + * @tc.name : deleteAuthToken promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_6200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6200 creat finish===="); + try { + appAccountManager.deleteAuthToken(); + } catch(err) { + console.debug("====>ActsAccountErrCode_6200 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6300 + * @tc.name : deleteAuthToken promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_6300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6300 creat finish===="); + try { + appAccountManager.deleteAuthToken(1234, "test_owner", "test_authType", "test_token"); + } catch(err) { + console.debug("====>ActsAccountErrCode_6300 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6310 + * @tc.name : deleteAuthToken promise + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_6310', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6310 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6310 creat finish===="); + try { + appAccountManager.deleteAuthToken("test_name", 123456, "test_authType", "test_token"); + } catch(err) { + console.debug("====>ActsAccountErrCode_6310 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6310 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6320 + * @tc.name : deleteAuthToken promise + * @tc.desc : test the type of parameters does not match(authType不匹配) + */ + it('ActsAccountErrCode_6320', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6320 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6320 creat finish===="); + try { + appAccountManager.deleteAuthToken("test_name", "test_owner", 1234, "test_token"); + } catch(err) { + console.debug("====>ActsAccountErrCode_6320 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6320 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6330 + * @tc.name : deleteAuthToken promise + * @tc.desc : test the type of parameters does not match(token不匹配) + */ + it('ActsAccountErrCode_6330', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6330 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6330 creat finish===="); + try { + appAccountManager.deleteAuthToken("test_name", "test_owner", "test_authType", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_6330 deleteAuthToken catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6330 end===="); + done(); + } + }); + + //setAuthTokenVisibility + /* + * @tc.number : ActsAccountErrCode_6000 + * @tc.name : setAuthTokenVisibility callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_6400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6400 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility((err)=>{ + console.debug("====>ActsAccountErrCode_6400 setAuthTokenVisibility callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_6400 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6500 + * @tc.name : setAuthTokenVisibility callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6500 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility("test_name", "test_authType", 123456, true, (err)=>{ + console.debug("====>ActsAccountErrCode_6500 setAuthTokenVisibility callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_6500 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6510 + * @tc.name : setAuthTokenVisibility callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6510', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6510 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6510 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility("test_name", "test_authType", "test_bundleName", true, 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_6510 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6510 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6600 + * @tc.name : setAuthTokenVisibility promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_6600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6600 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility(); + } catch(err) { + console.debug("====>ActsAccountErrCode_6600 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6700 + * @tc.name : setAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6700 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility("test_name", "test_authType", 123456, true); + } catch(err) { + console.debug("====>ActsAccountErrCode_6700 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6710 + * @tc.name : setAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_6710', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6710 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6710 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility(12345, "test_authType", "test_bundleName", true); + } catch(err) { + console.debug("====>ActsAccountErrCode_6710 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6710 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6710 + * @tc.name : setAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(authType不匹配) + */ + it('ActsAccountErrCode_6720', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6720 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6720 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility("test_name", 1234, "test_bundleName", true); + } catch(err) { + console.debug("====>ActsAccountErrCode_6720 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6720 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6720 + * @tc.name : setAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(bundleName不匹配) + */ + it('ActsAccountErrCode_6730', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6730 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6730 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility("test_name", "test_authType", 123456, true); + } catch(err) { + console.debug("====>ActsAccountErrCode_6730 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6730 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6730 + * @tc.name : setAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(isVisible不匹配) + */ + it('ActsAccountErrCode_6740', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6740 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6740 creat finish===="); + try { + appAccountManager.setAuthTokenVisibility("test_name", "test_authType", "test_bundleName", "231"); + } catch(err) { + console.debug("====>ActsAccountErrCode_6740 setAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6740 end===="); + done(); + } + }); + + + + //getAllAuthTokens + /* + * @tc.number : ActsAccountErrCode_6800 + * @tc.name : getAllAuthTokens callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_6800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6800 creat finish===="); + try { + appAccountManager.getAllAuthTokens("test_name", (err, data)=>{ + console.debug("====>ActsAccountErrCode_6800 getAllAuthTokens callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_6800 getAllAuthTokens catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6900 + * @tc.name : getAllAuthTokens callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6900 creat finish===="); + try { + appAccountManager.getAllAuthTokens("test_name", 123456, (err, data)=>{ + console.debug("====>ActsAccountErrCode_6900 getAllAuthTokens callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_6900 getAllAuthTokens catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6910 + * @tc.name : getAllAuthTokens callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_6910', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6910 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_6910 creat finish===="); + try { + appAccountManager.getAllAuthTokens("test_name", "test_owner", 124); + } catch(err) { + console.debug("====>ActsAccountErrCode_6910 getAllAuthTokens catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_6910 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7000 + * @tc.name : getAllAuthTokens promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_7000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7000 creat finish===="); + try { + var authTokenInfo = appAccountManager.getAllAuthTokens("test_name"); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7000 getAllAuthTokens catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7100 + * @tc.name : getAllAuthTokens promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_7100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7100 creat finish===="); + try { + var authTokenInfo = appAccountManager.getAllAuthTokens(123456, "test_owner"); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7100 getAllAuthTokens catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7110 + * @tc.name : getAllAuthTokens promise + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_7110', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7110 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7110 creat finish===="); + try { + var authTokenInfo = appAccountManager.getAllAuthTokens("test_name", 123456); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7110 getAllAuthTokens catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7110 end===="); + done(); + } + }); + + //getAuthList + /* + * @tc.number : ActsAccountErrCode_7200 + * @tc.name : getAuthList callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_7200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7200 creat finish===="); + try { + appAccountManager.getAuthList("test_name", (err, data)=>{ + console.debug("====>ActsAccountErrCode_7200 getAuthList callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_7200 getAuthList catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7300 + * @tc.name : getAuthList callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_7300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7300 creat finish===="); + try { + appAccountManager.getAuthList("test_name", 123456, (err, data)=>{ + console.debug("====>ActsAccountErrCode_7300 getAuthList callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_7300 getAuthList catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7310 + * @tc.name : getAuthList callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_7310', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7310 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7310 creat finish===="); + try { + appAccountManager.getAuthList("test_name", "test_authType", 123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_7310 getAuthList catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7310 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7400 + * @tc.name : getAuthList promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_7400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7400 creat finish===="); + try { + var authList = appAccountManager.getAuthList("test_name"); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7400 getAuthList catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7500 + * @tc.name : getAuthList promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_7500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7500 creat finish===="); + try { + var authList = appAccountManager.getAuthList(123456, "test_authType"); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7500 getAuthList catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7510 + * @tc.name : getAuthList promise + * @tc.desc : test the type of parameters does not match(authType不匹配) + */ + it('ActsAccountErrCode_7510', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7510 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7510 creat finish===="); + try { + var authList = appAccountManager.getAuthList("test_name", 123456); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7510 getAuthList catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7510 end===="); + done(); + } + }); + + //getAuthCallback + /* + * @tc.number : ActsAccountErrCode_7600 + * @tc.name : getAuthCallback callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_7600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7600 creat finish===="); + try { + appAccountManager.getAuthCallback((err, databack)=>{ + console.debug("====>ActsAccountErrCode_7600 getAuthCallback callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_7600 getAuthCallback catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7700 + * @tc.name : getAuthCallback callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_7700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7700 creat finish===="); + try { + appAccountManager.getAuthCallback(123456, (err, data)=>{ + console.debug("====>ActsAccountErrCode_7700 getAuthCallback callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_7700 getAuthCallback catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7710 + * @tc.name : getAuthCallback callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_7710', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7710 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7710 creat finish===="); + try { + appAccountManager.getAuthCallback("test_sessionId", 123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_7710 getAuthCallback catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7710 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7800 + * @tc.name : getAuthCallback promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_7800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7800 creat finish===="); + try { + var authCallback = appAccountManager.getAuthCallback(); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7800 getAuthCallback catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_7900 + * @tc.name : getAuthCallback promise + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_7900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_7900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_7900 creat finish===="); + try { + var authCallback = appAccountManager.getAuthCallback(123456); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_7900 getAuthCallback catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_7900 end===="); + done(); + } + }); + + //queryAuthenticatorInfo + /* + * @tc.number : ActsAccountErrCode_8000 + * @tc.name : queryAuthenticatorInfo callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_8000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8000 creat finish===="); + try { + appAccountManager.queryAuthenticatorInfo((err, authenticatorInfo)=>{ + console.debug("====>ActsAccountErrCode_8000 queryAuthenticatorInfo callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8000 queryAuthenticatorInfo catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8100 + * @tc.name : queryAuthenticatorInfo callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_8100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8100 creat finish===="); + try { + appAccountManager.queryAuthenticatorInfo(123456, (err, authenticatorInfo)=>{ + console.debug("====>ActsAccountErrCode_8100 queryAuthenticatorInfo callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8100 queryAuthenticatorInfo catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8110 + * @tc.name : queryAuthenticatorInfo callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_8110', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8110 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8110 creat finish===="); + try { + appAccountManager.queryAuthenticatorInfo("test_owner", 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_8110 queryAuthenticatorInfo catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8110 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8200 + * @tc.name : queryAuthenticatorInfo promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_8200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8200 creat finish===="); + try { + var authenticatorInfo = appAccountManager.queryAuthenticatorInfo(); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_8200 queryAuthenticatorInfo catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8300 + * @tc.name : queryAuthenticatorInfo promise + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_8300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8300 creat finish===="); + try { + var authenticatorInfo = appAccountManager.queryAuthenticatorInfo(123456); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_8300 queryAuthenticatorInfo catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8300 end===="); + done(); + } + }); + + + //deleteCredential + /* + * @tc.number : ActsAccountErrCode_8400 + * @tc.name : deleteCredential callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_8400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8400 creat finish===="); + try { + appAccountManager.deleteCredential("test_name", (err)=>{ + console.debug("====>ActsAccountErrCode_8400 deleteCredential callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8400 deleteCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8500 + * @tc.name : deleteCredential callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_8500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8500 creat finish===="); + try { + appAccountManager.deleteCredential("test_name", 123456, (err)=>{ + console.debug("====>ActsAccountErrCode_8500 deleteCredential callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8500 deleteCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8510 + * @tc.name : deleteCredential callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_8510', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8510 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8510 creat finish===="); + try { + appAccountManager.deleteCredential("test_name", "test_credentialType", 122); + } catch(err) { + console.debug("====>ActsAccountErrCode_8510 deleteCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8510 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8600 + * @tc.name : deleteCredential promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_8600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8600 creat finish===="); + try { + appAccountManager.deleteCredential(); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_8600 deleteCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8700 + * @tc.name : deleteCredential promise + * @tc.desc : test the type of parameters does not match(credentialType不匹配) + */ + it('ActsAccountErrCode_8700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8700 creat finish===="); + try { + appAccountManager.deleteCredential("test_name", 123456); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_8700 deleteCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8710 + * @tc.name : deleteCredential promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_8710', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8710 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8710 creat finish===="); + try { + appAccountManager.deleteCredential(12345, "test_credentialType"); + expect().assertFail(); + done(); + } catch(err) { + console.debug("====>ActsAccountErrCode_8710 deleteCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8710 end===="); + done(); + } + }); + + //verifyCredential + /* + * @tc.number : ActsAccountErrCode_8800 + * @tc.name : verifyCredential callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_8800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8800 creat finish===="); + try { + appAccountManager.verifyCredential("test_name", { + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_8800 verifyCredential_onRequestContinued") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8800 verifyCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8900 + * @tc.name : verifyCredential callback + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_8900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8900 creat finish===="); + try { + appAccountManager.verifyCredential("test_name", 123456, { + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_8900 verifyCredential_onRequestContinued") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8900 verifyCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8910 + * @tc.name : verifyCredential callback + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_8910', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8910 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8910 creat finish===="); + try { + appAccountManager.verifyCredential(12345, "test_owner", { + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_8910 verifyCredential_onRequestContinued") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_89100 verifyCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_89100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8920 + * @tc.name : verifyCredential callback + * @tc.desc : test the type of parameters does not match(option不匹配) + */ + it('ActsAccountErrCode_8920', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8920 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8920 creat finish===="); + try { + appAccountManager.verifyCredential("test_name", "test_owner", 1244, { + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_8920 verifyCredential_onRequestContinued") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_8920 verifyCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8920 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_8930 + * @tc.name : verifyCredential callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_8930', 0, async function (done) { + console.debug("====>ActsAccountErrCode_8930 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_8930 creat finish===="); + var options = {credentialType: "PIN", credential: "123456"} + try { + appAccountManager.verifyCredential("test_name", "test_owner", options, 1234); + } catch(err) { + console.debug("====>ActsAccountErrCode_8930 verifyCredential catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_8930 end===="); + done(); + } + }); + + + //setAuthenticatorProperties + /* + * @tc.number : ActsAccountErrCode_9000 + * @tc.name : setAuthenticatorProperties callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_9000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9000 creat finish===="); + try { + appAccountManager.setAuthenticatorProperties({ + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_9000 setAuthenticatorProperties") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9000 setAuthenticatorProperties catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9100 + * @tc.name : setAuthenticatorProperties callback + * @tc.desc : test the type of parameters does not match(owner不匹配) + */ + it('ActsAccountErrCode_9100', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9100 creat finish===="); + try { + appAccountManager.setAuthenticatorProperties(123456, { + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_9100 setAuthenticatorProperties") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9100 setAuthenticatorProperties catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9100 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9110 + * @tc.name : setAuthenticatorProperties callback + * @tc.desc : test the type of parameters does not match(option不匹配) + */ + it('ActsAccountErrCode_9110', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9110 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9110 creat finish===="); + try { + appAccountManager.setAuthenticatorProperties("test_owner", 12345, { + onResult:null, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountErrCode_9110 setAuthenticatorProperties") + } + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9110 setAuthenticatorProperties catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9110 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9120 + * @tc.name : setAuthenticatorProperties callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_9120', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9120 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9120 creat finish===="); + var options = {credentialType: "PIN", credential: "123456"} + try { + appAccountManager.setAuthenticatorProperties("test_owner", options, 124); + } catch(err) { + console.debug("====>ActsAccountErrCode_9120 setAuthenticatorProperties catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9120 end===="); + done(); + } + }); + + //on + /* + * @tc.number : ActsAccountErrCode_9200 + * @tc.name : on callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_9200', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9200 creat finish===="); + try { + appAccountManager.on('accountChange', function(data){ + console.debug("====>ActsAccountErrCode_9200 on catch err:" + JSON.stringify(data)); + }); + } catch(err) { + console.debug("====>ActsAccountErrCode_9200 on catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9300 + * @tc.name : on callback + * @tc.desc : test the type of parameters does not match(Array不匹配) + */ + it('ActsAccountErrCode_9300', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9300 creat finish===="); + try { + appAccountManager.on('accountChange', 12356, function(data){ + console.debug("====>ActsAccountErrCode_9300 on catch err:" + JSON.stringify(data)); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9300 on catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9400 + * @tc.name : on callback + * @tc.desc : test the type of parameters does not match(accountChange不匹配) + */ + it('ActsAccountErrCode_9400', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9400 creat finish===="); + try { + appAccountManager.on(12345, ["test_owner"], function(data){ + console.debug("====>ActsAccountErrCode_9400 on catch err:" + JSON.stringify(data)); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9400 on catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9400 end===="); + done(); + } + }); + + //off + /* + * @tc.number : ActsAccountErrCode_9500 + * @tc.name : off callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_9500', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9500 creat finish===="); + try { + appAccountManager.off(); + } catch(err) { + console.debug("====>ActsAccountErrCode_9500 off catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9500 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9600 + * @tc.name : off callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_9600', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9600 creat finish===="); + try { + appAccountManager.off(123456); + } catch(err) { + console.debug("====>ActsAccountErrCode_9600 off catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9600 end===="); + done(); + } + }); + + //checkAuthTokenVisibility + /* + * @tc.number : ActsAccountErrCode_6000 + * @tc.name : checkAuthTokenVisibility callback + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_9700', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9700 creat finish===="); + try { + appAccountManager.checkAuthTokenVisibility((err)=>{ + console.debug("====>ActsAccountErrCode_9700 checkAuthTokenVisibility callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9700 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9800 + * @tc.name : checkAuthTokenVisibility callback + * @tc.desc : test the type of parameters does not match + */ + it('ActsAccountErrCode_9800', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9800 creat finish===="); + try { + appAccountManager.checkAuthTokenVisibility("test_name", "test_authType", 123456, (err)=>{ + console.debug("====>ActsAccountErrCode_9800 checkAuthTokenVisibility callback err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch(err) { + console.debug("====>ActsAccountErrCode_9800 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_9810 + * @tc.name : checkAuthTokenVisibility callback + * @tc.desc : test the type of parameters does not match(callback不匹配) + */ + it('ActsAccountErrCode_9810', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9810 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9810 creat finish===="); + try { + appAccountManager.checkAuthTokenVisibility("test_name", "test_authType", "test_bundleName", 12234); + } catch(err) { + console.debug("====>ActsAccountErrCode_9810 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9810 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6600 + * @tc.name : checkAuthTokenVisibility promise + * @tc.desc : test the number of parameters does not match + */ + it('ActsAccountErrCode_9900', 0, async function (done) { + console.debug("====>ActsAccountErrCode_9900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_9900 creat finish===="); + try { + var visibility = appAccountManager.checkAuthTokenVisibility("test_name"); + } catch(err) { + console.debug("====>ActsAccountErrCode_9900 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_9900 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_10000 + * @tc.name : checkAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(name不匹配) + */ + it('ActsAccountErrCode_10000', 0, async function (done) { + console.debug("====>ActsAccountErrCode_6700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_10000 creat finish===="); + try { + var visibility = appAccountManager.checkAuthTokenVisibility(12345, "test_authType", "test_bundleName"); + } catch(err) { + console.debug("====>ActsAccountErrCode_10000 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_10000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6710 + * @tc.name : checkAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(authType不匹配) + */ + it('ActsAccountErrCode_10010', 0, async function (done) { + console.debug("====>ActsAccountErrCode_10010 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_10010 creat finish===="); + try { + var visibility = appAccountManager.checkAuthTokenVisibility("test_name", 1234, "test_bundleName"); + } catch(err) { + console.debug("====>ActsAccountErrCode_10010 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_10010 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrCode_6720 + * @tc.name : checkAuthTokenVisibility promise + * @tc.desc : test the type of parameters does not match(authType不匹配) + */ + it('ActsAccountErrCode_10020', 0, async function (done) { + console.debug("====>ActsAccountErrCode_10020 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountErrCode_10020 creat finish===="); + try { + var visibility = appAccountManager.checkAuthTokenVisibility("test_name", "test_authType", 12345); + } catch(err) { + console.debug("====>ActsAccountErrCode_10020 checkAuthTokenVisibility catch err:" + JSON.stringify(err)); + expect(err.code).assertEqual(401); + console.debug("====>ActsAccountErrCode_10020 end===="); + done(); + } + }); + + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/ErrPermission.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/ErrPermission.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a6f1061732e797ea114834b5895743120753558a --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/ErrPermission.test.js @@ -0,0 +1,241 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +const ERR_PERMISSION_DENIED = 201; +export default function ActsAccountErrPermission() { + describe('ActsAccountErrPermission', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountErrPermission_0100 + * @tc.name : setDataSyncEnabled callback + * @tc.desc : Set the added account to allow synchronization without permission + */ + it('ActsAccountErrPermission_0100', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_setnopermission", (err)=>{ + console.debug("====>add account ActsAccountErrPermission_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_setnopermission", true, (err)=>{ + console.debug("====>setDataSyncEnabled 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + appAccountManager.removeAccount("syncenable_callback_setnopermission", (err)=>{ + console.debug("====>delete Account ActsAccountErrPermission_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountErrPermission_0100 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsAccountErrPermission_0200 + * @tc.name : setDataSyncEnabled promise + * @tc.desc : Set the added account to allow synchronization without permission + */ + it('ActsAccountErrPermission_0200', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountErrPermission_0200 start===="); + await appAccountManager.createAccount("syncenable_promise_setnopermission"); + console.debug("====>setDataSyncEnabled ActsAccountErrPermission_0200 start===="); + try{ + await appAccountManager.setDataSyncEnabled("syncenable_promise_setnopermission", true); + } + catch(err){ + console.debug("====>setDataSyncEnabled 0200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + console.debug("====>delete account ActsAccountErrPermission_0200 start===="); + await appAccountManager.removeAccount("syncenable_promise_setnopermission"); + console.debug("====>ActsAccountErrPermission_0200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrPermission_0300 + * @tc.name : Check sync flag callback form + * @tc.desc : Check the added account synchronization without permission + */ + it('ActsAccountErrPermission_0300', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_checknopermission", (err)=>{ + console.debug("====>add account ActsAccountErrPermission_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_checknopermission", (err, data)=>{ + console.debug("====>checkDataSyncEnable 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + appAccountManager.removeAccount("syncenable_callback_checknopermission", (err)=>{ + console.debug("====>delete Account ActsAccountErrPermission_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountErrPermission_0300 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsAccountErrPermission_0400 + * @tc.name : Check sync flag promise form + * @tc.desc : Check the added account synchronization without permission + */ + it('ActsAccountErrPermission_0400', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountErrPermission_0400 start===="); + await appAccountManager.createAccount("syncenable_promise_checknopermission"); + console.debug("====>checkDataSyncEnable ActsAccountErrPermission_0400 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_checknopermission"); + } + catch(err){ + console.debug("====>checkDataSyncEnable 0400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + await appAccountManager.removeAccount("syncenable_promise_checknopermission"); + console.debug("====>ActsAccountErrPermission_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrPermission_0500 + * @tc.name : getAllAccounts callback + * @tc.desc : This application gets authorization after adding a single account without permission + */ + it('ActsAccountErrPermission_0500', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("accessibleAccount_callback_nopermission", (err)=>{ + console.debug("====> add account ActsAccountErrPermission_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + appAccountManager.removeAccount("accessibleAccount_callback_nopermission", (err)=>{ + console.debug("====>delete Account ActsAccountErrPermission_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountErrPermission_0500 end===="); + done(); + }) + }); + }); + }); + + /* + * @tc.number : ActsAccountErrPermission_0600 + * @tc.name : getAllAccounts promise + * @tc.desc : This application gets authorization after adding a single account without permission + */ + it('ActsAccountErrPermission_0600', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountErrPermission_0600 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_nopermission"); + console.debug("====>getAllAccounts 0600 start===="); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + await appAccountManager.removeAccount("accessibleAccount_promise_nopermission"); + console.debug("====>ActsAccountErrPermission_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountErrPermission_0700 + * @tc.name : getAccountsByOwner callback + * @tc.desc : This application gets its own application information after adding an account without permission + */ + it('ActsAccountErrPermission_0700', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsaccountoperatetest"; + appAccountManager.createAccount("getAll_callback_nopermission", (err)=>{ + console.debug("====>add account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountsByOwner(selfBundle, (err, data)=>{ + console.debug("====>getAccountsByOwner 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(data.length>0).assertEqual(true); + appAccountManager.removeAccount("getAll_callback_nopermission", (err)=>{ + console.debug("====>delete account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountErrPermission_0700 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsAccountErrPermission_0800 + * @tc.name : getAccountsByOwner promise + * @tc.desc : This application gets its own application information after adding an account without permission + */ + it('ActsAccountErrPermission_0800', 0, async function (done) { + console.debug("====>ActsAccountErrPermission_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsaccountoperatetest"; + console.debug("====>add account 0800 start===="); + await appAccountManager.createAccount("getAll_promise_nopermission"); + console.debug("====>getAccountsByOwner 0800 start===="); + try{ + var data = await appAccountManager.getAccountsByOwner(selfBundle); + console.debug("====>getAll_promise_nopermission data:" + JSON.stringify(data)) + expect(data.length>0).assertEqual(true); + done(); + } + catch(err){ + console.error("====>getAccountsByOwner 0800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_PERMISSION_DENIED); + await appAccountManager.removeAccount("getAll_promise_nopermission"); + console.debug("====>ActsAccountErrPermission_0800 end===="); + done(); + } + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/List.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..edf602357a2863f224fc113b82be19d3bd0e098d --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/List.test.js @@ -0,0 +1,38 @@ +/* + * 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 ActsAccountCreateAccount from './CreateAccount.test.js' +import ActsAccountRemoveAccount from './RemoveAccount.test.js' +import ActsAccountSetAppAccess from './SetAppAccess.test.js' +import ActsAccountCustomData from './CustomData.test.js' +import ActsAppAccountCredential from './AccountCredential.test.js' +import ActsAccountAuthToken from './AuthToken.test.js' +import ActsAccountManager from './AccountManager.test.js' +import ActsAccountErrPermission from './ErrPermission.test.js' +import ActsAccountOnOff from './ChangeOnOff.js' +import ActsAccountAuthenticator from './Authenticator.test.js' +import ActsAccountErrCode from './ErrCode.test.js' +export default function testsuite() { + ActsAccountCreateAccount() + ActsAccountSetAppAccess() + ActsAccountCustomData() + ActsAccountManager() + ActsAppAccountCredential() + ActsAccountRemoveAccount() + ActsAccountErrPermission() + ActsAccountAuthToken() + ActsAccountOnOff() + ActsAccountAuthenticator() + ActsAccountErrCode() +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/RemoveAccount.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/RemoveAccount.test.js new file mode 100644 index 0000000000000000000000000000000000000000..0a71ccc776b1f376bb7c3617eb6e3a107065f3bd --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/RemoveAccount.test.js @@ -0,0 +1,248 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +const NAMELIMIT = 512; +const TIMEOUT = 5000; +const ERR_INVALID_PARAMETER = 12300002 +const ERR_ACCOUNT_NO_EXIST = 12300003 +const createAccountOptions = {customData:{age:'12'}} +export default function ActsAccountRemoveAccount() { + describe('ActsAccountRemoveAccount', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0100 + * @tc.name : Remove account callback form + * @tc.desc : Remove the added account in callback form + */ + it('ActsAccountRemoveAccount_0100', 0, async function (done) { + console.debug("====>ActsAccountRemoveAccount_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("removeAccount_name_callback_first", createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountRemoveAccount_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("removeAccount_name_callback_first", (err)=>{ + console.debug("====>delete Account ActsAccountRemoveAccount_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountRemoveAccount_0100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0200 + * @tc.name : Remove account promise form + * @tc.desc : Remove the added account in promise form + */ + it('ActsAccountRemoveAccount_0200',0,async function (done){ + console.debug("====>ActsAccountRemoveAccount_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountcreateAccount_0200 start===="); + await appAccountManager.createAccount("removeAccount_name_promise_first",createAccountOptions); + try{ + await appAccountManager.removeAccount("removeAccount_name_promise_first"); + console.debug("====>ActsAccountRemoveAccount_0200 end===="); + done(); + } + catch(err){ + console.error("====>delete account ActsAccountRemoveAccount_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0300 + * @tc.name : Remove account callback form + * @tc.desc : Remove unadded account in callback form + */ + it('ActsAccountRemoveAccount_0300', 0, async function (done) { + console.debug("====>ActsAccountRemoveAccount_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.removeAccount("removeAccount_name_callback_second", (err)=>{ + console.debug("====>delete Account ActsAccountRemoveAccount_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NO_EXIST); + console.debug("====>ActsAccountRemoveAccount_0300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0400 + * @tc.name : Remove account promise form + * @tc.desc : Remove unadded account in promise form + */ + it('ActsAccountRemoveAccount_0400', 0, async function(done){ + console.debug("====>ActsAccountRemoveAccount_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.removeAccount("removeAccount_name_promise_second"); + } + catch(err){ + console.debug("====>delete account ActsAccountRemoveAccount_0400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NO_EXIST); + console.debug("====>ActsAccountRemoveAccount_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0500 + * @tc.name : Remove account callback form + * @tc.desc : Remove the added account, the first time it can be deleted, the second time the deletion fails + */ + it('ActsAccountRemoveAccount_0500', 0, async function (done) { + console.debug("====>ActsAccountRemoveAccount_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.createAccount("removeAccount_name_callback_third", createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountRemoveAccount_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("removeAccount_name_callback_third", (err)=>{ + console.debug("====>delete account first time err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("removeAccount_name_callback_third", (err)=>{ + console.debug("====>delete Account second time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NO_EXIST); + console.debug("====>ActsAccountRemoveAccount_0500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0600 + * @tc.name : Remove account promise form + * @tc.desc : Remove the added account, the first time it can be deleted, the second time the deletion fails + */ + it('ActsAccountRemoveAccount_0600', 0, async function (done){ + console.debug("====>ActsAccountRemoveAccount_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountcreateAccount_0600 start===="); + await appAccountManager.createAccount("removeAccount_name_promise_third", createAccountOptions); + console.debug("====>delete Account first time ActsAccountRemoveAccount_0600 start===="); + await appAccountManager.removeAccount("removeAccount_name_promise_third"); + console.debug("====>delete Account second time ActsAccountRemoveAccount_0600 start===="); + try{ + await appAccountManager.removeAccount("removeAccount_name_promise_third"); + } + catch(err){ + console.debug("====>delete account ActsAccountRemoveAccount_0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NO_EXIST); + console.debug("====>ActsAccountRemoveAccount_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0700 + * @tc.name : Remove account callback form + * @tc.desc : Remove the account name exceeds the length limit of 512 characters + */ + it('ActsAccountRemoveAccount_0700',0, async function (done){ + console.debug("====>ActsAccountRemoveAccount_0700 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.removeAccount(nameLimit, (err)=>{ + console.debug("====>delete Account ActsAccountRemoveAccount_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountRemoveAccount_0700 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountRemoveAccount_0800 + * @tc.name : Remove account promise form + * @tc.desc : Remove the account name exceeds the length limit of 512 characters + */ + it('ActsAccountRemoveAccount_0800', 0, async function (done){ + console.debug("====>ActsAccountRemoveAccount_0800 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + nameLimit += 'n'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>delete Account ActsAccountRemoveAccount_0800 start===="); + try{ + await appAccountManager.removeAccount(nameLimit); + } + catch(err){ + console.debug("====>delete account ActsAccountRemoveAccount_0800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountRemoveAccount_0800 end===="); + done(); + } + }) + + /* + * @tc.number : ActsAccountRemoveAccount_0900 + * @tc.name : Remove account callback form + * @tc.desc : Remove the account name is an empty string + */ + it('ActsAccountRemoveAccount_0900',0, async function (done){ + console.debug("====>ActsAccountRemoveAccount_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.removeAccount("", (err)=>{ + console.debug("====>delete Account ActsAccountRemoveAccount_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountRemoveAccount_0900 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountRemoveAccount_1000 + * @tc.name : Remove account promise form + * @tc.desc : Remove the account name is an empty string + */ + it('ActsAccountRemoveAccount_1000', 0, async function (done){ + console.debug("====>ActsAccountRemoveAccount_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>delete Account ActsAccountRemoveAccount_1000 start===="); + try{ + await appAccountManager.removeAccount(""); + } + catch(err){ + console.debug("====>delete account ActsAccountRemoveAccount_1000 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsAccountRemoveAccount_1000 end===="); + done(); + } + }) + }) +} diff --git a/account/appaccount/actsaccountoperatetest/src/main/js/test/SetAppAccess.test.js b/account/appaccount/actsaccountoperatetest/src/main/js/test/SetAppAccess.test.js new file mode 100644 index 0000000000000000000000000000000000000000..fc09f2e4640779572a7b3b7604a58374702b4e96 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/js/test/SetAppAccess.test.js @@ -0,0 +1,569 @@ +/* + * 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 account from '@ohos.account.appAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +const STRCOUNT = 513; +const EACHTIMEOUT = 500; +const createAccountOptions = {customData:{age:'12'}} +export default function ActsAccountSetAppAccess() { + describe('ActsAccountSetAppAccess', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + done(); + }) + + /* + * @tc.number : ActsAccountSetAppAccess_0100 + * @tc.name : enableAppAccess callback + * @tc.desc : Enable the app to access the app itself + */ + it('ActsAccountSetAppAccess_0100', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("AppAccess_callback_itself", createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_itself", "com.example.actsaccountappaccess", true, (err)=>{ + console.debug("====>enableAppAccess err:" + JSON.stringify(err)); + expect(err.code).assertEqual(12400001); + appAccountManager.removeAccount("AppAccess_callback_itself", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_0100 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0200 + * @tc.name : enableAppAccess promise + * @tc.desc : Enable the app to access the app itself + */ + it('ActsAccountSetAppAccess_0200', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountSetAppAccess_0200 start===="); + await appAccountManager.createAccount("AppAccess_promise_itself", createAccountOptions); + console.debug("====>enableAppAccess ActsAccountSetAppAccess_0200 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_itself", "com.example.actsaccountappaccess", true); + } + catch(err){ + console.debug("====>enableAppAccess 0200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(12400001); + console.debug("====>delete account ActsAccountSetAppAccess_0200 start===="); + await appAccountManager.removeAccount("AppAccess_promise_itself"); + console.debug("====>ActsAccountSetAppAccess_0200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0300 + * @tc.name : enableAppAccess callback + * @tc.desc : The enabled bundleName does not exist + */ + it('ActsAccountSetAppAccess_0300', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonExistBundle = "com.example.NonExistentBundleCallback"; + appAccountManager.createAccount("AppAccess_callback_NotExistBundle", createAccountOptions, (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_NotExistBundle", nonExistBundle, true, (err)=>{ + console.debug("====>enableAppAccess 0300 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + appAccountManager.removeAccount("AppAccess_callback_NotExistBundle", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_0300 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0400 + * @tc.name : enableAppAccess promise + * @tc.desc : The enabled bundleName does not exist + */ + it('ActsAccountSetAppAccess_0400', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonExistBundle = "com.example.NonExistentBundlePromise"; + console.debug("====>add account ActsAccountSetAppAccess_0400 start===="); + await appAccountManager.createAccount("AppAccess_promise_NotExistBundle", createAccountOptions); + console.debug("====>enableAppAccess ActsAccountSetAppAccess_0400 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_NotExistBundle", nonExistBundle, true); + } + catch(err){ + console.error("====>enableAppAccess ActsAccountSetAppAccess_0400 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + console.debug("====>delete account ActsAccountSetAppAccess_0400 start===="); + await appAccountManager.removeAccount("AppAccess_promise_NotExistBundle"); + console.debug("====>ActsAccountSetAppAccess_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0500 + * @tc.name : enableAppAccess callback + * @tc.desc : The enabled account name does not exist + */ + it('ActsAccountSetAppAccess_0500', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + var nonExistAccount = "NonExistentAccountCallback"; + appAccountManager.setAppAccess(nonExistAccount, enableBundle, true, (err)=>{ + console.debug("====>enableAppAccess 0500 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsAccountSetAppAccess_0500 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0600 + * @tc.name : enableAppAccess promise + * @tc.desc : The enabled account name does not exist + */ + it('ActsAccountSetAppAccess_0600', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + var nonExistAccount = "NonExistentAccountPromise"; + console.debug("====>enableAppAccess ActsAccountSetAppAccess_0600 start===="); + try{ + await appAccountManager.setAppAccess("NonExistentAccountPromise", enableBundle, true); + } + catch(err){ + console.debug("====>enableAppAccess 0600 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsAccountSetAppAccess_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0700 + * @tc.name : enableAppAccess disableAppAccess callback + * @tc.desc : Cancel the authorization after authorizing the account to another app + */ + it('ActsAccountSetAppAccess_0700', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + appAccountManager.createAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_account", enableBundle, true, (err)=>{ + console.debug("====>enableAppAccess 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_account", enableBundle, false, (err)=>{ + console.debug("====>disableAppAccess 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null) + appAccountManager.removeAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_0700 end===="); + done(); + }); + }) + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0800 + * @tc.name : enableAppAccess disableAppAccess promise + * @tc.desc : Cancel the authorization after authorizing the account to another account + */ + it('ActsAccountSetAppAccess_0800', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>add account ActsAccountSetAppAccess_0800 start===="); + try{ + await appAccountManager.createAccount("AppAccess_promise_account"); + } + catch(err){ + console.error("====>createAccount ActsAccountSetAppAccess_0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>enableAppAccess ActsAccountSetAppAccess_0800 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_account", enableBundle, true); + } + catch(err){ + console.error("====>enableAppAccess ActsAccountSetAppAccess_0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess ActsAccountSetAppAccess_0800 start===="); + await appAccountManager.setAppAccess("AppAccess_promise_account", enableBundle, false); + console.debug("====>delete account ActsAccountSetAppAccess_0800 start===="); + await appAccountManager.removeAccount("AppAccess_promise_account"); + console.debug("====>ActsAccountSetAppAccess_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountSetAppAccess_0900 + * @tc.name : enableAppAccess callback + * @tc.desc : The authorized account name is a long string + */ + it('ActsAccountSetAppAccess_0900', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigAccountName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigAccountName += 't'; + } + var enableBundle = "com.example.actsaccountsceneappaccess"; + appAccountManager.setAppAccess(bigAccountName, enableBundle, true, (err)=>{ + console.debug("====>enableAppAccess 0900 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>ActsAccountSetAppAccess_0900 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1000 + * @tc.name : enableAppAccess promise + * @tc.desc : The authorized account name is a long string + */ + it('ActsAccountSetAppAccess_1000', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigAccountName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigAccountName += 't'; + } + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>enableAppAccess ActsAccountSetAppAccess_1000 start===="); + try{ + await appAccountManager.setAppAccess(bigAccountName, enableBundle, true); + } + catch(err){ + console.debug("====>enableAppAccess 1000 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>ActsAccountSetAppAccess_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1100 + * @tc.name : enableAppAccess callback + * @tc.desc : The authorized bundle name is a long string + */ + it('ActsAccountSetAppAccess_1100', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigBundleName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigBundleName += 't'; + } + appAccountManager.createAccount("AppAccess_callback_bigBundleName", (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_bigBundleName", bigBundleName, true, (err)=>{ + console.debug("====>enableAppAccess 1100 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("AppAccess_callback_bigBundleName", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_1100 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1200 + * @tc.name : enableAppAccess promise + * @tc.desc : The authorized bundle name is a long string + */ + it('ActsAccountSetAppAccess_1200', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigBundleName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigBundleName += 't'; + } + console.debug("====>add account ActsAccountSetAppAccess_1200 start===="); + await appAccountManager.createAccount("AppAccess_promise_bigBundleName"); + console.debug("====>enableAppAccess ActsAccountSetAppAccess_1200 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_bigBundleName", bigBundleName, true); + } + catch(err){ + console.debug("====>enableAppAccess 1200 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAccountSetAppAccess_1200 start===="); + await appAccountManager.removeAccount("AppAccess_promise_bigBundleName"); + console.debug("====>ActsAccountSetAppAccess_1200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1300 + * @tc.name : enableAppAccess callback + * @tc.desc : The authorized account name is an empty string + */ + it('ActsAccountSetAppAccess_1300', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundleName = ''; + appAccountManager.createAccount("AppAccess_callback_emptyBundleName", (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_emptyBundleName", emptyBundleName, true, (err)=>{ + console.debug("====>enableAppAccess 1300 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + appAccountManager.removeAccount("AppAccess_callback_emptyBundleName", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_1300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_1300 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1400 + * @tc.name : enableAppAccess promise + * @tc.desc : The authorized account name is an empty string + */ + it('ActsAccountSetAppAccess_1400', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundleName = ''; + console.debug("====>add account ActsAccountSetAppAccess_1400 start===="); + await appAccountManager.createAccount("AppAccess_promise_emptyBundleName"); + console.debug("====>enableAppAccess ActsAccountSetAppAccess_1400 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_emptyBundleName", emptyBundleName, true); + } + catch(err){ + console.debug("====>enableAppAccess 1400 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>delete account ActsAccountSetAppAccess_1400 start===="); + await appAccountManager.removeAccount("AppAccess_promise_emptyBundleName"); + console.debug("====>ActsAccountSetAppAccess_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1500 + * @tc.name : disableAppAccess callback + * @tc.desc : Cancel authorization Accounts that have not authorized other applications + */ + it('ActsAccountSetAppAccess_1500', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + appAccountManager.createAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_account", enableBundle, false, (err)=>{ + console.debug("====>setAppAccess ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + appAccountManager.removeAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_1500 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1600 + * @tc.name : disableAppAccess promise + * @tc.desc : Cancel authorization Accounts that have not authorized other applications + */ + it('ActsAccountSetAppAccess_1600', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>add account ActsAccountSetAppAccess_1600 start===="); + try{ + await appAccountManager.createAccount("AppAccess_promise_account"); + } + catch(err){ + console.error("====>createAccount ActsAccountSetAppAccess_1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess ActsAccountSetAppAccess_1600 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_account", enableBundle,false); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>disableAppAccess ActsAccountSetAppAccess_1600 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + await appAccountManager.removeAccount("AppAccess_promise_account"); + console.debug("====>ActsAccountSetAppAccess_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1700 + * @tc.name : disableAppAccess callback + * @tc.desc : The disableAppAccess parameter bundleName does not exist + */ + it('ActsAccountSetAppAccess_1700', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistBundle = "com.example.actsaccountnotexistbundle"; + appAccountManager.createAccount("AppAccess_callback_notExistBundle", (err)=>{ + console.debug("====>add account ActsAccountSetAppAccess_1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setAppAccess("AppAccess_callback_notExistBundle", notExistBundle, false, (err)=>{ + expect(err.code == 12400001).assertEqual(true); + appAccountManager.removeAccount("AppAccess_callback_notExistBundle", (err)=>{ + console.debug("====>delete Account ActsAccountSetAppAccess_1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountSetAppAccess_1700 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1800 + * @tc.name : disableAppAccess promise + * @tc.desc : The disableAppAccess parameter bundleName does not exist + */ + it('ActsAccountSetAppAccess_1800', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistBundle = "com.example.actsaccountnotexistbundle"; + console.debug("====>add account ActsAccountSetAppAccess_1800 start===="); + await appAccountManager.createAccount("AppAccess_promise_notExistBundle"); + console.debug("====>disableAppAccess ActsAccountSetAppAccess_1800 start===="); + try{ + await appAccountManager.setAppAccess("AppAccess_promise_notExistBundle", notExistBundle, false); + } + catch(err){ + console.debug("====>disableAppAccess ActsAccountSetAppAccess_1800 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + console.debug("====>delete account ActsAccountSetAppAccess_1800 start===="); + await appAccountManager.removeAccount("AppAccess_promise_notExistBundle"); + console.debug("====>ActsAccountSetAppAccess_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetAppAccess_1900 + * @tc.name : disableAppAccess callback + * @tc.desc : The disableAppAccess parameter accountName does not exist + */ + it('ActsAccountSetAppAccess_1900', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistAccount = "AppAccess_callback_notExistAccount"; + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>disableAppAccess ActsAccountSetAppAccess_1900===="); + appAccountManager.setAppAccess(notExistAccount, enableBundle, false, (err)=>{ + console.debug("====>disableAppAccess ActsAccountSetAppAccess_1900 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsAccountSetAppAccess_1900 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsAccountSetAppAccess_2000 + * @tc.name : disableAppAccess promise + * @tc.desc : The disableAppAccess parameter accountName does not exist + */ + it('ActsAccountSetAppAccess_2000', 0, async function (done) { + console.debug("====>ActsAccountSetAppAccess_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistAccount = "AppAccess_promise_notExistAccount"; + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>disableAppAccess ActsAccountSetAppAccess_2000===="); + try{ + await appAccountManager.setAppAccess(notExistAccount, enableBundle, false); + } + catch(err){ + console.debug("====>disableAppAccess ActsAccountSetAppAccess_2000 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsAccountSetAppAccess_2000 end===="); + done(); + } + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/resources/base/element/string.json b/account/appaccount/actsaccountoperatetest/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5a685e30cae1638fb9c5fd966b9ab40b6b80b341 --- /dev/null +++ b/account/appaccount/actsaccountoperatetest/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actsaccountoperatetest/src/main/resources/base/media/icon.png b/account/appaccount/actsaccountoperatetest/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actsaccountoperatetest/src/main/resources/base/media/icon.png differ diff --git a/account/appaccount/actsaccounttest/Test.json b/account/appaccount/actsaccounttest/Test.json index 53ccc60a47b73491a80051dd6f3c28aef918c95d..acdfde0f7d606cbac302361c1ff54ef9501e2808 100644 --- a/account/appaccount/actsaccounttest/Test.json +++ b/account/appaccount/actsaccounttest/Test.json @@ -14,7 +14,8 @@ "ActsAccountSceneAppAccess.hap", "ActsAccountSceneOnOff.hap", "ActsAccountOauthtoken.hap", - "ActsAccountAuthenticator.hap" + "ActsAccountAuthenticator.hap", + "ActsAccountOperateTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js b/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js index 969f8bf7e1da25aa88969c65d2da855334509309..9cad0eb72281ddac598fffff94ca7b89f1fda7be 100755 --- a/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js @@ -352,11 +352,12 @@ export default function ActsAccountAddAccount() { var specialStr = " "; try{ await appAccountManager.addAccount(specialStr, "account_extraInfo_promise_eighth"); + expect().assertFail(); + done(); } catch(err){ - console.debug("====>add Account ActsAccountAddAccount_1600 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountAddAccount_1600 end===="); + console.debug("====>add Account ActsAccountAddAccount_1600 throw_err:" + JSON.stringify(err)); + expect(err.code != 0 ).assertEqual(true); done(); } }); diff --git a/account/appaccount/actsaccounttest/src/main/js/test/AssociatedData.test.js b/account/appaccount/actsaccounttest/src/main/js/test/AssociatedData.test.js index 226cd16e5df5a482f1cd2a7676d00ebb303f6d79..048eba2c0f7ec0ef5cbec8a99590e15639e089da 100755 --- a/account/appaccount/actsaccounttest/src/main/js/test/AssociatedData.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/AssociatedData.test.js @@ -1120,7 +1120,6 @@ export default function ActsAccountAssociatedData() { console.debug("====>getAssociatedData 2900 err:" + JSON.stringify(err)); console.debug("====>getAssociatedData 2900 data:" + JSON.stringify(data)); expect(err.code != 0).assertEqual(true); - expect(data).assertEqual(null); console.debug("====>ActsAccountAssociatedData_2900 end===="); done(); }); diff --git a/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js b/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js index 6a8b280d83e4bbcdc942d7ce29f47c15ce890edf..6fc2a5cb199008bdcdebf219f2e28bd22612fd4a 100644 --- a/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js @@ -35,6 +35,18 @@ export default function ActsAccountAppAccess() { beforeAll(async function (done) { done(); }); + beforeEach(async function (done) { + console.debug("====>afterEach start===="); + var appAccountManager = account.getAccountManager(); + var accounts = await appAccountManager.getAllAccountByOwner(owner) + for (i=0;i{ console.debug("====>ActsAccountDeleteAccountCredential_0100 setAccountCredential_err:" + JSON.stringify(err)); expect(err).assertEqual(null); - console.debug("====>ActsAccountDeleteAccountCredential_0100 setAccountCredential_data:" + JSON.stringify(data)); - appAccountManager.getAccountCredential(name, "PIN", (err) =>{ + appAccountManager.getAccountCredential(name, "PIN", (err, data) =>{ console.debug("====>ActsAccountDeleteAccountCredential_0100 getAccountCredential_err:" + JSON.stringify(err)) expect(err).assertEqual(null); console.debug("====>ActsAccountDeleteAccountCredential_0100 getAccountCredential_success:" + JSON.stringify(data)); @@ -386,9 +397,9 @@ export default function ActsAccountAppAccess() { console.debug("====>ActsAccountDeleteAccountCredential_0200 add_account_success"); appAccountManager.setAccountCredential(name, "PIN", '123456').then(() =>{ console.debug("====>ActsAccountDeleteAccountCredential_0200 setAccountCredential_success"); - appAccountManager.getAccountCredential(name, "PIN").then((data) =>{ + appAccountManager.getAccountCredential(name, "PIN").then((data) =>{ console.debug("====>ActsAccountDeleteAccountCredential_0200 getAccountCredential_data:" + JSON.stringify(data)); - appAccountManager.deleteAccountCredential(name, "PIN").then((data) =>{ + appAccountManager.deleteAccountCredential(name, "PIN").then((data) =>{ console.debug("====>ActsAccountDeleteAccountCredential_0200 data:" + JSON.stringify(data)); try{ appAccountManager.deleteAccount(name) @@ -436,24 +447,24 @@ export default function ActsAccountAppAccess() { console.debug("====>ActsAccountVerifyCredential_0100 add_account_err:" + JSON.stringify(err)); expect(err).assertEqual(null); appAccountManager.verifyCredential(name, owner, options, { - onResult:(resultCode, resultData)=>{ - console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultcode:" + JSON.stringify(resultCode)); - expect(resultCode).assertEqual(0) - console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultData:" + JSON.stringify(resultData)); - expect(resultData.booleanResult).assertEqual(true) - try{ - appAccountManager.deleteAccount(name) - console.debug('====>ActsAccountVerifyCredential_0100 deleteAccount_success') - done(); - } - catch{ - console.debug('====>ActsAccountVerifyCredential_0100 deleteAccount_err') - expect().assertFail() - } - done(); - }, - onRequestRedirected:null, - onRequestContinued: function(){ + onResult:(resultCode, resultData)=>{ + console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultcode:" + JSON.stringify(resultCode)); + expect(resultCode).assertEqual(0) + console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_resultData:" + JSON.stringify(resultData)); + expect(resultData.booleanResult).assertEqual(true) + try{ + appAccountManager.deleteAccount(name) + console.debug('====>ActsAccountVerifyCredential_0100 deleteAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountVerifyCredential_0100 deleteAccount_err') + expect().assertFail() + } + done(); + }, + onRequestRedirected:null, + onRequestContinued: function(){ console.debug("====>ActsAccountVerifyCredential_0100 verifyCredential_onRequestContinued") } }); @@ -473,30 +484,35 @@ export default function ActsAccountAppAccess() { appAccountManager.addAccount(name, (err)=>{ console.debug("====>ActsAccountVerifyCredential_0200 add_account_err:" + JSON.stringify(err)); expect(err).assertEqual(null); - console.debug("====>ActsAccountVerifyCredential_0200 add_account_err:" + JSON.stringify(err)); - expect(err).assertEqual(null); - appAccountManager.verifyCredential(name, owner, { - onResult:(resultCode, resultData)=>{ - console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultcode:" + JSON.stringify(resultCode)); - expect(resultCode).assertEqual(0) - console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultData:" + JSON.stringify(resultData)); - expect(resultData.booleanResult).assertEqual(false) - try{ - appAccountManager.deleteAccount(name) - console.debug('====>ActsAccountVerifyCredential_0200 deleteAccount_success') - done(); - } - catch{ - console.debug('====>ActsAccountVerifyCredential_0200 deleteAccount_err') - expect().assertFail() - } - done(); - }, - onRequestRedirected:null, - onRequestContinued: function(){ - console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_onRequestContinued") - } - }); + console.debug("====>ActsAccountVerifyCredential_0200 add_account_data:" + JSON.stringify(data)); + try{ + appAccountManager.verifyCredential(name, owner, { + onResult:(resultCode, resultData)=>{ + console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultcode:" + JSON.stringify(resultCode)); + expect(resultCode).assertEqual(0) + console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_resultData:" + JSON.stringify(resultData)); + expect(resultData.booleanResult).assertEqual(false) + try{ + appAccountManager.deleteAccount(name) + console.debug('====>ActsAccountVerifyCredential_0200 deleteAccount_success') + done(); + } + catch{ + console.debug('====>ActsAccountVerifyCredential_0200 deleteAccount_err') + expect().assertFail() + } + done(); + }, + onRequestRedirected:null, + onRequestContinued: function(){ + console.debug("====>ActsAccountVerifyCredential_0200 verifyCredential_onRequestContinued") + } + }); + }catch(err){ + console.debug('====>====>ActsAccountVerifyCredential_0200 err:'+JSON.stringify(err)) + expect().assertFail(); + done(); + } }); }); diff --git a/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js b/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js index f9ca813b7c1af3159e6f8fa32a6fe1d66ebe7345..ea7e113a9d7c4467c5b8b4cb5cd0652107ff6c9a 100644 --- a/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js @@ -427,7 +427,7 @@ export default function ActsAccountOAuthToken() { expect(err).assertEqual(null); appAccountManager.deleteOAuthToken("account_callback_empty_authType",OWNERSELF,"","callback_empty_authType_token",(err)=>{ console.debug("====>ActsAccountOAuthToken_7800 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err).assertEqual(null); + expect(err.code !=0).assertEqual(true); appAccountManager.getOAuthToken("account_callback_empty_authType",OWNERSELF,"authType",(err,data)=>{ console.debug("====>ActsAccountOAuthToken_7800 getOAuthToken err:" + JSON.stringify(err)); console.debug("====>ActsAccountOAuthToken_7800 getOAuthToken data:" + data); @@ -453,15 +453,19 @@ export default function ActsAccountOAuthToken() { console.debug("====>ActsAccountOAuthToken_7900 setOAuthToken start===="); await appAccountManager.setOAuthToken("account_promise_empty_authType","authType","promise_empty_authType_token"); console.debug("====>ActsAccountOAuthToken_7900 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_empty_authType",OWNERSELF,"","promise_empty_authType_token"); - console.debug("====>ActsAccountOAuthToken_7900 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_empty_authType",OWNERSELF,"authType"); - expect(data).assertEqual("promise_empty_authType_token"); - console.debug("====>ActsAccountOAuthToken_7900 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_empty_authType"); - console.debug("====>ActsAccountOAuthToken_7900 end===="); - done(); - + try{ + await appAccountManager.deleteOAuthToken("account_promise_empty_authType",OWNERSELF,"","promise_empty_authType_token"); + }catch(err){ + console.debug('====>ActsAccountAuthToken_7900 deleteAuthToken err:' + JSON.stringify(err)) + expect(err.code !=0 ).assertEqual(true); + console.debug("====>ActsAccountAuthToken_7900 getAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_empty_authType",OWNERSELF,"authType"); + expect(data).assertEqual("promise_empty_authType_token"); + console.debug("====>ActsAccountAuthToken_7900 removeAccount start===="); + await appAccountManager.deleteAccount("account_promise_empty_authType"); + console.debug("====>ActsAccountAuthToken_7900 end===="); + done(); + } }); @@ -485,7 +489,7 @@ export default function ActsAccountOAuthToken() { expect(data).assertEqual("callback_setSameAuthType_token2"); appAccountManager.deleteOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType","callback_setSameAuthType_token1",(err,data)=>{ console.debug("====>ActsAccountOAuthToken_8000 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err).assertEqual(null); + expect(err.code != 0).assertEqual(true); appAccountManager.deleteAccount("account_callback_setSameAuthType",(err)=>{ console.debug("====>ActsAccountOAuthToken_8000 deleteAccount err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -1331,12 +1335,17 @@ export default function ActsAccountOAuthToken() { console.debug("====>ActsAccountOAuthToken_2200 addAccount start===="); await appAccountManager.addAccount("account_promise_repeatDelete"); console.debug("====>setOAuthToken ActsAccountOAuthToken_2200 start===="); - await appAccountManager.setOAuthToken("account_promise_repeatDelete","aythType","promise_repeatDelete_token"); + await appAccountManager.setOAuthToken("account_promise_repeatDelete","authType","promise_repeatDelete_token"); console.debug("====>deleteOAuthToken first ActsAccountOAuthToken_2200 start===="); - await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); - console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2200 start===="); - await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 start===="); + await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"authType","promise_repeatDelete_token"); + try{ + console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2200 start===="); + await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"authType","promise_repeatDelete_token"); + }catch(err){ + console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2200 err:" + JSON.stringify(err)); + expect(err.code != 0 ).assertEqual(true); + done(); + } try{ var data = await appAccountManager.getOAuthToken("account_promise_repeatDelete",OWNERSELF,"authType"); } @@ -2417,22 +2426,27 @@ export default function ActsAccountOAuthToken() { appAccountManager.setOAuthToken("account_callback_delete_space","authType","account_callback_delete_space_token",(err)=>{ console.debug("====>ActsAccountOAuthToken_6900 setOAuthToken err:" + JSON.stringify(err)); expect(err).assertEqual(null); - appAccountManager.deleteOAuthToken("account_callback_delete_space",OWNERSELF,"authType","",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken err:" + JSON.stringify(err)); - expect(err).assertEqual(null); - appAccountManager.getOAuthToken("account_callback_delete_space",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken data:" + data); - expect(err).assertEqual(null); - expect(data).assertEqual("account_callback_delete_space_token"); - appAccountManager.deleteAccount("account_callback_delete_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6900 deleteAccount err:" + JSON.stringify(err)); + try{ + appAccountManager.deleteOAuthToken("account_callback_delete_space",OWNERSELF,"authType","",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6900 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code == 12400004).assertEqual(true) + appAccountManager.getOAuthToken("account_callback_delete_space",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_6900 getAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_6900 getAuthToken data:" + data); expect(err).assertEqual(null); - console.debug("====>ActsAccountOAuthToken_6900 end===="); - done(); - }); - }); - }); + expect(data).assertEqual("account_callback_delete_space_token"); + appAccountManager.deleteAccount("account_callback_delete_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6900 removeAccount err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsAccountOAuthToken_6900 end===="); + done(); + }); + }); + }) + }catch(err){ + expect().assertFail(); + done(); + }; }); }); }); @@ -2445,14 +2459,18 @@ export default function ActsAccountOAuthToken() { console.debug("====>ActsAccountOAuthToken_7000 setOAuthToken start===="); await appAccountManager.setOAuthToken("account_promise_delete_space","authType","account_promise_delete_space_token"); console.debug("====>ActsAccountOAuthToken_7000 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_delete_space",OWNERSELF,"authType",""); - console.debug("====>ActsAccountOAuthToken_7000 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_delete_space",OWNERSELF,"authType"); - expect(data).assertEqual("account_promise_delete_space_token"); - console.debug("====>ActsAccountOAuthToken_7000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_delete_space"); - console.debug("====>ActsAccountOAuthToken_7000 end===="); - done(); + try{ + await appAccountManager.deleteOAuthToken("account_promise_delete_space",OWNERSELF,"authType",""); + }catch(err){ + expect(err.code != 0).assertEqual(true) + console.debug("====>ActsAccountOAuthToken_7000 getOAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_delete_space",OWNERSELF,"authType"); + expect(data).assertEqual("account_promise_delete_space_token"); + console.debug("====>ActsAccountOAuthToken_7000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_delete_space"); + console.debug("====>ActsAccountOAuthToken_7000 end===="); + done(); + } }); it('ActsAccountOAuthToken_9200', 0, async function (done) { @@ -3398,7 +3416,7 @@ export default function ActsAccountOAuthToken() { it('ActsAccountOAuthToken_13400', 0, async function (done) { console.debug("====>ActsAccountOAuthToken_13400 start===="); var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccountImplicitly("com.example.actsaccountOauthtoken","authType",{},{ + appAccountManager.addAccountImplicitly("com.example.actsaccountOauthtoken", "authType", {},{ onResult: (resultCode, resultData) =>{ console.debug("====>ActsAccountOAuthToken_13400 authenticate resultCode:" + JSON.stringify(resultCode)); console.debug("====>ActsAccountOAuthToken_13400 authenticate resultData:" + JSON.stringify(resultData)); diff --git a/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js b/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js index c5020391e75ab38b21de17027fe8c9ba2fae3a4c..20487f3cb534515ecd4b3ac7cf8014d0330d49fa 100644 --- a/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js @@ -854,8 +854,7 @@ export default function ActsAccountChangeOnOff() { } catch(err){ console.error("====>on ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); + expect(err.code).assertEqual(201); } console.debug("====>setAccountExtraInfo start===="); try{ @@ -901,8 +900,7 @@ export default function ActsAccountChangeOnOff() { } catch(err){ console.error("====>on ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); + expect(err).assertFail(); } console.debug("====>setAccountExtraInfo start===="); try{ diff --git a/account/appaccount/actsaccounttstest/entry/src/main/ets/test/AuthTokenInfoTest.test.ets b/account/appaccount/actsaccounttstest/entry/src/main/ets/test/AuthTokenInfoTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..385dd42c45bf1a410ca8f862e74529ffc32619d4 --- /dev/null +++ b/account/appaccount/actsaccounttstest/entry/src/main/ets/test/AuthTokenInfoTest.test.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import appAccount from "@ohos.account.appAccount" + +export default function authTokenInfoTest() { + describe('AuthTokenInfoTest', function () { + beforeAll(async function (done) { + console.info('AccountTsTest: beforeAll'); + done(); + }) + + afterAll(async function (done) { + console.info('AccountTsTest: afterAll'); + done(); + }) + + beforeEach(async function (done) { + console.info('AccountTsTest: beforeEach'); + done(); + }) + + afterEach(async function (done) { + console.info('AccountTsTest: afterEach'); + done(); + }) + + /* + * @tc.number AuthTokenInfoTest_0100 + * @tc.name AuthTokenInfoTest_0100 + * @tc.desc AuthTokenInfo without account. + * @tc.size SmallTest + * @tc.type User + */ + it('AuthTokenInfoTest_0100', 0, async function (done) { + let info : appAccount.AuthTokenInfo = { + authType: "getSocialData", + token: "xxxxx" + } + console.log("AuthTokenInfoTest_0100 info: " + JSON.stringify(info)); + expect(info.hasOwnProperty("accounts")).assertEqual(false) + expect(info.hasOwnProperty("account")).assertEqual(false) + done() + }) + + /* + * @tc.number AuthTokenInfoTest_0200 + * @tc.name AuthTokenInfoTest_0200 + * @tc.desc AuthTokenInfo with account. + * @tc.size SmallTest + * @tc.type User + */ + it('AuthTokenInfoTest_0200', 0, async function (done) { + let info : appAccount.AuthTokenInfo = { + authType: "getSocialData", + token: "xxxxx", + account: { + name: "zhangsan", + owner: "com.ohos.testapp" + } + } + console.log("AuthTokenInfoTest_0200 info: " + JSON.stringify(info)) + expect(info.hasOwnProperty("accounts")).assertEqual(false) + expect(info.hasOwnProperty("account")).assertEqual(true) + expect(info.account.owner).assertEqual("com.ohos.testapp") + done(); + }) + }) +} diff --git a/account/appaccount/actsaccounttstest/entry/src/main/ets/test/List.test.ets b/account/appaccount/actsaccounttstest/entry/src/main/ets/test/List.test.ets index 484485f4d827531fb876d0acecb48cc1808bb1d2..c6174cfdf3e04d9b1157a52c35794f7aff93d1f0 100644 --- a/account/appaccount/actsaccounttstest/entry/src/main/ets/test/List.test.ets +++ b/account/appaccount/actsaccounttstest/entry/src/main/ets/test/List.test.ets @@ -13,7 +13,9 @@ * limitations under the License. */ import oauthTokenInfoTest from './OAuthTokenInfoTest.test.ets' +import authTokenInfoTest from './AuthTokenInfoTest.test.ets' export default function testsuite() { oauthTokenInfoTest() + authTokenInfoTest() } \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/BUILD.gn b/account/appaccount/actsgetaccountsbyowner/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cba31f9e007038b8d7a7e1a9129183c9f2cc8219 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsGetAccountsByOwnerTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsGetAccountsByOwnerTest" + subsystem_name = "account" + part_name = "os_account" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/account/appaccount/actsgetaccountsbyowner/Test.json b/account/appaccount/actsgetaccountsbyowner/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c7496071db71c6da781baf7ece6931771bbc707f --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/Test.json @@ -0,0 +1,20 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "bundle-name": "com.example.actsgetaccountsbyowner", + "package-name": "com.example.actsgetaccountsbyowner", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsGetAccountsByOwnerTest.hap", + "ActsSceneGetAllAccounts.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/actsgetaccountsbyowner/signature/openharmony_sx.p7b b/account/appaccount/actsgetaccountsbyowner/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/account/appaccount/actsgetaccountsbyowner/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/config.json b/account/appaccount/actsgetaccountsbyowner/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..0e54794356ec9d908cbbeb70917d4e279f2737eb --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/config.json @@ -0,0 +1,127 @@ +{ + "app": { + "bundleName": "com.example.actsgetaccountsbyowner", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsgetaccountsbyowner", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.GET_ALL_APP_ACCOUNTS" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_ALL_APP_ACCOUNTS", + "reason": "ceshi" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/app.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/i18n/en-US.json b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/i18n/zh-CN.json b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,24 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0c25c846b99ffeba372e8ad4c25d6d4c10c67498 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,30 @@ +/* + * 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. + */ +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "getAllAccounts" + }, + onInit() { + this.title = "getAllAccounts"; + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/app.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b45eb97c17e67ef5d63436aad8998113aa95d6d --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,50 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/test/Getaccountsbyowner.test.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/test/Getaccountsbyowner.test.js new file mode 100644 index 0000000000000000000000000000000000000000..07e7c355e13d71068d109fc39757272c1784b4c5 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/test/Getaccountsbyowner.test.js @@ -0,0 +1,647 @@ +/* + * 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 account from '@ohos.account.appAccount' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 2000; +const LENGTHLIMIT = 1024; +const SELFBUNDLE = 'com.example.actsgetaccountsbyowner' +const createAccountOptions = {customData:{age:'12'}} +export default function GetAccountsByOwner() { + describe('GetAccountsByOwner', function () { + + /* + * @tc.number : GetAccountsByOwner_0100 + * @tc.name : getAccountsByOwner callback + * @tc.desc : This application gets its own application information after adding an account + */ + it('GetAccountsByOwner_0100', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("Account_this_application_callback", (err)=>{ + console.debug("====>add account 0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountsByOwner(SELFBUNDLE, (err, data)=>{ + console.debug("====>getAccountsByOwner 0100 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 0100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + try{ + expect(data[0].name).assertEqual("Account_this_application_callback"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + } + catch(err){ + console.error("====>getAccountsByOwner 0100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.removeAccount("Account_this_application_callback", (err)=>{ + console.debug("====>delete account 0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>GetAccountsByOwner_0100 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : GetAccountsByOwner_0200 + * @tc.name : getAccountsByOwner promise + * @tc.desc : This application gets its own application information after adding an account + */ + it('GetAccountsByOwner_0200', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAccountsByOwner for clean===="); + try{ + var acclist = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add account 0200 start===="); + await appAccountManager.createAccount("Account_this_application_promise"); + console.debug("====>getAccountsByOwner 0200 start===="); + try{ + var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + expect(data[0].name).assertEqual("Account_this_application_promise"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + } + catch(err){ + console.error("====>check data 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 0200 start===="); + await appAccountManager.removeAccount("Account_this_application_promise"); + console.debug("====>GetAccountsByOwner_0200 end===="); + done(); + }); + + /* + * @tc.number : GetAccountsByOwner_0300 + * @tc.name : getAccountsByOwner callback + * @tc.desc : No account has been added to this application and it is not authorized by other applications to + * obtain account information for this application + */ + it('GetAccountsByOwner_0300', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.getAccountsByOwner(SELFBUNDLE, (err, data)=>{ + console.debug("====>getAccountsByOwner 0300 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 0300 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data.length).assertEqual(0); + console.debug("====>GetAccountsByOwner_0300 end===="); + done(); + }) + }); + + /* + * @tc.number : GetAccountsByOwner_0400 + * @tc.name : getAccountsByOwner promise + * @tc.desc : No account has been added to this application and it is not authorized by other applications to + * obtain account information for this application + */ + it('GetAccountsByOwner_0400', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAccountsByOwner for clean===="); + try{ + var acclist = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + console.debug("====>getAccountsByOwner 0400 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(0); + console.debug("====>GetAccountsByOwner_0400 end===="); + done(); + }); + + /* + * @tc.number : GetAccountsByOwner_0500 + * @tc.name : getAccountsByOwner callback + * @tc.desc : The parameter owner is an empty string + */ + it('GetAccountsByOwner_0500', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundle = ""; + appAccountManager.getAccountsByOwner(emptyBundle, (err, data)=>{ + console.debug("====>getAccountsByOwner 0500 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>GetAccountsByOwner_0500 end===="); + done(); + }) + }); + + /* + * @tc.number : GetAccountsByOwner_0600 + * @tc.name : getAccountsByOwner promise + * @tc.desc : The parameter owner is an empty string + */ + it('GetAccountsByOwner_0600', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundle = ""; + try{ + var data = await appAccountManager.getAccountsByOwner(emptyBundle); + } + catch(err){ + console.debug("====>getAccountsByOwner 0600 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>GetAccountsByOwner_0600 end===="); + done(); + } + }); + + /* + * @tc.number : GetAccountsByOwner_0700 + * @tc.name : getAccountsByOwner callback + * @tc.desc : The parameter owner is a string that exceeds the length limit + */ + it('GetAccountsByOwner_0700', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var limitBundle = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitBundle += 't'; + } + appAccountManager.getAccountsByOwner(limitBundle, (err, data)=>{ + console.debug("====>getAccountsByOwner 0700 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>GetAccountsByOwner_0700 end===="); + done(); + }) + }); + + /* + * @tc.number : GetAccountsByOwner_0800 + * @tc.name : getAccountsByOwner promise + * @tc.desc : The parameter owner is a string that exceeds the length limit + */ + it('GetAccountsByOwner_0800', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var limitBundle = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitBundle += 'n'; + } + try{ + var data = await appAccountManager.getAccountsByOwner(limitBundle); + } + catch(err){ + console.debug("====>getAccountsByOwner 0800 err:" + JSON.stringify(err)); + expect(err.code == 12300002).assertEqual(true); + console.debug("====>GetAccountsByOwner_0800 end===="); + done(); + } + }); + + /* + * @tc.number : GetAccountsByOwner_0900 + * @tc.name : getAccountsByOwner callback + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('GetAccountsByOwner_0900', 0, async function (done) { + console.debug("====>GetAccountsByOwner_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account 0900 start===="); + await appAccountManager.createAccount("Account_application_callback"); + console.debug("====>startAbility 0900 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + function getAllCallback(err, data){ + console.debug("====>getAccountsByOwner 0900 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 0900 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data[0].name).assertEqual("Account_application_callback"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + appAccountManager.removeAccount("Account_application_callback", (err)=>{ + console.debug("====>delete account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>GetAccountsByOwner_0900 end===="); + done(); + }); + } + setTimeout(async function(){ + console.debug("====>getAccountsByOwner 0900 start===="); + appAccountManager.getAccountsByOwner(SELFBUNDLE, getAllCallback); + }, TIMEOUT); + }); + + /* + * @tc.number : GetAccountsByOwner_1000 + * @tc.name : getAccountsByOwner promise + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('GetAccountsByOwner_1000', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account 1000 start===="); + await appAccountManager.createAccount("Account_application_promise"); + console.debug("====>startAbility 1000 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAccountsByOwner 1000 start===="); + try{ + var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountsByOwner 1000 data:" + JSON.stringify(data)); + try{ + expect(data[0].name).assertEqual("Account_application_promise"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + } + catch(err){ + console.error("====>check data 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 1000 start===="); + await appAccountManager.removeAccount("Account_application_promise"); + console.debug("====>GetAccountsByOwner_1000 end===="); + done(); + }, TIMEOUT); + }); + + /* + * @tc.number : GetAccountsByOwner_1100 + * @tc.name : getAccountsByOwner callback + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('GetAccountsByOwner_1100', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var specifiedBundle = "com.example.actsscenegetallaccounts"; + console.debug("====>startAbility 1100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + function getAllCallback(err, data){ + console.debug("====>getAccountsByOwner 1100 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 1100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); + console.debug("====>GetAccountsByOwner_1100 end===="); + done(); + } + setTimeout(async function(){ + console.debug("====>getAccountsByOwner 1100 start===="); + appAccountManager.getAccountsByOwner(specifiedBundle, getAllCallback); + }, TIMEOUT); + }); + + /* + * @tc.number : GetAccountsByOwner_1200 + * @tc.name : getAccountsByOwner promise + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('GetAccountsByOwner_1200', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var specifiedBundle = "com.example.actsscenegetallaccounts"; + console.debug("====>startAbility 1200 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAccountsByOwner 1200 start===="); + try{ + var data = await appAccountManager.getAccountsByOwner(specifiedBundle); + } + catch(err){ + console.error("====>getAccountsByOwner 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountsByOwner 1200 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); + console.debug("====>GetAccountsByOwner_1200 end===="); + done(); + }, TIMEOUT); + }); + + /* + * @tc.number : GetAccountsByOwner_1300 + * @tc.name : getAccountsByOwner callback + * @tc.desc : The parameter owner is a bundlename that does not exist + */ + it('GetAccountsByOwner_1300', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; + appAccountManager.getAccountsByOwner(nonexistentBundle, (err, data)=>{ + console.debug("====>getAccountsByOwner 1300 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + console.debug("====>GetAccountsByOwner_1300 end===="); + done(); + }) + }); + + /* + * @tc.number : GetAccountsByOwner_1400 + * @tc.name : getAccountsByOwner promise + * @tc.desc : The parameter owner is a bundlename that does not exist + */ + it('GetAccountsByOwner_1400', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; + try{ + var data = await appAccountManager.getAccountsByOwner(nonexistentBundle); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>getAccountsByOwner 1400 err:" + JSON.stringify(err)); + expect(err.code == 12400001).assertEqual(true); + console.debug("====>GetAccountsByOwner_1400 end===="); + done(); + } + }); + + /* + * @tc.number : GetAccountsByOwner_1500 + * @tc.name : getAccountsByOwner callback + * @tc.desc : Get account information after adding and deleting account + */ + it('GetAccountsByOwner_1500', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_callback_delete", (err)=>{ + console.debug("====>add account 1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountsByOwner(SELFBUNDLE, (err, data)=>{ + console.debug("====>getAccountsByOwner 1500 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 1500 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data[0].name).assertEqual("account_callback_delete"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + appAccountManager.removeAccount("account_callback_delete", (err)=>{ + console.debug("====>delete account 1500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountsByOwner(SELFBUNDLE, (err, data)=>{ + console.debug("====>getAccountsByOwner 1500 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 1500 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data.length).assertEqual(0); + console.debug("====>GetAccountsByOwner_1500 end===="); + done(); + }) + }); + }) + }); + }); + + /* + * @tc.number : GetAccountsByOwner_1600 + * @tc.name : getAccountsByOwner promise + * @tc.desc : Get account information after adding and deleting account + */ + it('GetAccountsByOwner_1600', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAccountsByOwner for clean===="); + try{ + var acclist = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add account 1600 start===="); + await appAccountManager.createAccount("account_promise_delete"); + console.debug("====>first getAccountsByOwner 1600 start===="); + try{ + var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(data[0].name).assertEqual("account_promise_delete"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + console.debug("====>delete account 1600 start===="); + await appAccountManager.removeAccount("account_promise_delete"); + console.debug("====>second getAccountsByOwner 1600 start===="); + try{ + var dataDelete = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>second getAccountsByOwner 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(dataDelete.length).assertEqual(0); + console.debug("====>GetAccountsByOwner_1600 end===="); + done(); + }); + + /* + * @tc.number : GetAccountsByOwner_1700 + * @tc.name : getAccountsByOwner callback + * @tc.desc : Get account information after adding an account with additional information and deleting an + * account + */ + it('GetAccountsByOwner_1700', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("account_callback_additional", createAccountOptions, (err)=>{ + console.debug("====>add account 1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountsByOwner(SELFBUNDLE, (err, data)=>{ + console.debug("====>getAccountsByOwner 1700 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 1700 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data[0].name).assertEqual("account_callback_additional"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + appAccountManager.removeAccount("account_callback_additional", (err)=>{ + console.debug("====>delete account 1700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAccountsByOwner(SELFBUNDLE, (err, data)=>{ + console.debug("====>getAccountsByOwner 1700 err:" + JSON.stringify(err)); + console.debug("====>getAccountsByOwner 1700 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data.length).assertEqual(0); + console.debug("====>GetAccountsByOwner_1700 end===="); + done(); + }) + }); + }) + }); + }); + + /* + * @tc.number : GetAccountsByOwner_1800 + * @tc.name : getAccountsByOwner promise + * @tc.desc : Get account information after adding an account with additional information and deleting an + * account + */ + it('GetAccountsByOwner_1800', 0, async function (done) { + console.debug("====>GetAccountsByOwner_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAccountsByOwner for clean===="); + try{ + var acclist = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add account 1800 start===="); + await appAccountManager.createAccount("account_promise_additional", createAccountOptions); + console.debug("====>first getAccountsByOwner 1800 start===="); + try{ + var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>getAccountsByOwner 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>first getAccountsByOwner 1800 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_promise_additional"); + expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner"); + console.debug("====>delete account 1800 start===="); + await appAccountManager.removeAccount("account_promise_additional"); + console.debug("====>second getAccountsByOwner 1800 start===="); + try{ + var dataDelete = await appAccountManager.getAccountsByOwner(SELFBUNDLE); + } + catch(err){ + console.error("====>second getAccountsByOwner 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>second getAccountsByOwner 1800 data:" + JSON.stringify(data)); + expect(dataDelete.length).assertEqual(0); + console.debug("====>GetAccountsByOwner_1800 end===="); + done(); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/js/test/List.test.js b/account/appaccount/actsgetaccountsbyowner/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..fa179292b4b511541e366eba067b09a3c8e3b3f0 --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 GetAccountsByOwner from './Getaccountsbyowner.test.js' + +export default function testsuite() { + GetAccountsByOwner() +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/resources/base/element/string.json b/account/appaccount/actsgetaccountsbyowner/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6e2452f1a3264fe13ac62b7949e4776513ba5e9a --- /dev/null +++ b/account/appaccount/actsgetaccountsbyowner/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actsgetaccountsbyowner/src/main/resources/base/media/icon.png b/account/appaccount/actsgetaccountsbyowner/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actsgetaccountsbyowner/src/main/resources/base/media/icon.png differ diff --git a/account/appaccount/actsgetallaccounts/Test.json b/account/appaccount/actsgetallaccounts/Test.json index 309f568ea4c540c1a6a0cdf642b61f927ea4fb54..9a6b63c1325809bfb85bcd791556640e28087407 100644 --- a/account/appaccount/actsgetallaccounts/Test.json +++ b/account/appaccount/actsgetallaccounts/Test.json @@ -3,8 +3,8 @@ "driver": { "type": "OHJSUnitTest", "test-timeout": "60000", - "bundle-name": "com.example.actsgetallaaccounts", - "package-name": "com.example.actsgetallaaccounts", + "bundle-name": "com.example.actsgetallaccounts", + "package-name": "com.example.actsgetallaccounts", "shell-timeout": "60000" }, "kits": [ diff --git a/account/appaccount/actsgetallaccounts/src/main/config.json b/account/appaccount/actsgetallaccounts/src/main/config.json index 0e0a22a317aa16eaa530d48032a053279a7cb43a..26de14108a4dff69938913cc520ad82693b4b5bc 100644 --- a/account/appaccount/actsgetallaccounts/src/main/config.json +++ b/account/appaccount/actsgetallaccounts/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.actsgetallaaccounts", + "bundleName": "com.example.actsgetallaccounts", "vendor": "example", "version": { "code": 1, @@ -14,12 +14,12 @@ }, "deviceConfig": {}, "module": { - "package": "com.example.actsgetallaaccounts", + "package": "com.example.actsgetallaccounts", "name": ".entry", "mainAbility": ".MainAbility", "srcPath":"", "deviceType": [ - "default", + "default", "phone" ], "distro": { diff --git a/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js b/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js index dace9ca6566eb97e56234f66ee0d055877d46259..91baf102fe97f044d616678f4b4dd930e21d6106 100755 --- a/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js +++ b/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js @@ -30,7 +30,7 @@ export default function ActsGetAllAccounts() { console.debug("====>ActsGetAllAccounts_0100 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; appAccountManager.addAccount("Account_this_application_callback", (err)=>{ console.debug("====>add account 0100 err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -40,7 +40,7 @@ export default function ActsGetAllAccounts() { expect(err).assertEqual(null); try{ expect(data[0].name).assertEqual("Account_this_application_callback"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); } catch(err){ console.error("====>getAllAccounts 0100 fail err:" + JSON.stringify(err)); @@ -67,7 +67,7 @@ export default function ActsGetAllAccounts() { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; try{ var acclist = await appAccountManager.getAllAccounts(selfBundle); } @@ -95,7 +95,7 @@ export default function ActsGetAllAccounts() { } try{ expect(data[0].name).assertEqual("Account_this_application_promise"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); } catch(err){ console.error("====>check data 0200 fail err:" + JSON.stringify(err)); @@ -118,7 +118,7 @@ export default function ActsGetAllAccounts() { console.debug("====>ActsGetAllAccounts_0300 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ console.debug("====>getAllAccounts 0300 err:" + JSON.stringify(err)); console.debug("====>getAllAccounts 0300 data:" + JSON.stringify(data)); @@ -140,7 +140,7 @@ export default function ActsGetAllAccounts() { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; try{ var acclist = await appAccountManager.getAllAccounts(selfBundle); } @@ -256,7 +256,7 @@ export default function ActsGetAllAccounts() { console.debug("====>ActsGetAllAccounts_0900 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; console.debug("====>add account 0900 start===="); await appAccountManager.addAccount("Account_application_callback"); console.debug("====>startAbility 0900 start===="); @@ -278,7 +278,7 @@ export default function ActsGetAllAccounts() { console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data)); expect(err).assertEqual(null); expect(data[0].name).assertEqual("Account_application_callback"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); appAccountManager.deleteAccount("Account_application_callback", (err)=>{ console.debug("====>delete account 0900 err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -302,7 +302,7 @@ export default function ActsGetAllAccounts() { console.debug("====>ActsGetAllAccounts_1000 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; console.debug("====>add account 1000 start===="); await appAccountManager.addAccount("Account_application_promise"); console.debug("====>startAbility 1000 start===="); @@ -332,7 +332,7 @@ export default function ActsGetAllAccounts() { console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data)); try{ expect(data[0].name).assertEqual("Account_application_promise"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); } catch(err){ console.error("====>check data 1000 fail err:" + JSON.stringify(err)); @@ -479,7 +479,7 @@ export default function ActsGetAllAccounts() { console.debug("====>ActsGetAllAccounts_1500 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; appAccountManager.addAccount("account_callback_delete", (err)=>{ console.debug("====>add account 1500 err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -488,7 +488,7 @@ export default function ActsGetAllAccounts() { console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); expect(err).assertEqual(null); expect(data[0].name).assertEqual("account_callback_delete"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); appAccountManager.deleteAccount("account_callback_delete", (err)=>{ console.debug("====>delete account 1500 err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -515,7 +515,7 @@ export default function ActsGetAllAccounts() { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; try{ var acclist = await appAccountManager.getAllAccounts(selfBundle); } @@ -542,7 +542,7 @@ export default function ActsGetAllAccounts() { done(); } expect(data[0].name).assertEqual("account_promise_delete"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); console.debug("====>delete account 1600 start===="); await appAccountManager.deleteAccount("account_promise_delete"); console.debug("====>second getAllAccounts 1600 start===="); @@ -569,7 +569,7 @@ export default function ActsGetAllAccounts() { console.debug("====>ActsGetAllAccounts_1700 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; appAccountManager.addAccount("account_callback_additional", "account_extrainfo", (err)=>{ console.debug("====>add account 1700 err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -578,7 +578,7 @@ export default function ActsGetAllAccounts() { console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); expect(err).assertEqual(null); expect(data[0].name).assertEqual("account_callback_additional"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); appAccountManager.deleteAccount("account_callback_additional", (err)=>{ console.debug("====>delete account 1700 err:" + JSON.stringify(err)); expect(err).assertEqual(null); @@ -606,7 +606,7 @@ export default function ActsGetAllAccounts() { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; + var selfBundle = "com.example.actsgetallaccounts"; try{ var acclist = await appAccountManager.getAllAccounts(selfBundle); } @@ -634,7 +634,7 @@ export default function ActsGetAllAccounts() { } console.debug("====>first getAllAccounts 1800 data:" + JSON.stringify(data)); expect(data[0].name).assertEqual("account_promise_additional"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccounts"); console.debug("====>delete account 1800 start===="); await appAccountManager.deleteAccount("account_promise_additional"); console.debug("====>second getAllAccounts 1800 start===="); diff --git a/account/appaccount/actssetcheckdatasyncenable/BUILD.gn b/account/appaccount/actssetcheckdatasyncenable/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0444985eb5999f32dfb83dca0502e647a40a5584 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsSetCheckDataSyncEnableTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsSetCheckDataSyncEnableTest" + subsystem_name = "account" + part_name = "os_account" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/account/appaccount/actssetcheckdatasyncenable/Test.json b/account/appaccount/actssetcheckdatasyncenable/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ecec00766314aabcc6614938705e98d5259881c5 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "bundle-name": "com.example.actssetcheckdatasyncenable", + "package-name": "com.example.actssetcheckdatasyncenable", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsSetCheckDataSyncEnableTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/actssetcheckdatasyncenable/signature/openharmony_sx.p7b b/account/appaccount/actssetcheckdatasyncenable/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/account/appaccount/actssetcheckdatasyncenable/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/config.json b/account/appaccount/actssetcheckdatasyncenable/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..5e61894391bcf2a8cddfb9f86ed5b429bc6f3792 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/config.json @@ -0,0 +1,131 @@ +{ + "app": { + "bundleName": "com.example.actssetcheckdatasyncenable", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actssetcheckdatasyncenable", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "user_grant", + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "ceshi" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "ceshi" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/app.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/i18n/en-US.json b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/i18n/zh-CN.json b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,24 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8406ae5685de38b44c93e31e36d151e91bd45765 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "setAppAccountSyncEnable和checkAppAccountSyncEnable" + }, + onInit() { + this.title = "setAppAccountSyncEnable和checkAppAccountSyncEnable"; + }, + onShow() { + console.info('onShow finish') + + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/app.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b45eb97c17e67ef5d63436aad8998113aa95d6d --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,50 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/test/List.test.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69eebde8007632fe5ccd4ca0778e092cbecfa6 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsSetCheckDataSyncEnable from './Syncenable.test.js' + +export default function testsuite() { + ActsSetCheckDataSyncEnable() +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/js/test/Syncenable.test.js b/account/appaccount/actssetcheckdatasyncenable/src/main/js/test/Syncenable.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ca3789d820719d041a97ad9d7d9593af9bb36c64 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/js/test/Syncenable.test.js @@ -0,0 +1,575 @@ +/* + * 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import account from '@ohos.account.appAccount' +import bundle from '@ohos.bundle' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 2000; +const PERMISSION_USER_SET = 1; +const PERMISSION_USER_NAME = "ohos.permission.DISTRIBUTED_DATASYNC"; +var tokenID = undefined; +export default function ActsSetCheckDataSyncEnabled() { + describe('ActsSetCheckDataSyncEnabled', function () { + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + var appInfo = await bundle.getApplicationInfo('com.example.actssetcheckdatasyncenable', 0, 100); + tokenID = appInfo.accessTokenId; + console.debug("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName); + var atManager = abilityAccessCtrl.createAtManager(); + var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); + console.debug("tokenId" + tokenID + " result:" + result); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0100 + * @tc.name : Check sync flag callback form + * @tc.desc : Get the synchronization flag of the account that has not set the synchronization flag + */ + it('ActsSetCheckDataSyncEnabled_0100', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_notset", (err)=>{ + console.debug("====>add account ActsSetCheckDataSyncEnabled_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_notset", (err, data)=>{ + console.debug("====>checkDataSyncEnabled 0100 err:" + JSON.stringify(err)); + console.debug("====>checkDataSyncEnabled 0100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(false); + appAccountManager.removeAccount("syncenable_callback_notset", (err)=>{ + console.debug("====>delete Account ActsSetCheckDataSyncEnabled_0100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsSetCheckDataSyncEnabled_0100 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0200 + * @tc.name : Check sync flag promise form + * @tc.desc : Get the synchronization flag of the account that has not set the synchronization flag + */ + it('ActsSetCheckDataSyncEnabled_0200', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckDataSyncEnabled_0200 start===="); + try{ + await appAccountManager.createAccount("syncenable_promise_notset"); + } + catch(err){ + console.error("====>add account ActsSetCheckDataSyncEnabled_0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_0200 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_notset"); + } + catch(err){ + console.error("====>checkDataSyncEnabled 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled 0200 data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + console.debug("====>delete account ActsSetCheckDataSyncEnabled_0200 start===="); + try{ + await appAccountManager.removeAccount("syncenable_promise_notset"); + } + catch(err){ + console.error("====>delete account 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckDataSyncEnabled_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0300 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to true for the account + */ + it('ActsSetCheckDataSyncEnabled_0300', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_settrue", (err)=>{ + console.debug("====>add account ActsSetCheckDataSyncEnabled_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_settrue", true, (err)=>{ + console.debug("====>setDataSyncEnabled 0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_settrue", (err, data)=>{ + console.debug("====>checkDataSyncEnabled 0300 err:" + JSON.stringify(err)); + console.debug("====>checkDataSyncEnabled 0300 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(true); + appAccountManager.removeAccount("syncenable_callback_settrue", (err)=>{ + console.debug("====>delete Account ActsSetCheckDataSyncEnabled_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsSetCheckDataSyncEnabled_0300 end===="); + done(); + }); + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0400 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to true for the account + */ + it('ActsSetCheckDataSyncEnabled_0400', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckDataSyncEnabled_0400 start===="); + try{ + await appAccountManager.createAccount("syncenable_promise_settrue"); + } + catch(err){ + console.error("====>add account ActsSetCheckDataSyncEnabled_0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setDataSyncEnabled ActsSetCheckDataSyncEnabled_0400 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_settrue", true); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_0400 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_settrue"); + } + catch(err){ + console.error("====>checkDataSyncEnabled 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled 0400 data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>delete account ActsSetCheckDataSyncEnabled_0400 start===="); + try{ + await appAccountManager.removeAccount("syncenable_promise_settrue"); + } + catch(err){ + console.error("====>delete account 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckDataSyncEnabled_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0500 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to false for the account + */ + it('ActsSetCheckDataSyncEnabled_0500', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_setfalse", (err)=>{ + console.debug("====>add account ActsSetCheckDataSyncEnabled_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_setfalse", false, (err)=>{ + console.debug("====>setDataSyncEnabled 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_setfalse", (err, data)=>{ + console.debug("====>checkDataSyncEnabled 0500 err:" + JSON.stringify(err)); + console.debug("====>checkDataSyncEnabled 0500 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(false); + appAccountManager.removeAccount("syncenable_callback_setfalse", (err)=>{ + console.debug("====>delete Account ActsSetCheckDataSyncEnabled_0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsSetCheckDataSyncEnabled_0500 end===="); + done(); + }); + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0600 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to false for the account + */ + it('ActsSetCheckDataSyncEnabled_0600', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckDataSyncEnabled_0600 start===="); + try{ + await appAccountManager.createAccount("syncenable_promise_setfalse"); + } + catch(err){ + console.error("====>add account ActsSetCheckDataSyncEnabled_0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setDataSyncEnabled ActsSetCheckDataSyncEnabled_0600 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_setfalse", false); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_0600 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_setfalse"); + } + catch(err){ + console.error("====>checkDataSyncEnabled 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled 0600 data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + console.debug("====>delete account ActsSetCheckDataSyncEnabled_0600 start===="); + try{ + await appAccountManager.removeAccount("syncenable_promise_setfalse"); + } + catch(err){ + console.error("====>delete account 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckDataSyncEnabled_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0700 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to false + * for the first time and true for the second time + */ + it('ActsSetCheckDataSyncEnabled_0700', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>add account ActsSetCheckDataSyncEnabled_0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_falsetrue", false, (err)=>{ + console.debug("====>setDataSyncEnabled first time 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_falsetrue", true, (err)=>{ + console.debug("====>setDataSyncEnabled second time 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_falsetrue", (err, data)=>{ + console.debug("====>checkDataSyncEnabled 0700 err:" + JSON.stringify(err)); + console.debug("====>checkDataSyncEnabled 0700 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(true); + appAccountManager.removeAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>delete Account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsSetCheckDataSyncEnabled_0700 end===="); + done(); + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0800 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to false + * for the first time and true for the second time + */ + it('ActsSetCheckDataSyncEnabled_0800', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckDataSyncEnabled_0800 start===="); + await appAccountManager.createAccount("syncenable_promise_truefalse"); + console.debug("====>setDataSyncEnabled first time ActsSetCheckDataSyncEnabled_0800 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_truefalse", false); + console.debug("====>setDataSyncEnabled second time ActsSetCheckDataSyncEnabled_0800 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_truefalse", true); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_0800 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>checkDataSyncEnabled 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled 0800 data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>delete account ActsSetCheckDataSyncEnabled_0800 start===="); + try{ + await appAccountManager.removeAccount("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>delete account 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckDataSyncEnabled_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_0900 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the first time and false for the second time + */ + it('ActsSetCheckDataSyncEnabled_0900', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>add account ActsSetCheckDataSyncEnabled_0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_falsetrue", true, (err)=>{ + console.debug("====>setDataSyncEnabled first time 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_falsetrue", false, (err)=>{ + console.debug("====>setDataSyncEnabled second time 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_falsetrue", (err, data)=>{ + console.debug("====>checkDataSyncEnabled 0900 err:" + JSON.stringify(err)); + console.debug("====>checkDataSyncEnabled 0900 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(false); + appAccountManager.removeAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>delete Account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsSetCheckDataSyncEnabled_0900 end===="); + done(); + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1000 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the first time and false for the second time + */ + it('ActsSetCheckDataSyncEnabled_1000', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckDataSyncEnabled_1000 start===="); + await appAccountManager.createAccount("syncenable_promise_truefalse"); + console.debug("====>setDataSyncEnabled first time ActsSetCheckDataSyncEnabled_1000 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_truefalse", true); + console.debug("====>setDataSyncEnabled second time ActsSetCheckDataSyncEnabled_1000 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_truefalse", false); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_1000 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>checkDataSyncEnabled 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled 1000 data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + console.debug("====>delete account ActsSetCheckDataSyncEnabled_1000 start===="); + try{ + await appAccountManager.removeAccount("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>delete account 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckDataSyncEnabled_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1100 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the first time and true for the second time + */ + it('ActsSetCheckDataSyncEnabled_1100', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("syncenable_callback_truetrue", (err)=>{ + console.debug("====>add account ActsSetCheckDataSyncEnabled_1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_truetrue", true, (err)=>{ + console.debug("====>setDataSyncEnabled first time 1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.setDataSyncEnabled("syncenable_callback_truetrue", true, (err)=>{ + console.debug("====>setDataSyncEnabled second time 1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.checkDataSyncEnabled("syncenable_callback_truetrue", (err, data)=>{ + console.debug("====>checkDataSyncEnabled 1100 err:" + JSON.stringify(err)); + console.debug("====>checkDataSyncEnabled 1100 data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(true); + appAccountManager.removeAccount("syncenable_callback_truetrue", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsSetCheckDataSyncEnabled_1100 end===="); + done(); + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1200 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the true time and true for the second time + */ + it('ActsSetCheckDataSyncEnabled_1200', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckDataSyncEnabled_1200 start===="); + await appAccountManager.createAccount("syncenable_promise_truetrue"); + console.debug("====>setDataSyncEnabled first time ActsSetCheckDataSyncEnabled_1200 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_truetrue", true); + console.debug("====>setDataSyncEnabled second time ActsSetCheckDataSyncEnabled_1200 start===="); + await appAccountManager.setDataSyncEnabled("syncenable_promise_truetrue", true); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_1200 start===="); + try{ + var data = await appAccountManager.checkDataSyncEnabled("syncenable_promise_truetrue"); + } + catch(err){ + console.error("====>checkDataSyncEnabled 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkDataSyncEnabled 1200 data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>delete account ActsSetCheckDataSyncEnabled_1200 start===="); + try{ + await appAccountManager.removeAccount("syncenable_promise_truetrue"); + } + catch(err){ + console.error("====>delete account 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckDataSyncEnabled_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1300 + * @tc.name : setDataSyncEnabled callback form + * @tc.desc : Set synchronization flag for non-existent account + */ + it('ActsSetCheckDataSyncEnabled_1300', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>setDataSyncEnabled ActsSetCheckDataSyncEnabled_1300 start====") + var accountNotExist = "syncenable_callback_notexist"; + appAccountManager.setDataSyncEnabled(accountNotExist, true, (err)=>{ + console.debug("====>setDataSyncEnabled 1300 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsSetCheckDataSyncEnabled_1300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1400 + * @tc.name : setDataSyncEnabled promise form + * @tc.desc : Set synchronization flag for non-existent account + */ + it('ActsSetCheckDataSyncEnabled_1400', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>setDataSyncEnabled ActsSetCheckDataSyncEnabled_1400 start====") + var accountNotExist = "syncenable_promise_notexist"; + try{ + await appAccountManager.setDataSyncEnabled(accountNotExist, true); + } + catch(err){ + console.debug("====>setDataSyncEnabled 1400 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsSetCheckDataSyncEnabled_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1500 + * @tc.name : checkDataSyncEnabled callback form + * @tc.desc : Check synchronization flag for non-existent account + */ + it('ActsSetCheckDataSyncEnabled_1500', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_1500 start====") + var accountNotExist = "syncenable_callback_notexist"; + appAccountManager.checkDataSyncEnabled(accountNotExist, (err, data)=>{ + console.debug("====>checkDataSyncEnabled 1500 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsSetCheckDataSyncEnabled_1500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsSetCheckDataSyncEnabled_1600 + * @tc.name : checkDataSyncEnabled promise form + * @tc.desc : Check synchronization flag for non-existent account + */ + it('ActsSetCheckDataSyncEnabled_1600', 0, async function (done) { + console.debug("====>ActsSetCheckDataSyncEnabled_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>checkDataSyncEnabled ActsSetCheckDataSyncEnabled_1600 start====") + var accountNotExist = "syncenable_promise_notexist"; + try{ + await appAccountManager.checkDataSyncEnabled(accountNotExist); + } + catch(err){ + console.debug("====>checkDataSyncEnabled 1600 err:" + JSON.stringify(err)); + expect(err.code == 12300003).assertEqual(true); + console.debug("====>ActsSetCheckDataSyncEnabled_1600 end===="); + done(); + } + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/resources/base/element/string.json b/account/appaccount/actssetcheckdatasyncenable/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..89f90a73a8b24448128dffdbcc82cd52cf23b287 --- /dev/null +++ b/account/appaccount/actssetcheckdatasyncenable/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsSetCheckSyncEnable" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actssetcheckdatasyncenable/src/main/resources/base/media/icon.png b/account/appaccount/actssetcheckdatasyncenable/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actssetcheckdatasyncenable/src/main/resources/base/media/icon.png differ diff --git a/account/appaccount/getallaccounts/BUILD.gn b/account/appaccount/getallaccounts/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e2fb5c041705b19f629e48fd178a22082acb6f67 --- /dev/null +++ b/account/appaccount/getallaccounts/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +group("getallaccounts") { + testonly = true + if (is_standard_system) { + deps = [ + "getallaccountsnoparameter:GetAllAccountsNoParameter", + "getmultipleaccounts:GetMultipleAccountsTest", + ] + } +} diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/BUILD.gn b/account/appaccount/getallaccounts/getallaccountsnoparameter/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8def05bcae8a7fbb244d281d57912fc4749bc393 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("GetAllAccountsNoParameter") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "GetAllAccountsNoParameter" + subsystem_name = "account" + part_name = "os_account" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/Test.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..67db914bdee03b030e6d3fc3a08d4d79345cb1a6 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/Test.json @@ -0,0 +1,20 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "bundle-name": "com.example.getallaccountsnoparameter", + "package-name": "com.example.getallaccountsnoparameter", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "GetAllAccountsNoParameter.hap", + "ActsAccountSceneAccessible.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/signature/openharmony_sx.p7b b/account/appaccount/getallaccounts/getallaccountsnoparameter/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/account/appaccount/getallaccounts/getallaccountsnoparameter/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/config.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..108d3d283f38d56d1b24fe713d7b24fcde692740 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/config.json @@ -0,0 +1,127 @@ +{ + "app": { + "bundleName": "com.example.getallaccountsnoparameter", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.getallaccountsnoparameter", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.GET_ALL_APP_ACCOUNTS" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_ALL_APP_ACCOUNTS", + "reason": "ceshi" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/app.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/i18n/en-US.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/i18n/zh-CN.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,24 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7ffbf87eadfca5fc7efc9873d5d6875ac40d68b2 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,31 @@ +/* + * 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. + */ + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "getAllAccessibleAccounts" + }, + onInit() { + this.title = "getAllAccessibleAccounts"; + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/app.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1ba8e4e82ace01dad36c1279ea520b4903c57e8f --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,37 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/test/Getallaccounts.test.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/test/Getallaccounts.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5527cc73d198963cae3045f2f1cab68d7cf1e4bb --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/test/Getallaccounts.test.js @@ -0,0 +1,600 @@ +/* + * 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 account from '@ohos.account.appAccount' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 2000; +const SELFBUNDLE = 'com.example.getallaccountsnoparameter' +export default function ActsGetAllAccountsNoParameter() { + describe('ActsGetAllAccountsNoParameter', function () { + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0100 + * @tc.name : getAllAccounts callback + * @tc.desc : This application has not added an account and has not been authorized by other applications to + * obtain authorization + */ + it('ActsGetAllAccountsNoParameter_0100', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts 0100 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0100 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts 0100 data.length:" + data.length); + expect(err).assertEqual(null); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccountsNoParameter_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0200 + * @tc.name : getAllAccounts promise + * @tc.desc : This application has not added an account and has not been authorized by other applications to + * obtain authorization + */ + it('ActsGetAllAccountsNoParameter_0200', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts 0200 start===="); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts 0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 0200 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts 0200 data.length:" + data.length); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccountsNoParameter_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0300 + * @tc.name : getAllAccounts callback + * @tc.desc : This application gets authorization after adding a single account + */ + it('ActsGetAllAccountsNoParameter_0300', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("accessibleAccount_callback_single", (err)=>{ + console.debug("====> add account ActsGetAllAccountsNoParameter_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts 0300 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0300 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts 0300 data.length:" + data.length); + expect(err).assertEqual(null); + expect(data.length).assertEqual(1); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_single"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>getAllAccounts check data 0300 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.removeAccount("accessibleAccount_callback_single", (err)=>{ + console.debug("====>delete Account ActsGetAllAccountsNoParameter_0300 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsGetAllAccountsNoParameter_0300 end===="); + done(); + }) + }); + }); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0400 + * @tc.name : getAllAccounts promise + * @tc.desc : This application gets authorization after adding a single account + */ + it('ActsGetAllAccountsNoParameter_0400', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts for clean===="); + try{ + var acclist = await appAccountManager.getAllAccounts(SELFBUNDLE); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add account ActsGetAllAccountsNoParameter_0400 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_single"); + console.debug("====>getAllAccounts 0400 start===="); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts 0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 0400 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts 0400 data.length:" + data.length); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_single"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>getAllAccounts check data 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.removeAccount("accessibleAccount_promise_single"); + console.debug("====>ActsGetAllAccountsNoParameter_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0500 + * @tc.name : getAllAccounts callback + * @tc.desc : This application is added to obtain authorization after adding multiple application accounts + */ + it('ActsGetAllAccountsNoParameter_0500', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("accessibleAccount_callback_first", (err)=>{ + console.debug("====>add account first time 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("accessibleAccount_callback_second", (err)=>{ + console.debug("====>add account second time 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("accessibleAccount_callback_third", (err)=>{ + console.debug("====>add account third time 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0500 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts 0500 data.length:" + data.length); + expect(err).assertEqual(null); + expect(data.length).assertEqual(3); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_callback_second"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[2].name).assertEqual("accessibleAccount_callback_third"); + expect(data[2].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data 0500 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.removeAccount("accessibleAccount_callback_first", (err)=>{ + console.debug("====>delete Account first 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("accessibleAccount_callback_second", (err)=>{ + console.debug("====>delete Account second 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("accessibleAccount_callback_third", (err)=>{ + console.debug("====>delete Account third 0500 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsGetAllAccountsNoParameter_0500 end===="); + done(); + }) + }) + }) + }); + }) + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0600 + * @tc.name : getAllAccounts promise + * @tc.desc : This application is added to obtain authorization after adding multiple application accounts + */ + it('ActsGetAllAccountsNoParameter_0600', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts for clean===="); + try{ + var acclist = await appAccountManager.getAllAccounts(SELFBUNDLE); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add first account 0600 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_first"); + console.debug("====>add second account 0600 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_second"); + console.debug("====>add third account 0600 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_third"); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 0600 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(3); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_promise_second"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[2].name).assertEqual("accessibleAccount_promise_third"); + expect(data[2].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete first account 0600 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_first"); + console.debug("====>delete second account 0600 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_second"); + console.debug("====>delete third account 0600 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_third"); + console.debug("====>ActsGetAllAccountsNoParameter_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0700 + * @tc.name : getAllAccounts callback + * @tc.desc : This application adds different application accounts three times in a row, and obtains + * authorization after deleting the account added for the second time + */ + it('ActsGetAllAccountsNoParameter_0700', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("accessibleAccount_callback_delete_first", (err)=>{ + console.debug("====>add first account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("accessibleAccount_callback_delete_second", (err)=>{ + console.debug("====>add second account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("accessibleAccount_callback_delete_third", (err)=>{ + console.debug("====>add third account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("accessibleAccount_callback_delete_second", (err)=>{ + console.debug("====>delete second account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0700 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts 0700 data.length:" + data.length); + expect(err).assertEqual(null); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_delete_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_callback_delete_third"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data 0700 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.removeAccount("accessibleAccount_callback_delete_first", (err)=>{ + console.debug("====>delete first account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("accessibleAccount_callback_delete_third", (err)=>{ + console.debug("====>delete third account 0700 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsGetAllAccountsNoParameter_0700 end===="); + done(); + }) + }) + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0800 + * @tc.name : getAllAccounts promise + * @tc.desc : This application adds different application accounts three times in a row, and obtains + * authorization after deleting the account added for the second time + */ + it('ActsGetAllAccountsNoParameter_0800', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts for clean===="); + try{ + var acclist = await appAccountManager.getAllAccounts(SELFBUNDLE); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add first account 0800 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_first"); + console.debug("====>add second account 0800 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_second"); + console.debug("====>add third account 0800 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_third"); + console.debug("====>delete second account 0800 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_second"); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 0800 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_promise_third"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete first account 0800 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_first"); + console.debug("====>delete third account 0800 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_third"); + console.debug("====>ActsGetAllAccountsNoParameter_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_0900 + * @tc.name : getAllAccounts callback + * @tc.desc : This application adds different application accounts three times in a row, and then obtains + * authorization multiple times + */ + it('ActsGetAllAccountsNoParameter_0900', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.createAccount("accessibleAccount_callback_multiple_first", (err)=>{ + console.debug("====>add first account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.createAccount("accessibleAccount_callback_multiple_second", (err)=>{ + console.debug("====>add third account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts first 0900 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts first 0900 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts first 0900 data.length:" + data.length); + expect(err).assertEqual(null); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_multiple_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_callback_multiple_second"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data first 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("====>getAllAccounts second 0900 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts second 0900 data:" + JSON.stringify(data)); + console.debug("====>getAllAccounts second 0900 data.length:" + data.length); + expect(err).assertEqual(null); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_multiple_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_callback_multiple_second"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data second 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.removeAccount("accessibleAccount_callback_multiple_first", (err)=>{ + console.debug("====>delete first account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + appAccountManager.removeAccount("accessibleAccount_callback_multiple_second", (err)=>{ + console.debug("====>delete second account 0900 err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsGetAllAccountsNoParameter_0900 end===="); + done(); + }) + }) + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_1000 + * @tc.name : getAllAccounts promise + * @tc.desc : This application adds different application accounts three times in a row, and then obtains + * authorization multiple times + */ + it('ActsGetAllAccountsNoParameter_1000', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts for clean===="); + try{ + var acclist = await appAccountManager.getAllAccounts(SELFBUNDLE); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.removeAccount(acclist[i].name); + } + } + console.debug("====>add first account 1000 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_multiple_first"); + console.debug("====>add second account 1000 start===="); + await appAccountManager.createAccount("accessibleAccount_promise_multiple_second"); + console.debug("====>getAllAccounts first 1000 start===="); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts first 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_multiple_first"); + expect(data[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(data[1].name).assertEqual("accessibleAccount_promise_multiple_second"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts second 1000 start===="); + try{ + var dataTwo = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts second 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1000 dataTwo:" + JSON.stringify(dataTwo)); + expect(data.length).assertEqual(2); + try{ + expect(dataTwo[0].name).assertEqual("accessibleAccount_promise_multiple_first"); + expect(dataTwo[0].owner).assertEqual("com.example.getallaccountsnoparameter"); + expect(dataTwo[1].name).assertEqual("accessibleAccount_promise_multiple_second"); + expect(dataTwo[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check dataTwo 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete first account 1000 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_multiple_first"); + console.debug("====>delete second account 1000 start===="); + await appAccountManager.removeAccount("accessibleAccount_promise_multiple_second"); + console.debug("====>ActsGetAllAccountsNoParameter_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccountsNoParameter_1100 + * @tc.name : getAllAccounts + * @tc.desc : This application adds an account, other application authorizes an account to this application + * and this application obtains authorization + */ + it('ActsGetAllAccountsNoParameter_1100', 0, async function (done) { + console.debug("====>ActsGetAllAccountsNoParameter_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account 1100 start===="); + await appAccountManager.createAccount("accessibleAccount_this_application"); + console.debug("====>startAbility 1100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountsceneaccessible", + abilityName: "com.example.actsaccountsceneaccessible.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAllAccounts 1100 start===="); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1100 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsaccountsceneaccessible"); + expect(data[1].name).assertEqual("accessibleAccount_this_application"); + expect(data[1].owner).assertEqual("com.example.getallaccountsnoparameter"); + } + catch(err){ + console.error("====>check data 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 1100 start===="); + await appAccountManager.removeAccount("accessibleAccount_this_application"); + console.debug("====>ActsGetAllAccountsNoParameter_1100 end===="); + done(); + }, TIMEOUT); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/test/List.test.js b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..930f2dae4a9d07f2239e6b15f1005a17ca2f3317 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsGetAllAccountsNoParameter from './Getallaccounts.test.js' + +export default function testsuite() { + ActsGetAllAccountsNoParameter() +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/resources/base/element/string.json b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b8c402107250a58e8ea8b91a03c84ad0c91af068 --- /dev/null +++ b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccessibleAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/resources/base/media/icon.png b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/getallaccounts/getallaccountsnoparameter/src/main/resources/base/media/icon.png differ diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/BUILD.gn b/account/appaccount/getallaccounts/getmultipleaccounts/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..756d785f4ed20ad95c078e0849d0cfaa077bd132 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("GetMultipleAccountsTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "GetMultipleAccountsTest" + subsystem_name = "account" + part_name = "os_account" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/Test.json b/account/appaccount/getallaccounts/getmultipleaccounts/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..39380a5c02e3d7edf13cf955dc759d1aa69ae9c4 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/Test.json @@ -0,0 +1,21 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "bundle-name": "com.example.getmultipleaccountstest", + "package-name": "com.example.getmultipleaccountstest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "GetMultipleAccountsTest.hap", + "ActsAccountAccessibleFirst.hap", + "ActsAccountAccessibleSecond.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/signature/openharmony_sx.p7b b/account/appaccount/getallaccounts/getmultipleaccounts/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/account/appaccount/getallaccounts/getmultipleaccounts/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/config.json b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..37e94203c6ff618821c3cc8d738a80ba35f4ffa0 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/config.json @@ -0,0 +1,127 @@ +{ + "app": { + "bundleName": "com.example.getmultipleaccountstest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.getmultipleaccountstest", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.GET_ALL_APP_ACCOUNTS" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_ALL_APP_ACCOUNTS", + "reason": "ceshi" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/app.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/i18n/en-US.json b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/i18n/zh-CN.json b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,24 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c4ec231829b3b39bbd75ff2411792dd9f3a4bc6e --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,30 @@ +/* + * 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. + */ +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "getAllAccessibleAccounts" + }, + onInit() { + this.title = "getAllAccessibleAccounts"; + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/app.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1ba8e4e82ace01dad36c1279ea520b4903c57e8f --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,37 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/test/Getmultipleaccounts.test.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/test/Getmultipleaccounts.test.js new file mode 100644 index 0000000000000000000000000000000000000000..13632ba77c1d16362e0ff25d963688df281edcff --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/test/Getmultipleaccounts.test.js @@ -0,0 +1,130 @@ +/* + * 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 account from '@ohos.account.appAccount' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 5000; +export default function ActsGetMultipleAccounts() { + describe('ActsGetMultipleAccounts', function () { + beforeAll(async function (done) { + console.debug("====>startAbility first start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountaccessiblefirst", + abilityName: "com.example.actsaccountaccessiblefirst.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + sleep(TIMEOUT); + done(); + }); + + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + /* + * @tc.number : ActsGetMultipleAccounts_0100 + * @tc.name : getAllAccounts + * @tc.desc : This application adds multiple account, other applications authorizes multiple accounts to this + * application and this application obtains authorization + */ + it('ActsGetMultipleAccounts_0100', 0, async function (done) { + console.debug("====>ActsGetMultipleAccounts_0100 start===="); + let dataMap = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add first account 0100 start===="); + await appAccountManager.createAccount("accessibleAccount_this_application_first"); + console.debug("====>add second account 0100 start===="); + await appAccountManager.createAccount("accessibleAccount_this_application_second"); + console.debug("====>add third account 0100 start===="); + await appAccountManager.createAccount("accessibleAccount_this_application_third"); + console.debug("====>getAllAccounts 0100 start===="); + try{ + var data = await appAccountManager.getAllAccounts(); + } + catch(err){ + console.error("====>getAllAccounts 0100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 0100 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(7); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("account_name_scene_first_first")).assertTrue(); + if (dataMap.has("account_name_scene_first_first")) { + let data = dataMap.get("account_name_scene_first_first"); + console.debug("====>first account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblefirst"); + } + expect(dataMap.has("account_name_scene_first_second")).assertTrue(); + if (dataMap.has("account_name_scene_first_second")) { + let data = dataMap.get("account_name_scene_first_second"); + console.debug("====>second account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblefirst"); + } + expect(dataMap.has("account_name_scene_second_first")).assertTrue(); + if (dataMap.has("account_name_scene_second_first")) { + let data = dataMap.get("account_name_scene_second_first"); + console.debug("====>third account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblesecond"); + } + expect(dataMap.has("account_name_scene_second_second")).assertTrue(); + if (dataMap.has("account_name_scene_second_second")) { + let data = dataMap.get("account_name_scene_second_second"); + console.debug("====>fourth account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblesecond"); + } + expect(dataMap.has("accessibleAccount_this_application_first")).assertTrue(); + if (dataMap.has("accessibleAccount_this_application_first")) { + let data = dataMap.get("accessibleAccount_this_application_first"); + console.debug("====>fifth account owner is: " + data); + expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + expect(dataMap.has("accessibleAccount_this_application_second")).assertTrue(); + if (dataMap.has("accessibleAccount_this_application_second")) { + let data = dataMap.get("accessibleAccount_this_application_second"); + console.debug("====>sixth account owner is: " + data); + expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + expect(dataMap.has("accessibleAccount_this_application_third")).assertTrue(); + if (dataMap.has("accessibleAccount_this_application_third")) { + let data = dataMap.get("accessibleAccount_this_application_third"); + console.debug("====>seventh account owner is: " + data); + expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + console.debug("====>delete account start===="); + await appAccountManager.removeAccount("accessibleAccount_this_application_first"); + await appAccountManager.removeAccount("accessibleAccount_this_application_second"); + await appAccountManager.removeAccount("accessibleAccount_this_application_third"); + console.debug("====>ActsGetAllAccessibleAccounts_0100 end===="); + done(); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/test/List.test.js b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..dd33ab1a20951da286f7708451fa7d296a2d2e72 --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsGetMultipleAccounts from './Getmultipleaccounts.test.js' + +export default function testsuite() { + ActsGetMultipleAccounts() +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/resources/base/element/string.json b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e2244febf6ffbfb2333c2c3ac0b78ae972b2bf1f --- /dev/null +++ b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccessibleMultiple" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/getallaccounts/getmultipleaccounts/src/main/resources/base/media/icon.png b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/getallaccounts/getmultipleaccounts/src/main/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js index c884b73634e280b3e062d7dbc3a30e46e7c5c7d7..75afbfba41b03791c4f7acae7f75e5341d9ecda4 100755 --- a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js @@ -14,6 +14,7 @@ */ import account from '@ohos.account.appAccount' import featureAbility from '@ohos.ability.featureAbility' +import app from '../../../../../../../../../getallaccounts/getallaccountsnoparameter/src/main/js/TestAbility/app' const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -29,29 +30,35 @@ export default { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat first scene manager finish===="); var enableBundle = "com.example.actsgetallaccessiblemultiple"; + var enableBundle_2 = "com.example.getmultipleaccountstest" console.debug("====>add first account start===="); - appAccountManager.addAccount("account_name_scene_first_first", (err)=>{ + appAccountManager.createAccount("account_name_scene_first_first", (err)=>{ console.debug("====>add first account err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_first_first", enableBundle, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_first_first", enableBundle, true, (err)=>{ console.debug("====>enableAppAccess first account err:" + JSON.stringify(err)); - appAccountManager.addAccount("account_name_scene_first_second", (err)=>{ - console.debug("====>add second account err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_first_second", enableBundle, (err)=>{ - console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); - console.debug("====>startAbility second start===="); - featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsaccountaccessiblesecond", - abilityName: "com.example.actsaccountaccessiblesecond.MainAbility", - action: "action1", - parameters: - {}, - }, - } - ); + appAccountManager.setAppAccess("account_name_scene_first_first", enableBundle_2, true, (err) => { + console.debug("====>enableAppAccess first account for enableBundle_2 err:" + JSON.stringify(err)); + appAccountManager.createAccount("account_name_scene_first_second", (err)=>{ + console.debug("====>add second account err:" + JSON.stringify(err)); + appAccountManager.setAppAccess("account_name_scene_first_second", enableBundle, true, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_first_second", enableBundle_2, true, (err)=>{ + console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); + console.debug("====>startAbility second start===="); + featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountaccessiblesecond", + abilityName: "com.example.actsaccountaccessiblesecond.MainAbility", + action: "action1", + parameters: + {}, + }, + } + ); + }) + }) }) }) }) diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js index 6e4591a430de8aa264a4a6eda34735ec60fdb9aa..570d3d741f43a59d1e801cb3cc3728451ffe8fb1 100755 --- a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js @@ -35,20 +35,25 @@ export default { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat second scene manager finish===="); var enableBundle = "com.example.actsgetallaccessiblemultiple"; + var enableBundle_2 = "com.example.getmultipleaccountstest" console.debug("====>add second account start===="); - appAccountManager.addAccount("account_name_scene_second_first", (err)=>{ + appAccountManager.createAccount("account_name_scene_second_first", (err)=>{ console.debug("====>add second account err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_second_first", enableBundle, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_second_first", enableBundle, true, (err)=>{ console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); - appAccountManager.addAccount("account_name_scene_second_second", (err)=>{ - console.debug("====>add second account err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_second_second", enableBundle, (err)=>{ - console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); - sleep(3000); - featureAbility.terminateSelf( - (err, data)=>{ - console.debug('====>Terminate Ability Success====') - }); + appAccountManager.setAppAccess("account_name_scene_second_first", enableBundle_2, true, (err) => { + appAccountManager.createAccount("account_name_scene_second_second", (err)=>{ + console.debug("====>add second account err:" + JSON.stringify(err)); + appAccountManager.setAppAccess("account_name_scene_second_second", enableBundle, true, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_second_second", enableBundle_2, true, (err) => { + console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); + sleep(3000); + featureAbility.terminateSelf( + (err, data)=>{ + console.debug('====>Terminate Ability Success====') + }); + }) + }) }) }) }) diff --git a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js index 7fb28fa798f5d0189e8358d3e0d703f07dc54b1c..6e1179359c0340de16ce301a9870cb53f219f42b 100644 --- a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js @@ -23,27 +23,34 @@ export default { this.title = this.$t('strings.world'); }, onShow() { - console.info('ServiceAbility onStart'); - var accountMgr = account_appAccount.createAppAccountManager(); - console.info('ServiceAbility lcc addAccount 01 onStart'); - accountMgr.addAccount("zhangsan", "",(data)=>{ - console.info('ServiceAbility lcc enableAppAccess 01 onStart'); - accountMgr.enableAppAccess("zhangsan", "com.example.actsaccounttest"); - console.info('ServiceAbility lcc addAccount 02 onStart'); - accountMgr.addAccount("lisi", "",(err)=>{ - console.info('ServiceAbility lcc enableAppAccess 02 onStart'); - accountMgr.enableAppAccess("lisi", "com.example.actsaccounttest"); - console.info('ServiceAbility lcc addAccount 03 onStart'); - accountMgr.addAccount("wangwu", "",(err)=>{ - console.info('ServiceAbility lcc enableAppAccess 03 onStart'); - accountMgr.enableAppAccess("wangwu", "com.example.actsaccounttest",(err)=>{ + console.info('====>ServiceAbility onStart'); + var accountMgr = account_appAccount.createAppAccountManager(); + accountMgr.createAccount("zhangsan", async(data)=>{ + console.info('====>ServiceAbility addAccount 01 onStart'); + console.info('====>ServiceAbility setAppAccess actsaccounttest zhangsan'); + await accountMgr.setAppAccess("zhangsan", "com.example.actsaccounttest", true); + console.info('====>ServiceAbility setAppAccess actsaccountoperatetest zhangsan'); + await accountMgr.setAppAccess("zhangsan", "com.example.actsaccountoperatetest", true); + console.info('====>ServiceAbility lcc addAccount 02 onStart'); + accountMgr.createAccount("lisi", async (err)=>{ + console.info('====>ServiceAbility setAppAccess actsaccounttest lisi'); + await accountMgr.setAppAccess("lisi", "com.example.actsaccounttest", true); + console.info('====>ServiceAbility setAppAccess actsaccountoperatetest lisi'); + await accountMgr.setAppAccess("lisi", "com.example.actsaccountoperatetest", true); + console.info('====>ServiceAbility lcc addAccount 03 onStart'); + accountMgr.createAccount("wangwu", async (err)=>{ + console.info('====>ServiceAbility lcc enableAppAccess 03 onStart'); + console.info('====>ServiceAbility setAppAccess actsaccounttest wangwu'); + await accountMgr.setAppAccess("wangwu", "com.example.actsaccounttest", true) + console.info('====>ServiceAbility setAppAccess actsaccountoperatetest wangwu'); + accountMgr.setAppAccess("wangwu", "com.example.actsaccountoperatetest", true, (err)=>{ featureAbility.terminateSelf(); - console.info('ServiceAbility add end'); + console.info('====>ServiceAbility add end'); }); }); }); }); - console.info('ServiceAbility onStart end'); + console.info('====>ServiceAbility onStart end'); }, onReady() { }, diff --git a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js index 4eb1de03bc83a5fd5d1ca225ba2ba4172023f269..5e15436cf100149887d2c5720db96845fcc983f3 100644 --- a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js +++ b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js @@ -13,11 +13,165 @@ * limitations under the License. */ import account_appAccount from '@ohos.account.appAccount'; -import featureAbility from '@ohos.ability.featureAbility' -import {MyAuthenticator} from '../Common/utils' var TAG = "[AccountTest]" var authenticator = null +var accountLabels = { + "zhangsan": ["male", "30-40", "level4"], + "lisi": ["female"] +} +var accountCredentials = { + "zhangsan": { + "PIN": "123456", + "NUMBER": "12356789" + }, + "lisi": { + "FACE": "X00001" + } +} +var accountRemovability = { + "zhangsan": false, + "lisi": true +} +var properties = {} + +class MyAuthenticator extends account_appAccount.Authenticator { + + addAccountImplicitly(authType, callerBundleName, options, callback) { + console.log(TAG + "authType: " + authType + "callerBundleName: " + callerBundleName + ", options: " + JSON.stringify(options)) + let appAccountMgr = account_appAccount.createAppAccountManager(); + let newAccountName = "addNewAccountName" + appAccountMgr.createAccount(newAccountName, (err) => { + let authResult = { + name: newAccountName, + owner: "com.example.accountauthenticator" + } + callback.onResult(0, authResult); + }); + } + + authenticate(name, authType, callerBundleName, options, callback) { + console.log(TAG + "name: " + name + "authType: " + authType + "callerBundleName: " + callerBundleName + ", options: " + JSON.stringify(options)) + let appAccountMgr = account_appAccount.createAppAccountManager(); + appAccountMgr.createAccount(name, (err) => { + callback.onResult(0, { + name: name, + authType: authType, + token: "123456" + }); + }) + } + + createAccountImplicitly(options, callback) { + console.log(TAG + "options: " + JSON.stringify(options)) + let appAccountMgr = account_appAccount.createAppAccountManager(); + let newAccountName = "createNewAccountName" + appAccountMgr.createAccount(newAccountName, (err) => { + let authResult = { + accountInfo: { + name: newAccountName, + owner: "com.example.accountauthenticator" + } + } + callback.onResult(0, authResult); + }); + } + + auth(name, authType, options, callback) { + console.log(TAG + "name: " + name + "authType: " + authType + ", options: " + JSON.stringify(options)) + let authResult = { + accountInfo: { + name: name, + owner: "com.example.accountauthenticator" + }, + tokenInfo: { + authType: "getSocialData", + token: "xxxxxxxxx" + } + } + callback.onResult(0, authResult); + } + + verifyCredential(name, options, callback) { + console.log(TAG + "name: " + name + ", options: " + JSON.stringify(options)) + if (name == "xiaoming") { + callback.onRequestContinued() + return + } + var credentialInfo = undefined + try { + credentialInfo = accountCredentials[name] + } catch (err) { + console.log(TAG + " no credential") + callback.onResult(0, {"booleanResult": false}) + return + } + if (options.credentialType == undefined || options.credential == undefined) { + callback.onRequestRedirected({ + bundleName: "com.example.accountauthenticator", + abilityName: "VerifyAbility", + parameters: { + credentialType: options.credentialType, credential: options.credential + } + }) + return + } + try { + var credential = credentialInfo[options.credentialType.toUpperCase()] + if (credential == options.credential) { + callback.onResult(0, {"booleanResult": true}) + } else { + callback.onResult(0, {"booleanResult": false}) + } + } catch(err) { + console.log(TAG + " check credential error"); + callback.onResult(0, {"booleanResult": false}); + } + } + + checkAccountLabels(name, labels, callback) { + console.log(TAG + "name: " + name + ", labels: " + JSON.stringify(labels) + ", callback: " + callback) + if (labels.length == 0) { + callback.onResult(0, {"booleanResult": true}) + return + } + var allLabels = [] + try { + allLabels = accountLabels[name] + } catch (err) { + console.log("no labels") + allLabels == undefined + } + if (allLabels == undefined || allLabels.length == 0) { + callback.onResult(0, {"booleanResult": false}) + return + } + for (var i = 0; i < labels.length; ++i) { + if (allLabels.indexOf(labels[i]) == -1) { + callback.onResult(0, {"booleanResult": false}) + return + } + } + callback.onResult(0, {"booleanResult": true}) + } + + setProperties(options, callback) { + console.log(TAG + "options: " + JSON.stringify(options)) + callback.onResult(10016, {}) + } + + isAccountRemovable(name, callback) { + console.log(TAG + "name: " + name) + var isRemovable = false; + try { + isRemovable = accountRemovability[name] + } catch (err) { + console.log(TAG + "error: " + JSON.stringify(err)) + } + callback.onResult(0, {"booleanResult": isRemovable}) + } +} + export default { onStart(want) { console.info('ServiceAbility onStart'); diff --git a/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/config.json index ad8171ba799f944c2d9f02d652c95498c502fe8f..394691cb4264566d2ce9f7dbd25361171cf30900 100644 --- a/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/config.json +++ b/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/config.json @@ -38,7 +38,7 @@ ] } ], - "name": "com.example.actsaccountOauthtoken.MainAbility", + "name": "com.example.actsaccountoauthtoken.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", "label": "$string:app_name", diff --git a/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/js/default/pages/index/index.js index 88cd36de997f200c8ffb67f73ef1649afafb2658..bb8e01412064fdadb6b1e3bba916037bb47d686b 100644 --- a/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountoauthtoken/entry/src/main/js/default/pages/index/index.js @@ -22,15 +22,30 @@ class MyAuthenticator extends appAccount.Authenticator authenticate(name, authType, callerBundleName, options, callback) { var randNumber = Math.ceil(Math.random()*10000) var newTokenData = "service/authenticate/tokenInfo" + randNumber; - console.log("Service authenticate name: " + name + ", authType: " + authType + ", options: "+ JSON.stringify(options)); + console.log("====>Service authenticate name: " + name + ", authType: " + authType + ", options: "+ JSON.stringify(options)); callback.onResult(0, {"name":name,"authType":authType,"token":newTokenData}); } addAccountImplicitly(authType, callerBundleName, options, callback) { - console.log("Service addAccountImplicitly authType: " + authType + " callerBundleName: " + callerBundleName + "options: "+ JSON.stringify(options)); + console.log("====>Service addAccountImplicitly authType: " + authType + " callerBundleName: " + callerBundleName + "options: "+ JSON.stringify(options)); callback.onRequestRedirected({ - bundleName: "com.huawei.openharmonyappdemo.service", - abilityName: "com.huawei.openharmonyappdemo.service.settingAbility", + bundleName: "com.ohos.openharmonyappdemo.service", + abilityName: "com.ohos.openharmonyappdemo.service.settingAbility", + }); + } + + auth(name, authType, callerBundleName, callback) { + var randNumber = Math.ceil(Math.random()*10000) + var newTokenData = "service/authenticate/tokenInfo" + randNumber; + console.log("====>Service authenticate name: " + name + ", authType: " + authType); + callback.onResult(0, {"name":name,"authType":authType,"token":newTokenData}); + } + + createAccountImplicitly(options, callback) { + console.log("====>Service createAccountImplicitly options: "+ JSON.stringify(options)); + callback.onRequestRedirected({ + bundleName: "com.ohos.openharmonyappdemo.service", + abilityName: "com.ohos.openharmonyappdemo.service.settingAbility", }); } } diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js index de497484928c2ce6f09188e9bfcb04486fbf2e59..9122b50d21060b6430caac0e00946a6280e8f918 100755 --- a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js @@ -28,10 +28,14 @@ export default { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat scene manager finish===="); var enableBundle = "com.example.actsgetallaccessibleaccounts"; + var enableBundle2 = "com.example.getallaccountsnoparameter"; console.debug("====>add account scene start===="); - appAccountManager.addAccount("account_name_scene_single", (err)=>{ + appAccountManager.createAccount("account_name_scene_single", (err)=>{ console.debug("====>add account scene err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_single", enableBundle, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_single", enableBundle, true, (err)=>{ + console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); + }); + appAccountManager.setAppAccess("account_name_scene_single", enableBundle2, true, (err)=>{ console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); }); }); diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js index efc3bc1fe434707e457c83850ae515237e285f71..6b3319524d065c1dd395518de465534e101d5ef6 100755 --- a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js @@ -31,13 +31,13 @@ export default { console.debug("====>creat scene manager finish===="); var enableBundle = "com.example.actsaccountpressure"; console.debug("====>add first account start===="); - appAccountManager.addAccount("account_name_scene_first", (err)=>{ + appAccountManager.createAccount("account_name_scene_first", (err)=>{ console.debug("====>add first account err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_first", enableBundle, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_first", enableBundle, true, (err)=>{ console.debug("====>enableAppAccess first account err:" + JSON.stringify(err)); - appAccountManager.addAccount("account_name_scene_second", (err)=>{ + appAccountManager.createAccount("account_name_scene_second", (err)=>{ console.debug("====>add second account err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_second", enableBundle, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_second", enableBundle, true, (err)=>{ console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); featureAbility.terminateSelf( (err, data)=>{ diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js index 769e6af03e548a0331c45a68555e52220fdc23a9..47c8c50db0aaec97b0e9614c1935420bd5e752ef 100755 --- a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js @@ -23,6 +23,12 @@ const ACCOUNT_TEST_ONOFF_DELETE = 4 const ACCOUNT_TEST_ONOFF_DELETEONLY = 5 const ACCOUNT_TEST_ONOFF_DISABLE = 6 const ACCOUNT_TEST_ONOFF_DISABLEONLY = 7 +const ACCOUNT_TEST_ONOFF_CUSTOMDATA = 8 +const ACCOUNT_TEST_ONOFF_SETCREDENTIAL = 9 +const ACCOUNT_TEST_ONOFF_REMOVE = 10 +const ACCOUNT_TEST_ONOFF_REMOVEONLY = 11 +const ACCOUNT_TEST_ONOFF_SETDISABLE = 12 +const ACCOUNT_TEST_ONOFF_SETDISABLEONLY = 13 const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -44,8 +50,10 @@ export default { function publishCallback(err){ console.debug("====>publish call back scene err:" + JSON.stringify(err)); console.debug("====>scene off start===="); - appAccountManager.off('change', function (){ - console.debug("====>scene off finish===="); + appAccountManager.off('accountChange', function (){ + appAccountManager.off('change', function (){ + console.debug("====>scene off finish===="); + }); }); featureAbility.terminateSelf() } @@ -98,6 +106,29 @@ export default { } } + function changeOnCustomData(data){ + console.debug("====>receive change 0200 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountoperatetest" && data[0].name == "onoff_cunstomdata"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_cuntomdata", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_customdata", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_customdata", commonEventPublishData, publishCallback); + } + } + function changeOnCredential(data){ console.debug("====>receive change 0300 data:" + JSON.stringify(data)); try{ @@ -121,6 +152,29 @@ export default { } } + function changeOnSetCredential(data){ + console.debug("====>receive change 0300 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountoperatetest" && data[0].name == "onoff_setcredential"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_setcredential", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_setcredential", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_setcredential", commonEventPublishData, publishCallback); + } + } + function changeOnDeleteAnother(data){ console.debug("====>receive change 0400 data:" + JSON.stringify(data)); try{ @@ -144,6 +198,29 @@ export default { } } + function changeOnRemoverAnother(data){ + console.debug("====>receive change 0400 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountoperatetest" && data[0].name == "onoff_removeFir"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_remove_another", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_remove_another", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_remove_another", commonEventPublishData, publishCallback); + } + } + function changeOnDelete(data){ console.debug("====>receive change 0500 data:" + JSON.stringify(data)); try{ @@ -167,6 +244,29 @@ export default { } } + function changeOnRemove(data){ + console.debug("====>receive change 0500 data:" + JSON.stringify(data)); + try{ + if(data.length == 0){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_remove", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_remove", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_remove", commonEventPublishData, publishCallback); + } + } + function changeOnDisableAnother(data){ console.debug("====>receive change 0600 data:" + JSON.stringify(data)); try{ @@ -190,6 +290,29 @@ export default { } } + function changeOnSetAnotherDisable(data){ + console.debug("====>receive change 1200 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountoperatetest" && data[0].name == "onoff_disableFir"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_set_another_disable", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_set_another_disable", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_set_another_disable", commonEventPublishData, publishCallback); + } + } + function changeOnDisable(data){ console.debug("====>receive change 0700 data:" + JSON.stringify(data)); try{ @@ -213,6 +336,29 @@ export default { } } + function changeOnSetDisable(data){ + console.debug("====>receive change 1300 data:" + JSON.stringify(data)); + try{ + if(data.length == 0){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_set_disable", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_set_disable", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_set_disable", commonEventPublishData, publishCallback); + } + } + // Receive events sent by the test application to correspond to different test cases function subscriberCallback(err, data){ console.debug("====>receive event err:" + JSON.stringify(err)); @@ -246,6 +392,30 @@ export default { console.debug("====>receive event 0700 event:" + data.event); appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDisable); break; + case ACCOUNT_TEST_ONOFF_CUSTOMDATA: + console.debug("====>receive event 0800 event:" + data.event); + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnCustomData); + break; + case ACCOUNT_TEST_ONOFF_SETCREDENTIAL: + console.debug("====>receive event 0900 event:" + data.event); + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnSetCredential); + break; + case ACCOUNT_TEST_ONOFF_REMOVE: + console.debug("====>receive event 1000 event:" + data.event); + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnRemoverAnother); + break; + case ACCOUNT_TEST_ONOFF_REMOVEONLY: + console.debug("====>receive event 1100 event:" + data.event); + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnRemove); + break; + case ACCOUNT_TEST_ONOFF_SETDISABLE: + console.debug("====>receive event 1200 event:" + data.event); + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnSetAnotherDisable); + break; + case ACCOUNT_TEST_ONOFF_SETDISABLEONLY: + console.debug("====>receive event 1300 event:" + data.event); + appAccountManager.on('accountChange', ["com.example.actsaccountoperatetest"], changeOnSetDisable); + break; default: console.debug("====>receive event enter default===="); break; diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js index 172e91fc0d5b23990a6cc0340b722b9373f3d719..7538c63b9a834c526e79f2a945d0c7e4e0f138be 100755 --- a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js @@ -29,12 +29,16 @@ export default { var appAccountManager = account.createAppAccountManager(); console.debug("====>creat scene manager finish===="); var enableBundle = "com.example.actsgetallaaccounts"; + var enableBundle2 = "com.example.actsgetaccountsbyowner"; console.debug("====>add account scene start===="); - appAccountManager.addAccount("account_name_scene_single", (err)=>{ + appAccountManager.createAccount("account_name_scene_single", (err)=>{ console.debug("====>add account scene err:" + JSON.stringify(err)); - appAccountManager.enableAppAccess("account_name_scene_single", enableBundle, (err)=>{ + appAccountManager.setAppAccess("account_name_scene_single", enableBundle, true, (err)=>{ console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); - featureAbility.terminateSelf() + appAccountManager.setAppAccess("account_name_scene_single", enableBundle2, true, (err)=>{ + console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); + featureAbility.terminateSelf() + }) }); }); }, diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js index 714b5ea8f578803b64958c698e402815bf128caa..26827cdcf315f16d51696482092eca2cbf189a97 100755 --- a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js @@ -14,7 +14,11 @@ */ import ActsOsAccountThirdPartyTest_third_2 from './OsAccountGet.test.js' import ActsOsAccountThirdPartyTest_third_1 from './OsAccountIs.test.js' +import ActsOsAccountThirdPartyTest_third_4 from './OsAccountQuery.test.js' +import ActsOsAccountThirdPartyTest_third_3 from './OsAccountCheck.test.js' export default function testsuite() { ActsOsAccountThirdPartyTest_third_2() ActsOsAccountThirdPartyTest_third_1() + ActsOsAccountThirdPartyTest_third_4() + ActsOsAccountThirdPartyTest_third_3() } \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountCheck.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountCheck.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d876a4ba5ae614cc5c3327e2ea26347ae4221f91 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountCheck.test.js @@ -0,0 +1,520 @@ +/* + * 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 distributedAccount from '@ohos.account.distributedAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 1000; +const ERR_PERMISSION_DENIED = 201; +const ERR_PARAMETER_CHECK_FAILED = 401; +const ERR_SYSTEM_SERVICE_ABNORMAL = 12300001; +const ERR_INVALID_PARAMETER = 12300002; +const ERR_ACCOUNT_NOT_EXIST = 12300003; +export default function ActsOsAccountThirdPartyTest_third_3() { + describe('ActsOsAccountThirdPartyTest_third_3', function () { + /* + * @tc.number : ActsOsAccountDeviceId_0100 + * @tc.name : queryDistributedVirtualDeviceId callback + * @tc.desc : get distributed virtual device ID + */ + it('ActsOsAccountDeviceId_0100', 0, async function(done){ + console.debug("====>ActsOsAccountDeviceId_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + const deviceId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; + const accountAbility = distributedAccount.getDistributedAccountAbility(); + accountAbility.updateOsAccountDistributedInfo( + { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" + }, (err)=>{ + console.debug("====>update distributedInfo err:" + JSON.stringify(err)); + AccountManager.queryDistributedVirtualDeviceId((err, id)=>{ + console.debug("====>queryDistributedVirtualDeviceId err:" + JSON.stringify(err)); + console.debug("====>queryDistributedVirtualDeviceId deviceId:" + id); + expect(err).assertEqual(null); + expect(id).assertEqual(deviceId); + console.debug("====>ActsOsAccountDeviceId_0100 end===="); + done(); + }) + }) + }) + + /* + * @tc.number : ActsOsAccountDeviceId_0200 + * @tc.name : queryDistributedVirtualDeviceId promise + * @tc.desc : get distributed virtual device ID + */ + it('ActsOsAccountDeviceId_0200', 0, async function(done){ + console.debug("====>ActsOsAccountDeviceId_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + const deviceId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; + const accountAbility = distributedAccount.getDistributedAccountAbility(); + accountAbility.updateOsAccountDistributedInfo( + { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" + }, async (err)=>{ + console.debug("====>update distributedInfo err:" + JSON.stringify(err)); + console.debug("====>queryDistributedVirtualDeviceId start===="); + var id = await AccountManager.queryDistributedVirtualDeviceId(); + console.debug("====>queryDistributedVirtualDeviceId:" + id); + expect(id).assertEqual(deviceId); + console.debug("====>ActsOsAccountDeviceId_0200 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0100 + * @tc.name : checkOsAccountActivated callback + * @tc.desc : Verify query 0 user status is true + */ + it('ActsOsAccountCheckActived_0100', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.checkOsAccountActivated(0, (err, isActived)=>{ + console.debug("====>checkOsAccountActivated err:" + JSON.stringify(err)); + console.debug("====>checkOsAccountActivated isActived:" + isActived); + expect(err).assertEqual(null); + expect(isActived).assertEqual(true); + console.debug("====>ActsOsAccountCheckActived_0100 end"); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0200 + * @tc.name : checkOsAccountActivated promise + * @tc.desc : Verify query 0 user status is true + */ + it('ActsOsAccountCheckActived_0200', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + var isActived = await AccountManager.checkOsAccountActivated(0); + } + catch(err){ + console.debug("====>catch checkOsAccountActivated err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkOsAccountActivated:" + isActived); + expect(isActived).assertEqual(true); + console.debug("====>ActsOsAccountCheckActived_0200 end"); + done(); + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0300 + * @tc.name : checkOsAccountActivated callback + * @tc.desc : Authentication failed to query the active status of the user that does not exist + */ + it('ActsOsAccountCheckActived_0300', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0300 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var nonExistLocalId = 1000; + AccountManager.checkOsAccountActivated(nonExistLocalId, (err)=>{ + console.debug("====>checkOsAccountActivated err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NOT_EXIST); + console.debug("====>ActsOsAccountCheckActived_0300 end"); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0400 + * @tc.name : checkOsAccountActivated promise + * @tc.desc : Authentication failed to query the active status of the user that does not exist + */ + it('ActsOsAccountCheckActived_0400', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0400 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var nonExistLocalId = 1000; + try{ + await AccountManager.checkOsAccountActivated(nonExistLocalId); + } + catch(err){ + console.debug("====>checkOsAccountActivated err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NOT_EXIST); + console.debug("====>ActsOsAccountCheckActived_0400 end"); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0500 + * @tc.name : checkOsAccountActivated callback + * @tc.desc : Verify that the query active state is not received with parameter type mismatch + */ + it('ActsOsAccountCheckActived_0500', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0500 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + try{ + AccountManager.checkOsAccountActivated(localIdStr, ()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED) + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0600 + * @tc.name : checkOsAccountActivated promise + * @tc.desc : Verify that the query active state is not received with parameter type mismatch + */ + it('ActsOsAccountCheckActived_0600', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0600 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + try{ + AccountManager.checkOsAccountActivated(localIdStr).then(()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED) + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0700 + * @tc.name : checkOsAccountActivated callback + * @tc.desc : Verify that the query active state is not received with parameter undefined + */ + it('ActsOsAccountCheckActived_0700', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0700 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + AccountManager.checkOsAccountActivated(undefined, ()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED) + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckActived_0800 + * @tc.name : checkOsAccountActivated promise + * @tc.desc : Verify that the query active state is not received with parameter undefined + */ + it('ActsOsAccountCheckActived_0800', 0, async function(done){ + console.debug("====>ActsOsAccountCheckActived_0800 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>ActsOsAccountCheckActived_0800 get os AccountManager finish===="); + try{ + AccountManager.checkOsAccountActivated(undefined).then(()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED) + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckMulty_0100 + * @tc.name : checkMultiOsAccountEnabled callback + * @tc.desc : Check whether the function of supporting multiple os account is enabled + */ + it('ActsOsAccountCheckMulty_0100', 0, async function(done){ + console.debug("====>ActsOsAccountCheckMulty_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.checkMultiOsAccountEnabled((err, data)=>{ + console.debug("====>checkMultiOsAccountEnabled err:" + JSON.stringify(err)); + console.debug("====>checkMultiOsAccountEnabled data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual(true); + console.debug("====>ActsOsAccountCheckMulty_0100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckMulty_0200 + * @tc.name : checkMultiOsAccountEnabled promise + * @tc.desc : Check whether the function of supporting multiple os account is enabled + */ + it('ActsOsAccountCheckMulty_0200', 0, async function(done){ + console.debug("====>ActsOsAccountCheckMulty_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + var data = await AccountManager.checkMultiOsAccountEnabled(); + } + catch(err){ + console.debug("====>catch checkMultiOsAccountEnabled err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkMultiOsAccountEnabled data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>ActsOsAccountCheckMulty_0200 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0100 + * @tc.name : checkOsAccountVerified callback + * @tc.desc : Verify that the initial state query is unlocked to false + */ + it('ActsOsAccountCheckVerified_0100', 0, async function(done){ + console.debug("====>checkOsAccountVerified_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.checkOsAccountVerified((err, data)=>{ + console.debug("====>checkOsAccountVerified err:" + JSON.stringify(err)); + console.debug("====>checkOsAccountVerified data:" + data); + expect(err).assertEqual(null); + expect(data).assertEqual(false); + console.debug("====>ActsOsAccountCheckVerified_0100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0200 + * @tc.name : checkOsAccountVerified promise + * @tc.desc : Verify that the initial state query is unlocked to false + */ + it('ActsOsAccountCheckVerified_0200', 0, async function(done){ + console.debug("====>checkOsAccountVerified_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var checkOsAccountVerified = await AccountManager.checkOsAccountVerified(); + console.debug("====>checkOsAccountVerified data:" + JSON.stringify(checkOsAccountVerified)); + expect(checkOsAccountVerified).assertEqual(false); + console.debug("====>ActsOsAccountCheckVerified_0200 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0300 + * @tc.name : checkOsAccountVerified callback + * @tc.desc : Verify that the initial state query 0 user is unlocked to false + */ + it('ActsOsAccountCheckVerified_0300', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0300 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.checkOsAccountVerified(0, (err, data)=>{ + console.debug("====>checkOsAccountVerified err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(data).assertFalse(); + console.debug("====>ActsOsAccountCheckVerified_0300 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0400 + * @tc.name : checkOsAccountVerified promise + * @tc.desc : Verify that the initial state query 0 user is unlocked to false + */ + it('ActsOsAccountCheckVerified_0400', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0400 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var checkOsAccountVerified = await AccountManager.checkOsAccountVerified(0); + console.debug("====>checkOsAccountVerified data:" + JSON.stringify(checkOsAccountVerified)); + expect(checkOsAccountVerified).assertFalse(); + console.debug("====>ActsOsAccountCheckVerified_0400 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0500 + * @tc.name : checkOsAccountVerified callback + * @tc.desc : Verify query "100" user is unlocked failed + */ + it('ActsOsAccountCheckVerified_0500', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0500 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + try{ + AccountManager.checkOsAccountVerified(localIdStr, ()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED); + console.debug("====>ActsOsAccountCheckVerified_0500 end===="); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0600 + * @tc.name : checkOsAccountVerified promise + * @tc.desc : Verify query "100" user is unlocked failed + */ + it('ActsOsAccountCheckVerified_0600', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0600 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + try{ + AccountManager.checkOsAccountVerified(localIdStr).then(()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED) + console.debug("====>ActsOsAccountCheckVerified_0600 end===="); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0700 + * @tc.name : checkOsAccountVerified callback + * @tc.desc : Verify query undefined user is unlocked failed + */ + it('ActsOsAccountCheckVerified_0700', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0700 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdUndefined = undefined; + try{ + AccountManager.checkOsAccountVerified(localIdUndefined, ()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED); + console.debug("====>ActsOsAccountCheckVerified_0700 end===="); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0800 + * @tc.name : checkOsAccountVerified promise + * @tc.desc : Verify query undefined user is unlocked failed + */ + it('ActsOsAccountCheckVerified_0800', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0800 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdUndefined = undefined; + try{ + AccountManager.checkOsAccountVerified(localIdUndefined).then(()=>{ + expect().assertFail(); + done(); + }) + }catch(err){ + expect(err.code).assertEqual(ERR_PARAMETER_CHECK_FAILED) + console.debug("====>ActsOsAccountCheckVerified_0800 end===="); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_0900 + * @tc.name : checkOsAccountVerified callback + * @tc.desc : Verify query does not exist user unlock failed + */ + it('ActsOsAccountCheckVerified_0900', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_0900 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var osAccountLocalId = 1000; + AccountManager.checkOsAccountVerified(osAccountLocalId, (err)=>{ + console.debug("====>checkOsAccountVerified err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NOT_EXIST) + console.debug("====>ActsOsAccountCheckVerified_0900 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckVerified_1000 + * @tc.name : checkOsAccountVerified promise + * @tc.desc : Verify query does not exist user unlock failed + */ + it('ActsOsAccountCheckVerified_1000', 0, async function(done){ + console.debug("====>ActsOsAccountCheckVerified_1000 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var osAccountLocalId = 1000; + try{ + await AccountManager.checkOsAccountVerified(osAccountLocalId); + } + catch(err){ + console.debug("====>checkOsAccountVerified err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_ACCOUNT_NOT_EXIST) + console.debug("====>ActsOsAccountCheckVerified_1000 end===="); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountCheckTest_0100 + * @tc.name : checkOsAccountTestable callback + * @tc.desc : check whether this OS account is a test OS account + */ + it('ActsOsAccountCheckTest_0100', 0, async function(done){ + console.debug("====>ActsOsAccountCheckTest_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.checkOsAccountTestable((err, data)=>{ + console.debug("====>checkOsAccountTestable err:" + JSON.stringify(err)); + console.debug("====>checkOsAccountTestable data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + expect(data).assertEqual(false); + console.debug("====>ActsOsAccountCheckTest_0100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckTest_0200 + * @tc.name : checkOsAccountTestable promise + * @tc.desc : check whether this OS account is a test OS account + */ + it('ActsOsAccountCheckTest_0200', 0, async function(done){ + console.debug("====>ActsOsAccountCheckTest_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var isTest = await AccountManager.checkOsAccountTestable(); + expect(isTest).assertFalse(); + console.debug("====>ActsOsAccountCheckTest_0200 end===="); + done(); + }) + + + }) +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountQuery.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountQuery.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7c6759d517b21a412d1e220a6b5ce2fb55c0c6b3 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountQuery.test.js @@ -0,0 +1,698 @@ +/* + * 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 '@ohos/hypium' + + +const ERR_INVALID_PARAMETER = 12300002; +export default function ActsOsAccountThirdPartyTest_third_4() { + describe('ActsOsAccountThirdPartyTest_third_4', function () { + afterEach(async function (done) { + console.debug("====>afterEach start===="); + var osAccountManager = osaccount.getAccountManager(); + var accounts = await osAccountManager.queryAllCreatedOsAccounts() + for (i=0;iActsOsAccountQueryIdFormUid_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + var testLocalId = await osAccountManager.queryOsAccountLocalIdFromProcess(); + console.debug("====>testLocalId:" + testLocalId) + 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.queryOsAccountLocalIdFromUid(uid, (err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by uid:" + localId); + expect(err).assertEqual(null); + expect(localId).assertEqual(testLocalId); + console.debug("====>ActsOsAccountQueryIdFormUid_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormUid_0200 + * @tc.name : queryOsAccountLocalIdFromUid promise + * @tc.desc : Verify that the user localId is obtained by uid + */ + it('ActsOsAccountQueryIdFormUid_0200', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormUid_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + var testLocalId = await osAccountManager.queryOsAccountLocalIdFromProcess(); + 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.queryOsAccountLocalIdFromUid(uid); + console.debug("====>localId obtained by uid:" + localId); + expect(localId).assertEqual(testLocalId); + console.debug("====>ActsOsAccountQueryIdFormUid_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormUid_0300 + * @tc.name : queryOsAccountLocalIdFromUid callback + * @tc.desc : Authentication failed to query user by uid -1 + */ + it('ActsOsAccountQueryIdFormUid_0300', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormUid_0300 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = -1; + osAccountManager.queryOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by uid:" + localId); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + expect(localId).assertEqual(null); + console.debug("====>ActsOsAccountQueryIdFormUid_0300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormUid_0400 + * @tc.name : queryOsAccountLocalIdFromUid promise + * @tc.desc : Authentication failed to query user by uid -1 + */ + it('ActsOsAccountQueryIdFormUid_0400', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormUid_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = -1; + try{ + await osAccountManager.queryOsAccountLocalIdFromUid(incorrectUid); + }catch(err){ + console.debug("====>get localId by uid err:" +JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsOsAccountQueryIdFormUid_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormUid_0500 + * @tc.name : queryOsAccountLocalIdFromUid callback + * @tc.desc : Authentication failed to query user by uid 2147483648 + */ + it('ActsOsAccountQueryIdFormUid_0500', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormUid_0500 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = 2147483648; + osAccountManager.queryOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by uid:" + localId); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + expect(localId).assertEqual(null); + console.debug("====>ActsOsAccountQueryIdFormUid_0500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormUid_0600 + * @tc.name : queryOsAccountLocalIdFromUid promise + * @tc.desc : Authentication failed to query user by uid 2147483648 + */ + it('ActsOsAccountQueryIdFormUid_0600', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormUid_0600 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = 2147483648; + try{ + await osAccountManager.queryOsAccountLocalIdFromUid(incorrectUid); + }catch(err){ + console.debug("====>get localId by uid err:" +JSON.stringify(err)); + expect(err.code).assertEqual(ERR_INVALID_PARAMETER); + console.debug("====>ActsOsAccountQueryIdFormUid_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormProcess_0100 + * @tc.name : queryOsAccountLocalIdFromProcess callback + * @tc.desc : Verify that the user localId obtained from the current process uid + */ + it('ActsOsAccountQueryIdFormProcess_0100', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormProcess_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + var bundleName = "com.example.actsosaccountthirdpartytest"; + var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + var uid = bundleInfo.uid; + var testLocalId = await osAccountManager.queryOsAccountLocalIdFromUid(uid) + console.debug("====>get AccountManager finish===="); + osAccountManager.queryOsAccountLocalIdFromProcess((err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by process:" + localId); + expect(err).assertEqual(null); + expect(localId).assertEqual(testLocalId); + console.debug("====>ActsOsAccountQueryIdFormProcess_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountQueryIdFormProcess_0200 + * @tc.name : queryOsAccountLocalIdFromProcess promise + * @tc.desc : Verify that the user localId obtained from the current process uid + */ + it('ActsOsAccountQueryIdFormProcess_0200', 0, async function (done) { + console.debug("====>ActsOsAccountQueryIdFormProcess_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + var bundleName = "com.example.actsosaccountthirdpartytest"; + var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + var uid = bundleInfo.uid; + var testLocalId = await osAccountManager.queryOsAccountLocalIdFromUid(uid) + console.debug("====>testLocalId obtained by process:" + testLocalId) + console.debug("====>get AccountManager finish===="); + var localId = await osAccountManager.queryOsAccountLocalIdFromProcess(); + console.debug("====>localId obtained by process:" + localId); + expect(localId).assertEqual(testLocalId); + console.debug("====>ActsOsAccountQueryIdFormProcess_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountgetType_0100 + * @tc.name : getOsAccountType callback + * @tc.desc : Verify that the user type obtained from the current process uid + */ + it('ActsOsAccountgetType_0100', 0, async function (done) { + console.debug("====>ActsOsAccountgetType_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.getOsAccountType((err, accountType)=>{ + console.debug("====>get type err: " + JSON.stringify(err)); + console.debug("====>type obtained by process:" + JSON.stringify(accountType)); + expect(err).assertEqual(null); + expect(accountType.ADMIN).assertEqual(0); + console.debug("====>ActsOsAccountgetType_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountgetType_0200 + * @tc.name : getOsAccountType promise + * @tc.desc : Verify that the user type obtained from the current process uid + */ + it('ActsOsAccountgetType_0200', 0, async function (done) { + console.debug("====>ActsOsAccountgetType_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var accountType = await osAccountManager.getOsAccountType(); + console.debug("====>type obtained by process:" + JSON.stringify(accountType)); + expect(accountType.ADMIN).assertEqual(0); + console.debug("====>ActsOsAccountgetType_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountQueryLocalIdSerial_0100 + * @tc.name : querySerialNumberByOsAccountLocalId callback + * @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber + */ + it('ActsOsAccountQueryLocalIdSerial_0100', 0, async function (done) { + console.debug("====>ActsOsAccountQueryLocalIdSerial_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + var testLocalId = await osAccountManager.queryOsAccountLocalIdFromProcess(); + console.debug("====>get AccountManager finish===="); + osAccountManager.querySerialNumberByOsAccountLocalId(testLocalId, (err, serialNumber)=>{ + console.debug("====>ger serialNumber err:" + JSON.stringify(err)); + console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" ); + expect(err).assertEqual(null); + var serialNumberStr = serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000001"); + osAccountManager.queryOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ + console.debug("====>ger localId err:" + JSON.stringify(err)); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(err).assertEqual(null); + expect(localId).assertEqual(testLocalId); + console.debug("====>ActsOsAccountQueryLocalIdSerial_0100 end===="); + done(); + }) + }) + }); + + /* + * @tc.number : ActsOsAccountQueryLocalIdSerial_0200 + * @tc.name : querySerialNumberByOsAccountLocalId promise + * @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber + */ + it('ActsOsAccountQueryLocalIdSerial_0200', 0, async function (done) { + console.debug("====>ActsOsAccountQueryLocalIdSerial_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + var testLocalId = await osAccountManager.queryOsAccountLocalIdFromProcess(); + console.debug("====>get AccountManager finish===="); + var serialNumber = await osAccountManager.querySerialNumberByOsAccountLocalId(testLocalId); + 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.queryOsAccountLocalIdBySerialNumber(serialNumber); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(localId).assertEqual(testLocalId); + console.debug("====>ActsOsAccountQueryLocalIdSerial_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountQueryLocalIdSerial_0300 + * @tc.name : queryOsAccountLocalIdBySerialNumber callback + * @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber + */ + it('ActsOsAccountQueryLocalIdSerial_0300', 0, async function (done) { + console.debug("====>ActsOsAccountQueryLocalIdSerial_0300 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.querySerialNumberByOsAccountLocalId(0, (err, serialNumber)=>{ + console.debug("====>ger serialNumber err:" + JSON.stringify(err)); + console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" ); + expect(err).assertEqual(null); + var serialNumberStr = serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000000"); + osAccountManager.queryOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ + console.debug("====>ger localId err:" + JSON.stringify(err)); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(err).assertEqual(null); + expect(localId).assertEqual(0); + console.debug("====>ActsOsAccountQueryLocalIdSerial_0300 end===="); + done(); + }) + }) + }); + + /* + * @tc.number : ActsOsAccountQueryLocalIdSerial_0400 + * @tc.name : queryOsAccountLocalIdBySerialNumber promise + * @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber + */ + it('ActsOsAccountQueryLocalIdSerial_0400', 0, async function (done) { + console.debug("====>ActsOsAccountQueryLocalIdSerial_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var serialNumber = await osAccountManager.querySerialNumberByOsAccountLocalId(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.queryOsAccountLocalIdBySerialNumber(serialNumber); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(localId).assertEqual(0); + console.debug("====>ActsOsAccountQueryLocalIdSerial_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountQueryLocalIdSerial_0500 + * @tc.name : querySerialNumberByOsAccountLocalId callback + * @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the + * serialNumber + */ + it('ActsOsAccountQueryLocalIdSerial_0500', 0, async function (done) { + console.debug("====>ActsOsAccountQueryLocalIdSerial_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).assertEqual(null); + expect(data.localName).assertEqual("osAccountNameIdSerialA"); + expect(data.domainInfo.accountName == "").assertEqual(true) + expect(data.type.NORMAL).assertEqual(1); + expect(data.constraints.length > 0).assertEqual(true); + expect(data.isVerified).assertEqual(false); + expect(data.distributedInfo.name != null).assertEqual(true); + expect(data.domainInfo.domain == "").assertEqual(true); + expect(data.photo == "").assertEqual(true); + expect(data.createTime != "").assertEqual(true); + expect(data.lastLoginTime>=0).assertEqual(true); + expect(data.serialNumber.toString().length == 16).assertEqual(true); + expect(data.isActived).assertEqual(false); + expect(data.isCreateCompleted).assertEqual(true) + localId = data.localId; + osAccountManager.querySerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ + console.debug("====>queryOsAccountById err:" + JSON.stringify(err)); + console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId); + expect(err).assertEqual(null); + osAccountManager.queryOsAccountLocalIdBySerialNumber(serialNumber, (err, getlocalId)=>{ + console.debug("====>ger localId err:" + JSON.stringify(err)); + console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber); + expect(err).assertEqual(null); + expect(getlocalId).assertEqual(localId); + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsOsAccountQueryLocalIdSerial_0500 end===="); + done(); + }) + }) + }) + }) + }); + + /* + * @tc.number : ActsOsAccountQueryLocalIdSerial_0600 + * @tc.name : queryOsAccountLocalIdBySerialNumber promise + * @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the + * serialNumber + */ + it('ActsOsAccountQueryLocalIdSerial_0600', 0, async function (done) { + console.debug("====>ActsOsAccountQueryLocalIdSerial_0600 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var localId; + var OsAccountInfo = await osAccountManager.createOsAccount("accountIdSerialB", osaccount.OsAccountType.GUEST); + console.debug("====>create os account OsAccountInfo: " + JSON.stringify(OsAccountInfo)); + expect(OsAccountInfo.localName).assertEqual("accountIdSerialB"); + localId = OsAccountInfo.localId; + var serialNumber = await osAccountManager.querySerialNumberByOsAccountLocalId(localId); + console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId); + var getlocalId = await osAccountManager.queryOsAccountLocalIdBySerialNumber(serialNumber); + console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber); + expect(getlocalId).assertEqual(localId); + await osAccountManager.removeOsAccount(localId); + console.debug("====>ActsOsAccountQueryLocalIdSerial_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountQueryCounts_0100 + * @tc.name : getOsAccountCount callback + * @tc.desc : Verify to obtain the number os all os accounts created + */ + it('ActsOsAccountQueryCounts_0100', 0, async function (done) { + console.debug("====>ActsOsAccountQueryCounts_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var obtainCount = 0; + var localIdFir; + var localIdSec; + osAccountManager.getOsAccountCount((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).assertEqual(null); + 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).assertEqual(null); + 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).assertEqual(null); + expect(data.localName).assertEqual("osAccountIdSerialF"); + osAccountManager.getOsAccountCount((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).assertEqual(null); + count = count - 2; + expect(count).assertEqual(obtainCount); + osAccountManager.removeOsAccount(localIdFir, (err)=>{ + console.debug("====>remove localId: " + localIdFir + " err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + osAccountManager.getOsAccountCount((err, data)=>{ + console.debug("====>obtains the number accounts created err:" + JSON.stringify(err)); + console.debug("====>obtains the number accounts created data:" + data); + expect(err).assertEqual(null); + data = data - 1; + expect(data).assertEqual(obtainCount); + osAccountManager.removeOsAccount(localIdSec, (err)=>{ + console.debug("====>remove localId: " + localIdSec + " err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsOsAccountQueryCounts_0100 end===="); + done(); + }) + }) + }) + }) + }) + }) + }) + }) + + /* + * @tc.number : ActsOsAccountQueryCounts_0200 + * @tc.name : getOsAccountCount promise + * @tc.desc : Verify to obtain the number os all os accounts created + */ + it('ActsOsAccountQueryCounts_0200', 0, async function (done) { + console.debug("====>ActsOsAccountQueryCounts_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var obtainCount = await osAccountManager.getOsAccountCount(); + 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.getOsAccountCount(); + 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.getOsAccountCount(); + 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("====>ActsOsAccountQueryCounts_0200 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountGetActivedOsAccountIds_0100 + * @tc.name : getActivatedOsAccountIds callback + * @tc.desc : query activated osAccount Ids + */ + it('ActsOsAccountGetActivedOsAccountIds_0100', 0, async function (done) { + console.debug("====>ActsOsAccountGetActivedOsAccountIds_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.getActivatedOsAccountIds((err,dataArray)=>{ + console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 err :" + JSON.stringify(err)); + expect(err).assertEqual(null) + console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 dataArray:" + dataArray); + expect(dataArray.length).assertEqual(1) + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountGetActivedOsAccountIds_0200 + * @tc.name : getActivatedOsAccountIds promise + * @tc.desc : query activated osAccount Ids + */ + it('ActsOsAccountGetActivedOsAccountIds_0200', 0, async function (done) { + console.debug("====>ActsOsAccountGetActivedOsAccountIds_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.getActivatedOsAccountIds().then((dataArray)=>{ + console.debug("====>ActsOsAccountGetActivedOsAccountIds_0200 data" + JSON.stringify(dataArray)) + expect(dataArray.length).assertEqual(1) + done(); + }).catch((err)=>{ + console.info("====>ActsOsAccountGetActivedOsAccountIds_0200 err " + JSON.stringify(err)); + expect(err).assertFalse(null) + done(); + }); + }) + + + /* + * @tc.number : ActsOsAccountCheckConstraints_0300 + * @tc.name : Constraints callback + * @tc.desc : get 0 local user all constraints + */ + it('ActsOsAccountCheckConstraints_3100', 0, async function(done){ + console.debug("====>ActsOsAccountCheckConstraints_3100 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + AccountManager.getOsAccountConstraints(0, (err, constraints)=>{ + console.debug("====>getOsAccountConstraints err:" + JSON.stringify(err)); + console.debug("====>getOsAccountConstraints:" + JSON.stringify(constraints)); + expect(err).assertEqual(null); + expect(constraints.length).assertEqual(0); + console.debug("====>ActsOsAccountCheckConstraints_3100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountCheckConstraints_0400 + * @tc.name : Constraints promise + * @tc.desc : get 0 local user all constraints + */ + it('ActsOsAccountCheckConstraints_3200', 0, async function(done){ + console.debug("====>ActsOsAccountCheckConstraints_3200 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("get AccountManager finish===="); + AccountManager.getOsAccountConstraints(0).then((data)=>{ + console.debug("====>ActsOsAccountCheckConstraints_3200 getOsAccountConstraints data:" + data); + done(); + }).catch((err)=>{ + console.debug("====>ActsOsAccountCheckConstraints_3200 getOsAccountConstraints err:" + JSON.stringify(err)); + expect().assertFalse() + done(); + }) + }) + + /** + * @tc.number ActsOsAccountQueryDomainTest_0300 + * @tc.name Test createOsAccountForDomain queryOsAccountLocalIdFromDomain callback + * @tc.desc Test createOsAccountForDomain queryOsAccountLocalIdFromDomain API functionality + */ + it('ActsOsAccountQueryDomainTest_0300', 0, async function (done) { + console.debug("====>ActsOsAccountQueryDomainTest_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.queryOsAccountLocalIdFromDomain({domain: "", accountName: ""}, (err)=>{ + console.debug("====>ActsOsAccountQueryDomainTest_0300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true) + console.debug("====>ActsOsAccountQueryDomainTest_0300 end===="); + done(); + }) + }); + + /** + * @tc.number ActsOsAccountQueryDomainTest_0400 + * @tc.name Test createOsAccountForDomain queryOsAccountLocalIdFromDomain pormise + * @tc.desc Test createOsAccountForDomain queryOsAccountLocalIdFromDomain API functionality + */ + it('ActsOsAccountQueryDomainTest_0400', 0, async function (done) { + console.debug("====>ActsOsAccountQueryDomainTest_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.queryOsAccountLocalIdFromDomain({domain: "", accountName: ""}).then((accountID)=>{ + console.debug("ActsOsAccountQueryDomainTest_0400 accountID:" + JSON.stringify(accountID)) + done(); + }).catch((err)=>{ + console.debug("ActsOsAccountQueryDomainTest_0400 err:" + JSON.stringify(err)) + expect(err.code != 0).assertEqual(true) + done(); + }) + }); + + /* + * @tc.number : ActsOsAccountGetCurrent_2100 + * @tc.name : getCurrentOsAccount callback + * @tc.desc : Get the os account information to which the application belongs + */ + it('ActsOsAccountGetCurrent_2100', 0, async function(done){ + console.debug("====>ActsOsAccountGetCurrent_2100 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.getCurrentOsAccount((err, data)=>{ + console.debug("====>getCurrentOsAccount err:" + JSON.stringify(err)); + console.debug("====>getCurrentOsAccount data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + console.debug("====>ActsOsAccountGetCurrent_2100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountGetCurrent_1800 + * @tc.name : getCurrentOsAccount promise + * @tc.desc : Get the os account information to which the application belongs + */ + it('ActsOsAccountGetCurrent_2200', 0, async function(done){ + console.debug("====>ActsOsAccountGetCurrent_2200 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var data = await AccountManager.getCurrentOsAccount(); + console.debug("====>getCurrentOsAccount data:" + JSON.stringify(data)); + expect(data.localId).assertEqual(100); + expect(data.type.ADMIN).assertEqual(0); + var serialNumberStr = data.serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000001"); + expect(data.isCreateCompleted).assertTrue(); + console.debug("====>ActsOsAccountGetCurrent_2200 end===="); + done(); + }) + + + /* + * @tc.number : ActsOsAccountCheckConstraints_3300 + * @tc.name : checkConstraintEnabled callback + * @tc.desc : the application call interface does not meet the permissions + */ + it('ActsOsAccountCheckConstraints_3300', 0, async function(done){ + console.debug("====>ActsOsAccountCheckConstraints_3300 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.checkConstraintEnabled(100, "constraint.bluetooth", (err, result)=>{ + console.debug("====>checkConstraintEnabled err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(result).assertTrue(); + console.debug("====>ActsOsAccountCheckConstraints_3300 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountPermission_3400 + * @tc.name : checkConstraintEnabled promise + * @tc.desc : the application call interface does not meet the permissions + */ + it('ActsOsAccountCheckConstraints_3400', 0, async function(done){ + console.debug("====>ActsOsAccountCheckConstraints_3400 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + await AccountManager.checkConstraintEnabled(100, "constraint.bluetooth"); + done(); + } + catch(err){ + console.debug("====>checkConstraintEnabled err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsOsAccountCheckConstraints_3400 end===="); + done(); + } + }) + }) +} \ No newline at end of file