• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "dm_device_info.h"
20 #include "deviceprofile_connector.h"
21 #include "dp_inited_callback_stub.h"
22 
23 using namespace testing;
24 using namespace testing::ext;
25 namespace OHOS {
26 namespace DistributedHardware {
SetUp()27 void DeviceProfileConnectorTest::SetUp()
28 {
29 }
30 
TearDown()31 void DeviceProfileConnectorTest::TearDown()
32 {
33 }
34 
SetUpTestCase()35 void DeviceProfileConnectorTest::SetUpTestCase()
36 {
37     multipleUserConnectorMock_ = std::make_shared<MultipleUserConnectorMock>();
38     DmMultipleUserConnector::dmMultipleUserConnector = multipleUserConnectorMock_;
39     cryptoMock_ = std::make_shared<CryptoMock>();
40     DmCrypto::dmCrypto = cryptoMock_;
41 }
42 
TearDownTestCase()43 void DeviceProfileConnectorTest::TearDownTestCase()
44 {
45     DmMultipleUserConnector::dmMultipleUserConnector = nullptr;
46     multipleUserConnectorMock_ = nullptr;
47     DmCrypto::dmCrypto = nullptr;
48     cryptoMock_ = nullptr;
49 }
50 
51 class MockDpInitedCallback : public DistributedDeviceProfile::DpInitedCallbackStub {
52 public:
MockDpInitedCallback()53     MockDpInitedCallback() {}
~MockDpInitedCallback()54     ~MockDpInitedCallback() {}
OnDpInited()55     int32_t OnDpInited()
56     {
57         return DM_OK;
58     }
59 };
60 
AddAccessControlProfileFirst(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)61 void AddAccessControlProfileFirst(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
62 {
63     int32_t userId = 123456;
64     int32_t bindType = 256;
65     int32_t deviceIdType = 1;
66     uint32_t bindLevel = 1;
67     uint32_t status = 1;
68     uint32_t authenticationType = 2;
69     uint32_t accesserId = 1;
70     uint32_t tokenId = 1001;
71 
72     std::string oldAccountId = "oldAccountId";
73     std::string newAccountId = "newAccountId";
74     std::string deviceIdEr = "remoteDeviceId";
75     std::string deviceIdEe = "localDeviceId";
76     std::string trustDeviceId = "123456";
77 
78     DistributedDeviceProfile::Accesser accesser;
79     accesser.SetAccesserId(accesserId);
80     accesser.SetAccesserDeviceId(deviceIdEr);
81     accesser.SetAccesserUserId(userId);
82     accesser.SetAccesserAccountId(oldAccountId);
83     accesser.SetAccesserTokenId(tokenId);
84     accesser.SetAccesserBundleName("bundleName");
85     accesser.SetAccesserHapSignature("uph1");
86     accesser.SetAccesserBindLevel(bindLevel);
87 
88     DistributedDeviceProfile::Accessee accessee;
89     accessee.SetAccesseeId(accesserId);
90     accessee.SetAccesseeDeviceId(deviceIdEe);
91     accessee.SetAccesseeUserId(userId);
92     accessee.SetAccesseeAccountId(newAccountId);
93     accessee.SetAccesseeTokenId(tokenId);
94     accessee.SetAccesseeBundleName("bundleName");
95     accessee.SetAccesseeHapSignature("uph1");
96     accessee.SetAccesseeBindLevel(bindLevel);
97 
98     DistributedDeviceProfile::AccessControlProfile profileFifth;
99     profileFifth.SetAccessControlId(accesserId);
100     profileFifth.SetAccesserId(accesserId);
101     profileFifth.SetAccesseeId(accesserId);
102     profileFifth.SetTrustDeviceId(trustDeviceId);
103     profileFifth.SetBindType(bindType);
104     profileFifth.SetAuthenticationType(authenticationType);
105     profileFifth.SetDeviceIdType(deviceIdType);
106     profileFifth.SetStatus(status);
107     profileFifth.SetBindLevel(bindLevel);
108     profileFifth.SetAccesser(accesser);
109     profileFifth.SetAccessee(accessee);
110     accessControlProfiles.push_back(profileFifth);
111 }
112 
AddAccessControlProfileFirst(DistributedDeviceProfile::AccessControlProfile & accessControlProfiles)113 void AddAccessControlProfileFirst(DistributedDeviceProfile::AccessControlProfile& accessControlProfiles)
114 {
115     int32_t userId = 123456;
116     int32_t bindType = 256;
117     int32_t deviceIdType = 1;
118     uint32_t bindLevel = 1;
119     uint32_t status = 1;
120     uint32_t authenticationType = 2;
121     uint32_t accesserId = 1;
122     uint32_t tokenId = 1001;
123 
124     std::string oldAccountId = "oldAccountId";
125     std::string newAccountId = "newAccountId";
126     std::string deviceIdEr = "remoteDeviceId";
127     std::string deviceIdEe = "localDeviceId";
128     std::string trustDeviceId = "123456";
129 
130     DistributedDeviceProfile::Accesser accesser;
131     accesser.SetAccesserId(accesserId);
132     accesser.SetAccesserDeviceId(deviceIdEr);
133     accesser.SetAccesserUserId(userId);
134     accesser.SetAccesserAccountId(oldAccountId);
135     accesser.SetAccesserTokenId(tokenId);
136     accesser.SetAccesserBundleName("bundleName");
137     accesser.SetAccesserHapSignature("uph1");
138     accesser.SetAccesserBindLevel(bindLevel);
139 
140     DistributedDeviceProfile::Accessee accessee;
141     accessee.SetAccesseeId(accesserId);
142     accessee.SetAccesseeDeviceId(deviceIdEe);
143     accessee.SetAccesseeUserId(userId);
144     accessee.SetAccesseeAccountId(newAccountId);
145     accessee.SetAccesseeTokenId(tokenId);
146     accessee.SetAccesseeBundleName("bundleName");
147     accessee.SetAccesseeHapSignature("uph1");
148     accessee.SetAccesseeBindLevel(bindLevel);
149 
150     accessControlProfiles.SetAccessControlId(accesserId);
151     accessControlProfiles.SetAccesserId(accesserId);
152     accessControlProfiles.SetAccesseeId(accesserId);
153     accessControlProfiles.SetTrustDeviceId(trustDeviceId);
154     accessControlProfiles.SetBindType(bindType);
155     accessControlProfiles.SetAuthenticationType(authenticationType);
156     accessControlProfiles.SetDeviceIdType(deviceIdType);
157     accessControlProfiles.SetStatus(status);
158     accessControlProfiles.SetBindLevel(bindLevel);
159     accessControlProfiles.SetAccesser(accesser);
160     accessControlProfiles.SetAccessee(accessee);
161 }
162 
AddAccessControlProfileSecond(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)163 void AddAccessControlProfileSecond(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
164 {
165     int32_t userId = 123456;
166     int32_t bindType = 256;
167     int32_t deviceIdType = 1;
168     uint32_t bindLevel = 3;
169     uint32_t status = 1;
170     uint32_t authenticationType = 2;
171     uint32_t accesserId = 1;
172     uint32_t tokenId = 1001;
173 
174     std::string oldAccountId = "oldAccountId";
175     std::string newAccountId = "newAccountId";
176     std::string deviceIdEr = "remoteDeviceId";
177     std::string deviceIdEe = "localDeviceId";
178     std::string trustDeviceId = "localDeviceId";
179 
180     DistributedDeviceProfile::Accesser accesser;
181     accesser.SetAccesserId(accesserId);
182     accesser.SetAccesserDeviceId(deviceIdEr);
183     accesser.SetAccesserUserId(userId);
184     accesser.SetAccesserAccountId(oldAccountId);
185     accesser.SetAccesserTokenId(tokenId);
186     accesser.SetAccesserBundleName("bundleName1");
187     accesser.SetAccesserHapSignature("uph1");
188     accesser.SetAccesserBindLevel(bindLevel);
189 
190     DistributedDeviceProfile::Accessee accessee;
191     accessee.SetAccesseeId(accesserId);
192     accessee.SetAccesseeDeviceId(deviceIdEe);
193     accessee.SetAccesseeUserId(userId);
194     accessee.SetAccesseeAccountId(newAccountId);
195     accessee.SetAccesseeTokenId(tokenId);
196     accessee.SetAccesseeBundleName("bundleName2");
197     accessee.SetAccesseeHapSignature("uph1");
198     accessee.SetAccesseeBindLevel(bindLevel);
199 
200     DistributedDeviceProfile::AccessControlProfile profileFifth;
201     profileFifth.SetAccessControlId(accesserId);
202     profileFifth.SetAccesserId(accesserId);
203     profileFifth.SetAccesseeId(accesserId);
204     profileFifth.SetTrustDeviceId(trustDeviceId);
205     profileFifth.SetBindType(bindType);
206     profileFifth.SetAuthenticationType(authenticationType);
207     profileFifth.SetDeviceIdType(deviceIdType);
208     profileFifth.SetStatus(status);
209     profileFifth.SetBindLevel(bindLevel);
210     profileFifth.SetAccesser(accesser);
211     profileFifth.SetAccessee(accessee);
212     accessControlProfiles.push_back(profileFifth);
213 }
214 
AddAccessControlProfileThird(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)215 void AddAccessControlProfileThird(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
216 {
217     int32_t userId = 123456;
218     int32_t bindType = 256;
219     int32_t deviceIdType = 1;
220     uint32_t bindLevel = 3;
221     uint32_t status = 1;
222     uint32_t authenticationType = 2;
223     uint32_t accesserId = 1;
224     uint32_t tokenId = 1001;
225 
226     std::string oldAccountId = "oldAccountId";
227     std::string newAccountId = "newAccountId";
228     std::string deviceIdEr = "remoteDeviceId";
229     std::string deviceIdEe = "localDeviceId";
230     std::string trustDeviceId = "remoteDeviceId";
231 
232     DistributedDeviceProfile::Accesser accesser;
233     accesser.SetAccesserId(accesserId);
234     accesser.SetAccesserDeviceId(deviceIdEr);
235     accesser.SetAccesserUserId(userId);
236     accesser.SetAccesserAccountId(oldAccountId);
237     accesser.SetAccesserTokenId(tokenId);
238     accesser.SetAccesserBundleName("bundleName1");
239     accesser.SetAccesserHapSignature("uph1");
240     accesser.SetAccesserBindLevel(bindLevel);
241 
242     DistributedDeviceProfile::Accessee accessee;
243     accessee.SetAccesseeId(accesserId);
244     accessee.SetAccesseeDeviceId(deviceIdEe);
245     accessee.SetAccesseeUserId(userId);
246     accessee.SetAccesseeAccountId(newAccountId);
247     accessee.SetAccesseeTokenId(tokenId);
248     accessee.SetAccesseeBundleName("bundleName2");
249     accessee.SetAccesseeHapSignature("uph1");
250     accessee.SetAccesseeBindLevel(bindLevel);
251 
252     DistributedDeviceProfile::AccessControlProfile profileFifth;
253     profileFifth.SetAccessControlId(accesserId);
254     profileFifth.SetAccesserId(accesserId);
255     profileFifth.SetAccesseeId(accesserId);
256     profileFifth.SetTrustDeviceId(trustDeviceId);
257     profileFifth.SetBindType(bindType);
258     profileFifth.SetAuthenticationType(authenticationType);
259     profileFifth.SetDeviceIdType(deviceIdType);
260     profileFifth.SetStatus(status);
261     profileFifth.SetBindLevel(bindLevel);
262     profileFifth.SetAccesser(accesser);
263     profileFifth.SetAccessee(accessee);
264     accessControlProfiles.push_back(profileFifth);
265 }
266 
AddAccessControlProfileForth(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)267 void AddAccessControlProfileForth(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
268 {
269     int32_t userId = 123456;
270     int32_t bindType = 256;
271     int32_t deviceIdType = 1;
272     uint32_t bindLevel = 2;
273     uint32_t status = 1;
274     uint32_t authenticationType = 2;
275     uint32_t accesserId = 1;
276     uint32_t tokenId = 1001;
277 
278     std::string oldAccountId = "oldAccountId";
279     std::string newAccountId = "newAccountId";
280     std::string deviceIdEr = "remoteDeviceId";
281     std::string deviceIdEe = "localDeviceId";
282     std::string trustDeviceId = "localDeviceId";
283 
284     DistributedDeviceProfile::Accesser accesser;
285     accesser.SetAccesserId(accesserId);
286     accesser.SetAccesserDeviceId(deviceIdEr);
287     accesser.SetAccesserUserId(userId);
288     accesser.SetAccesserAccountId(oldAccountId);
289     accesser.SetAccesserTokenId(tokenId);
290     accesser.SetAccesserBundleName("bundleName1");
291     accesser.SetAccesserHapSignature("uph1");
292     accesser.SetAccesserBindLevel(bindLevel);
293 
294     DistributedDeviceProfile::Accessee accessee;
295     accessee.SetAccesseeId(accesserId);
296     accessee.SetAccesseeDeviceId(deviceIdEe);
297     accessee.SetAccesseeUserId(userId);
298     accessee.SetAccesseeAccountId(newAccountId);
299     accessee.SetAccesseeTokenId(tokenId);
300     accessee.SetAccesseeBundleName("bundleName2");
301     accessee.SetAccesseeHapSignature("uph1");
302     accessee.SetAccesseeBindLevel(bindLevel);
303 
304     DistributedDeviceProfile::AccessControlProfile profileFifth;
305     profileFifth.SetAccessControlId(accesserId);
306     profileFifth.SetAccesserId(accesserId);
307     profileFifth.SetAccesseeId(accesserId);
308     profileFifth.SetTrustDeviceId(trustDeviceId);
309     profileFifth.SetBindType(bindType);
310     profileFifth.SetAuthenticationType(authenticationType);
311     profileFifth.SetDeviceIdType(deviceIdType);
312     profileFifth.SetStatus(status);
313     profileFifth.SetBindLevel(bindLevel);
314     profileFifth.SetAccesser(accesser);
315     profileFifth.SetAccessee(accessee);
316     accessControlProfiles.push_back(profileFifth);
317 }
318 
AddAccessControlProfileFifth(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)319 void AddAccessControlProfileFifth(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
320 {
321     int32_t userId = 123456;
322     int32_t bindType = 256;
323     int32_t deviceIdType = 1;
324     uint32_t bindLevel = 2;
325     uint32_t status = 1;
326     uint32_t authenticationType = 2;
327     uint32_t accesserId = 1;
328     uint32_t tokenId = 1001;
329 
330     std::string oldAccountId = "oldAccountId";
331     std::string newAccountId = "newAccountId";
332     std::string deviceIdEr = "remoteDeviceId";
333     std::string deviceIdEe = "localDeviceId";
334     std::string trustDeviceId = "remoteDeviceId";
335 
336     DistributedDeviceProfile::Accesser accesser;
337     accesser.SetAccesserId(accesserId);
338     accesser.SetAccesserDeviceId(deviceIdEr);
339     accesser.SetAccesserUserId(userId);
340     accesser.SetAccesserAccountId(oldAccountId);
341     accesser.SetAccesserTokenId(tokenId);
342     accesser.SetAccesserBundleName("bundleName1");
343     accesser.SetAccesserHapSignature("uph1");
344     accesser.SetAccesserBindLevel(bindLevel);
345 
346     DistributedDeviceProfile::Accessee accessee;
347     accessee.SetAccesseeId(accesserId);
348     accessee.SetAccesseeDeviceId(deviceIdEe);
349     accessee.SetAccesseeUserId(userId);
350     accessee.SetAccesseeAccountId(newAccountId);
351     accessee.SetAccesseeTokenId(tokenId);
352     accessee.SetAccesseeBundleName("bundleName2");
353     accessee.SetAccesseeHapSignature("uph1");
354     accessee.SetAccesseeBindLevel(bindLevel);
355 
356     DistributedDeviceProfile::AccessControlProfile profileFifth;
357     profileFifth.SetAccessControlId(accesserId);
358     profileFifth.SetAccesserId(accesserId);
359     profileFifth.SetAccesseeId(accesserId);
360     profileFifth.SetTrustDeviceId(trustDeviceId);
361     profileFifth.SetBindType(bindType);
362     profileFifth.SetAuthenticationType(authenticationType);
363     profileFifth.SetDeviceIdType(deviceIdType);
364     profileFifth.SetStatus(status);
365     profileFifth.SetBindLevel(bindLevel);
366     profileFifth.SetAccesser(accesser);
367     profileFifth.SetAccessee(accessee);
368     accessControlProfiles.push_back(profileFifth);
369 }
370 
AddAccessControlProfileSix(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)371 void AddAccessControlProfileSix(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
372 {
373     int32_t userId = 123456;
374     int32_t bindType = 256;
375     int32_t deviceIdType = 1;
376     uint32_t bindLevel = 2;
377     uint32_t status = 1;
378     uint32_t authenticationType = 2;
379     uint32_t accesserId = 1;
380     uint32_t tokenId = 1001;
381 
382     std::string oldAccountId = "oldAccountId";
383     std::string newAccountId = "newAccountId";
384     std::string deviceIdEr = "remoteDeviceId";
385     std::string deviceIdEe = "localDeviceId";
386     std::string trustDeviceId = "remoteDeviceId";
387 
388     DistributedDeviceProfile::Accesser accesser;
389     accesser.SetAccesserId(accesserId);
390     accesser.SetAccesserDeviceId(deviceIdEr);
391     accesser.SetAccesserUserId(userId);
392     accesser.SetAccesserAccountId(oldAccountId);
393     accesser.SetAccesserTokenId(tokenId);
394     accesser.SetAccesserBundleName("bundleName1");
395     accesser.SetAccesserHapSignature("uph1");
396     accesser.SetAccesserBindLevel(bindLevel);
397 
398     DistributedDeviceProfile::Accessee accessee;
399     accessee.SetAccesseeId(accesserId);
400     accessee.SetAccesseeDeviceId(deviceIdEe);
401     accessee.SetAccesseeUserId(userId);
402     accessee.SetAccesseeAccountId(newAccountId);
403     accessee.SetAccesseeTokenId(tokenId);
404     accessee.SetAccesseeBundleName("bundleName2");
405     accessee.SetAccesseeHapSignature("uph1");
406     accessee.SetAccesseeBindLevel(bindLevel);
407 
408     DistributedDeviceProfile::AccessControlProfile profileFifth;
409     profileFifth.SetAccessControlId(accesserId);
410     profileFifth.SetAccesserId(accesserId);
411     profileFifth.SetAccesseeId(accesserId);
412     profileFifth.SetTrustDeviceId(trustDeviceId);
413     profileFifth.SetBindType(bindType);
414     profileFifth.SetAuthenticationType(authenticationType);
415     profileFifth.SetDeviceIdType(deviceIdType);
416     profileFifth.SetStatus(status);
417     profileFifth.SetBindLevel(bindLevel);
418     profileFifth.SetAccesser(accesser);
419     profileFifth.SetAccessee(accessee);
420     accessControlProfiles.push_back(profileFifth);
421 }
422 
AddAccessControlProfile001(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)423 void AddAccessControlProfile001(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
424 {
425     int32_t userId = 123456;
426     int32_t bindType = 256;
427     int32_t deviceIdType = 1;
428     uint32_t bindLevel = 3;
429     uint32_t status = 1;
430     uint32_t authenticationType = 2;
431     uint32_t accesserId = 1;
432     uint32_t tokenId = 1001;
433 
434     std::string oldAccountId = "oldAccountId";
435     std::string newAccountId = "newAccountId";
436     std::string deviceIdEr = "remoteDeviceId";
437     std::string deviceIdEe = "localDeviceId";
438     std::string trustDeviceId = "localDeviceId";
439 
440     DistributedDeviceProfile::Accesser accesser;
441     accesser.SetAccesserId(accesserId);
442     accesser.SetAccesserDeviceId(deviceIdEr);
443     accesser.SetAccesserUserId(userId);
444     accesser.SetAccesserAccountId(oldAccountId);
445     accesser.SetAccesserTokenId(tokenId);
446     accesser.SetAccesserBundleName("bundleName1");
447     accesser.SetAccesserHapSignature("uph1");
448     accesser.SetAccesserBindLevel(bindLevel);
449 
450     DistributedDeviceProfile::Accessee accessee;
451     accessee.SetAccesseeId(accesserId);
452     accessee.SetAccesseeDeviceId(deviceIdEe);
453     accessee.SetAccesseeUserId(userId);
454     accessee.SetAccesseeAccountId(newAccountId);
455     accessee.SetAccesseeTokenId(tokenId);
456     accessee.SetAccesseeBundleName("bundleName2");
457     accessee.SetAccesseeHapSignature("uph1");
458     accessee.SetAccesseeBindLevel(bindLevel);
459 
460     DistributedDeviceProfile::AccessControlProfile profileFifth;
461     profileFifth.SetAccessControlId(accesserId);
462     profileFifth.SetAccesserId(accesserId);
463     profileFifth.SetAccesseeId(accesserId);
464     profileFifth.SetTrustDeviceId(trustDeviceId);
465     profileFifth.SetBindType(bindType);
466     profileFifth.SetAuthenticationType(authenticationType);
467     profileFifth.SetDeviceIdType(deviceIdType);
468     profileFifth.SetStatus(status);
469     profileFifth.SetBindLevel(bindLevel);
470     profileFifth.SetAccesser(accesser);
471     profileFifth.SetAccessee(accessee);
472     accessControlProfiles.push_back(profileFifth);
473 }
474 
AddAccessControlProfile002(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)475 void AddAccessControlProfile002(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
476 {
477     int32_t userId = 123456;
478     int32_t bindType = 256;
479     int32_t deviceIdType = 1;
480     uint32_t bindLevel = 3;
481     uint32_t status = 1;
482     uint32_t authenticationType = 2;
483     uint32_t accesserId = 1;
484     uint32_t tokenId = 1001;
485 
486     std::string oldAccountId = "oldAccountId";
487     std::string newAccountId = "newAccountId";
488     std::string deviceIdEr = "localDeviceId";
489     std::string deviceIdEe = "remoteDeviceId";
490     std::string trustDeviceId = "localDeviceId";
491 
492     DistributedDeviceProfile::Accesser accesser;
493     accesser.SetAccesserId(accesserId);
494     accesser.SetAccesserDeviceId(deviceIdEr);
495     accesser.SetAccesserUserId(userId);
496     accesser.SetAccesserAccountId(oldAccountId);
497     accesser.SetAccesserTokenId(tokenId);
498     accesser.SetAccesserBundleName("bundleName2");
499     accesser.SetAccesserHapSignature("uph1");
500     accesser.SetAccesserBindLevel(bindLevel);
501 
502     DistributedDeviceProfile::Accessee accessee;
503     accessee.SetAccesseeId(accesserId);
504     accessee.SetAccesseeDeviceId(deviceIdEe);
505     accessee.SetAccesseeUserId(userId);
506     accessee.SetAccesseeAccountId(newAccountId);
507     accessee.SetAccesseeTokenId(tokenId);
508     accessee.SetAccesseeBundleName("bundleName1");
509     accessee.SetAccesseeHapSignature("uph1");
510     accessee.SetAccesseeBindLevel(bindLevel);
511 
512     DistributedDeviceProfile::AccessControlProfile profileFifth;
513     profileFifth.SetAccessControlId(accesserId);
514     profileFifth.SetAccesserId(accesserId);
515     profileFifth.SetAccesseeId(accesserId);
516     profileFifth.SetTrustDeviceId(trustDeviceId);
517     profileFifth.SetBindType(bindType);
518     profileFifth.SetAuthenticationType(authenticationType);
519     profileFifth.SetDeviceIdType(deviceIdType);
520     profileFifth.SetStatus(status);
521     profileFifth.SetBindLevel(bindLevel);
522     profileFifth.SetAccesser(accesser);
523     profileFifth.SetAccessee(accessee);
524     accessControlProfiles.push_back(profileFifth);
525 }
526 
AddAccessControlProfileSeven(DistributedDeviceProfile::AccessControlProfile & accessControlProfiles)527 void AddAccessControlProfileSeven(DistributedDeviceProfile::AccessControlProfile& accessControlProfiles)
528 {
529     int32_t userId = 123456;
530     int32_t bindType = 256;
531     int32_t deviceIdType = 1;
532     uint32_t bindLevel = 2;
533     uint32_t status = 1;
534     uint32_t authenticationType = 2;
535     uint32_t accesserId = 1;
536     uint32_t tokenId = 1001;
537 
538     std::string oldAccountId = "oldAccountId";
539     std::string newAccountId = "newAccountId";
540     std::string deviceIdEr = "localDeviceId";
541     std::string deviceIdEe = "remoteDeviceId";
542     std::string trustDeviceId = "remoteDeviceId";
543 
544     DistributedDeviceProfile::Accesser accesser;
545     accesser.SetAccesserId(accesserId);
546     accesser.SetAccesserDeviceId(deviceIdEr);
547     accesser.SetAccesserUserId(userId);
548     accesser.SetAccesserAccountId(oldAccountId);
549     accesser.SetAccesserTokenId(tokenId);
550     accesser.SetAccesserBundleName("bundleName1");
551     accesser.SetAccesserHapSignature("uph1");
552     accesser.SetAccesserBindLevel(bindLevel);
553 
554     DistributedDeviceProfile::Accessee accessee;
555     accessee.SetAccesseeId(accesserId);
556     accessee.SetAccesseeDeviceId(deviceIdEe);
557     accessee.SetAccesseeUserId(userId);
558     accessee.SetAccesseeAccountId(newAccountId);
559     accessee.SetAccesseeTokenId(tokenId);
560     accessee.SetAccesseeBundleName("bundleName2");
561     accessee.SetAccesseeHapSignature("uph1");
562     accessee.SetAccesseeBindLevel(bindLevel);
563 
564     accessControlProfiles.SetAccessControlId(accesserId);
565     accessControlProfiles.SetAccesserId(accesserId);
566     accessControlProfiles.SetAccesseeId(accesserId);
567     accessControlProfiles.SetTrustDeviceId(trustDeviceId);
568     accessControlProfiles.SetBindType(bindType);
569     accessControlProfiles.SetAuthenticationType(authenticationType);
570     accessControlProfiles.SetDeviceIdType(deviceIdType);
571     accessControlProfiles.SetStatus(status);
572     accessControlProfiles.SetBindLevel(bindLevel);
573     accessControlProfiles.SetAccesser(accesser);
574     accessControlProfiles.SetAccessee(accessee);
575 }
576 
AddAccessControlProfileEight(DistributedDeviceProfile::AccessControlProfile & accessControlProfiles)577 void AddAccessControlProfileEight(DistributedDeviceProfile::AccessControlProfile& accessControlProfiles)
578 {
579     int32_t userId = 123456;
580     int32_t bindType = 1;
581     int32_t deviceIdType = 1;
582     uint32_t bindLevel = 2;
583     uint32_t status = 1;
584     uint32_t authenticationType = 2;
585     uint32_t accesserId = 1;
586     uint32_t tokenId = 1001;
587 
588     std::string oldAccountId = "oldAccountId";
589     std::string newAccountId = "newAccountId";
590     std::string deviceIdEr = "localDeviceId";
591     std::string deviceIdEe = "remoteDeviceId";
592     std::string trustDeviceId = "remoteDeviceId";
593 
594     DistributedDeviceProfile::Accesser accesser;
595     accesser.SetAccesserId(accesserId);
596     accesser.SetAccesserDeviceId(deviceIdEr);
597     accesser.SetAccesserUserId(userId);
598     accesser.SetAccesserAccountId(oldAccountId);
599     accesser.SetAccesserTokenId(tokenId);
600     accesser.SetAccesserBundleName("bundleName1");
601     accesser.SetAccesserHapSignature("uph1");
602     accesser.SetAccesserBindLevel(bindLevel);
603 
604     DistributedDeviceProfile::Accessee accessee;
605     accessee.SetAccesseeId(accesserId);
606     accessee.SetAccesseeDeviceId(deviceIdEe);
607     accessee.SetAccesseeUserId(0);
608     accessee.SetAccesseeAccountId(newAccountId);
609     accessee.SetAccesseeTokenId(tokenId);
610     accessee.SetAccesseeBundleName("bundleName2");
611     accessee.SetAccesseeHapSignature("uph1");
612     accessee.SetAccesseeBindLevel(bindLevel);
613 
614     accessControlProfiles.SetAccessControlId(accesserId);
615     accessControlProfiles.SetAccesserId(accesserId);
616     accessControlProfiles.SetAccesseeId(accesserId);
617     accessControlProfiles.SetTrustDeviceId(trustDeviceId);
618     accessControlProfiles.SetBindType(bindType);
619     accessControlProfiles.SetAuthenticationType(authenticationType);
620     accessControlProfiles.SetDeviceIdType(deviceIdType);
621     accessControlProfiles.SetStatus(status);
622     accessControlProfiles.SetBindLevel(bindLevel);
623     accessControlProfiles.SetAccesser(accesser);
624     accessControlProfiles.SetAccessee(accessee);
625 }
626 
GetAccessControlProfiles(std::vector<DistributedDeviceProfile::AccessControlProfile> & accessControlProfiles)627 void GetAccessControlProfiles(std::vector<DistributedDeviceProfile::AccessControlProfile>& accessControlProfiles)
628 {
629     AddAccessControlProfileFirst(accessControlProfiles);
630     AddAccessControlProfileSecond(accessControlProfiles);
631     AddAccessControlProfileThird(accessControlProfiles);
632     AddAccessControlProfileForth(accessControlProfiles);
633     AddAccessControlProfileFifth(accessControlProfiles);
634     AddAccessControlProfileSix(accessControlProfiles);
635 }
636 HWTEST_F(DeviceProfileConnectorTest, GetAccessControlProfile_001, testing::ext::TestSize.Level0)
637 {
638     auto ret = DeviceProfileConnector::GetInstance().GetAccessControlProfile();
639     EXPECT_EQ(ret.empty(), false);
640 }
641 
642 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_001, testing::ext::TestSize.Level0)
643 {
644     std::string pkgName;
645     std::string deviceId = "deviceId";
646     auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
647     EXPECT_EQ(ret.empty(), true);
648 }
649 
650 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_002, testing::ext::TestSize.Level0)
651 {
652     std::string pkgName = "bundleName";
653     std::string deviceId = "deviceId";
654     auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
655     EXPECT_EQ(ret.empty(), true);
656 }
657 
658 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_003, testing::ext::TestSize.Level0)
659 {
660     std::string pkgName = "bundleName";
661     std::string deviceId = "deviceId_003";
662     auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
663     EXPECT_EQ(ret.empty(), true);
664 }
665 
666 HWTEST_F(DeviceProfileConnectorTest, GetDeviceAclParam_001, testing::ext::TestSize.Level0)
667 {
668     DmDiscoveryInfo discoveryInfo;
669     bool isonline = true;
670     int32_t authForm = 0;
671     EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
672     int32_t ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
673     EXPECT_EQ(ret, DM_OK);
674 }
675 
676 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_001, testing::ext::TestSize.Level0)
677 {
678     DistributedDeviceProfile::AccessControlProfile profiles;
679     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
680     DmDiscoveryInfo discoveryInfo;
681     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
682     EXPECT_EQ(ret, IDENTICAL_ACCOUNT);
683 }
684 
685 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_002, testing::ext::TestSize.Level0)
686 {
687     DistributedDeviceProfile::AccessControlProfile profiles;
688     profiles.SetBindType(DM_POINT_TO_POINT);
689     profiles.SetBindLevel(DEVICE);
690     DmDiscoveryInfo discoveryInfo;
691     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
692     EXPECT_EQ(ret, PEER_TO_PEER);
693 }
694 
695 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_003, testing::ext::TestSize.Level0)
696 {
697     DistributedDeviceProfile::AccessControlProfile profiles;
698     profiles.SetBindType(DM_POINT_TO_POINT);
699     profiles.SetBindLevel(APP);
700     profiles.accesser_.SetAccesserBundleName("ohos_test");
701     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
702     DmDiscoveryInfo discoveryInfo;
703     discoveryInfo.pkgname = "ohos_test";
704     discoveryInfo.localDeviceId = "localDeviceId";
705     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
706     EXPECT_EQ(ret, PEER_TO_PEER);
707 }
708 
709 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_004, testing::ext::TestSize.Level0)
710 {
711     DistributedDeviceProfile::AccessControlProfile profiles;
712     profiles.SetBindType(DM_POINT_TO_POINT);
713     profiles.SetBindLevel(APP);
714     profiles.accessee_.SetAccesseeBundleName("ohos_test");
715     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
716     DmDiscoveryInfo discoveryInfo;
717     discoveryInfo.pkgname = "ohos_test";
718     discoveryInfo.localDeviceId = "localDeviceId";
719     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
720     EXPECT_EQ(ret, PEER_TO_PEER);
721 }
722 
723 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_005, testing::ext::TestSize.Level0)
724 {
725     DistributedDeviceProfile::AccessControlProfile profiles;
726     profiles.SetBindType(DM_ACROSS_ACCOUNT);
727     profiles.SetBindLevel(DEVICE);
728     DmDiscoveryInfo discoveryInfo;
729     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
730     EXPECT_EQ(ret, ACROSS_ACCOUNT);
731 }
732 
733 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSize.Level0)
734 {
735     DistributedDeviceProfile::AccessControlProfile profiles;
736     profiles.SetBindType(DM_ACROSS_ACCOUNT);
737     profiles.SetBindLevel(APP);
738     profiles.accesser_.SetAccesserBundleName("pkgName");
739     profiles.accesser_.SetAccesserDeviceId("localDeviceId");
740     DmDiscoveryInfo discoveryInfo;
741     discoveryInfo.pkgname = "pkgName";
742     discoveryInfo.localDeviceId = "localDeviceId";
743     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
744     EXPECT_EQ(ret, ACROSS_ACCOUNT);
745 }
746 
747 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSize.Level0)
748 {
749     DistributedDeviceProfile::AccessControlProfile profiles;
750     profiles.SetBindType(DM_ACROSS_ACCOUNT);
751     profiles.SetBindLevel(APP);
752     profiles.accessee_.SetAccesseeBundleName("pkgName");
753     profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
754     DmDiscoveryInfo discoveryInfo;
755     discoveryInfo.pkgname = "pkgName";
756     discoveryInfo.localDeviceId = "localDeviceId";
757     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
758     EXPECT_EQ(ret, ACROSS_ACCOUNT);
759 }
760 
761 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_008, testing::ext::TestSize.Level0)
762 {
763     DistributedDeviceProfile::AccessControlProfile profiles;
764     uint32_t invalidType = 10;
765     profiles.SetBindType(invalidType);
766     DmDiscoveryInfo discoveryInfo;
767     int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
768     EXPECT_EQ(ret, INVALID_TYPE);
769 }
770 
771 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_001, testing::ext::TestSize.Level0)
772 {
773     std::string trustDeviceId = "trustDeviceId";
774     std::string requestDeviceId = "requestDeviceId";
775     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
776     EXPECT_EQ(ret, INVALIED_TYPE);
777 }
778 
779 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_002, testing::ext::TestSize.Level0)
780 {
781     std::string trustDeviceId = "deviceId";
782     std::string requestDeviceId = "requestDeviceId";
783     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
784     EXPECT_NE(ret, IDENTICAL_ACCOUNT_TYPE);
785 }
786 
787 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_003, testing::ext::TestSize.Level0)
788 {
789     std::string trustDeviceId = "deviceId";
790     std::string requestDeviceId = "deviceId";
791     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
792     EXPECT_NE(ret, IDENTICAL_ACCOUNT_TYPE);
793 }
794 
795 HWTEST_F(DeviceProfileConnectorTest, GetBindTypeByPkgName_001, testing::ext::TestSize.Level0)
796 {
797     std::string pkgName;
798     std::string requestDeviceId;
799     std::string trustUdid;
800     auto ret = DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, requestDeviceId, trustUdid);
801     EXPECT_EQ(ret.empty(), true);
802 }
803 
804 HWTEST_F(DeviceProfileConnectorTest, GetBindTypeByPkgName_002, testing::ext::TestSize.Level0)
805 {
806     std::string pkgName;
807     std::string requestDeviceId;
808     std::string trustUdid = "123456";
809     auto ret = DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, requestDeviceId, trustUdid);
810     EXPECT_EQ(ret.empty(), true);
811 
812     requestDeviceId = "remoteDeviceId";
813     trustUdid = "localDeviceId";
814     ret = DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, requestDeviceId, trustUdid);
815     EXPECT_EQ(ret.empty(), false);
816 }
817 
818 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_001, testing::ext::TestSize.Level0)
819 {
820     DistributedDeviceProfile::AccessControlProfile profile;
821     profile.SetTrustDeviceId("deviceId");
822     profile.SetStatus(INACTIVE);
823     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
824     profiles.push_back(profile);
825     std::string pkgName;
826     std::vector<int32_t> sinkBindType;
827     std::string localDeviceId;
828     std::string targetDeviceId = "targetDeviceId";
829     auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
830         targetDeviceId);
831     EXPECT_EQ(ret.empty(), true);
832 }
833 
834 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_002, testing::ext::TestSize.Level0)
835 {
836     DistributedDeviceProfile::AccessControlProfile profile;
837     profile.SetTrustDeviceId("targetDeviceId");
838     profile.SetStatus(ACTIVE);
839     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
840     profiles.push_back(profile);
841     std::string pkgName;
842     std::vector<int32_t> sinkBindType;
843     std::string localDeviceId;
844     std::string targetDeviceId = "targetDeviceId";
845     auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
846         targetDeviceId);
847     EXPECT_EQ(ret.empty(), true);
848 }
849 
850 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_003, testing::ext::TestSize.Level0)
851 {
852     DistributedDeviceProfile::AccessControlProfile profile;
853     profile.SetTrustDeviceId("targetDeviceId");
854     profile.SetStatus(INACTIVE);
855     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
856     profiles.push_back(profile);
857     std::string pkgName;
858     std::vector<int32_t> sinkBindType;
859     std::string localDeviceId;
860     std::string targetDeviceId = "targetDeviceId";
861     auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
862         targetDeviceId);
863     EXPECT_EQ(ret.empty(), true);
864 }
865 
866 HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_001, testing::ext::TestSize.Level0)
867 {
868     std::string pkgName;
869     std::vector<int32_t> bindTypeVec;
870     std::string localDeviceId;
871     std::string targetDeviceId;
872     auto ret = DeviceProfileConnector::GetInstance().SyncAclByBindType(pkgName, bindTypeVec, localDeviceId,
873         targetDeviceId);
874     EXPECT_EQ(ret.empty(), true);
875 }
876 
877 HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_002, testing::ext::TestSize.Level0)
878 {
879     std::string pkgName;
880     std::vector<int32_t> bindTypeVec;
881     std::string localDeviceId;
882     std::string targetDeviceId = "123456";
883     bindTypeVec.push_back(IDENTICAL_ACCOUNT_TYPE);
884     bindTypeVec.push_back(DEVICE_PEER_TO_PEER_TYPE);
885     auto ret = DeviceProfileConnector::GetInstance().SyncAclByBindType(pkgName, bindTypeVec, localDeviceId,
886         targetDeviceId);
887     EXPECT_EQ(ret.empty(), false);
888 }
889 
890 HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_003, testing::ext::TestSize.Level0)
891 {
892     std::string pkgName = "bundleName";
893     std::vector<int32_t> bindTypeVec;
894     std::string localDeviceId = "deviceId";
895     std::string targetDeviceId = "remoteDeviceId";
896     bindTypeVec.push_back(DEVICE_ACROSS_ACCOUNT_TYPE);
897     bindTypeVec.push_back(APP_ACROSS_ACCOUNT_TYPE);
898     auto ret = DeviceProfileConnector::GetInstance().SyncAclByBindType(pkgName, bindTypeVec, localDeviceId,
899         targetDeviceId);
900     EXPECT_EQ(ret.empty(), false);
901 }
902 
903 HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_004, testing::ext::TestSize.Level0)
904 {
905     std::string pkgName = "bundleName";
906     std::vector<int32_t> bindTypeVec;
907     std::string localDeviceId = "deviceId";
908     std::string targetDeviceId = "remoteDeviceId";
909     bindTypeVec.push_back(DEVICE_PEER_TO_PEER_TYPE);
910     bindTypeVec.push_back(IDENTICAL_ACCOUNT_TYPE);
911     auto ret = DeviceProfileConnector::GetInstance().SyncAclByBindType(pkgName, bindTypeVec, localDeviceId,
912         targetDeviceId);
913     EXPECT_EQ(ret.empty(), true);
914 }
915 
916 HWTEST_F(DeviceProfileConnectorTest, GetProcessInfoFromAclByUserId_001, testing::ext::TestSize.Level0)
917 {
918     std::string localDeviceId = "localDeviceId";
919     std::string targetDeviceId = "targetDeviceId";
920     auto ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId, targetDeviceId, 100);
921     EXPECT_EQ(ret.empty(), true);
922 }
923 
924 HWTEST_F(DeviceProfileConnectorTest, GetProcessInfoFromAclByUserId_002, testing::ext::TestSize.Level0)
925 {
926     std::string localDeviceId = "123456";
927     std::string targetDeviceId = "deviceId";
928     auto ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId, targetDeviceId, 100);
929     EXPECT_EQ(ret.empty(), true);
930 }
931 
932 HWTEST_F(DeviceProfileConnectorTest, GetProcessInfoFromAclByUserId_003, testing::ext::TestSize.Level0)
933 {
934     std::string localDeviceId = "deviceId";
935     std::string targetDeviceId = "deviceId";
936     auto ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId, targetDeviceId, 100);
937     EXPECT_EQ(ret.empty(), true);
938 }
939 
940 HWTEST_F(DeviceProfileConnectorTest, PutAccessControlList_001, testing::ext::TestSize.Level0)
941 {
942     DmAclInfo aclInfo;
943     DmAccesser dmAccesser;
944     DmAccessee dmAccessee;
945     int32_t userId = 123456;
946     std::string localDeviceId = "deviceId";
947     DeviceProfileConnector::GetInstance().DeleteAclForUserRemoved(localDeviceId, userId);
948     int32_t ret = DeviceProfileConnector::GetInstance().PutAccessControlList(aclInfo, dmAccesser, dmAccessee);
949     EXPECT_EQ(ret, DM_OK);
950 }
951 
952 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_001, testing::ext::TestSize.Level0)
953 {
954     int32_t userId = 0;
955     std::string oldAccountId;
956     std::string newAccountId;
957     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
958     EXPECT_EQ(ret, DM_OK);
959 }
960 
961 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_002, testing::ext::TestSize.Level0)
962 {
963     int32_t userId = 123456;
964     std::string oldAccountId = "oldAccountId";
965     std::string newAccountId = "newAccountId";
966     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
967     EXPECT_EQ(ret, DM_OK);
968 }
969 
970 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_003, testing::ext::TestSize.Level0)
971 {
972     int32_t userId = 123456;
973     std::string oldAccountId = "accountId";
974     std::string newAccountId = "newAccountId";
975     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
976     EXPECT_EQ(ret, DM_OK);
977 }
978 
979 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_004, testing::ext::TestSize.Level0)
980 {
981     int32_t userId = 123456;
982     std::string oldAccountId = "accountId";
983     std::string newAccountId = "accountId";
984     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
985     EXPECT_EQ(ret, DM_OK);
986 }
987 
988 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_003, testing::ext::TestSize.Level0)
989 {
990     DistributedDeviceProfile::AccessControlProfile profiles;
991     profiles.SetBindType(DM_POINT_TO_POINT);
992     profiles.SetBindLevel(DEVICE);
993     std::string targetDeviceId = "targetDeviceId";
994     std::string localDeviceId = "localDeviceId";
995     uint32_t index = 0;
996     std::vector<int32_t> sinkBindType;
997     std::vector<int32_t> bindTypeIndex;
998     DeviceProfileConnector::GetInstance().ProcessBindType(profiles,
999         localDeviceId, sinkBindType, bindTypeIndex, index, targetDeviceId);
1000     EXPECT_EQ(sinkBindType, vector<int32_t>({DEVICE_PEER_TO_PEER_TYPE}));
1001     EXPECT_EQ(bindTypeIndex, vector<int32_t>({0}));
1002 }
1003 
1004 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_004, testing::ext::TestSize.Level0)
1005 {
1006     DistributedDeviceProfile::AccessControlProfile profiles;
1007     profiles.SetBindType(DM_ACROSS_ACCOUNT);
1008     profiles.SetBindLevel(DEVICE);
1009     std::string targetDeviceId = "targetDeviceId";
1010     std::string localDeviceId = "localDeviceId";
1011     uint32_t index = 0;
1012     std::vector<int32_t> sinkBindType;
1013     std::vector<int32_t> bindTypeIndex;
1014     DeviceProfileConnector::GetInstance().ProcessBindType(profiles,
1015         localDeviceId, sinkBindType, bindTypeIndex, index, targetDeviceId);
1016     EXPECT_EQ(sinkBindType, vector<int32_t>({DEVICE_ACROSS_ACCOUNT_TYPE}));
1017     EXPECT_EQ(bindTypeIndex, vector<int32_t>({0}));
1018 }
1019 
1020 HWTEST_F(DeviceProfileConnectorTest, CheckIdenticalAccount_001, testing::ext::TestSize.Level0)
1021 {
1022     int32_t userId = 0;
1023     std::string accountId;
1024     bool ret = DeviceProfileConnector::GetInstance().CheckIdenticalAccount(userId, accountId);
1025     EXPECT_EQ(ret, true);
1026 }
1027 
1028 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
1029 {
1030     std::string pkgName;
1031     std::string deviceId;
1032     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1033     EXPECT_EQ(ret, false);
1034 }
1035 
1036 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)
1037 {
1038     std::string pkgName = "bundleName";
1039     std::string deviceId = "123456";
1040     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1041     EXPECT_EQ(ret, false);
1042 }
1043 
1044 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)
1045 {
1046     std::string pkgName = "bundleName";
1047     std::string deviceId = "deviceId";
1048     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1049     EXPECT_EQ(ret, false);
1050 }
1051 
1052 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
1053 {
1054     std::string pkgName;
1055     std::string deviceId;
1056     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1057     EXPECT_EQ(ret, false);
1058 }
1059 
1060 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)
1061 {
1062     std::string pkgName = "bundleName";
1063     std::string deviceId = "123456";
1064     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1065     EXPECT_EQ(ret, false);
1066 }
1067 
1068 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)
1069 {
1070     std::string pkgName = "bundleName";
1071     std::string deviceId = "deviceId";
1072     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1073     EXPECT_EQ(ret, false);
1074 }
1075 
1076 HWTEST_F(DeviceProfileConnectorTest, CheckDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
1077 {
1078     std::string pkgName;
1079     std::string deviceId;
1080     bool ret = DeviceProfileConnector::GetInstance().CheckDevIdInAclForDevBind(pkgName, deviceId);
1081     EXPECT_EQ(ret, false);
1082 }
1083 
1084 HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_001, testing::ext::TestSize.Level0)
1085 {
1086     std::string deviceId;
1087     uint32_t ret = DeviceProfileConnector::GetInstance().DeleteTimeOutAcl(deviceId);
1088     EXPECT_EQ(ret, 0);
1089 }
1090 
1091 HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_001, testing::ext::TestSize.Level0)
1092 {
1093     std::string deviceId;
1094     int32_t ret = DeviceProfileConnector::GetInstance().GetTrustNumber(deviceId);
1095     EXPECT_EQ(ret, DM_OK);
1096 }
1097 
1098 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_001, testing::ext::TestSize.Level0)
1099 {
1100     std::string udid = "udid";
1101     int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
1102     EXPECT_EQ(ret, ERR_DM_FAILED);
1103 }
1104 
1105 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_002, testing::ext::TestSize.Level0)
1106 {
1107     std::string udid = "deviceId";
1108     int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
1109     EXPECT_EQ(ret, DM_OK);
1110 }
1111 
1112 HWTEST_F(DeviceProfileConnectorTest, GetAuthForm_001, testing::ext::TestSize.Level0)
1113 {
1114     DistributedDeviceProfile::AccessControlProfile profile;
1115     std::string trustDev = "";
1116     std::string reqDev = "";
1117     int32_t ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1118     EXPECT_EQ(ret, INVALIED_TYPE);
1119     profile.SetBindType(DM_IDENTICAL_ACCOUNT);
1120     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1121     EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
1122     profile.SetBindType(DM_POINT_TO_POINT);
1123     profile.SetBindLevel(DEVICE);
1124     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1125     EXPECT_EQ(ret, DEVICE_PEER_TO_PEER_TYPE);
1126     profile.SetBindType(DM_ACROSS_ACCOUNT);
1127     profile.SetBindLevel(DEVICE);
1128     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1129     EXPECT_EQ(ret, DEVICE_ACROSS_ACCOUNT_TYPE);
1130     profile.SetBindLevel(APP);
1131     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1132     EXPECT_EQ(ret, APP_ACROSS_ACCOUNT_TYPE);
1133     profile.SetBindType(INVALIED_TYPE);
1134     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1135     EXPECT_EQ(ret, INVALIED_TYPE);
1136 
1137     profile.SetBindType(DM_POINT_TO_POINT);
1138     profile.SetBindLevel(APP);
1139     ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1140     EXPECT_EQ(ret, APP_PEER_TO_PEER_TYPE);
1141 }
1142 
1143 HWTEST_F(DeviceProfileConnectorTest, GetBindLevel_001, testing::ext::TestSize.Level0)
1144 {
1145     std::string pkgName = "bundleName";
1146     std::string localUdid = "localDeviceId";
1147     std::string udid = "remoteDeviceId";
1148     uint64_t tokenId = 0;
1149 
1150     int32_t bindLevel = DeviceProfileConnector::GetInstance()
1151         .GetBindLevel(pkgName, localUdid, udid, tokenId);
1152 
1153     EXPECT_EQ(bindLevel, INVALIED_TYPE);
1154 }
1155 
1156 HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_001, testing::ext::TestSize.Level0)
1157 {
1158     std::string udid = "deviceId";
1159     int32_t bindType = DEVICE;
1160     std::map<std::string, int32_t> deviceMap;
1161     deviceMap[udid] = APP;
1162     DeviceProfileConnector::GetInstance().UpdateBindType(udid, bindType, deviceMap);
1163     EXPECT_EQ(deviceMap[udid], DEVICE);
1164 }
1165 
1166 HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_002, testing::ext::TestSize.Level0)
1167 {
1168     std::string udid = "deviceId";
1169     int32_t bindType = DEVICE;
1170     std::map<std::string, int32_t> deviceMap;
1171     DeviceProfileConnector::GetInstance().UpdateBindType(udid, bindType, deviceMap);
1172     EXPECT_EQ(deviceMap[udid], DEVICE);
1173 }
1174 
1175 HWTEST_F(DeviceProfileConnectorTest, HandleAccountLogoutEvent_001, testing::ext::TestSize.Level0)
1176 {
1177     int32_t remoteUserId = 0;
1178     std::string remoteAccountHash = "remoteAccountHash";
1179     std::string remoteUdid = "1";
1180     std::string localUdid = "localDeviceId";
1181 
1182     int32_t bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1183         remoteAccountHash, remoteUdid, localUdid);
1184     EXPECT_EQ(bindType, DM_INVALIED_BINDTYPE);
1185 }
1186 
1187 HWTEST_F(DeviceProfileConnectorTest, HandleDevUnBindEvent_001, testing::ext::TestSize.Level0)
1188 {
1189     int32_t remoteUserId = 0;
1190     std::string remoteUdid = "remoteDeviceId";
1191     std::string localUdid = "localDeviceId";
1192 
1193     int32_t bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid);
1194     EXPECT_EQ(bindType, DM_INVALIED_BINDTYPE);
1195 }
1196 
1197 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_001, testing::ext::TestSize.Level0)
1198 {
1199     int32_t remoteUserId = 0;
1200     int32_t tokenId = 0;
1201     std::string remoteUdid = "remoteDeviceId";
1202     std::string localUdid = "localDeviceId";
1203     std::string pkgName = "";
1204     ProcessInfo res;
1205 
1206     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
1207     EXPECT_EQ(pkgName, res.pkgName);
1208 
1209     int32_t peerTokenId = 1;
1210     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid,
1211         peerTokenId);
1212     EXPECT_EQ(pkgName, res.pkgName);
1213 }
1214 
1215 HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_001, testing::ext::TestSize.Level0)
1216 {
1217     DistributedDeviceProfile::AccessControlProfile profile;
1218     DmAccessCaller caller;
1219     DmAccessCallee callee;
1220     int32_t ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1221     EXPECT_EQ(ret, false);
1222     profile.SetBindType(DM_IDENTICAL_ACCOUNT);
1223     profile.accessee_.SetAccesseeBundleName("pkgName");
1224     profile.accessee_.SetAccesseeDeviceId("localDeviceId");
1225     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1226     EXPECT_EQ(ret, true);
1227     profile.SetBindType(DM_POINT_TO_POINT);
1228     profile.SetBindLevel(DEVICE);
1229     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1230     EXPECT_EQ(ret, true);
1231     profile.SetBindLevel(APP);
1232     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1233     EXPECT_EQ(ret, true);
1234     profile.SetBindLevel(SERVICE);
1235     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1236     EXPECT_EQ(ret, true);
1237     profile.SetBindType(DM_ACROSS_ACCOUNT);
1238     profile.SetBindLevel(DEVICE);
1239     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1240     EXPECT_EQ(ret, true);
1241     profile.SetBindLevel(APP);
1242     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1243     EXPECT_EQ(ret, true);
1244     profile.SetBindLevel(SERVICE);
1245     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1246     EXPECT_EQ(ret, true);
1247     profile.SetBindType(INVALIED_TYPE);
1248     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1249     EXPECT_EQ(ret, false);
1250 }
1251 
1252 HWTEST_F(DeviceProfileConnectorTest, GetAccessControlProfileByUserId_001, testing::ext::TestSize.Level0)
1253 {
1254     int32_t userId = DEVICE;
1255     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1256     profiles = DeviceProfileConnector::GetInstance().GetAccessControlProfileByUserId(userId);
1257     EXPECT_GE(profiles.size(), 0);
1258 }
1259 
1260 HWTEST_F(DeviceProfileConnectorTest, DeleteAppBindLevel_001, testing::ext::TestSize.Level0)
1261 {
1262     DmOfflineParam offlineParam;
1263     std::string pkgName = "bundleName1";
1264     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1265     std::string localUdid = "remoteDeviceId";
1266     std::string remoteUdid = "localDeviceId";
1267     GetAccessControlProfiles(profiles);
1268     DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid);
1269     EXPECT_EQ(offlineParam.bindType, APP);
1270 
1271     pkgName = "bundleName2";
1272     localUdid = "localDeviceId";
1273     remoteUdid="remoteDeviceId";
1274     DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid);
1275     EXPECT_EQ(offlineParam.bindType, APP);
1276 }
1277 
1278 HWTEST_F(DeviceProfileConnectorTest, DeleteAppBindLevel_003, testing::ext::TestSize.Level0)
1279 {
1280     DmOfflineParam offlineParam;
1281     std::string pkgName = "bundleName2";
1282     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1283     std::string localUdid = "localDeviceId";
1284     std::string remoteUdid="remoteDeviceId";
1285     std::string extra = "bundleName1";
1286     GetAccessControlProfiles(profiles);
1287     DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam,
1288         pkgName, profiles, localUdid, remoteUdid, extra);
1289     EXPECT_EQ(offlineParam.bindType, APP);
1290 }
1291 
1292 HWTEST_F(DeviceProfileConnectorTest, DeleteDeviceBindLevel_001, testing::ext::TestSize.Level0)
1293 {
1294     DmOfflineParam offlineParam;
1295     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1296     std::string localUdid = "remoteDeviceId";
1297     std::string remoteUdid="localDeviceId";
1298     GetAccessControlProfiles(profiles);
1299     DeviceProfileConnector::GetInstance().DeleteDeviceBindLevel(offlineParam, profiles, localUdid, remoteUdid);
1300     EXPECT_EQ(offlineParam.bindType, DEVICE);
1301 
1302     localUdid = "localDeviceId";
1303     remoteUdid="remoteDeviceId";
1304     DeviceProfileConnector::GetInstance().DeleteDeviceBindLevel(offlineParam, profiles, localUdid, remoteUdid);
1305     EXPECT_EQ(offlineParam.bindType, DEVICE);
1306 }
1307 
1308 HWTEST_F(DeviceProfileConnectorTest, DeleteServiceBindLevel_001, testing::ext::TestSize.Level0)
1309 {
1310     DmOfflineParam offlineParam;
1311     std::string pkgName = "bundleName1";
1312     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1313     std::string localUdid = "remoteDeviceId";
1314     std::string remoteUdid="localDeviceId";
1315     GetAccessControlProfiles(profiles);
1316     DeviceProfileConnector::GetInstance().DeleteServiceBindLevel(offlineParam, pkgName, profiles,
1317         localUdid, remoteUdid);
1318     EXPECT_EQ(offlineParam.bindType, SERVICE);
1319 
1320     pkgName = "bundleName2";
1321     localUdid = "localDeviceId";
1322     remoteUdid="remoteDeviceId";
1323     DeviceProfileConnector::GetInstance().DeleteServiceBindLevel(offlineParam, pkgName, profiles,
1324         localUdid, remoteUdid);
1325     EXPECT_EQ(offlineParam.bindType, SERVICE);
1326 }
1327 
1328 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_004, testing::ext::TestSize.Level0)
1329 {
1330     std::string pkgName = "bundleName";
1331     std::string deviceId = "localDeviceId";
1332     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1333     EXPECT_TRUE(ret);
1334 }
1335 
1336 HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_002, testing::ext::TestSize.Level0)
1337 {
1338     std::string deviceId = "remoteDeviceId";
1339     uint32_t ret = DeviceProfileConnector::GetInstance().DeleteTimeOutAcl(deviceId);
1340     EXPECT_EQ(ret, 0);
1341 }
1342 
1343 HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_002, testing::ext::TestSize.Level0)
1344 {
1345     std::string deviceId = "remoteDeviceId";
1346     int32_t ret = DeviceProfileConnector::GetInstance().GetTrustNumber(deviceId);
1347     EXPECT_NE(ret, DM_OK);
1348 }
1349 
1350 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_003, testing::ext::TestSize.Level0)
1351 {
1352     std::string udid = "123456";
1353     int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
1354     EXPECT_EQ(ret, DM_OK);
1355 }
1356 
1357 HWTEST_F(DeviceProfileConnectorTest, CheckAccessControl_001, testing::ext::TestSize.Level0)
1358 {
1359     DmAccessCaller caller;
1360     std::string srcUdid;
1361     DmAccessCallee callee;
1362     std::string sinkUdid;
1363     int32_t ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1364     EXPECT_EQ(ret, ERR_DM_FAILED);
1365 
1366     srcUdid = "123456";
1367     sinkUdid = "123456";
1368     ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1369     EXPECT_NE(ret, DM_OK);
1370 }
1371 
1372 HWTEST_F(DeviceProfileConnectorTest, CheckIsSameAccount_001, testing::ext::TestSize.Level0)
1373 {
1374     DmAccessCaller caller;
1375     std::string srcUdid;
1376     DmAccessCallee callee;
1377     std::string sinkUdid;
1378     int32_t ret = DeviceProfileConnector::GetInstance().CheckIsSameAccount(caller, srcUdid, callee, sinkUdid);
1379     EXPECT_EQ(ret, ERR_DM_FAILED);
1380 
1381     srcUdid = "123456";
1382     sinkUdid = "123456";
1383     ret = DeviceProfileConnector::GetInstance().CheckIsSameAccount(caller, srcUdid, callee, sinkUdid);
1384     EXPECT_NE(ret, DM_OK);
1385 }
1386 
1387 HWTEST_F(DeviceProfileConnectorTest, HandleAccountLogoutEvent_002, testing::ext::TestSize.Level0)
1388 {
1389     int32_t remoteUserId = 0;
1390     int32_t bindType = DM_INVALIED_BINDTYPE;
1391     std::string remoteAccountHash = "remoteAccountHash";
1392     std::string remoteUdid = "123456";
1393     std::string localUdid = "localDeviceId";
1394 
1395     bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1396         remoteAccountHash, remoteUdid, localUdid);
1397     EXPECT_NE(bindType, DM_IDENTICAL_ACCOUNT);
1398 
1399     localUdid = "remoteDeviceId";
1400     remoteUdid = "localDeviceId";
1401     bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1402         remoteAccountHash, remoteUdid, localUdid);
1403     EXPECT_EQ(bindType, DM_IDENTICAL_ACCOUNT);
1404 
1405     int32_t remoteId = 456;
1406     remoteUserId = remoteId;
1407     bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1408         remoteAccountHash, remoteUdid, localUdid);
1409     EXPECT_EQ(bindType, DM_IDENTICAL_ACCOUNT);
1410 }
1411 
1412 HWTEST_F(DeviceProfileConnectorTest, HandleDevUnBindEvent_002, testing::ext::TestSize.Level0)
1413 {
1414     int32_t remoteUserId = 0;
1415     std::string remoteUdid;
1416     std::string localUdid = "localDeviceId";
1417     int32_t bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid);
1418     EXPECT_EQ(bindType, DM_INVALIED_BINDTYPE);
1419 
1420     remoteUdid = "123456";
1421     bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid);
1422     EXPECT_EQ(bindType, DM_INVALIED_BINDTYPE);
1423 
1424     remoteUdid = "localDeviceId";
1425     remoteUserId = 1234;
1426     bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid);
1427     EXPECT_EQ(bindType, DM_IDENTICAL_ACCOUNT);
1428 
1429     remoteUserId = 456;
1430     bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid);
1431     EXPECT_EQ(bindType, 3);
1432 }
1433 
1434 HWTEST_F(DeviceProfileConnectorTest, GetAllAccessControlProfile_001, testing::ext::TestSize.Level0)
1435 {
1436     int64_t accessControlId = 1;
1437     DeviceProfileConnector::GetInstance().DeleteAccessControlById(accessControlId);
1438     auto ret = DeviceProfileConnector::GetInstance().GetAllAccessControlProfile();
1439     EXPECT_FALSE(ret.empty());
1440 }
1441 
1442 HWTEST_F(DeviceProfileConnectorTest, GetAclProfileByDeviceIdAndUserId_001, testing::ext::TestSize.Level0)
1443 {
1444     std::string deviceId = "deviceId";
1445     int32_t userId = 123456;
1446     auto ret = DeviceProfileConnector::GetInstance().GetAclProfileByDeviceIdAndUserId(deviceId, userId
1447     );
1448     EXPECT_FALSE(ret.empty());
1449 }
1450 
1451 HWTEST_F(DeviceProfileConnectorTest, DeleteAclForAccountLogOut_001, testing::ext::TestSize.Level0)
1452 {
1453     std::string localUdid;
1454     int32_t localUserId = 444;
1455     std::string peerUdid = "deviceId";
1456     int32_t peerUserId = 555;
1457     bool ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(localUdid, localUserId,
1458         peerUdid, peerUserId);
1459     EXPECT_FALSE(ret);
1460 
1461     localUdid = "deviceId";
1462     localUserId = 123456;
1463     peerUdid = "deviceId";
1464     peerUserId = 456;
1465     ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(localUdid, localUserId, peerUdid, peerUserId);
1466     EXPECT_FALSE(ret);
1467 
1468     localUdid = "deviceId";
1469     localUserId = 123456;
1470     peerUdid = "deviceId";
1471     peerUserId = 123456;
1472     ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(localUdid, localUserId, peerUdid, peerUserId);
1473     EXPECT_TRUE(ret);
1474 
1475     localUdid = "localDeviceId";
1476     localUserId = 123456;
1477     peerUdid = "remoteDeviceId";
1478     peerUserId = 123456;
1479     ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(localUdid, localUserId, peerUdid, peerUserId);
1480     EXPECT_FALSE(ret);
1481 
1482     localUdid = "remoteDeviceId";
1483     localUserId = 1234;
1484     peerUdid = "localDeviceId";
1485     peerUserId = 1234;
1486     ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(localUdid, localUserId, peerUdid, peerUserId);
1487     EXPECT_TRUE(ret);
1488 }
1489 
1490 HWTEST_F(DeviceProfileConnectorTest, GetProcessInfoFromAclByUserId_005, testing::ext::TestSize.Level0)
1491 {
1492     std::string localDeviceId = "deviceId";
1493     std::string targetDeviceId = "deviceId";
1494     int32_t userId = 123456;
1495     auto ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId,
1496         targetDeviceId, userId);
1497     EXPECT_FALSE(ret.empty());
1498 
1499     localDeviceId = "remoteDeviceId";
1500     targetDeviceId = "localDeviceId";
1501     userId = 456;
1502     ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId,
1503         targetDeviceId, userId);
1504     EXPECT_FALSE(ret.empty());
1505 }
1506 
1507 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndBindLevel_001, testing::ext::TestSize.Level0)
1508 {
1509     std::vector<int32_t> userIds;
1510     int32_t userId = 123456;
1511     int32_t localId = 456;
1512     userIds.push_back(userId);
1513     userIds.push_back(localId);
1514     std::string localUdid = "deviceId";
1515     auto ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndBindLevel(userIds, localUdid);
1516     EXPECT_FALSE(ret.empty());
1517 
1518     localUdid = "localDeviceId";
1519     ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndBindLevel(userIds, localUdid);
1520     EXPECT_FALSE(ret.empty());
1521 }
1522 
1523 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndUserId_001, testing::ext::TestSize.Level0)
1524 {
1525     int32_t userId = 123456;
1526     std::string accountId;
1527     std::string localUdid = "deviceId";
1528     auto ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(userId, accountId, localUdid);
1529     EXPECT_FALSE(ret.empty());
1530 
1531     localUdid = "localDeviceId";
1532     userId = 456;
1533     ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(userId, accountId, localUdid);
1534     EXPECT_FALSE(ret.empty());
1535 }
1536 
1537 HWTEST_F(DeviceProfileConnectorTest, HandleUserSwitched_001, testing::ext::TestSize.Level0)
1538 {
1539     int32_t currentUserId = 0;
1540     std::string localUdid = "deviceId";
1541     int32_t beforeUserId = 123456;
1542     std::vector<std::string> deviceVec;
1543     int32_t ret = DeviceProfileConnector::GetInstance().HandleUserSwitched(localUdid, deviceVec, currentUserId,
1544         beforeUserId);
1545     EXPECT_EQ(ret, DM_OK);
1546 
1547     beforeUserId = 1234;
1548     currentUserId = 123456;
1549     ret = DeviceProfileConnector::GetInstance().HandleUserSwitched(localUdid, deviceVec, currentUserId, beforeUserId);
1550     EXPECT_EQ(ret, DM_OK);
1551 
1552     std::vector<int32_t> remoteUserIds;
1553     remoteUserIds.push_back(currentUserId);
1554     std::string remoteUdid = "deviceId";
1555     std::vector<int32_t> localUserIds;
1556     localUserIds.push_back(currentUserId);
1557     DeviceProfileConnector::GetInstance().HandleSyncForegroundUserIdEvent(remoteUserIds, remoteUdid,
1558         localUserIds, localUdid);
1559 
1560     localUdid = "remoteDeviceId";
1561     remoteUdid = "localDeviceId";
1562     int32_t localdeviceId = 456;
1563     remoteUserIds.push_back(localdeviceId);
1564     localUserIds.push_back(localdeviceId);
1565     DeviceProfileConnector::GetInstance().HandleSyncForegroundUserIdEvent(remoteUserIds, remoteUdid,
1566         localUserIds, localUdid);
1567 }
1568 
1569 HWTEST_F(DeviceProfileConnectorTest, GetOfflineProcessInfo_001, testing::ext::TestSize.Level0)
1570 {
1571     std::string localUdid = "deviceId";
1572     std::vector<int32_t> localUserIds;
1573     std::string remoteUdid = "deviceId";
1574     std::vector<int32_t> remoteUserIds;
1575     int32_t userId = 123456;
1576     remoteUserIds.push_back(userId);
1577     localUserIds.push_back(userId);
1578     auto ret = DeviceProfileConnector::GetInstance().GetOfflineProcessInfo(localUdid, localUserIds, remoteUdid,
1579         remoteUserIds);
1580     EXPECT_FALSE(ret.empty());
1581 
1582     localUdid = "remoteDeviceId";
1583     remoteUdid = "localDeviceId";
1584     int32_t localdeviceId = 456;
1585     remoteUserIds.push_back(localdeviceId);
1586     localUserIds.push_back(localdeviceId);
1587     ret = DeviceProfileConnector::GetInstance().GetOfflineProcessInfo(localUdid, localUserIds, remoteUdid,
1588         remoteUserIds);
1589     EXPECT_FALSE(ret.empty());
1590 }
1591 
1592 HWTEST_F(DeviceProfileConnectorTest, GetUserIdAndBindLevel_001, testing::ext::TestSize.Level0)
1593 {
1594     std::string localUdid = "deviceId";
1595     std::string peerUdid = "deviceId";
1596     auto ret = DeviceProfileConnector::GetInstance().GetUserIdAndBindLevel(localUdid, peerUdid);
1597     EXPECT_FALSE(ret.empty());
1598 
1599     localUdid = "remoteDeviceId";
1600     peerUdid = "localDeviceId";
1601     ret = DeviceProfileConnector::GetInstance().GetUserIdAndBindLevel(localUdid, peerUdid);
1602     EXPECT_FALSE(ret.empty());
1603 
1604     localUdid = "remoteDeviceIdee";
1605     peerUdid = "localDeviceIder";
1606     ret = DeviceProfileConnector::GetInstance().GetUserIdAndBindLevel(localUdid, peerUdid);
1607     EXPECT_FALSE(ret.empty());
1608 
1609     int32_t userId = 123456;
1610     std::vector<int32_t> localUserIds;
1611     localUserIds.push_back(userId);
1612     std::string remoteUdid = "deviceId";
1613     std::vector<int32_t> remoteFrontUserIds;
1614     remoteFrontUserIds.push_back(userId);
1615     std::vector<int32_t> remoteBackUserIds;
1616     remoteBackUserIds.push_back(userId);
1617     DeviceProfileConnector::GetInstance().UpdateACL(localUdid, localUserIds, remoteUdid, remoteFrontUserIds,
1618         remoteBackUserIds);
1619 
1620     localUdid = "remoteDeviceId";
1621     remoteUdid = "localDeviceId";
1622     userId = 456;
1623     std::vector<int32_t> remoteUserIds;
1624     remoteUserIds.push_back(userId);
1625     localUserIds.push_back(userId);
1626     DeviceProfileConnector::GetInstance().HandleSyncBackgroundUserIdEvent(remoteUserIds, remoteUdid, localUserIds,
1627         localUdid);
1628 }
1629 
1630 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndUserId_002, testing::ext::TestSize.Level0)
1631 {
1632     std::string localUdid = "deviceId";
1633     int32_t localUserId = 123456;
1634     auto ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(localUdid, localUserId);
1635     EXPECT_FALSE(ret.empty());
1636 
1637     localUdid = "localDeviceId";
1638     localUserId = 456;
1639     ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(localUdid, localUserId);
1640     EXPECT_FALSE(ret.empty());
1641 
1642     std::vector<int32_t> remoteUserIds;
1643     remoteUserIds.push_back(localUserId);
1644     std::string remoteUdid = "deviceId";
1645     std::vector<int32_t> localUserIds;
1646     localUserIds.push_back(localUserId);
1647     DeviceProfileConnector::GetInstance().HandleSyncBackgroundUserIdEvent(remoteUserIds, remoteUdid, localUserIds,
1648         localUdid);
1649 
1650     ProcessInfo process;
1651     process.userId = 1;
1652     process.pkgName = "pkgName";
1653     ProcessInfo process1;
1654     process1.userId = 1;
1655     process1.pkgName = "pkgName";
1656     EXPECT_TRUE(process == process1);
1657 
1658     process.userId = 0;
1659     EXPECT_TRUE(process < process1);
1660 
1661     DmNotifyKey dmNotifyKey;
1662     dmNotifyKey.processUserId = 1;
1663     dmNotifyKey.processPkgName = "proName";
1664     dmNotifyKey.notifyUserId = 0;
1665     dmNotifyKey.udid = "udid";
1666 
1667     DmNotifyKey dmNotifyKey1;
1668     dmNotifyKey1.processUserId = 1;
1669     dmNotifyKey1.processPkgName = "proName";
1670     dmNotifyKey1.notifyUserId = 0;
1671     dmNotifyKey1.udid = "udid";
1672     EXPECT_TRUE(dmNotifyKey == dmNotifyKey1);
1673 
1674     dmNotifyKey1.processUserId = 2;
1675     EXPECT_TRUE(dmNotifyKey < dmNotifyKey1);
1676 }
1677 
1678 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_004, testing::ext::TestSize.Level0)
1679 {
1680     std::string pkgName = "bundleName";
1681     std::string deviceId = "deviceId";
1682 
1683     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(123456));
1684     auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1685     EXPECT_EQ(ret.empty(), false);
1686 
1687     deviceId = "remoteDeviceId";
1688     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(1234));
1689     ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1690     EXPECT_EQ(ret.empty(), false);
1691 
1692     deviceId = "remoteDeviceId";
1693     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(1234));
1694     ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1695     EXPECT_EQ(ret.empty(), false);
1696 
1697     deviceId = "remoteDeviceId";
1698     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(1234));
1699     ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1700     EXPECT_EQ(ret.empty(), false);
1701 
1702     deviceId = "remoteDeviceId";
1703     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(12345));
1704     ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1705     EXPECT_EQ(ret.empty(), false);
1706 
1707     deviceId = "remoteDeviceId";
1708     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(12345));
1709     ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1710     EXPECT_EQ(ret.empty(), false);
1711 
1712     std::string udid;
1713     DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid);
1714 
1715     udid = "deviceId";
1716     DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid);
1717 }
1718 
1719 HWTEST_F(DeviceProfileConnectorTest, GetDevIdAndUserIdByActHash_001, testing::ext::TestSize.Level0)
1720 {
1721     std::string localUdid = "deviceId";
1722     std::string peerUdid = "deviceId";
1723     int32_t peerUserId = 123456;
1724     std::string peerAccountHash = "";
1725     EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).WillOnce(Return(ERR_DM_FAILED));
1726     auto ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1727         peerUserId, peerAccountHash);
1728     EXPECT_TRUE(ret.empty());
1729 
1730     EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).WillOnce(Return(DM_OK)).WillOnce(Return(ERR_DM_FAILED));
1731     ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1732         peerUserId, peerAccountHash);
1733     EXPECT_TRUE(ret.empty());
1734 
1735     EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).Times(::testing::AtLeast(40)).WillOnce(Return(DM_OK));
1736     ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1737         peerUserId, peerAccountHash);
1738     EXPECT_FALSE(ret.empty());
1739 
1740     localUdid = "remoteDeviceId";
1741     peerUdid = "localDeviceId";
1742     peerUserId = 456;
1743     EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).Times(::testing::AtLeast(40)).WillOnce(Return(DM_OK));
1744     ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1745         peerUserId, peerAccountHash);
1746     EXPECT_FALSE(ret.empty());
1747 }
1748 
1749 HWTEST_F(DeviceProfileConnectorTest, GetDeviceAclParam_002, testing::ext::TestSize.Level0)
1750 {
1751     DmDiscoveryInfo discoveryInfo;
1752     discoveryInfo.remoteDeviceIdHash = "";
1753     discoveryInfo.localDeviceId = "deviceId";
1754     discoveryInfo.userId = 123456;
1755     discoveryInfo.pkgname = "";
1756     bool isonline = true;
1757     int32_t authForm = 0;
1758     EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
1759     int32_t ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
1760     EXPECT_EQ(ret, DM_OK);
1761 
1762     discoveryInfo.pkgname = "bundleName";
1763     discoveryInfo.localDeviceId = "deviceId";
1764     EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
1765     ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
1766     EXPECT_EQ(ret, DM_OK);
1767 
1768     discoveryInfo.localDeviceId = "trustDeviceId";
1769     EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
1770     ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
1771     EXPECT_EQ(ret, DM_OK);
1772 }
1773 
1774 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_004, testing::ext::TestSize.Level0)
1775 {
1776     std::string pkgName = "bundleName";
1777     std::string deviceId = "localDeviceId";
1778     bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1779     EXPECT_EQ(ret, true);
1780 }
1781 
1782 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_005, testing::ext::TestSize.Level0)
1783 {
1784     std::string pkgName = "bundleName";
1785     std::string deviceId = "123456";
1786     bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1787     EXPECT_FALSE(ret);
1788 
1789     DistributedDeviceProfile::AccessControlProfile profiles;
1790     std::string remoteUdid = "remoteDeviceId";
1791     std::vector<int32_t> remoteFrontUserIds;
1792     std::vector<int32_t> remoteBackUserIds;
1793     AddAccessControlProfileFirst(profiles);
1794     DeviceProfileConnector::GetInstance().DeleteSigTrustACL(profiles, remoteUdid,
1795         remoteFrontUserIds, remoteBackUserIds);
1796 
1797     remoteUdid = "localDeviceId";
1798     AddAccessControlProfileSeven(profiles);
1799     DeviceProfileConnector::GetInstance().DeleteSigTrustACL(profiles, remoteUdid,
1800         remoteFrontUserIds, remoteBackUserIds);
1801 
1802     AddAccessControlProfileEight(profiles);
1803     std::string localUdid = "localDeviceId";
1804     std::vector<int32_t> localUserIds;
1805     int32_t userId = 123456;
1806     localUserIds.push_back(userId);
1807     remoteUdid =  "remoteDeviceId";
1808     remoteFrontUserIds.push_back(0);
1809     remoteFrontUserIds.push_back(userId);
1810     DeviceProfileConnector::GetInstance().UpdatePeerUserId(profiles, localUdid, localUserIds, remoteUdid,
1811         remoteFrontUserIds);
1812 }
1813 
1814 HWTEST_F(DeviceProfileConnectorTest, CheckAccessControl_002, testing::ext::TestSize.Level0)
1815 {
1816     int32_t userId = 123456;
1817     DmAccessCaller caller;
1818     caller.userId = userId;
1819     std::string srcUdid = "deviceId";
1820     DmAccessCallee callee;
1821     callee.userId = userId;
1822     std::string sinkUdid = "deviceId";
1823     int32_t ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1824     EXPECT_EQ(ret, DM_OK);
1825 
1826     srcUdid = "remoteDeviceId";
1827     sinkUdid = "localDeviceId";
1828     caller.userId = 456;
1829     callee.userId = 456;
1830     ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1831     EXPECT_EQ(ret, DM_OK);
1832 
1833     callee.userId = 0;
1834     ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1835     EXPECT_EQ(ret, DM_OK);
1836 }
1837 
1838 HWTEST_F(DeviceProfileConnectorTest, CheckIsSameAccount_002, testing::ext::TestSize.Level0)
1839 {
1840     int32_t userId = 456;
1841     DmAccessCaller caller;
1842     caller.userId = userId;
1843     std::string srcUdid = "localDeviceId";
1844     DmAccessCallee callee;
1845     callee.userId = userId;
1846     std::string sinkUdid = "remoteDeviceId";
1847     int32_t ret = DeviceProfileConnector::GetInstance().CheckIsSameAccount(caller, srcUdid, callee, sinkUdid);
1848     EXPECT_EQ(ret, DM_OK);
1849 
1850     callee.userId = 0;
1851     ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1852     EXPECT_EQ(ret, DM_OK);
1853 }
1854 
1855 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_002, testing::ext::TestSize.Level0)
1856 {
1857     int32_t remoteUserId = 456;
1858     int32_t tokenId = 1001;
1859     std::string remoteUdid = "localDeviceId";
1860     std::string localUdid = "remoteDeviceId";
1861     std::string pkgName = "";
1862     ProcessInfo res;
1863     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
1864     EXPECT_EQ("bundleName", res.pkgName);
1865 
1866     int32_t peerTokenId = 1001;
1867     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid,
1868         peerTokenId);
1869     EXPECT_EQ("bundleName", res.pkgName);
1870 
1871     tokenId = 1002;
1872     peerTokenId = tokenId;
1873     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
1874     EXPECT_EQ("bundleName", res.pkgName);
1875 
1876     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid,
1877         peerTokenId);
1878     EXPECT_EQ("bundleName", res.pkgName);
1879 }
1880 
1881 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_003, testing::ext::TestSize.Level0)
1882 {
1883     int32_t remoteUserId = 0;
1884     int32_t tokenId = 0;
1885     std::string remoteUdid = "remoteDeviceId";
1886     std::string localUdid = "localDeviceId";
1887     std::string pkgName = "";
1888     int32_t peerTokenId = 1001;
1889     ProcessInfo res;
1890     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId,
1891         remoteUdid, tokenId, localUdid, peerTokenId);
1892     EXPECT_EQ(pkgName, res.pkgName);
1893 }
1894 
1895 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_004, testing::ext::TestSize.Level0)
1896 {
1897     int32_t remoteUserId = 123456;
1898     int32_t tokenId = 1001;
1899     std::string remoteUdid = "remoteDeviceId";
1900     std::string localUdid = "localDeviceId";
1901     std::string pkgName = "";
1902     int32_t peerTokenId = 1001;
1903     ProcessInfo res;
1904     res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId,
1905         remoteUdid, tokenId, localUdid, peerTokenId);
1906     EXPECT_EQ("bundleName", res.pkgName);
1907 }
1908 
1909 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_002, testing::ext::TestSize.Level0)
1910 {
1911     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1912     std::string pkgName = "bundleName2";
1913     std::string requestDeviceId = "localDeviceId";
1914     GetAccessControlProfiles(profiles);
1915     auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1916     EXPECT_EQ(ret, 0);
1917 }
1918 
1919 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_003, testing::ext::TestSize.Level0)
1920 {
1921     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1922     std::string pkgName = "bundleName8";
1923     std::string requestDeviceId = "localDeviceId9";
1924     GetAccessControlProfiles(profiles);
1925     auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1926     EXPECT_EQ(ret, 0);
1927 }
1928 
1929 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_004, testing::ext::TestSize.Level0)
1930 {
1931     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1932     std::string pkgName = "bundleName2";
1933     std::string requestDeviceId = "localDeviceId9";
1934     GetAccessControlProfiles(profiles);
1935     auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1936     EXPECT_EQ(ret, 0);
1937 }
1938 
1939 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_005, testing::ext::TestSize.Level0)
1940 {
1941     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1942     std::string pkgName;
1943     std::string requestDeviceId;
1944     GetAccessControlProfiles(profiles);
1945     auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1946     EXPECT_EQ(ret, 0);
1947 }
1948 
1949 HWTEST_F(DeviceProfileConnectorTest, GetAclProfileByUserId_001, testing::ext::TestSize.Level0)
1950 {
1951     std::string localUdid = "deviceId";
1952     int32_t userId = 123456;
1953     std::string remoteUdid  = "deviceId";
1954     auto ret = DeviceProfileConnector::GetInstance().GetAclProfileByUserId(localUdid, userId, remoteUdid);
1955     EXPECT_FALSE(ret.empty());
1956 
1957     localUdid = "remoteDeviceId";
1958     remoteUdid = "localDeviceId";
1959     userId = 456;
1960     ret = DeviceProfileConnector::GetInstance().GetAclProfileByUserId(localUdid, userId, remoteUdid);
1961     EXPECT_FALSE(ret.empty());
1962 }
1963 
1964 HWTEST_F(DeviceProfileConnectorTest, PutAllTrustedDevices_001, testing::ext::TestSize.Level0)
1965 {
1966     std::vector<DistributedDeviceProfile::TrustedDeviceInfo> deviceInfos;
1967     int32_t ret = DeviceProfileConnector::GetInstance().PutAllTrustedDevices(deviceInfos);
1968     EXPECT_NE(ret, DM_OK);
1969 }
1970 
1971 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_004, testing::ext::TestSize.Level0)
1972 {
1973     std::string peerUdid = "localDeviceId";
1974     std::string localUdid = "remoteDeviceId";
1975     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(0));
1976     uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(peerUdid, localUdid);
1977     EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
1978 
1979     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(1234));
1980     ret = DeviceProfileConnector::GetInstance().CheckBindType(peerUdid, localUdid);
1981     EXPECT_EQ(ret, 5);
1982 }
1983 
1984 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_001, testing::ext::TestSize.Level0)
1985 {
1986     std::string pkgName = "bundleName";
1987     std::string requestDeviceId = "remoteDeviceId";
1988     uint64_t ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1989     EXPECT_NE(ret, 0);
1990 
1991     requestDeviceId = "localDeviceId";
1992     ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1993     EXPECT_NE(ret, 0);
1994 }
1995 
1996 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_001, testing::ext::TestSize.Level0)
1997 {
1998     DistributedDeviceProfile::AccessControlProfile profiles;
1999     std::string requestDeviceId = "requestDeviceId";
2000     std::vector<int32_t> bindTypeVec;
2001     std::string trustUdid = "localUdid";
2002     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
2003     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2004     EXPECT_TRUE(bindTypeVec.empty());
2005 
2006     profiles.SetBindType(DM_POINT_TO_POINT);
2007     profiles.SetBindLevel(1);
2008     DistributedDeviceProfile::Accesser accesser;
2009     DistributedDeviceProfile::Accessee accessee;
2010     accesser.SetAccesserDeviceId(trustUdid);
2011     accessee.SetAccesseeDeviceId(requestDeviceId);
2012     profiles.SetAccesser(accesser);
2013     profiles.SetAccessee(accessee);
2014     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2015     EXPECT_FALSE(bindTypeVec.empty());
2016 
2017     bindTypeVec.clear();
2018     profiles.SetBindLevel(3);
2019     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2020     EXPECT_FALSE(bindTypeVec.empty());
2021 
2022     bindTypeVec.clear();
2023     profiles.SetBindType(DM_ACROSS_ACCOUNT);
2024     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2025     EXPECT_FALSE(bindTypeVec.empty());
2026 
2027     bindTypeVec.clear();
2028     profiles.SetBindLevel(1);
2029     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2030     EXPECT_FALSE(bindTypeVec.empty());
2031 
2032     bindTypeVec.clear();
2033     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
2034     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2035     EXPECT_FALSE(bindTypeVec.empty());
2036 
2037     bindTypeVec.clear();
2038     profiles.SetBindType(DM_INVALIED_BINDTYPE);
2039     DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2040     EXPECT_TRUE(bindTypeVec.empty());
2041 }
2042 
2043 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_001, testing::ext::TestSize.Level0)
2044 {
2045     DistributedDeviceProfile::AccessControlProfile profiles;
2046     std::string localDeviceId = "localDeviceId";
2047     std::vector<int32_t> sinkBindType;
2048     std::vector<int32_t> bindTypeIndex;
2049     uint32_t index = 1;
2050     std::string targetDeviceId = "remoteDeviceId";
2051     profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
2052     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2053         targetDeviceId);
2054     EXPECT_FALSE(sinkBindType.empty());
2055 
2056     profiles.SetBindType(DM_POINT_TO_POINT);
2057     profiles.SetBindLevel(1);
2058     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2059         targetDeviceId);
2060     EXPECT_FALSE(sinkBindType.empty());
2061 
2062     profiles.SetBindLevel(3);
2063     DistributedDeviceProfile::Accesser accesser;
2064     DistributedDeviceProfile::Accessee accessee;
2065     accesser.SetAccesserDeviceId(targetDeviceId);
2066     accessee.SetAccesseeDeviceId(localDeviceId);
2067     profiles.SetAccesser(accesser);
2068     profiles.SetAccessee(accessee);
2069     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2070         targetDeviceId);
2071     EXPECT_FALSE(sinkBindType.empty());
2072 
2073     accesser.SetAccesserDeviceId(localDeviceId);
2074     accessee.SetAccesseeDeviceId(targetDeviceId);
2075     profiles.SetAccesser(accesser);
2076     profiles.SetAccessee(accessee);
2077     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2078         targetDeviceId);
2079     EXPECT_FALSE(sinkBindType.empty());
2080 }
2081 
2082 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_002, testing::ext::TestSize.Level0)
2083 {
2084     DistributedDeviceProfile::AccessControlProfile profiles;
2085     std::string localDeviceId = "localDeviceId";
2086     std::vector<int32_t> sinkBindType;
2087     std::vector<int32_t> bindTypeIndex;
2088     uint32_t index = 1;
2089     std::string targetDeviceId = "remoteDeviceId";
2090     profiles.SetBindType(DM_ACROSS_ACCOUNT);
2091     profiles.SetBindLevel(1);
2092     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2093         targetDeviceId);
2094     EXPECT_FALSE(sinkBindType.empty());
2095 
2096     profiles.SetBindLevel(3);
2097     DistributedDeviceProfile::Accesser accesser;
2098     DistributedDeviceProfile::Accessee accessee;
2099     accesser.SetAccesserDeviceId(targetDeviceId);
2100     accessee.SetAccesseeDeviceId(localDeviceId);
2101     profiles.SetAccesser(accesser);
2102     profiles.SetAccessee(accessee);
2103     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2104         targetDeviceId);
2105     EXPECT_FALSE(sinkBindType.empty());
2106 
2107     accesser.SetAccesserDeviceId(localDeviceId);
2108     accessee.SetAccesseeDeviceId(targetDeviceId);
2109     profiles.SetAccesser(accesser);
2110     profiles.SetAccessee(accessee);
2111     DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2112         targetDeviceId);
2113     EXPECT_FALSE(sinkBindType.empty());
2114 }
2115 
2116 HWTEST_F(DeviceProfileConnectorTest, DeleteAclForRemoteUserRemoved_001, testing::ext::TestSize.Level0)
2117 {
2118     std::string peerUdid = "deviceId";
2119     int32_t peerUserId = 123456;
2120     std::vector<int32_t> userIds;
2121     DeviceProfileConnector::GetInstance().DeleteAclForRemoteUserRemoved(peerUdid, peerUserId, userIds);
2122     EXPECT_FALSE(userIds.empty());
2123 
2124     peerUdid = "remoteDeviceId";
2125     peerUserId = 1234;
2126     DeviceProfileConnector::GetInstance().DeleteAclForRemoteUserRemoved(peerUdid, peerUserId, userIds);
2127     EXPECT_FALSE(userIds.empty());
2128 }
2129 
2130 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_001, testing::ext::TestSize.Level0)
2131 {
2132     std::string pkgName;
2133     std::string localDeviceId = "remoteDeviceId";
2134     std::string remoteDeviceId;
2135     int32_t bindLevel = 3;
2136     std::string extra;
2137     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2138     DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2139         remoteDeviceId, bindLevel, extra);
2140     EXPECT_EQ(offlineParam.leftAclNumber, 0);
2141 
2142     extra = "extra";
2143     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2144     offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2145         remoteDeviceId, bindLevel, extra);
2146     EXPECT_EQ(offlineParam.leftAclNumber, 0);
2147 
2148     bindLevel = 2;
2149     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2150     offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2151         remoteDeviceId, bindLevel, extra);
2152     EXPECT_EQ(offlineParam.leftAclNumber, 0);
2153 
2154     bindLevel = 1;
2155     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2156     offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2157         remoteDeviceId, bindLevel, extra);
2158     EXPECT_EQ(offlineParam.leftAclNumber, 0);
2159 
2160     bindLevel = 5;
2161     offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2162         remoteDeviceId, bindLevel, extra);
2163     EXPECT_EQ(offlineParam.bindType, INVALIED_TYPE);
2164 
2165     bindLevel = 2;
2166     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(-1));
2167     offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2168         remoteDeviceId, bindLevel, extra);
2169     EXPECT_EQ(offlineParam.bindType, INVALIED_TYPE);
2170 }
2171 
2172 HWTEST_F(DeviceProfileConnectorTest, DeleteAppBindLevel_002, testing::ext::TestSize.Level0)
2173 {
2174     DmOfflineParam offlineParam;
2175     std::string pkgName = "bundleName1";
2176     std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
2177     std::string localUdid = "remoteDeviceId";
2178     std::string remoteUdid = "localDeviceId";
2179     std::string extra;
2180     AddAccessControlProfileSix(profiles);
2181     DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid,
2182         extra);
2183     EXPECT_EQ(offlineParam.leftAclNumber, 0);
2184 
2185     AddAccessControlProfile001(profiles);
2186     extra = "bundleName2";
2187     DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid,
2188         extra);
2189     EXPECT_EQ(offlineParam.bindType, APP);
2190 
2191     AddAccessControlProfile002(profiles);
2192     extra = "bundleName2";
2193     DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid,
2194         extra);
2195     EXPECT_EQ(offlineParam.bindType, APP);
2196 }
2197 
2198 HWTEST_F(DeviceProfileConnectorTest, GetBindLevel_002, testing::ext::TestSize.Level0)
2199 {
2200     std::string pkgName = "bundleName";
2201     std::string localUdid = "remoteDeviceId";
2202     std::string udid = "localDeviceId";
2203     uint64_t tokenId = 0;
2204     int32_t bindLevel = INVALIED_TYPE;
2205 
2206     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2207     bindLevel = DeviceProfileConnector::GetInstance().GetBindLevel(pkgName, localUdid, udid, tokenId);
2208     EXPECT_EQ(bindLevel, APP);
2209 
2210     localUdid = "deviceId";
2211     udid = "deviceId";
2212     EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(123456));
2213     bindLevel = DeviceProfileConnector::GetInstance().GetBindLevel(pkgName, localUdid, udid, tokenId);
2214     EXPECT_EQ(bindLevel, DEVICE);
2215 
2216     int32_t bindType = 256;
2217     std::string peerUdid = "123456";
2218     localUdid = "localDeviceId";
2219     int32_t localUserId = 1234;
2220     std::string localAccountId = "";
2221     DeviceProfileConnector::GetInstance().HandleDeviceUnBind(bindType, peerUdid, localUdid, localUserId,
2222         localAccountId);
2223 }
2224 
2225 HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_002, testing::ext::TestSize.Level0)
2226 {
2227     DistributedDeviceProfile::AccessControlProfile profile;
2228     DmAccessCaller caller;
2229     DmAccessCallee callee;
2230     profile.SetBindType(DM_POINT_TO_POINT);
2231     profile.SetBindLevel(APP);
2232     caller.pkgName = "bundleName";
2233     DistributedDeviceProfile::Accessee accessee;
2234     accessee.SetAccesseeBundleName("bundleName");
2235     profile.SetAccessee(accessee);
2236     int32_t ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
2237     EXPECT_EQ(ret, true);
2238 
2239 
2240     profile.SetBindType(DM_ACROSS_ACCOUNT);
2241     profile.SetBindLevel(APP);
2242     accessee.SetAccesseeBundleName("bundleName");
2243     profile.SetAccessee(accessee);
2244     ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
2245     EXPECT_EQ(ret, true);
2246 }
2247 
2248 HWTEST_F(DeviceProfileConnectorTest, CheckDeviceInfoPermission_001, testing::ext::TestSize.Level0)
2249 {
2250     std::string localUdid = "localUdid";
2251     std::string peerDeviceId = "localDeviceId";
2252     int32_t ret = DeviceProfileConnector::GetInstance().CheckDeviceInfoPermission(localUdid, peerDeviceId);
2253     EXPECT_EQ(ret, DM_OK);
2254 
2255     localUdid = "localDeviceId";
2256     peerDeviceId = "remoteDeviceId";
2257     EXPECT_CALL(*multipleUserConnectorMock_, GetTokenIdAndForegroundUserId(_, _))
2258         .WillOnce(DoAll(SetArgReferee<0>(1001), SetArgReferee<1>(456), Return()));
2259     EXPECT_CALL(*multipleUserConnectorMock_, GetOhosAccountIdByUserId(_)).WillOnce(Return(""));
2260     ret = DeviceProfileConnector::GetInstance().CheckDeviceInfoPermission(localUdid, peerDeviceId);
2261     EXPECT_EQ(ret, DM_OK);
2262 
2263     localUdid = "remoteDeviceId";
2264     peerDeviceId = "localDeviceId";
2265     EXPECT_CALL(*multipleUserConnectorMock_, GetTokenIdAndForegroundUserId(_, _))
2266         .WillOnce(DoAll(SetArgReferee<0>(1001), SetArgReferee<1>(456), Return()));
2267     EXPECT_CALL(*multipleUserConnectorMock_, GetOhosAccountIdByUserId(_)).WillOnce(Return("newAccountId"));
2268     ret = DeviceProfileConnector::GetInstance().CheckDeviceInfoPermission(localUdid, peerDeviceId);
2269     EXPECT_EQ(ret, DM_OK);
2270 }
2271 
2272 HWTEST_F(DeviceProfileConnectorTest, UpdateAclDeviceName_001, testing::ext::TestSize.Level0)
2273 {
2274     std::string udid = "localDeviceId";
2275     std::string newDeviceName = "deviceName";
2276     int32_t ret = DeviceProfileConnector::GetInstance().UpdateAclDeviceName(udid, newDeviceName);
2277     EXPECT_EQ(ret, DM_OK);
2278 
2279     udid = "remoteDeviceId";
2280     newDeviceName = "deviceNameInfo";
2281     ret = DeviceProfileConnector::GetInstance().UpdateAclDeviceName(udid, newDeviceName);
2282     EXPECT_EQ(ret, DM_OK);
2283 
2284     udid = "UDID";
2285     ret = DeviceProfileConnector::GetInstance().UpdateAclDeviceName(udid, newDeviceName);
2286     EXPECT_EQ(ret, ERR_DM_FAILED);
2287 }
2288 
2289 HWTEST_F(DeviceProfileConnectorTest, CheckAppLevelAccess_001, testing::ext::TestSize.Level0)
2290 {
2291     DistributedDeviceProfile::AccessControlProfile profile;
2292     int32_t acerTokenId = 1001;
2293     int32_t aceeTokenId = 1002;
2294     DmAccessCaller caller;
2295     DmAccessCallee callee;
2296     DistributedDeviceProfile::Accesser accesser;
2297     DistributedDeviceProfile::Accessee accessee;
2298     accesser.SetAccesserTokenId(acerTokenId);
2299     accessee.SetAccesseeTokenId(aceeTokenId);
2300     profile.SetAccesser(accesser);
2301     profile.SetAccessee(accessee);
2302     caller.tokenId = acerTokenId;
2303     callee.tokenId = aceeTokenId;
2304     bool ret = DeviceProfileConnector::GetInstance().CheckAppLevelAccess(profile, caller, callee);
2305     EXPECT_TRUE(ret);
2306 
2307     caller.tokenId = aceeTokenId;
2308     callee.tokenId = acerTokenId;
2309     ret = DeviceProfileConnector::GetInstance().CheckAppLevelAccess(profile, caller, callee);
2310     EXPECT_TRUE(ret);
2311 
2312     caller.tokenId = 1;
2313     callee.tokenId = 1;
2314     ret = DeviceProfileConnector::GetInstance().CheckAppLevelAccess(profile, caller, callee);
2315     EXPECT_FALSE(ret);
2316 }
2317 } // namespace DistributedHardware
2318 } // namespace OHOS
2319