From 07d2849f07c23cbbc7f19c5ee5f595027c6bbef6 Mon Sep 17 00:00:00 2001 From: 15829070344 Date: Tue, 23 Aug 2022 09:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B4=A6=E5=8F=B7=E3=80=91XTS?= =?UTF-8?q?=E5=86=BB=E7=BB=93=E9=80=82=E9=85=8D=EF=BC=8CNoPermissi=5F0700/?= =?UTF-8?q?0800?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 15829070344 --- .../src/main/js/test/NoPermission.test.js | 3 +- .../src/main/js/test/OAuthToken.test.js | 4 + .../actsaccounttest/src/main/js/test/OnOff.js | 19 +- .../src/main/js/test/Getallaccounts.test.js | 2 + .../src/main/js/default/pages/index/index.js | 4 +- .../src/main/js/default/pages/index/index.js | 2 + .../src/main/js/test/OsAccountGet.test.js | 195 +++++++++++++++++- .../src/main/js/test/OsAccountIs.test.js | 2 + 8 files changed, 223 insertions(+), 8 deletions(-) mode change 100755 => 100644 account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js diff --git a/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js b/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js index 5fa9b267b..b901cce6d 100755 --- a/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js @@ -198,7 +198,8 @@ export default function ActsAccountNoPermission() { expect(err).assertEqual(null); appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED); + expect(err).assertEqual(null); + expect(data.length>0).assertEqual(true); appAccountManager.deleteAccount("getAll_callback_nopermission", (err)=>{ console.debug("====>delete account 0700 err:" + JSON.stringify(err)); expect(err).assertEqual(null); 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 f9ca813b7..f023feedd 100644 --- a/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js @@ -596,6 +596,10 @@ export default function ActsAccountOAuthToken() { expect(ArrayData.length).assertEqual(1); expect(ArrayData[0].authType).assertEqual("authType"); expect(ArrayData[0].token).assertEqual("test_token"); + expect(ArrayData[0].account).assertEqual(undefined); + expect(ArrayData[0].accounts).assertEqual(undefined); + console.debug("====>test1" + JSON.stringify(ArrayData[0].account)) + console.debug("====>test2" + JSON.stringify(ArrayData[0].accounts)) appAccountManager.deleteAccount(limitName,(err)=>{ console.debug("====>ActsAccountOAuthToken_8500 deleteAccount err:" + JSON.stringify(err)); expect(err).assertEqual(null); diff --git a/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js b/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js index 971f5a097..b4188ed45 100644 --- a/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js @@ -30,7 +30,11 @@ export default function ActsAccountChangeOnOff() { console.info(`sleep #{time} over ...`) }) } - beforeAll(async function (done) { + beforeAll(async function (done) { + done(); + }); + + async function test_init(){ console.debug("====>startAbility start===="); await featureAbility.startAbility( { @@ -46,8 +50,7 @@ export default function ActsAccountChangeOnOff() { }, ); await sleep(TIMEOUT); - done(); - }); + } /* * @tc.number : ActsAccountChangeOnOff_0100 @@ -56,6 +59,7 @@ export default function ActsAccountChangeOnOff() { * the additional information */ it('ActsAccountChangeOnOff_0100', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0100 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); @@ -124,6 +128,7 @@ export default function ActsAccountChangeOnOff() { * the associatal data */ it('ActsAccountChangeOnOff_0200', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0200 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); @@ -187,6 +192,7 @@ export default function ActsAccountChangeOnOff() { * the credential */ it('ActsAccountChangeOnOff_0300', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0300 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); @@ -250,6 +256,7 @@ export default function ActsAccountChangeOnOff() { * authorized account */ it('ActsAccountChangeOnOff_0400', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0400 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); @@ -317,6 +324,7 @@ export default function ActsAccountChangeOnOff() { * the only authorized account */ it('ActsAccountChangeOnOff_0500', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0500 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); @@ -326,14 +334,13 @@ export default function ActsAccountChangeOnOff() { await appAccountManager.enableAppAccess("onoff_delete", "com.example.actsaccountsceneonoff"); function unSubscriberCallback(err){ console.debug("====>unsubscribe 0500 err:" + JSON.stringify(err)); - expect(err).assertEqual(null); - done(); } function subscriberCallback(err, data){ console.debug("====>subscriberCallback 0500 data:" + JSON.stringify(data)); expect(data.event).assertEqual("account_on_change_delete"); expect(data.data).assertEqual("SUCCESS"); commonevent.unsubscribe(subscriber, unSubscriberCallback); + done(); } function publishCallback(err){ console.debug("====>publish call back err:" + JSON.stringify(err)); @@ -376,6 +383,7 @@ export default function ActsAccountChangeOnOff() { * authorized account */ it('ActsAccountChangeOnOff_0600', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0600 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); @@ -447,6 +455,7 @@ export default function ActsAccountChangeOnOff() { * the only authorized account */ it('ActsAccountChangeOnOff_0700', 0, async function (done) { + test_init(); console.debug("====>ActsAccountChangeOnOff_0700 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); 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 34ad23ba2..dace9ca65 100755 --- a/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js +++ b/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js @@ -459,6 +459,8 @@ export default function ActsGetAllAccounts() { var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; try{ var data = await appAccountManager.getAllAccounts(nonexistentBundle); + expect().assertFail(); + done(); } catch(err){ console.debug("====>getAllAccounts 1400 err:" + JSON.stringify(err)); 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 2a4d51d25..769e6af03 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 @@ -14,6 +14,7 @@ */ import account from '@ohos.account.appAccount' import commonevent from '@ohos.commonEvent' +import featureAbility from '@ohos.ability.featureAbility' const ACCOUNT_TEST_ONOFF_EXTRA = 1 const ACCOUNT_TEST_ONOFF_ASSOCIATEDDATA = 2 @@ -46,6 +47,7 @@ export default { appAccountManager.off('change', function (){ console.debug("====>scene off finish===="); }); + featureAbility.terminateSelf() } // Subscribe to the callback of account information changes, verify the received account information, and send @@ -247,7 +249,7 @@ export default { default: console.debug("====>receive event enter default===="); break; - } + } } var subscriber commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ 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 080d2bb3a..172e91fc0 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 @@ -13,6 +13,7 @@ * limitations under the License. */ import account from '@ohos.account.appAccount' +import featureAbility from '@ohos.ability.featureAbility' const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -33,6 +34,7 @@ export default { console.debug("====>add account scene err:" + JSON.stringify(err)); appAccountManager.enableAppAccess("account_name_scene_single", enableBundle, (err)=>{ console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); + featureAbility.terminateSelf() }); }); }, diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js old mode 100755 new mode 100644 index d14f497fd..dd89d0c57 --- a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js @@ -235,7 +235,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() { var osAccountManager = osaccount.getAccountManager(); var testLocalId = await osAccountManager.getOsAccountLocalIdFromProcess(); console.debug("====>get AccountManager finish===="); - osAccountManager.getSerialNumberByOsAccountLocalId(100, (err, serialNumber)=>{ + osAccountManager.getSerialNumberByOsAccountLocalId(testLocalId, (err, serialNumber)=>{ console.debug("====>ger serialNumber err:" + JSON.stringify(err)); console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" ); expect(err).assertEqual(null); @@ -349,6 +349,12 @@ export default function ActsOsAccountThirdPartyTest_third_2() { 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.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ console.debug("====>queryOsAccountById err:" + JSON.stringify(err)); @@ -487,5 +493,192 @@ export default function ActsOsAccountThirdPartyTest_third_2() { console.debug("====>ActsOsAccountGetCount_0200 end===="); done(); }) + + /* + * @tc.number : ActsOsAccountQueryActivedOsAccountIds_0100 + * @tc.name : queryActivatedOsAccountIds callback + * @tc.desc : query activated osAccount Ids + */ + it('ActsOsAccountQueryActivedOsAccountIds_0100', 0, async function (done) { + console.debug("====>ActsOsAccountQueryActivedOsAccountIds_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.queryActivatedOsAccountIds((err,dataArray)=>{ + console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 err :" + JSON.stringify(err)); + expect(err).assertEqual(null) + console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 dataArray" + dataArray.length); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountQueryActivedOsAccountIds_0200 + * @tc.name : queryActivatedOsAccountIds promise + * @tc.desc : query activated osAccount Ids + */ + it('ActsOsAccountQueryActivedOsAccountIds_0200', 0, async function (done) { + console.debug("====>ActsOsAccountQueryActivedOsAccountIds_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.queryActivatedOsAccountIds().then((data)=>{ + console.debug("====>ActsOsAccountQueryActivedOsAccountIds_0200 data" + JSON.stringify(data)) + done(); + }).catch((err)=>{ + console.info("====>ActsOsAccountQueryActivedOsAccountIds_0200 err " + JSON.stringify(err)); + expect(err).assertEqual(null) + done(); + }); + }) + + + /* + * @tc.number : ActsOsAccountConstraints_0300 + * @tc.name : Constraints callback + * @tc.desc : get 0 local user all constraints + */ + it('ActsOsAccountConstraints_3100', 0, async function(done){ + console.debug("====>ActsOsAccountConstraints_3100 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + AccountManager.getOsAccountAllConstraints(0, (err, constraints)=>{ + console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err)); + console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints)); + expect(err).assertEqual(null); + expect(constraints.length).assertEqual(0); + console.debug("====>ActsOsAccountConstraints_3100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountConstraints_0400 + * @tc.name : Constraints promise + * @tc.desc : get 0 local user all constraints + */ + it('ActsOsAccountConstraints_3200', 0, async function(done){ + console.debug("====>ActsOsAccountConstraints_3200 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("get AccountManager finish===="); + AccountManager.getOsAccountAllConstraints(0).then((data)=>{ + console.debug("====>ActsOsAccountConstraints_3200 getOsAccountAllConstraints data:" + data); + done(); + }).catch((err)=>{ + console.debug("====>ActsOsAccountConstraints_3200 getOsAccountAllConstraints err:" + JSON.stringify(err)); + expect().assertFalse() + done(); + }) + }) + + /** + * @tc.number ActsAccountDomainTest_0300 + * @tc.name Test createOsAccountForDomain getOsAccountLocalIdFromDomain callback + * @tc.desc Test createOsAccountForDomain getOsAccountLocalIdFromDomain API functionality + */ + it('ActsOsAccountDomainTest_0300', 0, async function (done) { + console.debug("====>ActsOsAccountDomainTest_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.getOsAccountLocalIdFromDomain({domain: "", accountName: ""}, (err)=>{ + console.debug("====>ActsOsAccountDomainTest_0300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true) + console.debug("====>ActsOsAccountDomainTest_0300 end===="); + done(); + }) + }); + + /** + * @tc.number ActsAccountDomainTest_0400 + * @tc.name Test createOsAccountForDomain getOsAccountLocalIdFromDomain pormise + * @tc.desc Test createOsAccountForDomain getOsAccountLocalIdFromDomain API functionality + */ + it('ActsOsAccountDomainTest_0400', 0, async function (done) { + console.debug("====>ActsOsAccountDomainTest_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + osAccountManager.getOsAccountLocalIdFromDomain({domain: "", accountName: ""}).then((accountID)=>{ + console.debug("ActsOsAccountDomainTest_0400 accountID:" + JSON.stringify(accountID)) + done(); + }).catch((err)=>{ + console.debug("ActsOsAccountDomainTest_0400 err:" + JSON.stringify(err)) + expect(err.code != 0).assertEqual(true) + done(); + }) + }); + + /* + * @tc.number : ActsOsAccountQuery_1700 + * @tc.name : queryCurrentOsAccount callback + * @tc.desc : Get the os account information to which the application belongs + */ + it('ActsOsAccountQuery_2100', 0, async function(done){ + console.debug("====>ActsOsAccountQuery_2100 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.queryCurrentOsAccount((err, data)=>{ + console.debug("====>queryCurrentOsAccount err:" + JSON.stringify(err)); + console.debug("====>queryCurrentOsAccount data:" + JSON.stringify(data)); + expect(err).assertEqual(null); + console.debug("====>ActsOsAccountQuery_2100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountQuery_1800 + * @tc.name : queryCurrentOsAccount promise + * @tc.desc : Get the os account information to which the application belongs + */ + it('ActsOsAccountQuery_2200', 0, async function(done){ + console.debug("====>ActsOsAccountQuery_2200 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var data = await AccountManager.queryCurrentOsAccount(); + console.debug("====>queryCurrentOsAccount 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("====>ActsOsAccountQuery_2200 end===="); + done(); + }) + + + /* + * @tc.number : ActsOsAccountPermission_3300 + * @tc.name : isOsAccountConstraintEnable callback + * @tc.desc : the application call interface does not meet the permissions + */ + it('ActsOsAccountConstraints_3300', 0, async function(done){ + console.debug("====>ActsOsAccountConstraints_3300 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.isOsAccountConstraintEnable(100, "constraint.bluetooth", (err, result)=>{ + console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + expect(result).assertTrue(); + console.debug("====>ActsOsAccountConstraints_3300 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountPermission_3400 + * @tc.name : isOsAccountConstraintEnable promise + * @tc.desc : the application call interface does not meet the permissions + */ + it('ActsOsAccountConstraints_3400', 0, async function(done){ + console.debug("====>ActsOsAccountConstraints_3400 start===="); + var AccountManager = osaccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + await AccountManager.isOsAccountConstraintEnable(100, "constraint.bluetooth"); + done(); + } + catch(err){ + console.debug("====>isOsAccountConstraintEnable err:" + JSON.stringify(err)); + expect(err).assertEqual(null); + console.debug("====>ActsOsAccountConstraints_3400 end===="); + done(); + } + }) }) } \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js index b2f55d16a..1cebbcce2 100755 --- a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js @@ -499,5 +499,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() { console.debug("====>ActsOsAccountIsTest_0200 end===="); done(); }) + + }) } \ No newline at end of file -- GitLab