From 76f3099fb91a9338b64842a244c4590ae4f1825b Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Wed, 24 Nov 2021 16:00:42 +0800 Subject: [PATCH] Update account xts code 1124 Signed-off-by: zhaoyuan17 --- .../src/main/js/test/ExampleJsunit.test.js | 438 +++++++++++++++++- .../entry/src/main/js/test/AddAccount.test.js | 144 +++++- .../entry/src/main/js/test/AppAccess.test.js | 2 +- .../src/main/js/test/AssociatedData.test.js | 2 +- .../src/main/js/test/CreatManager.test.js | 2 +- .../entry/src/main/js/test/Credential.test.js | 2 +- .../src/main/js/test/DeleteAccount.test.js | 164 +++---- .../entry/src/main/js/test/ExtraInfo.test.js | 2 +- .../src/main/js/test/NoPermission.test.js | 2 +- .../entry/src/main/js/test/OAuthToken.test.js | 347 +++++++++++++- .../src/main/js/default/pages/index/index.js | 169 ++++++- 11 files changed, 1146 insertions(+), 128 deletions(-) diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js index 5aa08857f..3452f65f1 100755 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js @@ -45,40 +45,50 @@ describe('ActsAccountChangeOnOff', async function () { * the additional information */ it('ActsAccountChangeOnOff_0100', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0100 start====>"); + console.debug("====>ActsAccountChangeOnOff_0100 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat appAccountManager finish"); console.debug("====>add account ActsAccountChangeOnOff_0100 start"); - await appAccountManager.addAccount("changeonoff_first"); + await appAccountManager.addAccount("changeonoff_extra"); console.debug("====>enableAppAccess ActsAccountChangeOnOff_0100 start"); - await appAccountManager.enableAppAccess("changeonoff_first", "com.example.actsaccountsceneonoff"); + await appAccountManager.enableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff"); function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0100 err:" + JSON.stringify(err)); + console.debug("====>`unsubscribe` 0100 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function disCallback(err){ + console.debug("====>delete account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("changeonoff_extra", deleteAccountCallback); } function subscriberCallback(err, data){ console.debug("====>subscriberCallback 0100 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_change_first"); + expect(data.event).assertEqual("account_on_change_extra"); expect(data.data).assertEqual("SUCCESS"); commonevent.unsubscribe(subscriber, unSubscriberCallback); - done(); + appAccountManager.disableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff", disCallback); } function publishCallback(err){ console.debug("====>publish call back err:" + JSON.stringify(err)); setTimeout(async function (){ console.debug("====>setAccountExtraInfo start===="); - console.debug("====>setAccountExtraInfo ActsAccountChangeOnOff_0100 start"); try{ - await appAccountManager.setAccountExtraInfo("changeonoff_first", "change_extra"); + await appAccountManager.setAccountExtraInfo("changeonoff_extra", "change_extra"); } catch(err){ console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); expect().assertFail(); done(); - } + } + console.debug("====>setAccountExtraInfo finish===="); }, 500) } var commonEventSubscribeInfo = { - events: ["account_on_change_first"] + events: ["account_on_change_extra"] } var subscriber commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ @@ -96,7 +106,413 @@ describe('ActsAccountChangeOnOff', async function () { }, 1000) setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0100====>"); + console.debug("====>time out ActsAccountChangeOnOff_0100===="); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0200 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the associatal data + */ + it('ActsAccountChangeOnOff_0200', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0200 start"); + await appAccountManager.addAccount("onoff_associatedata"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0200 start"); + await appAccountManager.enableAppAccess("onoff_associatedata", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0200 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0200 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_associatedata"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_associatedata", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setAssociatedData start===="); + try{ + await appAccountManager.setAssociatedData("onoff_associatedata", "change_key", "change_value"); + } + catch(err){ + console.error("====>setAssociatedData fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAssociatedData finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_associatedata"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0200 finish====") + }); + + var commonEventPublishData = { + code: 2 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0200===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000) + + setTimeout(function(){ + console.debug("====>time out ActsAccountChangeOnOff_0200===="); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0300 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the credential + */ + it('ActsAccountChangeOnOff_0300', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0300 start"); + await appAccountManager.addAccount("onoff_credential"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0300 start"); + await appAccountManager.enableAppAccess("onoff_credential", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0300 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0300 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_credential"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_credential", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setAccountCredential start===="); + try{ + await appAccountManager.setAccountCredential("onoff_credential", "credentialType", "credential"); + } + catch(err){ + console.error("====>setAccountCredential fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountCredential finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_credential"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0300 finish====") + }); + + var commonEventPublishData = { + code: 3 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0300===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000) + + setTimeout(function(){ + console.debug("====>time out ActsAccountChangeOnOff_0300===="); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0400 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to delete + * authorized account + */ + it('ActsAccountChangeOnOff_0400', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountChangeOnOff_0400 start"); + await appAccountManager.addAccount("onoff_deleteFir"); + console.debug("====>add second account ActsAccountChangeOnOff_0400 start"); + await appAccountManager.addAccount("onoff_deleteSec"); + console.debug("====>enableAppAccess first ActsAccountChangeOnOff_0400 start"); + await appAccountManager.enableAppAccess("onoff_deleteFir", "com.example.actsaccountsceneonoff"); + console.debug("====>enableAppAccess second ActsAccountChangeOnOff_0400 start"); + await appAccountManager.enableAppAccess("onoff_deleteSec", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0400 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0400 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_delete_another"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_deleteFir", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>deleteAccount start===="); + try{ + await appAccountManager.deleteAccount("onoff_deleteSec"); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>deleteAccount finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_delete_another"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0400 finish====") + }); + + var commonEventPublishData = { + code: 4 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0400===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000) + + setTimeout(function(){ + console.debug("====>time out ActsAccountChangeOnOff_0400===="); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0500 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to delete + * the only authorized account + */ + it('ActsAccountChangeOnOff_0500', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0500 start"); + await appAccountManager.addAccount("onoff_delete"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0500 start"); + await appAccountManager.enableAppAccess("onoff_delete", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + 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); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>deleteAccount start===="); + try{ + await appAccountManager.deleteAccount("onoff_delete"); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>deleteAccount finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_delete"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0500 finish====") + }); + + var commonEventPublishData = { + code: 5 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0500===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000) + + setTimeout(function(){ + console.debug("====>time out ActsAccountChangeOnOff_0500===="); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0600 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to cancel + * authorized account + */ + it('ActsAccountChangeOnOff_0600', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountChangeOnOff_0600 start"); + await appAccountManager.addAccount("onoff_enableFir"); + console.debug("====>add second account ActsAccountChangeOnOff_0600 start"); + await appAccountManager.addAccount("onoff_enableSec"); + console.debug("====>enableAppAccess first ActsAccountChangeOnOff_0600 start"); + await appAccountManager.enableAppAccess("onoff_enableFir", "com.example.actsaccountsceneonoff"); + console.debug("====>enableAppAccess second ActsAccountChangeOnOff_0600 start"); + await appAccountManager.enableAppAccess("onoff_enableSec", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0600 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete first account 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("onoff_enableSec", (err)=>{ + console.debug("====>delete second account 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + }); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0600 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_disable_another"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_enableFir", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>disableAppAccess start===="); + try{ + await appAccountManager.disableAppAccess("onoff_enableSec", "com.example.actsaccountsceneonoff"); + } + catch(err){ + console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_disable_another"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0600 finish====") + }); + + var commonEventPublishData = { + code: 6 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0600===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000) + + setTimeout(function(){ + console.debug("====>time out ActsAccountChangeOnOff_0600===="); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0700 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to cancel + * the only authorized account + */ + it('ActsAccountChangeOnOff_0700', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0700 start"); + await appAccountManager.addAccount("onoff_disable"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0700 start"); + await appAccountManager.enableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0700 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_disable"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>disableAppAccess start===="); + try{ + await appAccountManager.disableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); + } + catch(err){ + console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_disable"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0700 finish====") + }); + + var commonEventPublishData = { + code: 7 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0700===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000) + + setTimeout(function(){ + console.debug("====>time out ActsAccountChangeOnOff_0700===="); }, TIMEOUT); }); }) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js index 07b1d7c7d..a037e04ae 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js @@ -15,7 +15,8 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const STRCOUNT = 1025; +const NAMELIMIT = 512; +const LENGTHLIMIT = 1024; describe('ActsAccountAddAccount', function () { /* @@ -159,16 +160,16 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0700 * @tc.name : Add account calllback form - * @tc.desc : The account name exceeds the length limit of 1024 + * @tc.desc : The account name exceeds the length limit of 512 characters */ it('ActsAccountAddAccount_0700', 0, async function (done) { console.debug("====>ActsAccountAddAccount_0700 start===="); - var bigAccountName = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigAccountName += 't'; + var limitAccountName = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + limitAccountName += 't'; } var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount(bigAccountName, "account_extraInfo_callback_fourth", (err)=>{ + appAccountManager.addAccount(limitAccountName, "account_extraInfo_callback_fourth", (err)=>{ console.debug("====>add account ActsAccountAddAccount_0700 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); console.debug("====>ActsAccountAddAccount_0700 end===="); @@ -179,17 +180,17 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0800 * @tc.name : Add account promise form - * @tc.desc : The account name exceeds the length limit of 1024 + * @tc.desc : The account name exceeds the length limit of 512 characters */ it('ActsAccountAddAccount_0800', 0, async function (done) { console.debug("====>ActsAccountAddAccount_0800 start===="); - var bigStr = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigStr += 't'; + var limitAccountName = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + limitAccountName += 'n'; } var appAccountManager = account.createAppAccountManager(); try{ - await appAccountManager.addAccount(bigStr, "account_extraInfo_promise_fourth"); + await appAccountManager.addAccount(limitAccountName, "account_extraInfo_promise_fourth"); } catch(err){ console.debug("====>add account ActsAccountAddAccount_0800 err:" + JSON.stringify(err)); @@ -202,16 +203,16 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0900 * @tc.name : Add account calllback form - * @tc.desc : Additional information exceeds the length limit of 1024 + * @tc.desc : Additional information exceeds the length limit of 1024 characters */ it('ActsAccountAddAccount_0900', 0, async function (done) { console.debug("====>ActsAccountAddAccount_0900 start===="); - var bigExtraInfo = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigExtraInfo += 't'; + var limitAccountExtra = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitAccountExtra += 't'; } var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_name_callback_fifth", bigExtraInfo, (err)=>{ + appAccountManager.addAccount("account_name_callback_fifth", limitAccountExtra, (err)=>{ console.debug("====>add account ActsAccountAddAccount_0900 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); console.debug("====>ActsAccountAddAccount_0900 end===="); @@ -222,17 +223,17 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_1000 * @tc.name : Add account promise form - * @tc.desc : Additional information exceeds the length limit of 1024 + * @tc.desc : Additional information exceeds the length limit of 1024 characters */ it('ActsAccountAddAccount_1000', 0, async function (done) { console.debug("====>ActsAccountAddAccount_1000 start===="); - var bigStrExtra = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigStrExtra += 't'; + var limitAccountExtra = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitAccountExtra += 'e'; } var appAccountManager = account.createAppAccountManager(); try{ - await appAccountManager.addAccount("account_name_promise_fifth", bigStrExtra); + await appAccountManager.addAccount("account_name_promise_fifth", limitAccountExtra); } catch(err){ console.debug("====>add account ActsAccountAddAccount_1000 err:" + JSON.stringify(err)); @@ -539,4 +540,105 @@ describe('ActsAccountAddAccount', function () { done(); } }); + + /* + * @tc.number : ActsAccountAddAccount_2500 + * @tc.name : Add account calllback form + * @tc.desc : The account name reaches the limit of 512 characters + */ + it('ActsAccountAddAccount_2500', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2500 start===="); + var limitName = ''; + for (var i = 0; i < NAMELIMIT; i++) { + limitName += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount(limitName, "account_extraInfo_callback", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount(limitName, (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_2500 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2600 + * @tc.name : Add account promise form + * @tc.desc : The account name reaches the limit of 512 characters + */ + it('ActsAccountAddAccount_2600', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2600 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountAddAccount_2600 start===="); + try{ + await appAccountManager.addAccount(nameLimit, "account_extraInfo_promise"); + } + catch(err){ + console.error("====>add account ActsAccountAddAccount_2600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_2600 start===="); + await appAccountManager.deleteAccount(nameLimit); + console.debug("====>ActsAccountAddAccount_2600 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_2700 + * @tc.name : Add account calllback form + * @tc.desc : Additional information reaches the limit of 1024 characters + */ + it('ActsAccountAddAccount_2700', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2700 start===="); + var limitExtra = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + limitExtra += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_extra_callback_limit", limitExtra, (err)=>{ + console.debug("====>add account ActsAccountAddAccount_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_extra_callback_limit", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_2700 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2800 + * @tc.name : Add account promise form + * @tc.desc : Additional information reaches the limit of 1024 characters + */ + it('ActsAccountAddAccount_2800', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2800 start===="); + var extraLimit = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + extraLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount("account_extra_promise_limit", extraLimit); + } + catch(err){ + console.error("====>add account ActsAccountAddAccount_2800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_2800 start===="); + appAccountManager.deleteAccount("account_extra_promise_limit"); + console.debug("====>ActsAccountAddAccount_2800 end===="); + done(); + }); }) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js index ffdf6c181..1efef799a 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; const STRCOUNT = 1025; describe('ActsAccountAppAccess', function () { function sleep(delay) { diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js index 38c4dec1e..32e906f35 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; describe('ActsAccountAssociatedData', function () { function sleep(delay) { var start = (new Date()).getTime(); diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js index fea28ae05..7013de12f 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; describe('ActsCreatAppAccountManager', function () { function sleep(delay) { var start = (new Date()).getTime(); diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js index 8f6dd8139..d6cfb932e 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; describe('ActsAccountCredential', function () { function sleep(delay) { var start = (new Date()).getTime(); diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js index 250208234..c46c59ff2 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; const STRCOUNT = 1025; describe('ActsAccountDeleteAccount', function () { function sleep(delay) { @@ -55,169 +55,169 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0200 - * @tc.name : Delete account calllback form - * @tc.desc : Delete unadded account in callback form + * @tc.name : Delete account promise form + * @tc.desc : Delete the added account in promise form */ - it('ActsAccountDeleteAccount_0200', 0, async function (done) { + it('ActsAccountDeleteAccount_0200',0,async function (done){ console.debug("====>ActsAccountDeleteAccount_0200 start===="); var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{ - console.debug("====>delete Account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); + console.debug("====>add account ActsAccountAddAccount_0200 start===="); + await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first"); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_first"); console.debug("====>ActsAccountDeleteAccount_0200 end===="); done(); - }); + } + catch(err){ + console.error("====>delete account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } }); /* * @tc.number : ActsAccountDeleteAccount_0300 * @tc.name : Delete account calllback form - * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails + * @tc.desc : Delete unadded account in callback form */ it('ActsAccountDeleteAccount_0300', 0, async function (done) { console.debug("====>ActsAccountDeleteAccount_0300 start===="); var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{ - console.debug("====>add account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{ - console.debug("====>delete account first time err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{ - console.debug("====>delete Account second time err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0300 end===="); - done(); - }); - }); + console.debug("====>creat finish===="); + appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0300 end===="); + done(); }); }); /* * @tc.number : ActsAccountDeleteAccount_0400 - * @tc.name : Delete account calllback form - * @tc.desc : Delete the account name exceeds the length limit of 1024 + * @tc.name : Delete account promise form + * @tc.desc : Delete unadded account in promise form */ - it('ActsAccountDeleteAccount_0400',0, async function (done){ + it('ActsAccountDeleteAccount_0400', 0, async function(done){ console.debug("====>ActsAccountDeleteAccount_0400 start===="); - var bigStr = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigStr += 't'; - } var appAccountManager = account.createAppAccountManager(); - appAccountManager.deleteAccount(bigStr, (err)=>{ - console.debug("====>delete Account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err)); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_second"); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); console.debug("====>ActsAccountDeleteAccount_0400 end===="); done(); - }); + } }); /* * @tc.number : ActsAccountDeleteAccount_0500 * @tc.name : Delete account calllback form - * @tc.desc : Delete the account name is an empty string + * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails */ - it('ActsAccountDeleteAccount_0500',0, async function (done){ + it('ActsAccountDeleteAccount_0500', 0, async function (done) { console.debug("====>ActsAccountDeleteAccount_0500 start===="); var appAccountManager = account.createAppAccountManager(); - appAccountManager.deleteAccount("", (err)=>{ - console.debug("====>delete Account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0500 end===="); - done(); + appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{ + console.debug("====>add account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{ + console.debug("====>delete account first time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{ + console.debug("====>delete Account second time err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0500 end===="); + done(); + }); + }); }); }); /* * @tc.number : ActsAccountDeleteAccount_0600 * @tc.name : Delete account promise form - * @tc.desc : Delete the added account in promise form + * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails */ - it('ActsAccountDeleteAccount_0600',0,async function (done){ + it('ActsAccountDeleteAccount_0600', 0, async function (done){ console.debug("====>ActsAccountDeleteAccount_0600 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>add account ActsAccountAddAccount_0600 start===="); - await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first"); + await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third"); + console.debug("====>delete Account first time ActsAccountDeleteAccount_0600 start===="); + await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); + console.debug("====>delete Account second time ActsAccountDeleteAccount_0600 start===="); try{ - await appAccountManager.deleteAccount("deleteAccount_name_promise_first"); - console.debug("====>ActsAccountDeleteAccount_0600 end===="); - done(); + await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); } catch(err){ - console.error("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err)); - expect().assertFail(); + console.debug("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0600 end===="); done(); } }); /* * @tc.number : ActsAccountDeleteAccount_0700 - * @tc.name : Delete account promise form - * @tc.desc : Delete unadded account in promise form + * @tc.name : Delete account calllback form + * @tc.desc : Delete the account name exceeds the length limit of 1024 */ - it('ActsAccountDeleteAccount_0700', 0, async function(done){ + it('ActsAccountDeleteAccount_0700',0, async function (done){ console.debug("====>ActsAccountDeleteAccount_0700 start===="); - var appAccountManager = account.createAppAccountManager(); - try{ - await appAccountManager.deleteAccount("deleteAccount_name_promise_second"); + var bigStr = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigStr += 't'; } - catch(err){ - console.debug("====>delete account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteAccount(bigStr, (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); console.debug("====>ActsAccountDeleteAccount_0700 end===="); done(); - } + }); }); /* * @tc.number : ActsAccountDeleteAccount_0800 * @tc.name : Delete account promise form - * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails + * @tc.desc : Delete the account name exceeds the length limit of 1024 */ it('ActsAccountDeleteAccount_0800', 0, async function (done){ console.debug("====>ActsAccountDeleteAccount_0800 start===="); + var bigStr = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigStr += 't'; + } var appAccountManager = account.createAppAccountManager(); - console.debug("====>add account ActsAccountAddAccount_0800 start===="); - await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third"); - console.debug("====>delete Account first time ActsAccountDeleteAccount_0800 start===="); - await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); - console.debug("====>delete Account second time ActsAccountDeleteAccount_0800 start===="); + console.debug("====>delete Account ActsAccountDeleteAccount_0800 start===="); try{ - await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); + await appAccountManager.deleteAccount(bigStr); } catch(err){ - console.debug("====>delete account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); + console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0700 end===="); + console.debug("====>ActsAccountDeleteAccount_0800 end===="); done(); } - }); + }) /* * @tc.number : ActsAccountDeleteAccount_0900 - * @tc.name : Delete account promise form - * @tc.desc : Delete the account name exceeds the length limit of 1024 + * @tc.name : Delete account calllback form + * @tc.desc : Delete the account name is an empty string */ - it('ActsAccountDeleteAccount_0900', 0, async function (done){ + it('ActsAccountDeleteAccount_0900',0, async function (done){ console.debug("====>ActsAccountDeleteAccount_0900 start===="); - var bigStr = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigStr += 't'; - } var appAccountManager = account.createAppAccountManager(); - console.debug("====>delete Account ActsAccountDeleteAccount_0900 start===="); - try{ - await appAccountManager.deleteAccount(bigStr); - } - catch(err){ - console.debug("====>delete account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err)); + appAccountManager.deleteAccount("", (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); console.debug("====>ActsAccountDeleteAccount_0900 end===="); done(); - } - }) + }); + }); /* * @tc.number : ActsAccountDeleteAccount_1000 diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js index ee3d581d8..3987b7aab 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; describe('ActsAccountSetGetExtraInfo', function () { function sleep(delay) { var start = (new Date()).getTime(); diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js index 8053a94f1..d8fa94b90 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js @@ -15,7 +15,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521990; describe('ActsAccountNoPermission', function () { function sleep(delay) { diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js index 649995589..e0fbdff93 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js @@ -15,7 +15,8 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 10000; +const TIMEOUT = 1000; +const LENGTHLIMIT = 1024; describe('ActsAccountOAuthToken', function () { function sleep(delay) { var start = (new Date()).getTime(); @@ -559,4 +560,348 @@ describe('ActsAccountOAuthToken', function () { console.debug("====>ActsAccountOAuthToken_2000 end===="); done(); }); + + /* + * @tc.number : ActsAccountOAuthToken_2100 + * @tc.name : Test oauth token in callback form + * @tc.desc : Get the token after setting the token to an empty string + */ + it('ActsAccountOAuthToken_2100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_callback_empty", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_empty", "", (err)=>{ + console.debug("====>setOAuthToken 2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_empty", (err, data)=>{ + console.debug("====>getOAuthToken 2100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 2100 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_empty", (err)=>{ + console.debug("====>delete Account 2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2200 + * @tc.name : Test oauth token in promise form + * @tc.desc : Get the token after setting the token to an empty string + */ + it('ActsAccountOAuthToken_2200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_2200 start===="); + await appAccountManager.addAccount("accountToken_promise_empty"); + console.debug("====>setOAuthToken 2200 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_empty", ""); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_empty"); + expect(data).assertEqual(""); + await appAccountManager.deleteAccount("accountToken_promise_empty"); + console.debug("====>ActsAccountOAuthToken_2000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2300 + * @tc.name : Test oauth token in callback form + * @tc.desc : Get the token after setting the token to a space string + */ + it('ActsAccountOAuthToken_2300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_callback_space", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_space", " ", (err)=>{ + console.debug("====>setOAuthToken 2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_space", (err, data)=>{ + console.debug("====>getOAuthToken 2300 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 2300 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(" "); + appAccountManager.deleteAccount("account_callback_space", (err)=>{ + console.debug("====>delete Account 2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2300 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2400 + * @tc.name : Test oauth token in promise form + * @tc.desc : Get the token after setting the token to a space string + */ + it('ActsAccountOAuthToken_2400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_2400 start===="); + await appAccountManager.addAccount("accountToken_promise_space"); + console.debug("====>setOAuthToken 2400 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_space", " "); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2400 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_space"); + expect(data).assertEqual(" "); + await appAccountManager.deleteAccount("accountToken_promise_space"); + console.debug("====>ActsAccountOAuthToken_2400 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2500 + * @tc.name : Test oauth token in callback form + * @tc.desc : Set the length of the token to exceed the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_2500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2500 start===="); + var limitToken = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitToken += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_callback_lengthlimit", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_lengthlimit", limitToken, (err)=>{ + console.debug("====>setOAuthToken 2500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_lengthlimit", (err)=>{ + console.debug("====>delete Account 2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2600 + * @tc.name : Test oauth token in promise form + * @tc.desc : Set the length of the token to exceed the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_2600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2600 start===="); + var limitToken = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitToken += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_2600 start===="); + await appAccountManager.addAccount("account_promise_lengthlimit"); + console.debug("====>setOAuthToken 2600 start===="); + try{ + await appAccountManager.setOAuthToken("account_promise_lengthlimit", limitToken); + } + catch(err){ + console.debug("====>setOAuthToken ActsAccountOAuthToken_2600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountOAuthToken_2600 start===="); + await appAccountManager.deleteAccount("account_promise_lengthlimit"); + console.debug("====>ActsAccountOAuthToken_2600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_2700 + * @tc.name : Test oauth token in callback form + * @tc.desc : Set the length of the token to just reach the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_2700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2700 start===="); + var tokenLimit = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + tokenLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_callback_limit", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_limit", tokenLimit, (err)=>{ + console.debug("====>setOAuthToken 2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_limit", (err, data)=>{ + console.debug("====>getOAuthToken 2700 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 2700 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(tokenLimit); + appAccountManager.deleteAccount("account_callback_limit", (err)=>{ + console.debug("====>delete Account 2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2700 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2800 + * @tc.name : Test oauth token in promise form + * @tc.desc : Set the length of the token to just reach the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_2800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2800 start===="); + var tokenLimit = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + tokenLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_2800 start===="); + await appAccountManager.addAccount("accountToken_promise_limit"); + console.debug("====>setOAuthToken 2400 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_limit", tokenLimit); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2800 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_limit"); + expect(data).assertEqual(tokenLimit); + await appAccountManager.deleteAccount("accountToken_promise_limit"); + console.debug("====>ActsAccountOAuthToken_2800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2900 + * @tc.name : Test oauth token in callback form + * @tc.desc : Clear token parameter name is an empty string + */ + it('ActsAccountOAuthToken_2900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.clearOAuthToken("", (err)=>{ + console.debug("====>clearOAuthToken 2900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1900 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_3000 + * @tc.name : Test oauth token in promise form + * @tc.desc : Clear token parameter name is an empty string + */ + it('ActsAccountOAuthToken_3000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>clearOAuthToken 3000 start===="); + try{ + await appAccountManager.clearOAuthToken(""); + } + catch(err){ + console.debug("====>clearOAuthToken ActsAccountOAuthToken_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_3100 + * @tc.name : Test oauth token in callback form + * @tc.desc : The clear token parameter name is a space string + */ + it('ActsAccountOAuthToken_3100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.clearOAuthToken(" ", (err)=>{ + console.debug("====>clearOAuthToken 3100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_3200 + * @tc.name : Test oauth token in promise form + * @tc.desc : The clear token parameter name is a space string + */ + it('ActsAccountOAuthToken_3200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>clearOAuthToken 3200 start===="); + try{ + await appAccountManager.clearOAuthToken(" "); + } + catch(err){ + console.debug("====>clearOAuthToken ActsAccountOAuthToken_3200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_3300 + * @tc.name : Test oauth token in callback form + * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_3300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3300 start===="); + var nameLimit = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.clearOAuthToken(nameLimit, (err)=>{ + console.debug("====>clearOAuthToken first 3300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_3400 + * @tc.name : Test oauth token in promise form + * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_3400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3400 start===="); + var nameLimit = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>clearOAuthToken first 3400 start===="); + try{ + await appAccountManager.clearOAuthToken(nameLimit); + } + catch(err){ + console.debug("====>clearOAuthToken ActsAccountOAuthToken_3400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3400 end===="); + done(); + } + }); }) \ No newline at end of file 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 2823edb32..901d37a0e 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 @@ -36,26 +36,158 @@ export default { console.debug("====>scene off finish===="); }); } - function changeOnCallbackFirst(data){ + function changeOnExtra(data){ console.debug("====>receive change 0100 data:" + JSON.stringify(data)); try{ - if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_first"){ + if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_extra"){ var commonEventPublishData = { data: "SUCCESS" } - commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback); + commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback); }else{ var commonEventPublishData = { data: "FAIL" } - commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback); + commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback); } } catch(err){ var commonEventPublishData = { data: "FAIL" } - commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback); + commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback); + } + } + function changeOnAssociateData(data){ + console.debug("====>receive change 0200 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_associatedata"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback); + } + } + function changeOnCredential(data){ + console.debug("====>receive change 0300 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_credential"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback); + } + } + function changeOnDeleteAnother(data){ + console.debug("====>receive change 0400 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_deleteFir"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback); + } + } + function changeOnDelete(data){ + console.debug("====>receive change 0500 data:" + JSON.stringify(data)); + try{ + if(data.length == 0){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback); + } + } + function changeOnDisableAnother(data){ + console.debug("====>receive change 0600 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_enableFir"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback); + } + } + function changeOnDisable(data){ + console.debug("====>receive change 0700 data:" + JSON.stringify(data)); + try{ + if(data.length == 0){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback); } } function subscriberCallback(err, data){ @@ -64,13 +196,36 @@ export default { switch(data.code){ case 1: console.debug("====>receive event 0100 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCallbackFirst); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnExtra); + break; + case 2: + console.debug("====>receive event 0200 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnAssociateData); + break; + case 3: + console.debug("====>receive event 0300 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCredential); + break; + case 4: + console.debug("====>receive event 0400 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDeleteAnother); + break; + case 5: + console.debug("====>receive event 0500 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDelete); + break; + case 6: + console.debug("====>receive event 0600 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisableAnother); + break; + case 7: + console.debug("====>receive event 0700 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisable); break; default: console.debug("====>receive event enter default===="); break; } - } var subscriber commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ -- GitLab