• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import account from '@ohos.account.appAccount'
16import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
17
18const TIMEOUT = 5000;
19const EACHTIMEOUT = 500;
20const ERR_JS_CREDENTIAL_NOT_EXIST = 12300102;
21export default function ActsAppAccountCredential() {
22    describe('ActsAppAccountCredential', function () {
23        /*
24        * @tc.number    : ActsAppAccountCredential_0100
25        * @tc.name      : The correct calls setAssociatedData and getCredential get the credential
26        * @tc.desc      : The setCredential setting credential is called when the forwarding parameters
27        *                 are correct, and then getCredential is called for the credential(callback)
28        */
29        it('ActsAppAccountCredential_0100', 0, async function (done) {
30            console.info("====>ActsAppAccountCredential_0100 start====");
31            var appAccountManager = account.createAppAccountManager();
32            console.info("====>creat finish====");
33            appAccountManager.createAccount("account_name_0100", (err)=>{
34                console.info("====>add account ActsAppAccountCredential_0100 err:" + JSON.stringify(err));
35                expect(err).assertEqual(null);
36                appAccountManager.setCredential("account_name_0100", "credentialType1", "credential1",(err)=>{
37                    console.info("====>ActsAppAccountCredential_0100 setCredential:" + JSON.stringify(err));
38                    expect(err).assertEqual(null);
39                    appAccountManager.getCredential("account_name_0100", "credentialType1", (err,data)=>{
40                        console.info("====>getCredential 0100 err:" + JSON.stringify(err));
41                        console.info("====>getCredential 0100 data:" + JSON.stringify(data));
42                        expect(err).assertEqual(null);
43                        expect(data).assertEqual("credential1");
44                        appAccountManager.removeAccount("account_name_0100", (err)=>{
45                            console.info("====>delete Account 0100 err:" + JSON.stringify(err));
46                            expect(err).assertEqual(null);
47                            console.info("====>ActsAppAccountCredential_0100 end====");
48                            done();
49                        });
50                    });
51                });
52            });
53        });
54
55        /*
56        * @tc.number    : ActsAppAccountCredential_0200
57        * @tc.name      : The correct calls setCredential and getCredential get the credential
58        * @tc.desc      : The setAssociatedData setting credential is called when the forwarding parameters
59        *                 are correct, and then getCredential is called for the credential(promise)
60        */
61        it('ActsAppAccountCredential_0200', 0, async function (done) {
62            console.info("====>ActsAppAccountCredential_0200 start====");
63            var appAccountManager = account.createAppAccountManager();
64            console.info("====>creat finish====");
65            console.info("====>add accountActsAppAccountCredential_0200 start====");
66            await appAccountManager.createAccount("account_name_0200");
67            console.info("====>setCredential ActsAppAccountCredential_0200 start====");
68            try{
69                await appAccountManager.setCredential("account_name_0200", "credentialType2", "credential2");
70            }
71            catch(err){
72                console.error("setCredential ActsAppAccountCredential_0200 err:" + JSON.stringify(err));
73                expect().assertFail();
74                done();
75            }
76            console.info("====>getCredential ActsAppAccountCredential_0200 start====");
77            try{
78                var data = await appAccountManager.getCredential("account_name_0200", "credentialType2");
79            }
80            catch(err){
81                console.error("getCredential ActsAppAccountCredential_0200 err:" + JSON.stringify(err));
82                expect().assertFail();
83                done();
84            }
85            console.info("====>getCredential ActsAppAccountCredential_0200 data:" + JSON.stringify(data));
86            expect(data).assertEqual("credential2");
87            console.info("====>delete account ActsAppAccountCredential_0200 start====");
88            appAccountManager.removeAccount("account_name_0200")
89            console.info("====>ActsAppAccountCredential_0200 end====");
90            done();
91        });
92
93        /*
94        * @tc.number    : ActsAppAccountCredential_0300
95        * @tc.name      : Whether getAssociatedData can get the correct value when calling setCredential two times
96        * @tc.desc      : When the first setCredential is called and the second setCredential
97        *                 is called,the setting of the credential is different if the call getCredential
98        *                 can get the second credential(callback)
99        */
100        it('ActsAppAccountCredential_0300', 0, async function (done) {
101            console.info("====>ActsAppAccountCredential_0300 start====");
102            var appAccountManager = account.createAppAccountManager();
103            console.info("====>creat finish====");
104            appAccountManager.createAccount("account_name_0300",(err)=>{
105                console.info("====>add account ActsAppAccountCredential_0300 err:" + JSON.stringify(err));
106                expect(err).assertEqual(null);
107                appAccountManager.setCredential("account_name_0300", "credentialType3", "credential3",(err)=>{
108                    console.info("====>setCredential first time 0300 err:" + JSON.stringify(err));
109                    expect(err).assertEqual(null);
110                    appAccountManager.setCredential("account_name_0300", "credentialType3", "newcredential3",(err)=>{
111                        console.info("====>setCredential second time 0300 err:" + JSON.stringify(err));
112                        expect(err).assertEqual(null);
113                        appAccountManager.getCredential("account_name_0300", "credentialType3", (err, data)=>{
114                            console.info("====>getCredential 0300 err:" + JSON.stringify(err));
115                            console.info("====>getCredential 0300 data:" + JSON.stringify(data));
116                            expect(err).assertEqual(null);
117                            expect(data).assertEqual("newcredential3");
118                            appAccountManager.removeAccount("account_name_0300", (err)=>{
119                                console.info("====>delete Account 0300 err:" + JSON.stringify(err));
120                                expect(err).assertEqual(null);
121                                console.info("====>ActsAppAccountCredential_0300 end====");
122                                done();
123                            });
124                        });
125                    });
126                });
127            });
128        });
129
130        /*
131        * @tc.number    : ActsAppAccountCredential_0400
132        * @tc.name      : Whether getAssociatedData can get the correct value when calling setCredential two times
133        * @tc.desc      : When the first setCredential is called and the second setCredential
134        *                 is called,the setting of the credential is different if the call getCredential
135        *                 can get the second credential(promise)
136        */
137        it('ActsAppAccountCredential_0400', 0, async function (done) {
138            console.info("====>ActsAppAccountCredential_0400 start====");
139            var appAccountManager = account.createAppAccountManager();
140            console.info("====>creat finish====");
141            console.info("====>add account ActsAppAccountCredential_0400 start====");
142            await appAccountManager.createAccount("account_name_0400");
143            try{
144                await appAccountManager.setCredential("account_name_0400", "credentialType4", "credential4");
145                await appAccountManager.setCredential("account_name_0400", "credentialType4", "newcredential4")
146            }
147            catch(err){
148                console.error("setCredential ActsAppAccountCredential_0400 err:" + JSON.stringify(err));
149                expect().assertFail();
150                done();
151            }
152            try{
153                var data = await appAccountManager.getCredential("account_name_0400", "credentialType4");
154            }
155            catch(err){
156                console.error("getCredential ActsAppAccountCredential_0400 err:" + JSON.stringify(err));
157                expect().assertFail();
158                done();
159            }
160            console.info("====>ActsAppAccountCredential_0400 getCredential data:" + JSON.stringify(data));
161            expect(data).assertEqual("newcredential4");
162            console.info("====>delete account ActsAppAccountCredential_0400 start====");
163            appAccountManager.removeAccount("account_name_0400")
164            console.info("====>ActsAppAccountCredential_0400 end====");
165            done();
166        });
167
168        /*
169        * @tc.number    : ActsAppAccountCredential_0500
170        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is null
171        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming credential is null(callback)
172        */
173        it('ActsAppAccountCredential_0500', 0, async function (done) {
174            console.info("====>ActsAppAccountCredential_0500 start====");
175            var appAccountManager = account.createAppAccountManager();
176            console.info("====>creat finish====");
177            appAccountManager.createAccount("account_name_0500",(err)=>{
178                console.info("====>add account ActsAppAccountCredential_0500 err:" + JSON.stringify(err));
179                expect(err).assertEqual(null);
180                appAccountManager.setCredential("account_name_0500", "credentialType5", "", (err)=>{
181                    console.info("====>setCredential ActsAppAccountCredential_0500 err:" + JSON.stringify(err));
182                    expect(err).assertEqual(null);
183                    appAccountManager.getCredential("account_name_0500", "credentialType5", (err,data)=>{
184                        console.info("====>getCredential ActsAppAccountCredential_0500 err:" + JSON.stringify(err));
185                        console.info("====>getCredential ActsAppAccountCredential_0500 data:" + JSON.stringify(data));
186                        expect(err).assertEqual(null);
187                        expect(data).assertEqual("");
188                        appAccountManager.removeAccount("account_name_0500", (err)=>{
189                            console.info("====>delete Account ActsAppAccountCredential_0500 err:" + JSON.stringify(err));
190                            expect(err).assertEqual(null);
191                            console.info("====>ActsAppAccountCredential_0500 end====");
192                            done();
193                        });
194                    });
195                });
196            });
197        });
198
199        /*
200        * @tc.number    : ActsAppAccountCredential_0600
201        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is null
202        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming credential is null(promise)
203        */
204        it('ActsAppAccountCredential_0600', 0, async function (done) {
205            console.info("====>ActsAppAccountCredential_0600 start====");
206            var appAccountManager = account.createAppAccountManager();
207            console.info("====>creat finish====");
208            console.info("====>add account ActsAppAccountCredential_0600 start====");
209            await appAccountManager.createAccount("account_name_0600");
210            console.info("====>setCredential ActsAppAccountCredential_0600 start====");
211            await appAccountManager.setCredential("account_name_0600", "credentialType6", "");
212            console.info("====>getCredential ActsAppAccountCredential_0600 start====");
213            var data = await appAccountManager.getCredential("account_name_0600", "credentialType6");
214            console.info("====>getCredential ActsAppAccountCredential_0600 data" + JSON.stringify(data));
215            expect(data).assertEqual("");
216            console.info("====>delete account ActsAppAccountCredential_0600 start====");
217            await appAccountManager.removeAccount("account_name_0600");
218            console.info("====>ActsAppAccountCredential_0600 end====");
219            done();
220        });
221
222        /*
223        * @tc.number    : ActsAppAccountCredential_0700
224        * @tc.name      : setAssociatedData setting value is called when the argument is wrong
225        * @tc.desc      : Call setAssociatedData setting credential when the incoming parameter type is null(callback)
226        */
227        it('ActsAppAccountCredential_0700', 0, async function (done) {
228            console.info("====>ActsAppAccountCredential_0700 start====");
229            var appAccountManager = account.createAppAccountManager();
230            console.info("====>creat finish====");
231            appAccountManager.createAccount("account_name_0700", (err)=>{
232                console.info("====>add account ActsAppAccountCredential_0700 err:" + JSON.stringify(err));
233                expect(err).assertEqual(null);
234                appAccountManager.setCredential("account_name_0700", "", "credential7", (err)=>{
235                    console.info("====>setCredential ActsAppAccountCredential_0700 err:" + JSON.stringify(err));
236                    expect(err.code == 12300002).assertEqual(true);
237                    appAccountManager.removeAccount("account_name_0700", (err)=>{
238                        console.info("====>delete Account ActsAppAccountCredential_0700 err:" + JSON.stringify(err));
239                        expect(err).assertEqual(null);
240                        console.info("====>ActsAppAccountCredential_0700 end====");
241                        done();
242                    });
243                });
244            });
245        });
246
247        /*
248        * @tc.number    : ActsAppAccountCredential_0800
249        * @tc.name      : setAssociatedData setting value is called when the argument is wrong
250        * @tc.desc      : Call setAssociatedData setting credential when the incoming parameter type is null(promise)
251        */
252        it('ActsAppAccountCredential_0800', 0, async function (done) {
253            console.info("====>ActsAppAccountCredential_0800 start====");
254            var appAccountManager = account.createAppAccountManager();
255            console.info("====>creat finish====");
256            console.info("====>add account ccountActsAppAccountCredential_0800 start====");
257            await appAccountManager.createAccount("account_name_0800");
258            try{
259                await appAccountManager.setCredential("account_name_0800", "", "credential8");
260            }
261            catch(err){
262                console.info("====>setCredential ActsAppAccountCredential_0800 err:" + JSON.stringify(err));
263                expect(err.code == 12300002).assertEqual(true);
264                console.info("====>delete account ActsAppAccountCredential_0800 start====");
265                appAccountManager.removeAccount("account_name_0800");
266                console.info("====>ActsAppAccountCredential_0800 end====");
267                done();
268            }
269        });
270
271        /*
272        * @tc.number    : ActsAppAccountCredential_0900
273        * @tc.name      : getCredential getting value is called when the argument is wrong
274        * @tc.desc      : Call getCredential getting credential when the incoming parameter type is wrong(callback)
275        */
276        it('ActsAppAccountCredential_0900', 0, async function (done) {
277            console.info("====>ActsAppAccountCredential_0900 start====");
278            var appAccountManager = account.createAppAccountManager();
279            console.info("====>creat finish====");
280            appAccountManager.createAccount("account_name_0900", (err)=>{
281                console.info("====>add account ActsAppAccountCredential_0900 err:" + JSON.stringify(err));
282                expect(err).assertEqual(null);
283                appAccountManager.getCredential("account_name_0900", "", (err)=>{
284                    console.info("====>getCredential ActsAppAccountCredential_0900 err:" + JSON.stringify(err));
285                    expect(err.code == 12300002).assertEqual(true);
286                    appAccountManager.removeAccount("account_name_0900", (err)=>{
287                        console.info("====>delete Account ActsAppAccountCredential_0900 err:" + JSON.stringify(err));
288                        expect(err).assertEqual(null);
289                        console.info("====>ActsAppAccountCredential_0900 end====");
290                        done();
291                    });
292                });
293            });
294        });
295
296        /*
297        * @tc.number    : ActsAppAccountCredential_1000
298        * @tc.name      : getCredential getting value is called when the argument is wrong
299        * @tc.desc      : Call getCredential getting credential when the incoming parameter type is wrong(promise)
300        */
301        it('ActsAppAccountCredential_1000', 0, async function (done) {
302            console.info("====>ActsAppAccountCredential_1000 start====");
303            var appAccountManager = account.createAppAccountManager();
304            console.info("====>creat finish====");
305            console.info("====>add account ActsAppAccountCredential_1000 start====");
306            await appAccountManager.createAccount("account_name_1000");
307            try{
308                await appAccountManager.getCredential("account_name_1000","");
309            }
310            catch(err){
311                console.info("====>getCredential ActsAppAccountCredential_1000 err:" + JSON.stringify(err));
312                expect(err.code == 12300002).assertEqual(true);
313                console.info("====>delete account ActsAppAccountCredential_1000 start====");
314                await appAccountManager.removeAccount("account_name_1000");
315                console.info("====>ActsAppAccountCredential_1000 end====");
316                done();
317            }
318        });
319
320        /*
321        * @tc.number    : ActsAppAccountCredential_1100
322        * @tc.name      : setAssociatedData setting credential is called when the argument is sapce
323        * @tc.desc      : Call setAssociatedData setting credential when the incoming parameter type is space
324        *                 then use getCredential getting the credential(callback)
325        */
326        it('ActsAppAccountCredential_1100', 0, async function (done) {
327            console.info("====>ActsAppAccountCredential_1100 start====");
328            var appAccountManager = account.createAppAccountManager();
329            console.info("====>creat finish====");
330            appAccountManager.createAccount("account_name_1100",(err)=>{
331                console.info("====>add account ActsAppAccountCredential_1100 err:" + JSON.stringify(err));
332                expect(err).assertEqual(null);
333                appAccountManager.setCredential("account_name_1100", " ", "credential11",(err)=>{
334                    console.info("====>setCredential ActsAppAccountCredential_1100 err:" + JSON.stringify(err));
335                    expect(err).assertEqual(null);
336                    appAccountManager.getCredential("account_name_1100", " ", (err, data)=>{
337                        console.info("====>getCredential 1100 err:" + JSON.stringify(err));
338                        console.info("====>getCredential 1100 data:" + JSON.stringify(data));
339                        expect(err).assertEqual(null);
340                        expect(data).assertEqual("credential11");
341                        appAccountManager.removeAccount("account_name_1100", (err)=>{
342                            console.info("====>delete Account 1100 err:" + JSON.stringify(err));
343                            expect(err).assertEqual(null);
344                            console.info("====>ActsAppAccountCredential_1100 end====");
345                            done();
346                        });
347                    });
348                });
349            });
350        });
351
352        /*
353        * @tc.number    : ActsAppAccountCredential_1200
354        * @tc.name      : setAssociatedData setting credential is called when the argument is sapce
355        * @tc.desc      : Call setAssociatedData setting credential when the incoming parameter type is space
356        *                 then use getCredential getting the credential(promise)
357        */
358        it('ActsAppAccountCredential_1200', 0, async function (done) {
359            console.info("====>ActsAppAccountCredential_1200 start====");
360            var appAccountManager = account.createAppAccountManager();
361            console.info("====>creat finish====");
362            console.info("====>add account ActsAppAccountCredential_1200 start====");
363            await appAccountManager.createAccount("account_name_1200");
364            console.info("====>setCredential ActsAppAccountCredential_1200 start====");
365            await appAccountManager.setCredential("account_name_1200", " ", "credential12");
366            console.info("====>getCredential ActsAppAccountCredential_1200 start====");
367            var data = await appAccountManager.getCredential("account_name_1200", " ");
368            console.info("====>getCredential ActsAppAccountCredential_1200 data" + JSON.stringify(data));
369            expect(data).assertEqual("credential12");
370            console.info("====>delete account ActsAppAccountCredential_1200 start====");
371            await appAccountManager.removeAccount("account_name_1200");
372            console.info("====>ActsAppAccountCredential_1200 end====");
373            done();
374        });
375
376        /*
377        * @tc.number    : ActsAppAccountCredential_1300
378        * @tc.name      : setAssociatedData setting credential is called when the argument is wrong
379        * @tc.desc      : Call setAssociatedData setting credential when the incoming parameter name is null(callback)
380        */
381        it('ActsAppAccountCredential_1300', 0, async function (done) {
382            console.info("====>ActsAppAccountCredential_1300 start====");
383            var appAccountManager = account.createAppAccountManager();
384            console.info("====>creat finish====");
385            appAccountManager.createAccount("account_name_1300",(err)=>{
386                console.info("====>add account ActsAppAccountCredential_1300 err:" + JSON.stringify(err));
387                expect(err).assertEqual(null);
388                appAccountManager.setCredential("", "credentialType13", "credential13", (err)=>{
389                    console.info("====>setCredential ActsAppAccountCredential_1300 err:" + JSON.stringify(err));
390                    expect(err.code == 12300002).assertEqual(true);
391                    appAccountManager.removeAccount("account_name_1300", (err)=>{
392                        console.info("====>delete Account ActsAppAccountCredential_1300 err:" + JSON.stringify(err));
393                        expect(err).assertEqual(null);
394                        console.info("====>ActsAppAccountCredential_1300 end====");
395                        done();
396                    });
397                });
398            });
399        });
400
401        /*
402        * @tc.number    : ActsAppAccountCredential_1400
403        * @tc.name      : setAssociatedData setting credential is called when the argument is wrong
404        * @tc.desc      : Call setAssociatedData setting credential when the incoming parameter name is null(promise)
405        */
406        it('ActsAppAccountCredential_1400', 0, async function (done) {
407            console.info("====>ActsAppAccountCredential_1400 start====");
408            var appAccountManager = account.createAppAccountManager();
409            console.info("====>creat finish====");
410            console.info("====>add account ActsAppAccountCredential_1400 start====");
411            await appAccountManager.createAccount("account_name_1400");
412            try{
413                await appAccountManager.setCredential("", "credentialType14", "credential14");
414            }
415            catch(err){
416                console.info("====>setCredential ActsAppAccountCredential_1400 err:" + JSON.stringify(err));
417                expect(err.code == 12300002).assertEqual(true);
418                console.info("====>delete account ActsAppAccountCredential_1400 start====");
419                await appAccountManager.removeAccount("account_name_1400");
420                console.info("====>ActsAppAccountCredential_1400 end====");
421                done();
422            }
423        });
424
425        /*
426        * @tc.number    : ActsAppAccountCredential_1500
427        * @tc.name      : Get it directly without setting credential callback
428        * @tc.desc      : Call getCredential directly to get credential without calling setCredential
429        */
430        it('ActsAppAccountCredential_1500', 0, async function (done) {
431            console.info("====>ActsAppAccountCredential_1500 start====");
432            var appAccountManager = account.createAppAccountManager();
433            console.info("====>creat finish====");
434            appAccountManager.createAccount("account_name_1500", (err)=>{
435                console.info("====>add account ActsAppAccountCredential_1500 err:" + JSON.stringify(err));
436                expect(err).assertEqual(null);
437                appAccountManager.getCredential("account_name_1500", "credentialType15", (err)=>{
438                    console.info("====>getCredential ActsAppAccountCredential_1500 err:" + JSON.stringify(err));
439                    expect(err.code == ERR_JS_CREDENTIAL_NOT_EXIST).assertEqual(true);
440                    appAccountManager.removeAccount("account_name_1500", (err)=>{
441                        console.info("====>delete Account ActsAppAccountCredential_1500 err:" + JSON.stringify(err));
442                        expect(err).assertEqual(null);
443                        console.info("====>ActsAppAccountCredential_1500 end====");
444                        done();
445                    });
446                });
447            });
448        });
449
450        /*
451        * @tc.number    : ActsAppAccountCredential_1600
452        * @tc.name      : Get it directly without setting credential promise
453        * @tc.desc      : Call getCredential directly to get credential without calling setCredential
454        */
455        it('ActsAppAccountCredential_1600', 0, async function (done) {
456            console.info("cActsAppAccountCredential_1600 start====");
457            var appAccountManager = account.createAppAccountManager();
458            console.info("====>creat finish====");
459            console.info("====>add account ActsAppAccountCredential_1600 start====");
460            await appAccountManager.createAccount("account_name_1600");
461            try{
462                await appAccountManager.getCredential("account_name_1600", "credentialType16");
463            }
464            catch(err){
465                console.info("====>getCredential ActsAppAccountCredential_1600 err:" + JSON.stringify(err));
466                expect(err.code == ERR_JS_CREDENTIAL_NOT_EXIST).assertEqual(true);
467                console.info("====>delete account ActsAppAccountCredential_1600 start====");
468                await appAccountManager.removeAccount("account_name_1600");
469                console.info("====>ActsAppAccountCredential_1600 end====");
470                done();
471            }
472        });
473
474        /*
475        * @tc.number    : ActsAppAccountCredential_1700
476        * @tc.name      : setCredential setting credential is called when the argument is wrong callback
477        * @tc.desc      : Call setCredential setting credential when the incoming parameter credential is wrong
478        */
479        it('ActsAppAccountCredential_1700', 0, async function (done) {
480            console.info("====>ActsAppAccountCredential_1700 start====");
481            var CREDENTIALOVERSIZE = "K"
482            for(var i = 0;i < 256;i++)
483            CREDENTIALOVERSIZE = CREDENTIALOVERSIZE + "K!@#";
484            var appAccountManager = account.createAppAccountManager();
485            console.info("====>creat finish====");
486            appAccountManager.createAccount("account_name_1700", (err)=>{
487                console.info("====>add account ActsAppAccountCredential_1700 err:" + JSON.stringify(err));
488                expect(err).assertEqual(null);
489                appAccountManager.setCredential("account_name_1700", "credentialType17", CREDENTIALOVERSIZE, (err)=>{
490                    console.info("====>CREDENTIALOVERSIZE.length:" + JSON.stringify(CREDENTIALOVERSIZE.length));
491                    expect(CREDENTIALOVERSIZE.length).assertEqual(1025);
492                    console.info("====>setCredential ActsAppAccountCredential_1700 err:" + JSON.stringify(err));
493                    expect(err.code == 12300002).assertEqual(true);
494                    appAccountManager.removeAccount("account_name_1700", (err)=>{
495                        console.info("====>delete Account ActsAppAccountCredential_1700 err:" + JSON.stringify(err));
496                        expect(err).assertEqual(null);
497                        console.info("====>ActsAppAccountCredential_1700 end====");
498                        done();
499                    });
500                });
501            });
502        });
503
504        /*
505        * @tc.number    : ActsAppAccountCredential_1800
506        * @tc.name      : setCredential setting credential is called when the argument is wrong promise
507        * @tc.desc      : Call setCredential setting credential when the incoming parameter credential is wrong
508        */
509        it('ActsAppAccountCredential_1800', 0, async function (done) {
510            console.info("====>ActsAppAccountCredential_1800 start====");
511            var bigStr = "K"
512            for(var i = 0;i < 256;i++)
513            bigStr = bigStr + "K!@#";
514            var appAccountManager = account.createAppAccountManager();
515            console.info("====>creat finish====");
516            console.info("====>add account ActsAppAccountCredential_1800 start====");
517            await appAccountManager.createAccount("account_name_1800");
518            try{
519                await appAccountManager.setCredential("account_name_1800", "credentialType18", bigStr);
520            }
521            catch(err){
522                console.info("====>bigStr.length:" + JSON.stringify(bigStr.length));
523                expect(bigStr.length).assertEqual(1025);
524                console.info("====>setCredential ActsAppAccountCredential_1800 err:" + JSON.stringify(err));
525                expect(err.code == 12300002).assertEqual(true);
526                console.info("====>delete account ActsAppAccountCredential_1800 start====");
527                await appAccountManager.removeAccount("account_name_1800");
528                console.info("====>ActsAppAccountCredential_1800 end====");
529                done();
530            }
531        });
532
533        /*
534        * @tc.number    : ActsAppAccountCredential_1900
535        * @tc.name      : setCredential setting credential is called when the argument is wrong
536        * @tc.desc      : Call setCredential setting type when the incoming parameter credential is wrong(callback)
537        */
538        it('ActsAppAccountCredential_1900', 0, async function (done) {
539            console.info("====>ActsAppAccountCredential_1900 start====");
540            var CREDENTIALTYPEOVERSIZE = "K"
541            for(var i = 0;i < 256;i++)
542            CREDENTIALTYPEOVERSIZE = CREDENTIALTYPEOVERSIZE + "K!@#";
543            var appAccountManager = account.createAppAccountManager();
544            console.info("====>creat finish====");
545            appAccountManager.createAccount("account_name_1900", (err)=>{
546                console.info("====>add account ActsAppAccountCredential_1900 err:" + JSON.stringify(err));
547                expect(err).assertEqual(null);
548                appAccountManager.setCredential("account_name_1900", CREDENTIALTYPEOVERSIZE, "credential19", (err)=>{
549                    console.info("====>CREDENTIALTYPEOVERSIZE.length:" + JSON.stringify(CREDENTIALTYPEOVERSIZE.length));
550                    expect(CREDENTIALTYPEOVERSIZE.length).assertEqual(1025);
551                    console.info("====>setCredential ActsAppAccountCredential_1900 err:" + JSON.stringify(err));
552                    expect(err.code == 12300002).assertEqual(true);
553                    appAccountManager.removeAccount("account_name_1900", (err)=>{
554                        console.info("====>delete Account ActsAppAccountCredential_1900 err:" + JSON.stringify(err));
555                        expect(err).assertEqual(null);
556                        console.info("====>ActsAppAccountCredential_1900 end====");
557                        done();
558                    });
559                });
560            });
561        });
562
563        /*
564        * @tc.number    : ActsAppAccountCredential_2000
565        * @tc.name      : setCredential setting credential is called when the argument is wrong
566        * @tc.desc      : Call setCredential setting type when the incoming parameter credential is wrong(promise)
567        */
568        it('ActsAppAccountCredential_2000', 0, async function (done) {
569            console.info("====>ActsAppAccountCredential_2000 start====");
570            var CREDENTIALTYPEOVERSIZE = "K"
571            for(var i = 0;i < 256;i++)
572            CREDENTIALTYPEOVERSIZE=CREDENTIALTYPEOVERSIZE+"K!@#";
573            var appAccountManager = account.createAppAccountManager();
574            console.info("====>creat finish====");
575            console.info("====>add account ActsAppAccountCredential_2000 start====");
576            await appAccountManager.createAccount("account_name_2000");
577            try{
578                await appAccountManager.setCredential("account_name_2000", CREDENTIALTYPEOVERSIZE , "credential20");
579            }
580            catch(err){
581                console.info("====>CREDENTIALTYPEOVERSIZE.length:" + JSON.stringify(CREDENTIALTYPEOVERSIZE.length));
582                expect(CREDENTIALTYPEOVERSIZE.length).assertEqual(1025);
583                console.info("====>setCredential ActsAppAccountCredential_2000 err:" + JSON.stringify(err));
584                expect(err.code == 12300002).assertEqual(true);
585                console.info("====>delete account ActsAppAccountCredential_2000 start====");
586                await appAccountManager.removeAccount("account_name_2000");
587                console.info("====>ActsAppAccountCredential_2000 end====");
588                done();
589            }
590        });
591
592        /*
593        * @tc.number    : ActsAppAccountCredential_2100
594        * @tc.name      : setCredential setting credential is called when the argument is wrong
595        * @tc.desc      : Call setCredential setting name when the incoming parameter name is wrong(callback)
596        */
597        it('ActsAppAccountCredential_2100', 0, async function (done) {
598            console.info("====>ActsAppAccountCredential_2100 start====");
599            var NAMEOVERSIZE = "n"
600            for(var i = 0;i < 256;i++)
601            NAMEOVERSIZE = NAMEOVERSIZE + "name";
602            var appAccountManager = account.createAppAccountManager();
603            console.info("====>creat finish====");
604            appAccountManager.createAccount("account_name_2100", (err)=>{
605                console.info("====>add account ActsAppAccountCredential_2100 err:" + JSON.stringify(err));
606                expect(err).assertEqual(null);
607                appAccountManager.setCredential(NAMEOVERSIZE, "credentialType21", "credential21", (err)=>{
608                    console.info("====>setCredential ActsAppAccountCredential_2100 err:" + JSON.stringify(err));
609                    expect(err.code == 12300002).assertEqual(true);
610                    appAccountManager.removeAccount("account_name_2100", (err)=>{
611                        console.info("====>delete Account ActsAppAccountCredential_2100 err:" + JSON.stringify(err));
612                        console.info("====>ActsAppAccountCredential_2100 end====");
613                        expect(err).assertEqual(null);
614                        done();
615                    });
616                });
617            });
618        });
619
620        /*
621        * @tc.number    : ActsAppAccountCredential_2200
622        * @tc.name      : setCredential setting credential is called when the argument is wrong
623        * @tc.desc      : Call setCredential setting name when the incoming parameter name is wrong(promise)
624        */
625        it('ActsAppAccountCredential_2200', 0, async function (done) {
626            console.info("====>ActsAppAccountCredential_2200 start====");
627            var NAMEOVERSIZE ="n"
628            for(var i=0;i<256;i++)
629            NAMEOVERSIZE=NAMEOVERSIZE+"name";
630            var appAccountManager = account.createAppAccountManager();
631            console.info("====>creat finish====");
632            console.info("====>add account ActsAppAccountCredential_2200 start====");
633            try{
634                await appAccountManager.createAccount("account_name_2200");
635            }
636            catch(err){
637                console.info("====>add account ActsAppAccountCredential_2200 err:" + JSON.stringify(err));
638                expect().assertFail();
639                done();
640            }
641            console.info("====>setCredential ActsAppAccountCredential_2200 start====");
642            try{
643                await appAccountManager.setCredential(NAMEOVERSIZE, "credentialType22", "credential22");
644            }
645            catch(err){
646                console.info("====>setCredential ActsAppAccountCredential_2200 err:" + JSON.stringify(err));
647                expect(err.code == 12300002).assertEqual(true);
648                console.info("====>delete account ActsAppAccountCredential_2200 start====");
649                await appAccountManager.removeAccount("account_name_2200");
650                console.info("====>ActsAppAccountCredential_2200 end====");
651                done();
652            }
653        });
654    })
655}