• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2024 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 */
15
16import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
17
18import osAccount from '@ohos.account.osAccount'
19
20export default function ActsOANoPermissionTest() {
21    describe('ActsOANoPermissionTest', function () {
22
23        /**
24         * @tc.number  : SUB_Account_OsAccount_NoPermission_0100
25         * @tc.name    : test getOsAccountCount errcode 201 callback
26         * @tc.desc    : no ohos.permission.MANAGE_LOCAL_ACCOUNTS.
27         * @tc.level   : Level3
28         * @tc.size    : MediumTest
29         * @tc.type    : Function
30         */
31        it('SUB_Account_OsAccount_NoPermission_0100', 0, async (done) => {
32            console.info("====>SUB_Account_OsAccount_NoPermission_0100 start====");
33            let accountManager = osAccount.getAccountManager();
34            try {
35                accountManager.getOsAccountCount((err, count) => {
36                    console.info('====>getOsAccountCount failed, error: ' + JSON.stringify(err));
37                    try {
38                        expect(err.code).assertEqual(201);
39                    } catch (err) {
40                        console.info('====>Assert err: ' + JSON.stringify(err));
41                    }
42                    done();
43                });
44            } catch (err) {
45                console.info('====>getOsAccountCount exception: ' + JSON.stringify(err));
46                expect(err.code).assertEqual(201);
47                done();
48            }
49        });
50
51        /**
52         * @tc.number  : SUB_Account_OsAccount_NoPermission_0200
53         * @tc.name    : test getOsAccountCount errcode 201 promise
54         * @tc.desc    : no ohos.permission.MANAGE_LOCAL_ACCOUNTS.
55         * @tc.level   : Level3
56         * @tc.size    : MediumTest
57         * @tc.type    : Function
58         */
59        it('SUB_Account_OsAccount_NoPermission_0200', 0, async (done) => {
60            console.info("====>SUB_Account_OsAccount_NoPermission_0200 start====");
61            let accountManager = osAccount.getAccountManager();
62            try {
63                await accountManager.getOsAccountCount();
64                expect(true).assertFalse()
65                done()
66            } catch (err) {
67                console.info('====>getOsAccountCount err: ' + JSON.stringify(err));
68                expect(err.code).assertEqual(201);
69                done();
70            }
71        });
72
73        /**
74         * @tc.number  : SUB_Account_OsAccount_NoPermission_0300
75         * @tc.name    : test getOsAccountLocalIdForDomain errcode 201 callback
76         * @tc.desc    : no ohos.permission.MANAGE_LOCAL_ACCOUNTS.
77         * @tc.level   : Level3
78         * @tc.size    : MediumTest
79         * @tc.type    : Function
80         */
81        it('SUB_Account_OsAccount_NoPermission_0300', 0, async (done) => {
82            console.info("====>SUB_Account_OsAccount_NoPermission_0300 start====");
83            let domainInfo = { domain: 'testDomain', accountName: 'testAccountName' };
84            let accountManager = osAccount.getAccountManager();
85            try {
86                accountManager.getOsAccountLocalIdForDomain(domainInfo, (err, localId) => {
87                    console.info('====>getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
88                    try {
89                        expect(err.code).assertEqual(201);
90                    } catch (err) {
91                        console.info('====>Assert err: ' + JSON.stringify(err));
92                    }
93                    done();
94                });
95            } catch (err) {
96                console.info('====>getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err));
97                expect(err.code).assertEqual(201);
98                done();
99            }
100        });
101
102        /**
103         * @tc.number  : SUB_Account_OsAccount_NoPermission_0400
104         * @tc.name    : test getOsAccountLocalIdForDomain errcode 201 promise
105         * @tc.desc    : no ohos.permission.MANAGE_LOCAL_ACCOUNTS.
106         * @tc.level   : Level3
107         * @tc.size    : MediumTest
108         * @tc.type    : Function
109         */
110        it('SUB_Account_OsAccount_NoPermission_0400', 0, async (done) => {
111            console.info("====>SUB_Account_OsAccount_NoPermission_0400 start====");
112            let domainInfo = { domain: 'testDomain', accountName: 'testAccountName' };
113            let accountManager = osAccount.getAccountManager();
114            try {
115                await accountManager.getOsAccountLocalIdForDomain(domainInfo);
116                expect(true).assertFalse()
117                done()
118            } catch (err) {
119                console.info('====>checkDataSyncEnabled err: ' + JSON.stringify(err));
120                expect(err.code).assertEqual(201);
121                done();
122            }
123        });
124
125        /**
126         * @tc.number  : SUB_Account_OsAccount_NoPermission_0500
127         * @tc.name    : test queryDistributedVirtualDeviceId errcode 201 callback
128         * @tc.desc    : no ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC.
129         * @tc.level   : Level3
130         * @tc.size    : MediumTest
131         * @tc.type    : Function
132         */
133        it('SUB_Account_OsAccount_NoPermission_0500', 0, async (done) => {
134            console.info("====>SUB_Account_OsAccount_NoPermission_0500 start====");
135            let accountManager = osAccount.getAccountManager();
136            try {
137                accountManager.queryDistributedVirtualDeviceId((err, virtualID) => {
138                    console.info('====>queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
139                    try {
140                        expect(err.code).assertEqual(201);
141                    } catch (err) {
142                        console.info('====>Assert err: ' + JSON.stringify(err));
143                    }
144                    done();
145                });
146            } catch (err) {
147                console.info('====>queryDistributedVirtualDeviceId exception: ' + JSON.stringify(err));
148                expect(err.code).assertEqual(201);
149                done();
150            }
151        });
152
153        /**
154         * @tc.number  : SUB_Account_OsAccount_NoPermission_0600
155         * @tc.name    : test queryDistributedVirtualDeviceId errcode 201 promise
156         * @tc.desc    : no ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC.
157         * @tc.level   : Level3
158         * @tc.size    : MediumTest
159         * @tc.type    : Function
160         */
161        it('SUB_Account_OsAccount_NoPermission_0600', 0, async (done) => {
162            console.info("====>SUB_Account_OsAccount_NoPermission_0600 start====");
163            let accountManager = osAccount.getAccountManager();
164            try {
165                await accountManager.queryDistributedVirtualDeviceId();
166                expect(true).assertFalse()
167                done()
168            } catch (err) {
169                console.info('====>checkDataSyncEnabled err: ' + JSON.stringify(err));
170                expect(err.code).assertEqual(201);
171                done();
172            }
173        });
174    });
175}