1 /*
2 * Copyright (c) 2023-2025 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.Level1)
637 {
638 auto ret = DeviceProfileConnector::GetInstance().GetAccessControlProfile();
639 EXPECT_EQ(ret.empty(), false);
640 }
641
642 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_001, testing::ext::TestSize.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
686 {
687 DistributedDeviceProfile::AccessControlProfile profiles;
688 profiles.SetBindType(DM_POINT_TO_POINT);
689 profiles.SetBindLevel(USER);
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.Level1)
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.Level1)
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.Level1)
724 {
725 DistributedDeviceProfile::AccessControlProfile profiles;
726 profiles.SetBindType(DM_ACROSS_ACCOUNT);
727 profiles.SetBindLevel(USER);
728 DmDiscoveryInfo discoveryInfo;
729 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
730 EXPECT_EQ(ret, PEER_TO_PEER);
731 }
732
733 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSize.Level1)
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, PEER_TO_PEER);
745 }
746
747 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSize.Level1)
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, PEER_TO_PEER);
759 }
760
761 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_008, testing::ext::TestSize.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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_NE(ret.empty(), DM_OK);
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
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.Level1)
941 {
942 DmAclInfo aclInfo;
943 DmAccesser dmAccesser;
944 DmAccessee dmAccessee;
945 int32_t userId = 123456;
946 std::string localDeviceId = "deviceId";
947 std::vector<std::string> peerUdids;
948 std::multimap<std::string, int32_t> peerUserIdMap;
949 DmOfflineParam offlineParam;
950 DeviceProfileConnector::GetInstance().DeleteAclForUserRemoved(localDeviceId, userId, peerUdids, peerUserIdMap,
951 offlineParam);
952 int32_t ret = DeviceProfileConnector::GetInstance().PutAccessControlList(aclInfo, dmAccesser, dmAccessee);
953 EXPECT_EQ(ret, DM_OK);
954 }
955
956 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_001, testing::ext::TestSize.Level1)
957 {
958 int32_t userId = 0;
959 std::string oldAccountId;
960 std::string newAccountId;
961 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
962 EXPECT_EQ(ret, DM_OK);
963 }
964
965 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_002, testing::ext::TestSize.Level1)
966 {
967 int32_t userId = 123456;
968 std::string oldAccountId = "oldAccountId";
969 std::string newAccountId = "newAccountId";
970 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
971 EXPECT_EQ(ret, DM_OK);
972 }
973
974 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_003, testing::ext::TestSize.Level1)
975 {
976 int32_t userId = 123456;
977 std::string oldAccountId = "accountId";
978 std::string newAccountId = "newAccountId";
979 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
980 EXPECT_EQ(ret, DM_OK);
981 }
982
983 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_004, testing::ext::TestSize.Level1)
984 {
985 int32_t userId = 123456;
986 std::string oldAccountId = "accountId";
987 std::string newAccountId = "accountId";
988 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
989 EXPECT_EQ(ret, DM_OK);
990 }
991
992 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_003, testing::ext::TestSize.Level1)
993 {
994 DistributedDeviceProfile::AccessControlProfile profiles;
995 profiles.SetBindType(DM_POINT_TO_POINT);
996 profiles.SetBindLevel(USER);
997 std::string targetDeviceId = "targetDeviceId";
998 std::string localDeviceId = "localDeviceId";
999 uint32_t index = 0;
1000 std::vector<int32_t> sinkBindType;
1001 std::vector<int32_t> bindTypeIndex;
1002 DeviceProfileConnector::GetInstance().ProcessBindType(profiles,
1003 localDeviceId, sinkBindType, bindTypeIndex, index, targetDeviceId);
1004 EXPECT_EQ(sinkBindType, vector<int32_t>({DEVICE_PEER_TO_PEER_TYPE}));
1005 EXPECT_EQ(bindTypeIndex, vector<int32_t>({0}));
1006 }
1007
1008 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_004, testing::ext::TestSize.Level1)
1009 {
1010 DistributedDeviceProfile::AccessControlProfile profiles;
1011 profiles.SetBindType(DM_ACROSS_ACCOUNT);
1012 profiles.SetBindLevel(USER);
1013 std::string targetDeviceId = "targetDeviceId";
1014 std::string localDeviceId = "localDeviceId";
1015 uint32_t index = 0;
1016 std::vector<int32_t> sinkBindType;
1017 std::vector<int32_t> bindTypeIndex;
1018 DeviceProfileConnector::GetInstance().ProcessBindType(profiles,
1019 localDeviceId, sinkBindType, bindTypeIndex, index, targetDeviceId);
1020 EXPECT_EQ(sinkBindType, vector<int32_t>({DEVICE_ACROSS_ACCOUNT_TYPE}));
1021 EXPECT_EQ(bindTypeIndex, vector<int32_t>({0}));
1022 }
1023
1024 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_001, testing::ext::TestSize.Level1)
1025 {
1026 std::string pkgName;
1027 std::string deviceId;
1028 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1029 EXPECT_EQ(ret, false);
1030 }
1031
1032 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_002, testing::ext::TestSize.Level1)
1033 {
1034 std::string pkgName = "bundleName";
1035 std::string deviceId = "123456";
1036 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1037 EXPECT_EQ(ret, false);
1038 }
1039
1040 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_003, testing::ext::TestSize.Level1)
1041 {
1042 std::string pkgName = "bundleName";
1043 std::string deviceId = "deviceId";
1044 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1045 EXPECT_EQ(ret, false);
1046 }
1047
1048 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_001, testing::ext::TestSize.Level1)
1049 {
1050 std::string pkgName;
1051 std::string deviceId;
1052 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1053 EXPECT_EQ(ret, false);
1054 }
1055
1056 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_002, testing::ext::TestSize.Level1)
1057 {
1058 std::string pkgName = "bundleName";
1059 std::string deviceId = "123456";
1060 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1061 EXPECT_EQ(ret, false);
1062 }
1063
1064 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_003, testing::ext::TestSize.Level1)
1065 {
1066 std::string pkgName = "bundleName";
1067 std::string deviceId = "deviceId";
1068 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1069 EXPECT_EQ(ret, false);
1070 }
1071
1072 HWTEST_F(DeviceProfileConnectorTest, CheckDevIdInAclForDevBind_001, testing::ext::TestSize.Level1)
1073 {
1074 std::string pkgName;
1075 std::string deviceId;
1076 bool ret = DeviceProfileConnector::GetInstance().CheckDevIdInAclForDevBind(pkgName, deviceId);
1077 EXPECT_EQ(ret, false);
1078 }
1079
1080 HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_001, testing::ext::TestSize.Level1)
1081 {
1082 std::string deviceId;
1083 DmOfflineParam offlineParam;
1084 uint32_t ret = DeviceProfileConnector::GetInstance().DeleteTimeOutAcl(deviceId, offlineParam);
1085 EXPECT_EQ(ret, 0);
1086 }
1087
1088 HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_001, testing::ext::TestSize.Level1)
1089 {
1090 std::string deviceId;
1091 int32_t ret = DeviceProfileConnector::GetInstance().GetTrustNumber(deviceId);
1092 EXPECT_EQ(ret, DM_OK);
1093 }
1094
1095 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_001, testing::ext::TestSize.Level1)
1096 {
1097 std::string udid = "udid";
1098 int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
1099 EXPECT_EQ(ret, ERR_DM_FAILED);
1100 }
1101
1102 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_002, testing::ext::TestSize.Level1)
1103 {
1104 std::string udid = "deviceId";
1105 int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
1106 EXPECT_EQ(ret, DM_OK);
1107 }
1108
1109 HWTEST_F(DeviceProfileConnectorTest, GetAuthForm_001, testing::ext::TestSize.Level1)
1110 {
1111 DistributedDeviceProfile::AccessControlProfile profile;
1112 std::string trustDev = "";
1113 std::string reqDev = "";
1114 int32_t ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1115 EXPECT_EQ(ret, INVALIED_TYPE);
1116 profile.SetBindType(DM_IDENTICAL_ACCOUNT);
1117 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1118 EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
1119 profile.SetBindType(DM_SHARE);
1120 profile.SetBindLevel(USER);
1121 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1122 EXPECT_EQ(ret, SHARE_TYPE);
1123 profile.SetBindType(DM_POINT_TO_POINT);
1124 profile.SetBindLevel(USER);
1125 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1126 EXPECT_EQ(ret, DEVICE_PEER_TO_PEER_TYPE);
1127 profile.SetBindType(DM_ACROSS_ACCOUNT);
1128 profile.SetBindLevel(USER);
1129 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1130 EXPECT_EQ(ret, DEVICE_ACROSS_ACCOUNT_TYPE);
1131 profile.SetBindLevel(APP);
1132 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1133 EXPECT_EQ(ret, APP_ACROSS_ACCOUNT_TYPE);
1134 profile.SetBindType(INVALIED_TYPE);
1135 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1136 EXPECT_EQ(ret, INVALIED_TYPE);
1137
1138 profile.SetBindType(DM_POINT_TO_POINT);
1139 profile.SetBindLevel(APP);
1140 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
1141 EXPECT_EQ(ret, APP_PEER_TO_PEER_TYPE);
1142 }
1143
1144 HWTEST_F(DeviceProfileConnectorTest, GetBindLevel_001, testing::ext::TestSize.Level1)
1145 {
1146 std::string pkgName = "bundleName";
1147 std::string localUdid = "localDeviceId";
1148 std::string udid = "remoteDeviceId";
1149 uint64_t tokenId = 0;
1150 int32_t bindLevel = INVALIED_TYPE;
1151
1152 bindLevel = DeviceProfileConnector::GetInstance()
1153 .GetBindLevel(pkgName, localUdid, udid, tokenId);
1154
1155 EXPECT_EQ(bindLevel, INVALIED_TYPE);
1156 }
1157
1158 HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_001, testing::ext::TestSize.Level1)
1159 {
1160 std::string udid = "deviceId";
1161 int32_t bindType = USER;
1162 std::map<std::string, int32_t> deviceMap;
1163 deviceMap[udid] = APP;
1164 DeviceProfileConnector::GetInstance().UpdateBindType(udid, bindType, deviceMap);
1165 EXPECT_EQ(deviceMap[udid], USER);
1166 }
1167
1168 HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_002, testing::ext::TestSize.Level1)
1169 {
1170 std::string udid = "deviceId";
1171 int32_t bindType = USER;
1172 std::map<std::string, int32_t> deviceMap;
1173 DeviceProfileConnector::GetInstance().UpdateBindType(udid, bindType, deviceMap);
1174 EXPECT_EQ(deviceMap[udid], USER);
1175 }
1176
1177 HWTEST_F(DeviceProfileConnectorTest, HandleAccountLogoutEvent_001, testing::ext::TestSize.Level1)
1178 {
1179 int32_t remoteUserId = 0;
1180 int32_t bindType = DM_INVALIED_TYPE;
1181 std::string remoteAccountHash = "remoteAccountHash";
1182 std::string remoteUdid = "1";
1183 std::string localUdid = "localDeviceId";
1184
1185 bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1186 remoteAccountHash, remoteUdid, localUdid);
1187 EXPECT_EQ(bindType, DM_INVALIED_TYPE);
1188 }
1189
1190 HWTEST_F(DeviceProfileConnectorTest, HandleDevUnBindEvent_001, testing::ext::TestSize.Level1)
1191 {
1192 int32_t remoteUserId = 0;
1193 std::string remoteUdid = "remoteDeviceId";
1194 std::string localUdid = "localDeviceId";
1195 DmOfflineParam offlineParam;
1196 int32_t bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid,
1197 offlineParam);
1198 EXPECT_EQ(bindType, DM_INVALIED_TYPE);
1199 }
1200
1201 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_001, testing::ext::TestSize.Level1)
1202 {
1203 int32_t remoteUserId = 0;
1204 int32_t tokenId = 0;
1205 std::string remoteUdid = "remoteDeviceId";
1206 std::string localUdid = "localDeviceId";
1207 std::string pkgName = "";
1208 DmOfflineParam res;
1209
1210 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
1211 EXPECT_EQ(0, res.processVec.size());
1212
1213 int32_t peerTokenId = 1;
1214 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid,
1215 peerTokenId);
1216 EXPECT_EQ(0, res.processVec.size());
1217 }
1218
1219 HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_001, testing::ext::TestSize.Level1)
1220 {
1221 DistributedDeviceProfile::AccessControlProfile profile;
1222 DmAccessCaller caller;
1223 DmAccessCallee callee;
1224 int32_t ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1225 EXPECT_EQ(ret, false);
1226 profile.SetBindType(DM_IDENTICAL_ACCOUNT);
1227 profile.accessee_.SetAccesseeBundleName("pkgName");
1228 profile.accessee_.SetAccesseeDeviceId("localDeviceId");
1229 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1230 EXPECT_EQ(ret, true);
1231 profile.SetBindType(DM_POINT_TO_POINT);
1232 profile.SetBindLevel(USER);
1233 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1234 EXPECT_EQ(ret, true);
1235 profile.SetBindLevel(APP);
1236 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1237 EXPECT_EQ(ret, true);
1238 profile.SetBindLevel(SERVICE);
1239 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1240 EXPECT_EQ(ret, true);
1241 profile.SetBindType(DM_ACROSS_ACCOUNT);
1242 profile.SetBindLevel(USER);
1243 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1244 EXPECT_EQ(ret, true);
1245 profile.SetBindLevel(APP);
1246 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1247 EXPECT_EQ(ret, true);
1248 profile.SetBindLevel(SERVICE);
1249 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1250 EXPECT_EQ(ret, true);
1251 profile.SetBindType(INVALIED_TYPE);
1252 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
1253 EXPECT_EQ(ret, false);
1254 }
1255
1256 HWTEST_F(DeviceProfileConnectorTest, GetAccessControlProfileByUserId_001, testing::ext::TestSize.Level1)
1257 {
1258 int32_t userId = USER;
1259 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1260 profiles = DeviceProfileConnector::GetInstance().GetAccessControlProfileByUserId(userId);
1261 EXPECT_GE(profiles.size(), 0);
1262 }
1263
1264 HWTEST_F(DeviceProfileConnectorTest, DeleteAppBindLevel_001, testing::ext::TestSize.Level1)
1265 {
1266 DmOfflineParam offlineParam;
1267 std::string pkgName = "bundleName1";
1268 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1269 std::string localUdid = "remoteDeviceId";
1270 std::string remoteUdid = "localDeviceId";
1271 GetAccessControlProfiles(profiles);
1272 DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid);
1273 EXPECT_EQ(offlineParam.bindType, APP);
1274
1275 pkgName = "bundleName2";
1276 localUdid = "localDeviceId";
1277 remoteUdid="remoteDeviceId";
1278 DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam, pkgName, profiles, localUdid, remoteUdid);
1279 EXPECT_EQ(offlineParam.bindType, APP);
1280 }
1281
1282 HWTEST_F(DeviceProfileConnectorTest, DeleteAppBindLevel_003, testing::ext::TestSize.Level1)
1283 {
1284 DmOfflineParam offlineParam;
1285 std::string pkgName = "bundleName2";
1286 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1287 std::string localUdid = "localDeviceId";
1288 std::string remoteUdid="remoteDeviceId";
1289 std::string extra = "bundleName1";
1290 GetAccessControlProfiles(profiles);
1291 DeviceProfileConnector::GetInstance().DeleteAppBindLevel(offlineParam,
1292 pkgName, profiles, localUdid, remoteUdid, extra);
1293 EXPECT_NE(offlineParam.bindType, APP);
1294 }
1295
1296 HWTEST_F(DeviceProfileConnectorTest, DeleteDeviceBindLevel_001, testing::ext::TestSize.Level1)
1297 {
1298 DmOfflineParam offlineParam;
1299 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1300 std::string localUdid = "remoteDeviceId";
1301 std::string remoteUdid="localDeviceId";
1302 GetAccessControlProfiles(profiles);
1303 DeviceProfileConnector::GetInstance().DeleteDeviceBindLevel(offlineParam, profiles, localUdid, remoteUdid);
1304 EXPECT_EQ(offlineParam.bindType, USER);
1305
1306 localUdid = "localDeviceId";
1307 remoteUdid="remoteDeviceId";
1308 DeviceProfileConnector::GetInstance().DeleteDeviceBindLevel(offlineParam, profiles, localUdid, remoteUdid);
1309 EXPECT_EQ(offlineParam.bindType, USER);
1310 }
1311
1312 HWTEST_F(DeviceProfileConnectorTest, DeleteServiceBindLevel_001, testing::ext::TestSize.Level1)
1313 {
1314 DmOfflineParam offlineParam;
1315 std::string pkgName = "bundleName1";
1316 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1317 std::string localUdid = "remoteDeviceId";
1318 std::string remoteUdid="localDeviceId";
1319 GetAccessControlProfiles(profiles);
1320 DeviceProfileConnector::GetInstance().DeleteServiceBindLevel(offlineParam, pkgName, profiles,
1321 localUdid, remoteUdid);
1322 EXPECT_EQ(offlineParam.bindType, SERVICE);
1323
1324 pkgName = "bundleName2";
1325 localUdid = "localDeviceId";
1326 remoteUdid="remoteDeviceId";
1327 DeviceProfileConnector::GetInstance().DeleteServiceBindLevel(offlineParam, pkgName, profiles,
1328 localUdid, remoteUdid);
1329 EXPECT_EQ(offlineParam.bindType, SERVICE);
1330 }
1331
1332 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_004, testing::ext::TestSize.Level1)
1333 {
1334 std::string pkgName = "bundleName";
1335 std::string deviceId = "localDeviceId";
1336 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1337 EXPECT_TRUE(ret);
1338 }
1339
1340 HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_002, testing::ext::TestSize.Level1)
1341 {
1342 std::string deviceId = "remoteDeviceId";
1343 DmOfflineParam offlineParam;
1344 uint32_t ret = DeviceProfileConnector::GetInstance().DeleteTimeOutAcl(deviceId, offlineParam);
1345 EXPECT_EQ(ret, 0);
1346 }
1347
1348 HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_002, testing::ext::TestSize.Level1)
1349 {
1350 std::string deviceId = "remoteDeviceId";
1351 int32_t ret = DeviceProfileConnector::GetInstance().GetTrustNumber(deviceId);
1352 EXPECT_NE(ret, DM_OK);
1353 }
1354
1355 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_003, testing::ext::TestSize.Level1)
1356 {
1357 std::string udid = "123456";
1358 int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
1359 EXPECT_EQ(ret, DM_OK);
1360 }
1361
1362 HWTEST_F(DeviceProfileConnectorTest, CheckAccessControl_001, testing::ext::TestSize.Level1)
1363 {
1364 DmAccessCaller caller;
1365 std::string srcUdid;
1366 DmAccessCallee callee;
1367 std::string sinkUdid;
1368 bool ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1369 EXPECT_EQ(ret, false);
1370
1371 srcUdid = "123456";
1372 sinkUdid = "123456";
1373 ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1374 EXPECT_NE(ret, true);
1375 }
1376
1377 HWTEST_F(DeviceProfileConnectorTest, CheckIsSameAccount_001, testing::ext::TestSize.Level1)
1378 {
1379 DmAccessCaller caller;
1380 std::string srcUdid;
1381 DmAccessCallee callee;
1382 std::string sinkUdid;
1383 bool ret = DeviceProfileConnector::GetInstance().CheckIsSameAccount(caller, srcUdid, callee, sinkUdid);
1384 EXPECT_EQ(ret, false);
1385
1386 srcUdid = "123456";
1387 sinkUdid = "123456";
1388 ret = DeviceProfileConnector::GetInstance().CheckIsSameAccount(caller, srcUdid, callee, sinkUdid);
1389 EXPECT_NE(ret, true);
1390 }
1391
1392 HWTEST_F(DeviceProfileConnectorTest, HandleAccountLogoutEvent_002, testing::ext::TestSize.Level1)
1393 {
1394 int32_t remoteUserId = 0;
1395 int32_t bindType = DM_INVALIED_TYPE;
1396 std::string remoteAccountHash = "remoteAccountHash";
1397 std::string remoteUdid = "123456";
1398 std::string localUdid = "localDeviceId";
1399
1400 bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1401 remoteAccountHash, remoteUdid, localUdid);
1402 EXPECT_NE(bindType, DM_IDENTICAL_ACCOUNT);
1403
1404 localUdid = "remoteDeviceId";
1405 remoteUdid = "localDeviceId";
1406 bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1407 remoteAccountHash, remoteUdid, localUdid);
1408 EXPECT_EQ(bindType, DM_IDENTICAL_ACCOUNT);
1409
1410 int32_t remoteId = 456;
1411 remoteUserId = remoteId;
1412 bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
1413 remoteAccountHash, remoteUdid, localUdid);
1414 EXPECT_EQ(bindType, DM_IDENTICAL_ACCOUNT);
1415 }
1416
1417 HWTEST_F(DeviceProfileConnectorTest, HandleDevUnBindEvent_002, testing::ext::TestSize.Level1)
1418 {
1419 int32_t remoteUserId = 0;
1420 std::string remoteUdid;
1421 std::string localUdid = "localDeviceId";
1422 DmOfflineParam offlineParam;
1423 int32_t bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid,
1424 offlineParam);
1425 EXPECT_EQ(bindType, DM_INVALIED_TYPE);
1426
1427 remoteUdid = "123456";
1428 bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid,
1429 offlineParam);
1430 EXPECT_EQ(bindType, DM_INVALIED_TYPE);
1431
1432 remoteUdid = "localDeviceId";
1433 remoteUserId = 1234;
1434 bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid,
1435 offlineParam);
1436 EXPECT_NE(bindType, DM_IDENTICAL_ACCOUNT);
1437
1438 remoteUserId = 456;
1439 bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid,
1440 offlineParam);
1441 EXPECT_EQ(bindType, DM_INVALIED_TYPE);
1442 }
1443
1444 HWTEST_F(DeviceProfileConnectorTest, GetAllAccessControlProfile_001, testing::ext::TestSize.Level1)
1445 {
1446 int64_t accessControlId = 1;
1447 DeviceProfileConnector::GetInstance().DeleteAccessControlById(accessControlId);
1448 auto ret = DeviceProfileConnector::GetInstance().GetAllAccessControlProfile();
1449 EXPECT_FALSE(ret.empty());
1450 }
1451
1452 HWTEST_F(DeviceProfileConnectorTest, GetAclProfileByDeviceIdAndUserId_001, testing::ext::TestSize.Level1)
1453 {
1454 std::string deviceId = "deviceId";
1455 int32_t userId = 123456;
1456 auto ret = DeviceProfileConnector::GetInstance().GetAclProfileByDeviceIdAndUserId(deviceId, userId
1457 );
1458 EXPECT_FALSE(ret.empty());
1459 }
1460
1461 HWTEST_F(DeviceProfileConnectorTest, DeleteAclForAccountLogOut_001, testing::ext::TestSize.Level1)
1462 {
1463 std::string localUdid;
1464 int32_t localUserId = 444;
1465 std::string peerUdid = "deviceId";
1466 int32_t peerUserId = 555;
1467 DmOfflineParam offlineParam;
1468 DMAclQuadInfo info = {localUdid, localUserId, peerUdid, peerUserId};
1469 std::string accountId = "accountId";
1470 bool ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(info, accountId, offlineParam);
1471 EXPECT_FALSE(ret);
1472
1473 localUdid = "deviceId";
1474 localUserId = 123456;
1475 peerUdid = "deviceId";
1476 peerUserId = 456;
1477 info = {localUdid, localUserId, peerUdid, peerUserId};
1478 ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(info, accountId, offlineParam);
1479 EXPECT_FALSE(ret);
1480
1481 localUdid = "deviceId";
1482 localUserId = 123456;
1483 peerUdid = "deviceId";
1484 peerUserId = 123456;
1485 info = {localUdid, localUserId, peerUdid, peerUserId};
1486 ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(info, accountId, offlineParam);
1487 EXPECT_FALSE(ret);
1488
1489 localUdid = "localDeviceId";
1490 localUserId = 123456;
1491 peerUdid = "remoteDeviceId";
1492 peerUserId = 123456;
1493 info = {localUdid, localUserId, peerUdid, peerUserId};
1494 ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(info, accountId, offlineParam);
1495 EXPECT_FALSE(ret);
1496
1497 localUdid = "remoteDeviceId";
1498 localUserId = 1234;
1499 peerUdid = "localDeviceId";
1500 peerUserId = 1234;
1501 info = {localUdid, localUserId, peerUdid, peerUserId};
1502 ret = DeviceProfileConnector::GetInstance().DeleteAclForAccountLogOut(info, accountId, offlineParam);
1503 EXPECT_FALSE(ret);
1504 }
1505
1506 HWTEST_F(DeviceProfileConnectorTest, GetProcessInfoFromAclByUserId_005, testing::ext::TestSize.Level1)
1507 {
1508 std::string localDeviceId = "deviceId";
1509 std::string targetDeviceId = "deviceId";
1510 int32_t userId = 123456;
1511 auto ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId,
1512 targetDeviceId, userId);
1513 EXPECT_FALSE(ret.empty());
1514
1515 localDeviceId = "remoteDeviceId";
1516 targetDeviceId = "localDeviceId";
1517 userId = 456;
1518 ret = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId,
1519 targetDeviceId, userId);
1520 EXPECT_FALSE(ret.empty());
1521 }
1522
1523 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndBindLevel_001, testing::ext::TestSize.Level1)
1524 {
1525 std::vector<int32_t> userIds;
1526 int32_t userId = 123456;
1527 int32_t localId = 456;
1528 userIds.push_back(userId);
1529 userIds.push_back(localId);
1530 std::string localUdid = "deviceId";
1531 auto ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndBindLevel(userIds, localUdid);
1532 EXPECT_FALSE(ret.empty());
1533
1534 localUdid = "localDeviceId";
1535 ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndBindLevel(userIds, localUdid);
1536 EXPECT_FALSE(ret.empty());
1537 }
1538
1539 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndUserId_001, testing::ext::TestSize.Level1)
1540 {
1541 int32_t userId = 123456;
1542 std::string accountId;
1543 std::string localUdid = "deviceId";
1544 auto ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(userId, accountId, localUdid);
1545 EXPECT_TRUE(ret.empty());
1546
1547 localUdid = "localDeviceId";
1548 userId = 456;
1549 ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(userId, accountId, localUdid);
1550 EXPECT_TRUE(ret.empty());
1551 }
1552
1553 HWTEST_F(DeviceProfileConnectorTest, HandleUserSwitched_001, testing::ext::TestSize.Level1)
1554 {
1555 int32_t currentUserId = 0;
1556 std::string localUdid = "deviceId";
1557 int32_t beforeUserId = 123456;
1558 std::vector<std::string> deviceVec;
1559 int32_t ret = DeviceProfileConnector::GetInstance().HandleUserSwitched(localUdid, deviceVec, currentUserId,
1560 beforeUserId);
1561 EXPECT_EQ(ret, DM_OK);
1562
1563 beforeUserId = 1234;
1564 currentUserId = 123456;
1565 ret = DeviceProfileConnector::GetInstance().HandleUserSwitched(localUdid, deviceVec, currentUserId, beforeUserId);
1566 EXPECT_EQ(ret, DM_OK);
1567
1568 std::vector<int32_t> remoteUserIds;
1569 remoteUserIds.push_back(currentUserId);
1570 std::string remoteUdid = "deviceId";
1571 std::vector<int32_t> localUserIds;
1572 localUserIds.push_back(currentUserId);
1573 DeviceProfileConnector::GetInstance().HandleSyncForegroundUserIdEvent(remoteUserIds, remoteUdid,
1574 localUserIds, localUdid);
1575
1576 localUdid = "remoteDeviceId";
1577 remoteUdid = "localDeviceId";
1578 int32_t localdeviceId = 456;
1579 remoteUserIds.push_back(localdeviceId);
1580 localUserIds.push_back(localdeviceId);
1581 DeviceProfileConnector::GetInstance().HandleSyncForegroundUserIdEvent(remoteUserIds, remoteUdid,
1582 localUserIds, localUdid);
1583 }
1584
1585 HWTEST_F(DeviceProfileConnectorTest, GetOfflineProcessInfo_001, testing::ext::TestSize.Level1)
1586 {
1587 std::string localUdid = "deviceId";
1588 std::vector<int32_t> localUserIds;
1589 std::string remoteUdid = "deviceId";
1590 std::vector<int32_t> remoteUserIds;
1591 int32_t userId = 123456;
1592 remoteUserIds.push_back(userId);
1593 localUserIds.push_back(userId);
1594 auto ret = DeviceProfileConnector::GetInstance().GetOfflineProcessInfo(localUdid, localUserIds, remoteUdid,
1595 remoteUserIds);
1596 EXPECT_FALSE(ret.empty());
1597
1598 localUdid = "remoteDeviceId";
1599 remoteUdid = "localDeviceId";
1600 int32_t localdeviceId = 456;
1601 remoteUserIds.push_back(localdeviceId);
1602 localUserIds.push_back(localdeviceId);
1603 ret = DeviceProfileConnector::GetInstance().GetOfflineProcessInfo(localUdid, localUserIds, remoteUdid,
1604 remoteUserIds);
1605 EXPECT_FALSE(ret.empty());
1606 }
1607
1608 HWTEST_F(DeviceProfileConnectorTest, GetUserIdAndBindLevel_001, testing::ext::TestSize.Level1)
1609 {
1610 std::string localUdid = "deviceId";
1611 std::string peerUdid = "deviceId";
1612 auto ret = DeviceProfileConnector::GetInstance().GetUserIdAndBindLevel(localUdid, peerUdid);
1613 EXPECT_FALSE(ret.empty());
1614
1615 localUdid = "remoteDeviceId";
1616 peerUdid = "localDeviceId";
1617 ret = DeviceProfileConnector::GetInstance().GetUserIdAndBindLevel(localUdid, peerUdid);
1618 EXPECT_FALSE(ret.empty());
1619
1620 localUdid = "remoteDeviceIdee";
1621 peerUdid = "localDeviceIder";
1622 ret = DeviceProfileConnector::GetInstance().GetUserIdAndBindLevel(localUdid, peerUdid);
1623 EXPECT_FALSE(ret.empty());
1624
1625 int32_t userId = 123456;
1626 std::vector<int32_t> localUserIds;
1627 localUserIds.push_back(userId);
1628 std::string remoteUdid = "deviceId";
1629 std::vector<int32_t> remoteFrontUserIds;
1630 remoteFrontUserIds.push_back(userId);
1631 std::vector<int32_t> remoteBackUserIds;
1632 remoteBackUserIds.push_back(userId);
1633 DmOfflineParam offlineParam;
1634 DeviceProfileConnector::GetInstance().UpdateACL(localUdid, localUserIds, remoteUdid, remoteFrontUserIds,
1635 remoteBackUserIds, offlineParam);
1636
1637 localUdid = "remoteDeviceId";
1638 remoteUdid = "localDeviceId";
1639 userId = 456;
1640 std::vector<int32_t> remoteUserIds;
1641 remoteUserIds.push_back(userId);
1642 localUserIds.push_back(userId);
1643 DeviceProfileConnector::GetInstance().HandleSyncBackgroundUserIdEvent(remoteUserIds, remoteUdid, localUserIds,
1644 localUdid);
1645 }
1646
1647 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndUserId_002, testing::ext::TestSize.Level1)
1648 {
1649 std::string localUdid = "deviceId";
1650 int32_t localUserId = 123456;
1651 auto ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(localUdid, localUserId);
1652 EXPECT_FALSE(ret.empty());
1653
1654 localUdid = "localDeviceId";
1655 localUserId = 456;
1656 ret = DeviceProfileConnector::GetInstance().GetDeviceIdAndUserId(localUdid, localUserId);
1657 EXPECT_FALSE(ret.empty());
1658
1659 std::vector<int32_t> remoteUserIds;
1660 remoteUserIds.push_back(localUserId);
1661 std::string remoteUdid = "deviceId";
1662 std::vector<int32_t> localUserIds;
1663 localUserIds.push_back(localUserId);
1664 DeviceProfileConnector::GetInstance().HandleSyncBackgroundUserIdEvent(remoteUserIds, remoteUdid, localUserIds,
1665 localUdid);
1666
1667 ProcessInfo process;
1668 process.userId = 1;
1669 process.pkgName = "pkgName";
1670 ProcessInfo process1;
1671 process1.userId = 1;
1672 process1.pkgName = "pkgName";
1673 EXPECT_TRUE(process == process1);
1674
1675 process.userId = 0;
1676 EXPECT_TRUE(process < process1);
1677
1678 DmNotifyKey dmNotifyKey;
1679 dmNotifyKey.processUserId = 1;
1680 dmNotifyKey.processPkgName = "proName";
1681 dmNotifyKey.notifyUserId = 0;
1682 dmNotifyKey.udid = "udid";
1683
1684 DmNotifyKey dmNotifyKey1;
1685 dmNotifyKey1.processUserId = 1;
1686 dmNotifyKey1.processPkgName = "proName";
1687 dmNotifyKey1.notifyUserId = 0;
1688 dmNotifyKey1.udid = "udid";
1689 EXPECT_TRUE(dmNotifyKey == dmNotifyKey1);
1690
1691 dmNotifyKey1.processUserId = 2;
1692 EXPECT_TRUE(dmNotifyKey < dmNotifyKey1);
1693 }
1694
1695 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_004, testing::ext::TestSize.Level1)
1696 {
1697 std::string pkgName = "bundleName";
1698 std::string deviceId = "deviceId";
1699
1700 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(123456));
1701 auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1702 EXPECT_NE(ret.empty(), false);
1703
1704 deviceId = "remoteDeviceId";
1705 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId())
1706 .Times(::testing::AtLeast(1))
1707 .WillOnce(Return(1234));
1708 ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1709 EXPECT_EQ(ret.empty(), true);
1710
1711 deviceId = "remoteDeviceId";
1712 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId())
1713 .Times(::testing::AtLeast(1))
1714 .WillOnce(Return(1234));
1715 ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1716
1717 deviceId = "remoteDeviceId";
1718 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId())
1719 .Times(::testing::AtLeast(1))
1720 .WillOnce(Return(1234));
1721 ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1722
1723 deviceId = "remoteDeviceId";
1724 ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1725
1726 deviceId = "remoteDeviceId";
1727 ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
1728
1729 std::string udid;
1730 DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid);
1731
1732 udid = "deviceId";
1733 DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid);
1734 }
1735
1736 HWTEST_F(DeviceProfileConnectorTest, GetDevIdAndUserIdByActHash_001, testing::ext::TestSize.Level1)
1737 {
1738 std::string localUdid = "deviceId";
1739 std::string peerUdid = "deviceId";
1740 int32_t peerUserId = 123456;
1741 std::string peerAccountHash = "";
1742 EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).WillOnce(Return(ERR_DM_FAILED));
1743 auto ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1744 peerUserId, peerAccountHash);
1745 EXPECT_TRUE(ret.empty());
1746
1747 EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).WillOnce(Return(DM_OK)).WillOnce(Return(ERR_DM_FAILED));
1748 ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1749 peerUserId, peerAccountHash);
1750 EXPECT_TRUE(ret.empty());
1751
1752 EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).Times(::testing::AtLeast(40)).WillOnce(Return(DM_OK));
1753 ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1754 peerUserId, peerAccountHash);
1755 EXPECT_FALSE(ret.empty());
1756
1757 localUdid = "remoteDeviceId";
1758 peerUdid = "localDeviceId";
1759 peerUserId = 456;
1760 EXPECT_CALL(*cryptoMock_, GetAccountIdHash(_, _)).Times(::testing::AtLeast(40)).WillOnce(Return(DM_OK));
1761 ret = DeviceProfileConnector::GetInstance().GetDevIdAndUserIdByActHash(localUdid, peerUdid,
1762 peerUserId, peerAccountHash);
1763 EXPECT_FALSE(ret.empty());
1764 }
1765
1766 HWTEST_F(DeviceProfileConnectorTest, GetDeviceAclParam_002, testing::ext::TestSize.Level1)
1767 {
1768 DmDiscoveryInfo discoveryInfo;
1769 discoveryInfo.remoteDeviceIdHash = "";
1770 discoveryInfo.localDeviceId = "deviceId";
1771 discoveryInfo.userId = 123456;
1772 discoveryInfo.pkgname = "";
1773 bool isonline = true;
1774 int32_t authForm = 0;
1775 EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
1776 int32_t ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
1777 EXPECT_EQ(ret, DM_OK);
1778
1779 discoveryInfo.pkgname = "bundleName";
1780 discoveryInfo.localDeviceId = "deviceId";
1781 EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
1782 ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
1783 EXPECT_EQ(ret, DM_OK);
1784
1785 discoveryInfo.localDeviceId = "trustDeviceId";
1786 EXPECT_CALL(*cryptoMock_, GetUdidHash(_, _)).Times(::testing::AtLeast(38)).WillOnce(Return(DM_OK));
1787 ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
1788 EXPECT_EQ(ret, DM_OK);
1789 }
1790
1791 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_004, testing::ext::TestSize.Level1)
1792 {
1793 std::string pkgName = "bundleName";
1794 std::string deviceId = "localDeviceId";
1795 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
1796 EXPECT_EQ(ret, true);
1797 }
1798
1799 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_005, testing::ext::TestSize.Level1)
1800 {
1801 std::string pkgName = "bundleName";
1802 std::string deviceId = "123456";
1803 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
1804 EXPECT_FALSE(ret);
1805
1806 DistributedDeviceProfile::AccessControlProfile profiles;
1807 std::string remoteUdid = "remoteDeviceId";
1808 std::vector<int32_t> remoteFrontUserIds;
1809 std::vector<int32_t> remoteBackUserIds;
1810 AddAccessControlProfileFirst(profiles);
1811 DmOfflineParam offlineParam;
1812 DeviceProfileConnector::GetInstance().DeleteSigTrustACL(profiles, remoteUdid,
1813 remoteFrontUserIds, remoteBackUserIds, offlineParam);
1814
1815 remoteUdid = "localDeviceId";
1816 AddAccessControlProfileSeven(profiles);
1817 DeviceProfileConnector::GetInstance().DeleteSigTrustACL(profiles, remoteUdid,
1818 remoteFrontUserIds, remoteBackUserIds, offlineParam);
1819
1820 AddAccessControlProfileEight(profiles);
1821 std::string localUdid = "localDeviceId";
1822 std::vector<int32_t> localUserIds;
1823 int32_t userId = 123456;
1824 localUserIds.push_back(userId);
1825 remoteUdid = "remoteDeviceId";
1826 remoteFrontUserIds.push_back(0);
1827 remoteFrontUserIds.push_back(userId);
1828 DeviceProfileConnector::GetInstance().UpdatePeerUserId(profiles, localUdid, localUserIds, remoteUdid,
1829 remoteFrontUserIds);
1830 }
1831
1832 HWTEST_F(DeviceProfileConnectorTest, CheckAccessControl_002, testing::ext::TestSize.Level1)
1833 {
1834 int32_t userId = 123456;
1835 DmAccessCaller caller;
1836 caller.userId = userId;
1837 std::string srcUdid = "deviceId";
1838 DmAccessCallee callee;
1839 callee.userId = userId;
1840 std::string sinkUdid = "deviceId";
1841 bool ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1842 EXPECT_EQ(ret, true);
1843
1844 srcUdid = "remoteDeviceId";
1845 sinkUdid = "localDeviceId";
1846 caller.userId = 456;
1847 callee.userId = 456;
1848 ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1849 EXPECT_EQ(ret, true);
1850
1851 callee.userId = 0;
1852 ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1853 EXPECT_EQ(ret, true);
1854 }
1855
1856 HWTEST_F(DeviceProfileConnectorTest, CheckIsSameAccount_002, testing::ext::TestSize.Level1)
1857 {
1858 int32_t userId = 456;
1859 DmAccessCaller caller;
1860 caller.userId = userId;
1861 std::string srcUdid = "localDeviceId";
1862 DmAccessCallee callee;
1863 callee.userId = userId;
1864 std::string sinkUdid = "remoteDeviceId";
1865 bool ret = DeviceProfileConnector::GetInstance().CheckIsSameAccount(caller, srcUdid, callee, sinkUdid);
1866 EXPECT_EQ(ret, true);
1867
1868 callee.userId = 0;
1869 ret = DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid);
1870 EXPECT_EQ(ret, true);
1871 }
1872
1873 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_002, testing::ext::TestSize.Level1)
1874 {
1875 int32_t remoteUserId = 456;
1876 int32_t tokenId = 1001;
1877 std::string remoteUdid = "localDeviceId";
1878 std::string localUdid = "remoteDeviceId";
1879 std::string pkgName = "";
1880 DmOfflineParam res;
1881 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
1882 EXPECT_NE(1, res.processVec.size());
1883
1884 int32_t peerTokenId = 1001;
1885 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid,
1886 peerTokenId);
1887 EXPECT_NE(3, res.processVec.size());
1888
1889 tokenId = 1002;
1890 peerTokenId = tokenId;
1891 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
1892 EXPECT_NE(3, res.processVec.size());
1893
1894 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid,
1895 peerTokenId);
1896 EXPECT_NE(3, res.processVec.size());
1897 }
1898
1899 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_003, testing::ext::TestSize.Level1)
1900 {
1901 int32_t remoteUserId = 0;
1902 int32_t tokenId = 0;
1903 std::string remoteUdid = "remoteDeviceId";
1904 std::string localUdid = "localDeviceId";
1905 std::string pkgName = "";
1906 int32_t peerTokenId = 1001;
1907 DmOfflineParam res;
1908 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId,
1909 remoteUdid, tokenId, localUdid, peerTokenId);
1910 EXPECT_EQ(0, res.processVec.size());
1911 }
1912
1913 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_004, testing::ext::TestSize.Level1)
1914 {
1915 int32_t remoteUserId = 123456;
1916 int32_t tokenId = 1001;
1917 std::string remoteUdid = "remoteDeviceId";
1918 std::string localUdid = "localDeviceId";
1919 std::string pkgName = "";
1920 int32_t peerTokenId = 1001;
1921 DmOfflineParam res;
1922 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId,
1923 remoteUdid, tokenId, localUdid, peerTokenId);
1924 EXPECT_NE(2, res.processVec.size());
1925 }
1926
1927 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_002, testing::ext::TestSize.Level1)
1928 {
1929 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1930 std::string pkgName = "bundleName2";
1931 std::string requestDeviceId = "localDeviceId";
1932 GetAccessControlProfiles(profiles);
1933 auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1934 EXPECT_EQ(ret, 0);
1935 }
1936
1937 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_003, testing::ext::TestSize.Level1)
1938 {
1939 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1940 std::string pkgName = "bundleName8";
1941 std::string requestDeviceId = "localDeviceId9";
1942 GetAccessControlProfiles(profiles);
1943 auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1944 EXPECT_EQ(ret, 0);
1945 }
1946
1947 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_004, testing::ext::TestSize.Level1)
1948 {
1949 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1950 std::string pkgName = "bundleName2";
1951 std::string requestDeviceId = "localDeviceId9";
1952 GetAccessControlProfiles(profiles);
1953 auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1954 EXPECT_EQ(ret, 0);
1955 }
1956
1957 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_005, testing::ext::TestSize.Level1)
1958 {
1959 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
1960 std::string pkgName;
1961 std::string requestDeviceId;
1962 GetAccessControlProfiles(profiles);
1963 auto ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
1964 EXPECT_EQ(ret, 0);
1965 }
1966
1967 HWTEST_F(DeviceProfileConnectorTest, GetAclProfileByUserId_001, testing::ext::TestSize.Level1)
1968 {
1969 std::string localUdid = "deviceId";
1970 int32_t userId = 123456;
1971 std::string remoteUdid = "deviceId";
1972 auto ret = DeviceProfileConnector::GetInstance().GetAclProfileByUserId(localUdid, userId, remoteUdid);
1973 EXPECT_FALSE(ret.empty());
1974
1975 localUdid = "remoteDeviceId";
1976 remoteUdid = "localDeviceId";
1977 userId = 456;
1978 ret = DeviceProfileConnector::GetInstance().GetAclProfileByUserId(localUdid, userId, remoteUdid);
1979 EXPECT_FALSE(ret.empty());
1980 }
1981
1982 HWTEST_F(DeviceProfileConnectorTest, PutAllTrustedDevices_001, testing::ext::TestSize.Level1)
1983 {
1984 std::vector<DistributedDeviceProfile::TrustedDeviceInfo> deviceInfos;
1985 int32_t ret = DeviceProfileConnector::GetInstance().PutAllTrustedDevices(deviceInfos);
1986 EXPECT_NE(ret, DM_OK);
1987 }
1988
1989 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_004, testing::ext::TestSize.Level1)
1990 {
1991 std::string peerUdid = "localDeviceId";
1992 std::string localUdid = "remoteDeviceId";
1993 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(0));
1994 uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(peerUdid, localUdid);
1995 EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
1996
1997 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(1234));
1998 ret = DeviceProfileConnector::GetInstance().CheckBindType(peerUdid, localUdid);
1999 EXPECT_NE(ret, -1);
2000 }
2001
2002 HWTEST_F(DeviceProfileConnectorTest, GetTokenIdByNameAndDeviceId_001, testing::ext::TestSize.Level1)
2003 {
2004 std::string pkgName = "bundleName";
2005 std::string requestDeviceId = "remoteDeviceId";
2006 uint64_t ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
2007 EXPECT_EQ(ret, 0);
2008
2009 requestDeviceId = "localDeviceId";
2010 ret = DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId);
2011 EXPECT_EQ(ret, 0);
2012 }
2013
2014 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_001, testing::ext::TestSize.Level1)
2015 {
2016 DistributedDeviceProfile::AccessControlProfile profiles;
2017 std::string requestDeviceId = "requestDeviceId";
2018 std::vector<int32_t> bindTypeVec;
2019 std::string trustUdid = "localUdid";
2020 profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
2021 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2022 EXPECT_TRUE(bindTypeVec.empty());
2023
2024 profiles.SetBindType(DM_POINT_TO_POINT);
2025 profiles.SetBindLevel(1);
2026 DistributedDeviceProfile::Accesser accesser;
2027 DistributedDeviceProfile::Accessee accessee;
2028 accesser.SetAccesserDeviceId(trustUdid);
2029 accessee.SetAccesseeDeviceId(requestDeviceId);
2030 profiles.SetAccesser(accesser);
2031 profiles.SetAccessee(accessee);
2032 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2033 EXPECT_TRUE(bindTypeVec.size() == 1);
2034
2035 bindTypeVec.clear();
2036 profiles.SetBindLevel(3);
2037 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2038 EXPECT_TRUE(bindTypeVec.size() == 1);
2039
2040 bindTypeVec.clear();
2041 profiles.SetBindType(DM_ACROSS_ACCOUNT);
2042 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2043 EXPECT_TRUE(bindTypeVec.size() == 1);
2044
2045 bindTypeVec.clear();
2046 profiles.SetBindLevel(1);
2047 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2048 EXPECT_TRUE(bindTypeVec.size() == 1);
2049
2050 bindTypeVec.clear();
2051 profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
2052 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2053 EXPECT_TRUE(bindTypeVec.size() == 1);
2054
2055 bindTypeVec.clear();
2056 profiles.SetBindType(DM_INVALIED_TYPE);
2057 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid);
2058 EXPECT_TRUE(bindTypeVec.empty());
2059 }
2060
2061 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_001, testing::ext::TestSize.Level1)
2062 {
2063 DistributedDeviceProfile::AccessControlProfile profiles;
2064 std::string localDeviceId = "localDeviceId";
2065 std::vector<int32_t> sinkBindType;
2066 std::vector<int32_t> bindTypeIndex;
2067 uint32_t index = 1;
2068 std::string targetDeviceId = "remoteDeviceId";
2069 profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
2070 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2071 targetDeviceId);
2072 EXPECT_FALSE(sinkBindType.empty());
2073
2074 profiles.SetBindType(DM_POINT_TO_POINT);
2075 profiles.SetBindLevel(1);
2076 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2077 targetDeviceId);
2078 EXPECT_FALSE(sinkBindType.empty());
2079
2080 profiles.SetBindLevel(3);
2081 DistributedDeviceProfile::Accesser accesser;
2082 DistributedDeviceProfile::Accessee accessee;
2083 accesser.SetAccesserDeviceId(targetDeviceId);
2084 accessee.SetAccesseeDeviceId(localDeviceId);
2085 profiles.SetAccesser(accesser);
2086 profiles.SetAccessee(accessee);
2087 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2088 targetDeviceId);
2089 EXPECT_FALSE(sinkBindType.empty());
2090
2091 accesser.SetAccesserDeviceId(localDeviceId);
2092 accessee.SetAccesseeDeviceId(targetDeviceId);
2093 profiles.SetAccesser(accesser);
2094 profiles.SetAccessee(accessee);
2095 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2096 targetDeviceId);
2097 EXPECT_FALSE(sinkBindType.empty());
2098 }
2099
2100 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_002, testing::ext::TestSize.Level1)
2101 {
2102 DistributedDeviceProfile::AccessControlProfile profiles;
2103 std::string localDeviceId = "localDeviceId";
2104 std::vector<int32_t> sinkBindType;
2105 std::vector<int32_t> bindTypeIndex;
2106 uint32_t index = 1;
2107 std::string targetDeviceId = "remoteDeviceId";
2108 profiles.SetBindType(DM_ACROSS_ACCOUNT);
2109 profiles.SetBindLevel(1);
2110 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2111 targetDeviceId);
2112 EXPECT_FALSE(sinkBindType.empty());
2113
2114 profiles.SetBindLevel(3);
2115 DistributedDeviceProfile::Accesser accesser;
2116 DistributedDeviceProfile::Accessee accessee;
2117 accesser.SetAccesserDeviceId(targetDeviceId);
2118 accessee.SetAccesseeDeviceId(localDeviceId);
2119 profiles.SetAccesser(accesser);
2120 profiles.SetAccessee(accessee);
2121 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2122 targetDeviceId);
2123 EXPECT_FALSE(sinkBindType.empty());
2124
2125 accesser.SetAccesserDeviceId(localDeviceId);
2126 accessee.SetAccesseeDeviceId(targetDeviceId);
2127 profiles.SetAccesser(accesser);
2128 profiles.SetAccessee(accessee);
2129 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, sinkBindType, bindTypeIndex, index,
2130 targetDeviceId);
2131 EXPECT_FALSE(sinkBindType.empty());
2132 }
2133
2134 HWTEST_F(DeviceProfileConnectorTest, DeleteAclForRemoteUserRemoved_001, testing::ext::TestSize.Level1)
2135 {
2136 std::string peerUdid = "deviceId";
2137 int32_t peerUserId = 123456;
2138 std::vector<int32_t> userIds;
2139 DmOfflineParam offlineParam;
2140 DeviceProfileConnector::GetInstance().DeleteAclForRemoteUserRemoved(peerUdid, peerUserId, userIds, offlineParam);
2141 EXPECT_TRUE(userIds.empty());
2142
2143 peerUdid = "remoteDeviceId";
2144 peerUserId = 1234;
2145 DeviceProfileConnector::GetInstance().DeleteAclForRemoteUserRemoved(peerUdid, peerUserId, userIds, offlineParam);
2146 EXPECT_TRUE(userIds.empty());
2147 }
2148
2149 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_001, testing::ext::TestSize.Level1)
2150 {
2151 std::string pkgName;
2152 std::string localDeviceId = "remoteDeviceId";
2153 std::string remoteDeviceId;
2154 int32_t bindLevel = 3;
2155 std::string extra;
2156 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2157 DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2158 remoteDeviceId, bindLevel, extra);
2159 EXPECT_EQ(offlineParam.leftAclNumber, 0);
2160
2161 extra = "extra";
2162 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2163 offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2164 remoteDeviceId, bindLevel, extra);
2165 EXPECT_EQ(offlineParam.leftAclNumber, 0);
2166
2167 bindLevel = 2;
2168 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2169 offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2170 remoteDeviceId, bindLevel, extra);
2171 EXPECT_EQ(offlineParam.leftAclNumber, 0);
2172
2173 bindLevel = 1;
2174 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2175 offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2176 remoteDeviceId, bindLevel, extra);
2177 EXPECT_EQ(offlineParam.leftAclNumber, 0);
2178
2179 bindLevel = 5;
2180 offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2181 remoteDeviceId, bindLevel, extra);
2182 EXPECT_EQ(offlineParam.bindType, INVALIED_TYPE);
2183
2184 bindLevel = 2;
2185 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(-1));
2186 offlineParam = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId,
2187 remoteDeviceId, bindLevel, extra);
2188 EXPECT_EQ(offlineParam.bindType, INVALIED_TYPE);
2189 }
2190
2191 HWTEST_F(DeviceProfileConnectorTest, GetBindLevel_002, testing::ext::TestSize.Level1)
2192 {
2193 std::string pkgName = "bundleName";
2194 std::string localUdid = "remoteDeviceId";
2195 std::string udid = "localDeviceId";
2196 uint64_t tokenId = 0;
2197 int32_t bindLevel = INVALIED_TYPE;
2198
2199 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(456));
2200 bindLevel = DeviceProfileConnector::GetInstance().GetBindLevel(pkgName, localUdid, udid, tokenId);
2201 EXPECT_EQ(bindLevel, APP);
2202
2203 localUdid = "deviceId";
2204 udid = "deviceId";
2205 EXPECT_CALL(*multipleUserConnectorMock_, GetFirstForegroundUserId()).WillOnce(Return(123456));
2206 bindLevel = DeviceProfileConnector::GetInstance().GetBindLevel(pkgName, localUdid, udid, tokenId);
2207 EXPECT_EQ(bindLevel, USER);
2208
2209 int32_t bindType = 256;
2210 std::string peerUdid = "123456";
2211 localUdid = "localDeviceId";
2212 int32_t localUserId = 1234;
2213 std::string localAccountId = "";
2214 DeviceProfileConnector::GetInstance().HandleDeviceUnBind(bindType, peerUdid, localUdid, localUserId,
2215 localAccountId);
2216 }
2217
2218 HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_002, testing::ext::TestSize.Level1)
2219 {
2220 DistributedDeviceProfile::AccessControlProfile profile;
2221 DmAccessCaller caller;
2222 DmAccessCallee callee;
2223 profile.SetBindType(DM_POINT_TO_POINT);
2224 profile.SetBindLevel(APP);
2225 caller.pkgName = "bundleName";
2226 DistributedDeviceProfile::Accessee accessee;
2227 accessee.SetAccesseeBundleName("bundleName");
2228 profile.SetAccessee(accessee);
2229 int32_t ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
2230 EXPECT_EQ(ret, true);
2231
2232
2233 profile.SetBindType(DM_ACROSS_ACCOUNT);
2234 profile.SetBindLevel(APP);
2235 accessee.SetAccesseeBundleName("bundleName");
2236 profile.SetAccessee(accessee);
2237 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
2238 EXPECT_EQ(ret, true);
2239 }
2240
2241 HWTEST_F(DeviceProfileConnectorTest, CheckDeviceInfoPermission_001, testing::ext::TestSize.Level1)
2242 {
2243 std::string localUdid = "localUdid";
2244 std::string peerDeviceId = "localDeviceId";
2245 int32_t ret = DeviceProfileConnector::GetInstance().CheckDeviceInfoPermission(localUdid, peerDeviceId);
2246 EXPECT_EQ(ret, DM_OK);
2247
2248 localUdid = "localDeviceId";
2249 peerDeviceId = "remoteDeviceId";
2250 EXPECT_CALL(*multipleUserConnectorMock_, GetTokenIdAndForegroundUserId(_, _))
2251 .WillOnce(DoAll(SetArgReferee<0>(1001), SetArgReferee<1>(456), Return()));
2252 EXPECT_CALL(*multipleUserConnectorMock_, GetOhosAccountIdByUserId(_)).WillOnce(Return(""));
2253 ret = DeviceProfileConnector::GetInstance().CheckDeviceInfoPermission(localUdid, peerDeviceId);
2254 EXPECT_EQ(ret, DM_OK);
2255
2256 localUdid = "remoteDeviceId";
2257 peerDeviceId = "localDeviceId";
2258 EXPECT_CALL(*multipleUserConnectorMock_, GetTokenIdAndForegroundUserId(_, _))
2259 .WillOnce(DoAll(SetArgReferee<0>(1001), SetArgReferee<1>(456), Return()));
2260 EXPECT_CALL(*multipleUserConnectorMock_, GetOhosAccountIdByUserId(_)).WillOnce(Return("newAccountId"));
2261 ret = DeviceProfileConnector::GetInstance().CheckDeviceInfoPermission(localUdid, peerDeviceId);
2262 EXPECT_EQ(ret, DM_OK);
2263 }
2264
2265 HWTEST_F(DeviceProfileConnectorTest, UpdateAclDeviceName_001, testing::ext::TestSize.Level1)
2266 {
2267 std::string udid = "localDeviceId";
2268 std::string newDeviceName = "deviceName";
2269 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAclDeviceName(udid, newDeviceName);
2270 EXPECT_EQ(ret, DM_OK);
2271
2272 udid = "remoteDeviceId";
2273 newDeviceName = "deviceNameInfo";
2274 ret = DeviceProfileConnector::GetInstance().UpdateAclDeviceName(udid, newDeviceName);
2275 EXPECT_EQ(ret, DM_OK);
2276
2277 udid = "UDID";
2278 ret = DeviceProfileConnector::GetInstance().UpdateAclDeviceName(udid, newDeviceName);
2279 EXPECT_EQ(ret, ERR_DM_FAILED);
2280 }
2281
2282 HWTEST_F(DeviceProfileConnectorTest, CheckAppLevelAccess_001, testing::ext::TestSize.Level1)
2283 {
2284 DistributedDeviceProfile::AccessControlProfile profile;
2285 int32_t acerTokenId = 1001;
2286 int32_t aceeTokenId = 1002;
2287 DmAccessCaller caller;
2288 DmAccessCallee callee;
2289 DistributedDeviceProfile::Accesser accesser;
2290 DistributedDeviceProfile::Accessee accessee;
2291 accesser.SetAccesserTokenId(acerTokenId);
2292 accessee.SetAccesseeTokenId(aceeTokenId);
2293 profile.SetAccesser(accesser);
2294 profile.SetAccessee(accessee);
2295 caller.tokenId = acerTokenId;
2296 callee.tokenId = aceeTokenId;
2297 bool ret = DeviceProfileConnector::GetInstance().CheckAppLevelAccess(profile, caller, callee);
2298 EXPECT_TRUE(ret);
2299
2300 caller.tokenId = aceeTokenId;
2301 callee.tokenId = acerTokenId;
2302 ret = DeviceProfileConnector::GetInstance().CheckAppLevelAccess(profile, caller, callee);
2303 EXPECT_TRUE(ret);
2304
2305 caller.tokenId = 1;
2306 callee.tokenId = 1;
2307 ret = DeviceProfileConnector::GetInstance().CheckAppLevelAccess(profile, caller, callee);
2308 EXPECT_FALSE(ret);
2309 }
2310 } // namespace DistributedHardware
2311 } // namespace OHOS
2312