提交 369291cb 编写于 作者: L lichenchen

应用账号atcs用例配合底层错误码返回结果整改

Signed-off-by: Nlichenchen <lichenchen15@huawei.com>
上级 31d61ec3
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const AccountErrCode = {
"ERR_JS_SUCCESS" : 0,
"ERR_JS_PERMISSION_DENIED" : 201,
"ERR_JS_PARAMETER_ERROR" : 401,
"ERR_JS_CAPABILITY_NOT_SUPPORTED" : 801,
"ERR_JS_SYSTEM_SERVICE_EXCEPTION" : 12300001,
"ERR_JS_INVALID_PARAMETER" : 12300002,
"ERR_JS_ACCOUNT_NOT_FOUND" : 12300003,
"ERR_JS_ACCOUNT_ALREADY_EXIST" : 12300004,
"ERR_JS_MULTI_USER_NOT_SUPPORT" : 12300005,
"ERR_JS_ACCOUNT_TYPE_NOT_SUPPORT" : 12300006,
"ERR_JS_ACCOUNT_NUMBER_REACH_LIMIT" : 12300007,
"ERR_JS_ACCOUNT_RESTRICTED" : 12300008,
"ERR_JS_ACCOUNT_ALREADY_ACTIVATED" : 12300009,
"ERR_JS_ACCOUNT_SERVICE_BUSY" : 12300010,
"ERR_JS_LISTENER_ALREADY_REGISTERED" : 12300011,
"ERR_JS_LISTENER_NOT_REGISTERED" : 12300012,
"ERR_JS_AUTH_CREDENTIAL_WRONG_ERROR" : 12300101,
"ERR_JS_CREDENTIAL_NOT_EXIST" : 12300102,
"ERR_JS_CREDENTIAL_INPUTER_ALREADY_EXIST" : 12300103,
"ERR_JS_CREDENTIAL_INPUTER_NOT_EXIST" : 12300104,
"ERR_JS_TRUST_LEVEL_NOT_SUPPORTED" : 12300105,
"ERR_JS_AUTH_TYPE_NOT_SUPPORTED" : 12300106,
"ERR_JS_AUTH_TYPE_NOT_FOUND" : 12300107,
"ERR_JS_SESSION_NOT_EXIST" : 12300108,
"ERR_JS_AUTH_CANCELLED" : 12300109,
"ERR_JS_AUTH_SERVICE_LOCKED" : 12300110,
"ERR_JS_AUTH_TIMEOUT" : 12300111,
"ERR_JS_AUTH_SERVICE_BUSY" : 12300112,
"ERR_JS_ACCOUNT_AUTHENTICATOR_NOT_EXIST" : 12300113,
"ERR_JS_ACCOUNT_AUTHENTICATOR_SERVICE_EXCEPTION" : 12300114,
"ERR_JS_INVALID_CONTEXT_ID" : 12300002,
"ERR_JS_APPLICATION_NOT_EXIST" : 12400001,
"ERR_JS_CUSTOM_DATA_NOT_FOUND" : 12400002,
"ERR_JS_CUSTOM_DATA_NUMBER_REACH_LIMIT" : 12400003,
"ERR_JS_TOKEN_NUMBER_REACH_LIMIT" : 12400004,
"ERR_JS_AUTHORIZATION_LIST_TOO_LARGE" : 12400005
}
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
*/ */
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {AccountErrCode} from './AccountErrCode.test.js'
const NAMELIMIT = 512; const NAMELIMIT = 512;
const LENGTHLIMIT = 1024; const LENGTHLIMIT = 1024;
const ERR_PARAMETER_CHECK_FAILD =401 const ERR_PARAMETER_CHECK_FAILD =401
const ERR_INVALID_PARAMETER = 12300002 const ERR_INVALID_PARAMETER = 12300002
const ERR_ACCOUNT_EXIST = 12300004
const createAccountOptions = {customData:{age:'12'}} //k and v length 1024 ,k and v size 1024 const createAccountOptions = {customData:{age:'12'}} //k and v length 1024 ,k and v size 1024
const createAccountOptionsDiff = {customData:{sex:'male'}} const createAccountOptionsDiff = {customData:{sex:'male'}}
export default function ActsAccountCreateAccount() { export default function ActsAccountCreateAccount() {
...@@ -129,7 +129,8 @@ export default function ActsAccountCreateAccount() { ...@@ -129,7 +129,8 @@ export default function ActsAccountCreateAccount() {
expect(err).assertEqual(null); expect(err).assertEqual(null);
appAccountManager.createAccount("account_name_callback_third", createAccountOptions, (err)=>{ appAccountManager.createAccount("account_name_callback_third", createAccountOptions, (err)=>{
console.debug("====>add account second time ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); console.debug("====>add account second time ActsAccountCreateAccount_0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_ACCOUNT_EXIST); console.debug("====>ActsAccountCreateAccount_0500 AccountErrCode.JsErrCode:" + AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST);
expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST);
appAccountManager.removeAccount("account_name_callback_third", (err)=>{ appAccountManager.removeAccount("account_name_callback_third", (err)=>{
console.debug("====>delete Account ActsAccountCreateAccount_0500 err:" + JSON.stringify(err)); console.debug("====>delete Account ActsAccountCreateAccount_0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
...@@ -156,7 +157,7 @@ export default function ActsAccountCreateAccount() { ...@@ -156,7 +157,7 @@ export default function ActsAccountCreateAccount() {
} }
catch(err){ catch(err){
console.debug("====>add account for the second time 0600 err:" + JSON.stringify(err)); console.debug("====>add account for the second time 0600 err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_ACCOUNT_EXIST); expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST);
await appAccountManager.removeAccount("account_name_promise_third"); await appAccountManager.removeAccount("account_name_promise_third");
console.debug("====>ActsAccountCreateAccount_0600 end===="); console.debug("====>ActsAccountCreateAccount_0600 end====");
done(); done();
...@@ -521,7 +522,7 @@ export default function ActsAccountCreateAccount() { ...@@ -521,7 +522,7 @@ export default function ActsAccountCreateAccount() {
expect(err).assertEqual(null); expect(err).assertEqual(null);
appAccountManager.createAccount("account_name_callback_same", createAccountOptionsDiff, (err)=>{ appAccountManager.createAccount("account_name_callback_same", createAccountOptionsDiff, (err)=>{
console.debug("====>add account second time ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); console.debug("====>add account second time ActsAccountCreateAccount_2300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_ACCOUNT_EXIST); expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST);
appAccountManager.removeAccount("account_name_callback_same", (err)=>{ appAccountManager.removeAccount("account_name_callback_same", (err)=>{
console.debug("====>delete Account ActsAccountCreateAccount_2300 err:" + JSON.stringify(err)); console.debug("====>delete Account ActsAccountCreateAccount_2300 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
...@@ -548,7 +549,7 @@ export default function ActsAccountCreateAccount() { ...@@ -548,7 +549,7 @@ export default function ActsAccountCreateAccount() {
} }
catch(err){ catch(err){
console.debug("====>add account for the second time err:" + JSON.stringify(err)); console.debug("====>add account for the second time err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_ACCOUNT_EXIST); expect(err.code).assertEqual(AccountErrCode.ERR_JS_ACCOUNT_ALREADY_EXIST);
appAccountManager.removeAccount("account_name_promise_same"); appAccountManager.removeAccount("account_name_promise_same");
console.debug("====>ActsAccountCreateAccount_2400 end===="); console.debug("====>ActsAccountCreateAccount_2400 end====");
done(); done();
......
...@@ -427,7 +427,7 @@ export default function ActsAccountSetAppAccess() { ...@@ -427,7 +427,7 @@ export default function ActsAccountSetAppAccess() {
expect(err).assertEqual(null); expect(err).assertEqual(null);
appAccountManager.setAppAccess("AppAccess_callback_account", enableBundle, false, (err)=>{ appAccountManager.setAppAccess("AppAccess_callback_account", enableBundle, false, (err)=>{
console.debug("====>setAppAccess ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err)); console.debug("====>setAppAccess ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err));
expect(err.code == 12400001).assertEqual(true); expect(err).assertEqual(null);
appAccountManager.removeAccount("AppAccess_callback_account", (err)=>{ appAccountManager.removeAccount("AppAccess_callback_account", (err)=>{
console.debug("====>delete Account ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err)); console.debug("====>delete Account ActsAccountSetAppAccess_1500 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
...@@ -459,17 +459,17 @@ export default function ActsAccountSetAppAccess() { ...@@ -459,17 +459,17 @@ export default function ActsAccountSetAppAccess() {
} }
console.debug("====>disableAppAccess ActsAccountSetAppAccess_1600 start===="); console.debug("====>disableAppAccess ActsAccountSetAppAccess_1600 start====");
try{ try{
await appAccountManager.setAppAccess("AppAccess_promise_account", enableBundle,false); await appAccountManager.setAppAccess("AppAccess_promise_account", enableBundle, false);
expect().assertFail();
done();
} }
catch(err){ catch(err){
console.debug("====>disableAppAccess ActsAccountSetAppAccess_1600 err:" + JSON.stringify(err)); console.debug("====>disableAppAccess ActsAccountSetAppAccess_1800 err:" + JSON.stringify(err));
expect(err.code == 12400001).assertEqual(true);
await appAccountManager.removeAccount("AppAccess_promise_account"); await appAccountManager.removeAccount("AppAccess_promise_account");
console.debug("====>ActsAccountSetAppAccess_1600 end===="); expect().assertFail();
done(); done();
} }
await appAccountManager.removeAccount("AppAccess_promise_account");
console.debug("====>ActsAccountSetAppAccess_1600 end====");
done();
}); });
/* /*
...@@ -486,7 +486,7 @@ export default function ActsAccountSetAppAccess() { ...@@ -486,7 +486,7 @@ export default function ActsAccountSetAppAccess() {
console.debug("====>add account ActsAccountSetAppAccess_1700 err:" + JSON.stringify(err)); console.debug("====>add account ActsAccountSetAppAccess_1700 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
appAccountManager.setAppAccess("AppAccess_callback_notExistBundle", notExistBundle, false, (err)=>{ appAccountManager.setAppAccess("AppAccess_callback_notExistBundle", notExistBundle, false, (err)=>{
expect(err.code == 12400001).assertEqual(true); expect(err).assertEqual(null);
appAccountManager.removeAccount("AppAccess_callback_notExistBundle", (err)=>{ appAccountManager.removeAccount("AppAccess_callback_notExistBundle", (err)=>{
console.debug("====>delete Account ActsAccountSetAppAccess_1700 err:" + JSON.stringify(err)); console.debug("====>delete Account ActsAccountSetAppAccess_1700 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
...@@ -515,13 +515,15 @@ export default function ActsAccountSetAppAccess() { ...@@ -515,13 +515,15 @@ export default function ActsAccountSetAppAccess() {
} }
catch(err){ catch(err){
console.debug("====>disableAppAccess ActsAccountSetAppAccess_1800 err:" + JSON.stringify(err)); console.debug("====>disableAppAccess ActsAccountSetAppAccess_1800 err:" + JSON.stringify(err));
expect(err.code == 12400001).assertEqual(true); await appAccountManager.removeAccount("AppAccess_promise_account");
console.debug("====>delete account ActsAccountSetAppAccess_1800 start===="); expect().assertFail();
await appAccountManager.removeAccount("AppAccess_promise_notExistBundle");
console.debug("====>ActsAccountSetAppAccess_1600 end====");
done(); done();
} }
}); console.debug("====>delete account ActsAccountSetAppAccess_1800 start====");
await appAccountManager.removeAccount("AppAccess_promise_notExistBundle");
console.debug("====>ActsAccountSetAppAccess_1600 end====");
done();
});
/* /*
* @tc.number : ActsAccountSetAppAccess_1900 * @tc.number : ActsAccountSetAppAccess_1900
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册