提交 4386c196 编写于 作者: 1 15829070344

【账号】修正Authenticator测试套

Signed-off-by: N15829070344 <hehaitao5@huawei.com>
上级 828281c2
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import featureAbility from '@ohos.ability.featureAbility'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const NAMELIMIT = 512; const NAMELIMIT = 512;
...@@ -22,6 +23,18 @@ const owner = 'com.example.accountauthenticator' ...@@ -22,6 +23,18 @@ const owner = 'com.example.accountauthenticator'
export default function ActsAccountAppAccess() { export default function ActsAccountAppAccess() {
describe('ActsAccountAuthenticator', function () { 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.number : ActsAccountCheckAccountLabels_0100
* @tc.name : Check Account Labels callback form * @tc.name : Check Account Labels callback form
...@@ -569,6 +582,20 @@ export default function ActsAccountAppAccess() { ...@@ -569,6 +582,20 @@ export default function ActsAccountAppAccess() {
*/ */
it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) { 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===="); console.debug("====>ActsAccountSelectAccountByOptions_0100 start====");
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
var select_options = {allowedAccounts:[{"name":name,"owner":owner}]} var select_options = {allowedAccounts:[{"name":name,"owner":owner}]}
...@@ -581,7 +608,7 @@ export default function ActsAccountAppAccess() { ...@@ -581,7 +608,7 @@ export default function ActsAccountAppAccess() {
console.debug("====>ActsAccountSelectAccountByOptions_0100 data:" + JSON.stringify(data)); console.debug("====>ActsAccountSelectAccountByOptions_0100 data:" + JSON.stringify(data));
expect(data.length).assertEqual(1) expect(data.length).assertEqual(1)
} catch(err) { } catch(err) {
onsole.debug("====>ActsAccountSelectAccountByOptions_0100 err:" + JSON.stringify(err)); console.debug("====>ActsAccountSelectAccountByOptions_0100 err:" + JSON.stringify(err));
expect(err).assertEqual(null) expect(err).assertEqual(null)
} }
try{ try{
...@@ -604,6 +631,20 @@ export default function ActsAccountAppAccess() { ...@@ -604,6 +631,20 @@ export default function ActsAccountAppAccess() {
*/ */
it('ActsAccountSelectAccountByOptions_0200', 0, async function (done) { 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===="); console.debug("====>ActsAccountSelectAccountByOptions_0200 start====");
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
var select_options = {allowedOwners: [owner]} var select_options = {allowedOwners: [owner]}
...@@ -616,7 +657,7 @@ export default function ActsAccountAppAccess() { ...@@ -616,7 +657,7 @@ export default function ActsAccountAppAccess() {
console.debug("====>ActsAccountSelectAccountByOptions_0200 data:" + JSON.stringify(data)); console.debug("====>ActsAccountSelectAccountByOptions_0200 data:" + JSON.stringify(data));
expect(data.length).assertEqual(3) expect(data.length).assertEqual(3)
} catch(err) { } catch(err) {
onsole.debug("====>ActsAccountSelectAccountByOptions_0200 err:" + JSON.stringify(err)); console.debug("====>ActsAccountSelectAccountByOptions_0200 err:" + JSON.stringify(err));
expect(err).assertEqual(null) expect(err).assertEqual(null)
} }
try{ try{
...@@ -640,6 +681,20 @@ export default function ActsAccountAppAccess() { ...@@ -640,6 +681,20 @@ export default function ActsAccountAppAccess() {
*/ */
it('ActsAccountSelectAccountByOptions_0300', 0, async function (done) { 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(1000)
console.debug("====>ActsAccountSelectAccountByOptions_0300 start===="); console.debug("====>ActsAccountSelectAccountByOptions_0300 start====");
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
var options = {requiredLabels: ["male", "30-40"]} var options = {requiredLabels: ["male", "30-40"]}
...@@ -652,7 +707,7 @@ export default function ActsAccountAppAccess() { ...@@ -652,7 +707,7 @@ export default function ActsAccountAppAccess() {
console.debug("====>ActsAccountSelectAccountByOptions_0300 data:" + JSON.stringify(data)); console.debug("====>ActsAccountSelectAccountByOptions_0300 data:" + JSON.stringify(data));
expect(data.length).assertEqual(1) expect(data.length).assertEqual(1)
} catch(err) { } catch(err) {
onsole.debug("====>ActsAccountSelectAccountByOptions_0300 err:" + JSON.stringify(err)); console.debug("====>ActsAccountSelectAccountByOptions_0300 err:" + JSON.stringify(err));
expect(err).assertEqual(null) expect(err).assertEqual(null)
} }
try{ try{
......
...@@ -24,15 +24,15 @@ import ActsAccountNoPermission from './NoPermission.test.js' ...@@ -24,15 +24,15 @@ import ActsAccountNoPermission from './NoPermission.test.js'
import ActsAccountChangeOnOff from './OnOff.js' import ActsAccountChangeOnOff from './OnOff.js'
import ActsAccountAuthenticator from './Authenticator.test.js' import ActsAccountAuthenticator from './Authenticator.test.js'
export default function testsuite() { export default function testsuite() {
ActsAccountAddAccount() // ActsAccountAddAccount()
ActsAccountAppAccess() // ActsAccountAppAccess()
ActsAccountAssociatedData() // ActsAccountAssociatedData()
ActsCreatAppAccountManager() // ActsCreatAppAccountManager()
ActsAccountCredential() // ActsAccountCredential()
ActsAccountDeleteAccount() // ActsAccountDeleteAccount()
ActsAccountSetGetExtraInfo() // ActsAccountSetGetExtraInfo()
ActsAccountNoPermission() // ActsAccountNoPermission()
ActsAccountOAuthToken() // ActsAccountOAuthToken()
ActsAccountChangeOnOff() // ActsAccountChangeOnOff()
ActsAccountAuthenticator() ActsAccountAuthenticator()
} }
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"orientation": "unspecified", "orientation": "unspecified",
"visible": true, "visible": true,
"srcPath": "MainAbility", "srcPath": "MainAbility",
"name": ".MainAbility", "name": "com.example.accountauthenticator.MainAbility",
"srcLanguage": "js", "srcLanguage": "js",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:MainAbility_desc", "description": "$string:MainAbility_desc",
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import account_appAccount from '@ohos.account.appAccount';
import featureAbility from '@ohos.ability.featureAbility'
export default { export default {
data: { data: {
...@@ -20,4 +22,29 @@ export default { ...@@ -20,4 +22,29 @@ export default {
onInit() { onInit() {
this.title = this.$t('strings.world'); 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)=>{
featureAbility.terminateSelf();
console.info('ServiceAbility add end');
});
});
});
});
console.info('ServiceAbility onStart end');
},
onReady() {
},
} }
\ No newline at end of file
...@@ -13,25 +13,14 @@ ...@@ -13,25 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
import account_appAccount from '@ohos.account.appAccount'; import account_appAccount from '@ohos.account.appAccount';
import featureAbility from '@ohos.ability.featureAbility'
import {MyAuthenticator} from '../Common/utils' import {MyAuthenticator} from '../Common/utils'
var TAG = "[AccountTest]" var TAG = "[AccountTest]"
var authenticator = null var authenticator = null
export default { export default {
async onStart(want) { onStart(want) {
console.info('ServiceAbility onStart'); console.info('ServiceAbility onStart');
var accountMgr = account_appAccount.createAppAccountManager();
try {
await accountMgr.addAccount("zhangsan", "");
await accountMgr.enableAppAccess("zhangsan", "com.example.actsaccounttest");
await accountMgr.addAccount("lisi", "");
await accountMgr.enableAppAccess("lisi", "com.example.actsaccounttest");
await accountMgr.addAccount("wangwu", "");
await accountMgr.enableAppAccess("wangwu", "com.example.actsaccounttest");
} catch(err) {
console.error(TAG + "addAccount or enableAppAccess failed, error: " + JSON.stringify(err))
}
console.info('ServiceAbility onStart end');
}, },
async onStop() { async onStop() {
console.info('ServiceAbility onStop'); console.info('ServiceAbility onStop');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册