1 /*
2  * Copyright (c) 2023-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 
16 #include "UTTest_dm_deviceprofile_connector.h"
17 
18 #include "dm_constants.h"
19 #include "deviceprofile_connector.h"
20 
21 namespace OHOS {
22 namespace DistributedHardware {
SetUp()23 void DeviceProfileConnectorTest::SetUp()
24 {
25 }
26 
TearDown()27 void DeviceProfileConnectorTest::TearDown()
28 {
29 }
30 
SetUpTestCase()31 void DeviceProfileConnectorTest::SetUpTestCase()
32 {
33 }
34 
TearDownTestCase()35 void DeviceProfileConnectorTest::TearDownTestCase()
36 {
37 }
38 
39 HWTEST_F(DeviceProfileConnectorTest, GetAccessControlProfile_001, testing::ext::TestSize.Level0)
40 {
41     auto ret = DeviceProfileConnector::GetInstance().GetAccessControlProfile();
42     EXPECT_EQ(ret.empty(), false);
43 }
44 
45 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_001, testing::ext::TestSize.Level0)
46 {
47     std::string pkgName;
48     std::string deviceId = "deviceId";
49     auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
50     EXPECT_EQ(ret.empty(), true);
51 }
52 
53 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_002, testing::ext::TestSize.Level0)
54 {
55     std::string pkgName = "bundleName";
56     std::string deviceId = "deviceId";
57     auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
58     EXPECT_EQ(ret.empty(), true);
59 }
60 
61 HWTEST_F(DeviceProfileConnectorTest, GetDeviceAclParam_001, testing::ext::TestSize.Level0)
62 {
63     DmDiscoveryInfo discoveryInfo;
64     bool isonline = true;
65     int32_t authForm = 0;
66     int32_t ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
67     EXPECT_EQ(ret, DM_OK);
68 }
69 
70 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_001, testing::ext::TestSize.Level0)
71 {
72     DistributedDeviceProfile::AccessControlProfile profiles;
73     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
74     DmDiscoveryInfo discoveryInfo;
75     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
76     EXPECT_EQ(ret, IDENTICAL_ACCOUNT);
77 }
78 
79 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_002, testing::ext::TestSize.Level0)
80 {
81     DistributedDeviceProfile::AccessControlProfile profiles;
82     profiles.SetBindType(DM_POINT_TO_POINT);
83     profiles.SetBindLevel(DEVICE);
84     DmDiscoveryInfo discoveryInfo;
85     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
86     EXPECT_EQ(ret, PEER_TO_PEER);
87 }
88 
89 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_003, testing::ext::TestSize.Level0)
90 {
91     DistributedDeviceProfile::AccessControlProfile profiles;
92     profiles.SetBindType(DM_POINT_TO_POINT);
93     profiles.SetBindLevel(APP);
94     profiles.accesser_.SetAccesserBundleName("ohos_test");
95     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
96     DmDiscoveryInfo discoveryInfo;
97     discoveryInfo.pkgname = "ohos_test";
98     discoveryInfo.localDeviceId = "localDeviceId";
99     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
100     EXPECT_EQ(ret, PEER_TO_PEER);
101 }
102 
103 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_004, testing::ext::TestSize.Level0)
104 {
105     DistributedDeviceProfile::AccessControlProfile profiles;
106     profiles.SetBindType(DM_POINT_TO_POINT);
107     profiles.SetBindLevel(APP);
108     profiles.accessee_.SetAccesseeBundleName("ohos_test");
109     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
110     DmDiscoveryInfo discoveryInfo;
111     discoveryInfo.pkgname = "ohos_test";
112     discoveryInfo.localDeviceId = "localDeviceId";
113     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
114     EXPECT_EQ(ret, PEER_TO_PEER);
115 }
116 
117 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_005, testing::ext::TestSize.Level0)
118 {
119     DistributedDeviceProfile::AccessControlProfile profiles;
120     profiles.SetBindType(DM_ACROSS_ACCOUNT);
121     profiles.SetBindLevel(DEVICE);
122     DmDiscoveryInfo discoveryInfo;
123     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
124     EXPECT_EQ(ret, ACROSS_ACCOUNT);
125 }
126 
127 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSize.Level0)
128 {
129     DistributedDeviceProfile::AccessControlProfile profiles;
130     profiles.SetBindType(DM_ACROSS_ACCOUNT);
131     profiles.SetBindLevel(APP);
132     profiles.accesser_.SetAccesserBundleName("pkgName");
133     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
134     DmDiscoveryInfo discoveryInfo;
135     discoveryInfo.pkgname = "pkgName";
136     discoveryInfo.localDeviceId = "localDeviceId";
137     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
138     EXPECT_EQ(ret, ACROSS_ACCOUNT);
139 }
140 
141 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSize.Level0)
142 {
143     DistributedDeviceProfile::AccessControlProfile profiles;
144     profiles.SetBindType(DM_ACROSS_ACCOUNT);
145     profiles.SetBindLevel(APP);
146     profiles.accessee_.SetAccesseeBundleName("pkgName");
147     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
148     DmDiscoveryInfo discoveryInfo;
149     discoveryInfo.pkgname = "pkgName";
150     discoveryInfo.localDeviceId = "localDeviceId";
151     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
152     EXPECT_EQ(ret, ACROSS_ACCOUNT);
153 }
154 
155 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_008, testing::ext::TestSize.Level0)
156 {
157     DistributedDeviceProfile::AccessControlProfile profiles;
158     uint32_t invalidType = 10;
159     profiles.SetBindType(invalidType);
160     DmDiscoveryInfo discoveryInfo;
161     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
162     EXPECT_EQ(ret, INVALID_TYPE);
163 }
164 
165 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_001, testing::ext::TestSize.Level0)
166 {
167     std::string trustDeviceId = "trustDeviceId";
168     std::string requestDeviceId = "requestDeviceId";
169     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
170     EXPECT_EQ(ret, INVALIED_TYPE);
171 }
172 
173 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_002, testing::ext::TestSize.Level0)
174 {
175     std::string trustDeviceId = "deviceId";
176     std::string requestDeviceId = "requestDeviceId";
177     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
178     EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
179 }
180 
181 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_003, testing::ext::TestSize.Level0)
182 {
183     std::string trustDeviceId = "deviceId";
184     std::string requestDeviceId = "deviceId";
185     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
186     EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
187 }
188 
189 HWTEST_F(DeviceProfileConnectorTest, GetBindTypeByPkgName_001, testing::ext::TestSize.Level0)
190 {
191     std::string pkgName;
192     std::string requestDeviceId;
193     std::string trustUdid;
194     auto ret = DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, requestDeviceId, trustUdid);
195     EXPECT_EQ(ret.empty(), true);
196 }
197 
198 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_001, testing::ext::TestSize.Level0)
199 {
200     DistributedDeviceProfile::AccessControlProfile profiles;
201     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
202     std::string pkgName;
203     std::string requestDeviceId;
204     std::vector<int32_t> bindTypeVec;
205     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
206     EXPECT_EQ(bindTypeVec.empty(), false);
207 }
208 
209 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_002, testing::ext::TestSize.Level0)
210 {
211     DistributedDeviceProfile::AccessControlProfile profiles;
212     profiles.SetBindType(DM_POINT_TO_POINT);
213     profiles.SetBindLevel(DEVICE);
214     std::string pkgName;
215     std::string requestDeviceId;
216     std::vector<int32_t> bindTypeVec;
217     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
218     EXPECT_EQ(bindTypeVec.empty(), false);
219 }
220 
221 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_003, testing::ext::TestSize.Level0)
222 {
223     DistributedDeviceProfile::AccessControlProfile profiles;
224     profiles.SetBindType(DM_POINT_TO_POINT);
225     profiles.SetBindLevel(APP);
226     profiles.accesser_.SetAccesserBundleName("pkgName");
227     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
228     std::string pkgName = "pkgName";
229     std::string requestDeviceId = "localDeviceId";
230     std::vector<int32_t> bindTypeVec;
231     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
232     EXPECT_EQ(bindTypeVec.empty(), false);
233 }
234 
235 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_004, testing::ext::TestSize.Level0)
236 {
237     DistributedDeviceProfile::AccessControlProfile profiles;
238     profiles.SetBindType(DM_POINT_TO_POINT);
239     profiles.SetBindLevel(APP);
240     profiles.accessee_.SetAccesseeBundleName("pkgName");
241     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
242     std::string pkgName = "pkgName";
243     std::string requestDeviceId = "localDeviceId";
244     std::vector<int32_t> bindTypeVec;
245     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
246     EXPECT_EQ(bindTypeVec.empty(), false);
247 }
248 
249 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_005, testing::ext::TestSize.Level0)
250 {
251     DistributedDeviceProfile::AccessControlProfile profiles;
252     profiles.SetBindType(DM_ACROSS_ACCOUNT);
253     profiles.SetBindLevel(DEVICE);
254     std::string pkgName;
255     std::string requestDeviceId;
256     std::vector<int32_t> bindTypeVec;
257     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
258     EXPECT_EQ(bindTypeVec.empty(), false);
259 }
260 
261 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_006, testing::ext::TestSize.Level0)
262 {
263     DistributedDeviceProfile::AccessControlProfile profiles;
264     profiles.SetBindType(DM_ACROSS_ACCOUNT);
265     profiles.SetBindLevel(APP);
266     profiles.accesser_.SetAccesserBundleName("pkgName");
267     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
268     std::string pkgName = "pkgName";
269     std::string requestDeviceId = "localDeviceId";
270     std::vector<int32_t> bindTypeVec;
271     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
272     EXPECT_EQ(bindTypeVec.empty(), false);
273 }
274 
275 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_007, testing::ext::TestSize.Level0)
276 {
277     DistributedDeviceProfile::AccessControlProfile profiles;
278     profiles.SetBindType(DM_ACROSS_ACCOUNT);
279     profiles.SetBindLevel(APP);
280     profiles.accessee_.SetAccesseeBundleName("pkgName");
281     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
282     std::string pkgName = "pkgName";
283     std::string requestDeviceId = "localDeviceId";
284     std::vector<int32_t> bindTypeVec;
285     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
286     EXPECT_EQ(bindTypeVec.empty(), false);
287 }
288 
289 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_001, testing::ext::TestSize.Level0)
290 {
291     DistributedDeviceProfile::AccessControlProfile profile;
292     profile.SetTrustDeviceId("deviceId");
293     profile.SetStatus(INACTIVE);
294     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
295     profiles.push_back(profile);
296     std::string pkgName;
297     std::vector<int32_t> sinkBindType;
298     std::string localDeviceId;
299     std::string targetDeviceId = "targetDeviceId";
300     auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
301         targetDeviceId);
302     EXPECT_EQ(ret.empty(), true);
303 }
304 
305 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_002, testing::ext::TestSize.Level0)
306 {
307     DistributedDeviceProfile::AccessControlProfile profile;
308     profile.SetTrustDeviceId("targetDeviceId");
309     profile.SetStatus(ACTIVE);
310     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
311     profiles.push_back(profile);
312     std::string pkgName;
313     std::vector<int32_t> sinkBindType;
314     std::string localDeviceId;
315     std::string targetDeviceId = "targetDeviceId";
316     auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
317         targetDeviceId);
318     EXPECT_EQ(ret.empty(), true);
319 }
320 
321 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_003, testing::ext::TestSize.Level0)
322 {
323     DistributedDeviceProfile::AccessControlProfile profile;
324     profile.SetTrustDeviceId("targetDeviceId");
325     profile.SetStatus(INACTIVE);
326     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
327     profiles.push_back(profile);
328     std::string pkgName;
329     std::vector<int32_t> sinkBindType;
330     std::string localDeviceId;
331     std::string targetDeviceId = "targetDeviceId";
332     auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
333         targetDeviceId);
334     EXPECT_EQ(ret.empty(), true);
335 }
336 
337 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_001, testing::ext::TestSize.Level0)
338 {
339     DistributedDeviceProfile::AccessControlProfile profiles;
340     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
341     DmDiscoveryInfo paramInfo;
342     std::vector<int32_t> sinkBindType;
343     std::vector<int32_t> bindTypeIndex;
344     uint32_t index = 0;
345     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
346     EXPECT_EQ(sinkBindType.empty(), false);
347 }
348 
349 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_002, testing::ext::TestSize.Level0)
350 {
351     DistributedDeviceProfile::AccessControlProfile profiles;
352     profiles.SetBindType(DM_POINT_TO_POINT);
353     profiles.SetBindLevel(DEVICE);
354     DmDiscoveryInfo paramInfo;
355     std::vector<int32_t> sinkBindType;
356     std::vector<int32_t> bindTypeIndex;
357     uint32_t index = 0;
358     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
359     EXPECT_EQ(sinkBindType.empty(), false);
360 }
361 
362 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_003, testing::ext::TestSize.Level0)
363 {
364     DistributedDeviceProfile::AccessControlProfile profiles;
365     profiles.SetBindType(DM_POINT_TO_POINT);
366     profiles.SetBindLevel(APP);
367     profiles.accesser_.SetAccesserBundleName("pkgName");
368     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
369     DmDiscoveryInfo paramInfo;
370     paramInfo.pkgname = "pkgName";
371     paramInfo.localDeviceId = "localDeviceId";
372     std::vector<int32_t> sinkBindType;
373     std::vector<int32_t> bindTypeIndex;
374     uint32_t index = 0;
375     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
376     EXPECT_EQ(sinkBindType.empty(), false);
377 }
378 
379 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_004, testing::ext::TestSize.Level0)
380 {
381     DistributedDeviceProfile::AccessControlProfile profiles;
382     profiles.SetBindType(DM_POINT_TO_POINT);
383     profiles.SetBindLevel(APP);
384     profiles.accessee_.SetAccesseeBundleName("pkgName");
385     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
386     DmDiscoveryInfo paramInfo;
387     paramInfo.pkgname = "pkgName";
388     paramInfo.localDeviceId = "localDeviceId";
389     std::vector<int32_t> sinkBindType;
390     std::vector<int32_t> bindTypeIndex;
391     uint32_t index = 0;
392     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
393     EXPECT_EQ(sinkBindType.empty(), false);
394 }
395 
396 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_005, testing::ext::TestSize.Level0)
397 {
398     DistributedDeviceProfile::AccessControlProfile profiles;
399     profiles.SetBindType(DM_ACROSS_ACCOUNT);
400     profiles.SetBindLevel(DEVICE);
401     DmDiscoveryInfo paramInfo;
402     std::vector<int32_t> sinkBindType;
403     std::vector<int32_t> bindTypeIndex;
404     uint32_t index = 0;
405     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
406     EXPECT_EQ(sinkBindType.empty(), false);
407 }
408 
409 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_006, testing::ext::TestSize.Level0)
410 {
411     DistributedDeviceProfile::AccessControlProfile profiles;
412     profiles.SetBindType(DM_ACROSS_ACCOUNT);
413     profiles.SetBindLevel(APP);
414     profiles.accesser_.SetAccesserBundleName("pkgName");
415     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
416     DmDiscoveryInfo paramInfo;
417     paramInfo.pkgname = "pkgName";
418     paramInfo.localDeviceId = "localDeviceId";
419     std::vector<int32_t> sinkBindType;
420     std::vector<int32_t> bindTypeIndex;
421     uint32_t index = 0;
422     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
423     EXPECT_EQ(sinkBindType.empty(), false);
424 }
425 
426 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_007, testing::ext::TestSize.Level0)
427 {
428     DistributedDeviceProfile::AccessControlProfile profiles;
429     profiles.SetBindType(DM_ACROSS_ACCOUNT);
430     profiles.SetBindLevel(APP);
431     profiles.accessee_.SetAccesseeBundleName("pkgName");
432     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
433     DmDiscoveryInfo paramInfo;
434     paramInfo.pkgname = "pkgName";
435     paramInfo.localDeviceId = "localDeviceId";
436     std::vector<int32_t> sinkBindType;
437     std::vector<int32_t> bindTypeIndex;
438     uint32_t index = 0;
439     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
440     EXPECT_EQ(sinkBindType.empty(), false);
441 }
442 
443 HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_001, testing::ext::TestSize.Level0)
444 {
445     std::string pkgName;
446     std::vector<int32_t> bindTypeVec;
447     std::string localDeviceId;
448     std::string targetDeviceId;
449     auto ret = DeviceProfileConnector::GetInstance().SyncAclByBindType(pkgName, bindTypeVec, localDeviceId,
450         targetDeviceId);
451     EXPECT_EQ(ret.empty(), true);
452 }
453 
454 HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_001, testing::ext::TestSize.Level0)
455 {
456     std::string localDeviceId = "localDeviceId";
457     std::string targetDeviceId = "targetDeviceId";
458     auto ret = DeviceProfileConnector::GetInstance().GetPkgNameFromAcl(localDeviceId, targetDeviceId);
459     EXPECT_EQ(ret.empty(), true);
460 }
461 
462 HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_002, testing::ext::TestSize.Level0)
463 {
464     std::string localDeviceId = "123456";
465     std::string targetDeviceId = "deviceId";
466     auto ret = DeviceProfileConnector::GetInstance().GetPkgNameFromAcl(localDeviceId, targetDeviceId);
467     EXPECT_EQ(ret.empty(), true);
468 }
469 
470 HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_003, testing::ext::TestSize.Level0)
471 {
472     std::string localDeviceId = "deviceId";
473     std::string targetDeviceId = "deviceId";
474     auto ret = DeviceProfileConnector::GetInstance().GetPkgNameFromAcl(localDeviceId, targetDeviceId);
475     EXPECT_EQ(ret.empty(), false);
476 }
477 
478 HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_001, testing::ext::TestSize.Level0)
479 {
480     std::string trustDeviceId = "trustDeviceId";
481     std::string requestDeviceId = "deviceId";
482     auto ret = DeviceProfileConnector::GetInstance().GetOfflineParamFromAcl(trustDeviceId, requestDeviceId);
483     EXPECT_EQ(ret.bindType, INVALIED_TYPE);
484 }
485 
486 HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_002, testing::ext::TestSize.Level0)
487 {
488     std::string trustDeviceId = "123456";
489     std::string requestDeviceId = "deviceId";
490     auto ret = DeviceProfileConnector::GetInstance().GetOfflineParamFromAcl(trustDeviceId, requestDeviceId);
491     EXPECT_EQ(ret.bindType, INVALIED_TYPE);
492 }
493 
494 HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_003, testing::ext::TestSize.Level0)
495 {
496     std::string trustDeviceId = "deviceId";
497     std::string requestDeviceId = "deviceId";
498     auto ret = DeviceProfileConnector::GetInstance().GetOfflineParamFromAcl(trustDeviceId, requestDeviceId);
499     EXPECT_EQ(ret.bindType, IDENTICAL_ACCOUNT_TYPE);
500 }
501 
502 HWTEST_F(DeviceProfileConnectorTest, PutAccessControlList_001, testing::ext::TestSize.Level0)
503 {
504     DmAclInfo aclInfo;
505     DmAccesser dmAccesser;
506     DmAccessee dmAccessee;
507     int32_t ret = DeviceProfileConnector::GetInstance().PutAccessControlList(aclInfo, dmAccesser, dmAccessee);
508     EXPECT_EQ(ret, DM_OK);
509 }
510 
511 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_001, testing::ext::TestSize.Level0)
512 {
513     int32_t userId = 0;
514     std::string accountId;
515     int32_t ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(userId, accountId);
516     EXPECT_EQ(ret, DM_OK);
517 }
518 
519 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_002, testing::ext::TestSize.Level0)
520 {
521     std::string pkgName;
522     std::string localDeviceId;
523     std::string remoteDeviceId;
524     auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId);
525     EXPECT_EQ(ret.bindType, INVALIED_TYPE);
526 }
527 
528 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_003, testing::ext::TestSize.Level0)
529 {
530     std::string pkgName = "bundleName";
531     std::string localDeviceId = "localDeviceId";
532     std::string remoteDeviceId = "remoteDeviceId";
533     auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId);
534     EXPECT_EQ(ret.bindType, INVALIED_TYPE);
535 }
536 
537 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_004, testing::ext::TestSize.Level0)
538 {
539     std::string pkgName = "bundleName";
540     std::string localDeviceId = "123456";
541     std::string remoteDeviceId = "deviceId";
542     auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId);
543     EXPECT_EQ(ret.bindType, INVALIED_TYPE);
544 }
545 
546 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_005, testing::ext::TestSize.Level0)
547 {
548     std::string pkgName = "bundleName";
549     std::string localDeviceId = "deviceId";
550     std::string remoteDeviceId = "deviceId";
551     auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId);
552     EXPECT_EQ(ret.bindType, INVALIED_TYPE);
553 }
554 
555 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_001, testing::ext::TestSize.Level0)
556 {
557     int32_t userId = 0;
558     std::string oldAccountId;
559     std::string newAccountId;
560     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
561     EXPECT_EQ(ret, DM_OK);
562 }
563 
564 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_002, testing::ext::TestSize.Level0)
565 {
566     int32_t userId = 123456;
567     std::string oldAccountId = "oldAccountId";
568     std::string newAccountId = "newAccountId";
569     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
570     EXPECT_EQ(ret, DM_OK);
571 }
572 
573 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_003, testing::ext::TestSize.Level0)
574 {
575     int32_t userId = 123456;
576     std::string oldAccountId = "accountId";
577     std::string newAccountId = "newAccountId";
578     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
579     EXPECT_EQ(ret, DM_OK);
580 }
581 
582 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_004, testing::ext::TestSize.Level0)
583 {
584     int32_t userId = 123456;
585     std::string oldAccountId = "accountId";
586     std::string newAccountId = "accountId";
587     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
588     EXPECT_EQ(ret, DM_OK);
589 }
590 
591 HWTEST_F(DeviceProfileConnectorTest, CheckIdenticalAccount_001, testing::ext::TestSize.Level0)
592 {
593     int32_t userId = 0;
594     std::string accountId;
595     bool ret = DeviceProfileConnector::GetInstance().CheckIdenticalAccount(userId, accountId);
596     EXPECT_EQ(ret, true);
597 }
598 
599 HWTEST_F(DeviceProfileConnectorTest, DeleteP2PAccessControlList_001, testing::ext::TestSize.Level0)
600 {
601     int32_t userId = 0;
602     std::string accountId;
603     int32_t ret = DeviceProfileConnector::GetInstance().DeleteP2PAccessControlList(userId, accountId);
604     EXPECT_EQ(ret, DM_OK);
605 }
606 
607 HWTEST_F(DeviceProfileConnectorTest, DeleteP2PAccessControlList_002, testing::ext::TestSize.Level0)
608 {
609     int32_t userId = 123456;
610     std::string accountId = "newAccountId";
611     int32_t ret = DeviceProfileConnector::GetInstance().DeleteP2PAccessControlList(userId, accountId);
612     EXPECT_EQ(ret, DM_OK);
613 }
614 
615 HWTEST_F(DeviceProfileConnectorTest, DeleteP2PAccessControlList_003, testing::ext::TestSize.Level0)
616 {
617     int32_t userId = 123456;
618     std::string accountId = "accountId";
619     int32_t ret = DeviceProfileConnector::GetInstance().DeleteP2PAccessControlList(userId, accountId);
620     EXPECT_EQ(ret, DM_OK);
621 }
622 
623 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
624 {
625     std::string pkgName;
626     std::string deviceId;
627     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
628     EXPECT_EQ(ret, false);
629 }
630 
631 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)
632 {
633     std::string pkgName = "bundleName";
634     std::string deviceId = "123456";
635     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
636     EXPECT_EQ(ret, false);
637 }
638 
639 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)
640 {
641     std::string pkgName = "bundleName";
642     std::string deviceId = "deviceId";
643     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
644     EXPECT_EQ(ret, false);
645 }
646 
647 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
648 {
649     std::string pkgName;
650     std::string deviceId;
651     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
652     EXPECT_EQ(ret, false);
653 }
654 
655 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)
656 {
657     std::string pkgName = "bundleName";
658     std::string deviceId = "123456";
659     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
660     EXPECT_EQ(ret, false);
661 }
662 
663 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)
664 {
665     std::string pkgName = "bundleName";
666     std::string deviceId = "deviceId";
667     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
668     EXPECT_EQ(ret, false);
669 }
670 
671 HWTEST_F(DeviceProfileConnectorTest, CheckDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
672 {
673     std::string pkgName;
674     std::string deviceId;
675     bool ret = DeviceProfileConnector::GetInstance().CheckDevIdInAclForDevBind(pkgName, deviceId);
676     EXPECT_EQ(ret, false);
677 }
678 
679 HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_001, testing::ext::TestSize.Level0)
680 {
681     std::string deviceId;
682     uint32_t ret = DeviceProfileConnector::GetInstance().DeleteTimeOutAcl(deviceId);
683     EXPECT_EQ(ret, 0);
684 }
685 
686 HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_001, testing::ext::TestSize.Level0)
687 {
688     std::string deviceId;
689     int32_t ret = DeviceProfileConnector::GetInstance().GetTrustNumber(deviceId);
690     EXPECT_EQ(ret, DM_OK);
691 }
692 
693 HWTEST_F(DeviceProfileConnectorTest, CheckPkgnameInAcl_001, testing::ext::TestSize.Level0)
694 {
695     std::string pkgName;
696     std::string localDeviceId;
697     std::string remoteDeviceId;
698     bool ret = DeviceProfileConnector::GetInstance().CheckPkgnameInAcl(pkgName, localDeviceId, remoteDeviceId);
699     EXPECT_EQ(ret, false);
700 }
701 
702 HWTEST_F(DeviceProfileConnectorTest, CheckPkgnameInAcl_002, testing::ext::TestSize.Level0)
703 {
704     std::string pkgName = "bundleName";
705     std::string localDeviceId = "localDeviceId";
706     std::string remoteDeviceId = "remoteDeviceId";
707     bool ret = DeviceProfileConnector::GetInstance().CheckPkgnameInAcl(pkgName, localDeviceId, remoteDeviceId);
708     EXPECT_EQ(ret, false);
709 }
710 
711 HWTEST_F(DeviceProfileConnectorTest, CheckPkgnameInAcl_003, testing::ext::TestSize.Level0)
712 {
713     std::string pkgName = "bundleName";
714     std::string localDeviceId = "deviceId";
715     std::string remoteDeviceId = "remoteDeviceId";
716     bool ret = DeviceProfileConnector::GetInstance().CheckPkgnameInAcl(pkgName, localDeviceId, remoteDeviceId);
717     EXPECT_EQ(ret, false);
718 }
719 
720 HWTEST_F(DeviceProfileConnectorTest, CheckPkgnameInAcl_004, testing::ext::TestSize.Level0)
721 {
722     std::string pkgName = "bundleName";
723     std::string localDeviceId = "deviceId";
724     std::string remoteDeviceId = "deviceId";
725     bool ret = DeviceProfileConnector::GetInstance().CheckPkgnameInAcl(pkgName, localDeviceId, remoteDeviceId);
726     EXPECT_EQ(ret, false);
727 }
728 
729 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_001, testing::ext::TestSize.Level0)
730 {
731     std::string udid = "udid";
732     int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
733     EXPECT_EQ(ret, ERR_DM_FAILED);
734 }
735 
736 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_002, testing::ext::TestSize.Level0)
737 {
738     std::string udid = "deviceId";
739     int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
740     EXPECT_EQ(ret, DM_OK);
741 }
742 
743 HWTEST_F(DeviceProfileConnectorTest, GetAuthForm_001, testing::ext::TestSize.Level0)
744 {
745     DistributedDeviceProfile::AccessControlProfile profile;
746     std::string trustDev = "";
747     std::string reqDev = "";
748     int32_t ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
749     EXPECT_EQ(ret, INVALIED_TYPE);
750     profile.SetBindType(DM_IDENTICAL_ACCOUNT);
751     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
752     EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
753     profile.SetBindType(DM_POINT_TO_POINT);
754     profile.SetBindLevel(DEVICE);
755     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
756     EXPECT_EQ(ret, DEVICE_PEER_TO_PEER_TYPE);
757     profile.SetBindType(DM_ACROSS_ACCOUNT);
758     profile.SetBindLevel(DEVICE);
759     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
760     EXPECT_EQ(ret, DEVICE_ACROSS_ACCOUNT_TYPE);
761     profile.SetBindLevel(APP);
762     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
763     EXPECT_EQ(ret, APP_ACROSS_ACCOUNT_TYPE);
764     profile.SetBindType(INVALIED_TYPE);
765     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
766     EXPECT_EQ(ret, INVALIED_TYPE);
767 }
768 
769 HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_001, testing::ext::TestSize.Level0)
770 {
771     DistributedDeviceProfile::AccessControlProfile profile;
772     DmAccessCaller caller;
773     DmAccessCallee callee;
774     int32_t ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
775     EXPECT_EQ(ret, false);
776     profile.SetBindType(DM_IDENTICAL_ACCOUNT);
777     profile.accessee_.SetAccesseeBundleName("pkgName");
778     profile.accessee_.SetAccesseeDeviceId("localDeviceId");
779     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
780     EXPECT_EQ(ret, true);
781     profile.SetBindType(DM_POINT_TO_POINT);
782     profile.SetBindLevel(DEVICE);
783     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
784     EXPECT_EQ(ret, true);
785     profile.SetBindLevel(APP);
786     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
787     EXPECT_EQ(ret, true);
788     profile.SetBindLevel(SERVICE);
789     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
790     EXPECT_EQ(ret, true);
791     profile.SetBindType(DM_ACROSS_ACCOUNT);
792     profile.SetBindLevel(DEVICE);
793     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
794     EXPECT_EQ(ret, true);
795     profile.SetBindLevel(APP);
796     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
797     EXPECT_EQ(ret, true);
798     profile.SetBindLevel(SERVICE);
799     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
800     EXPECT_EQ(ret, true);
801     profile.SetBindType(INVALIED_TYPE);
802     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
803     EXPECT_EQ(ret, false);
804 }
805 } // namespace DistributedHardware
806 } // namespace OHOS
807