• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <gtest/gtest.h>
17 #include <securec.h>
18 
19 #include "auth_device_profile_mock.h"
20 #include "auth_deviceprofile.cpp"
21 #include "lnn_app_bind_interface.h"
22 #include "softbus_error_code.h"
23 #include "trust_device_profile.h"
24 
25 namespace OHOS {
26 using namespace testing;
27 using namespace testing::ext;
28 const int64_t TEST_ACCOUNT_ID = 123456789;
29 const int32_t TEST_SESSION_KEY_ID = 1;
30 const int32_t TEST_LOCAL_USER_ID = 100;
31 const char TEST_UDID[] = "1234567890";
32 const char TEST_UDID_HASH[] = "abcd";
33 const int32_t TEST_SOURCE_USER_ID = 1;
34 const int32_t TEST_SINK_USER_ID = 2;
35 const int64_t TEST_SOURCE_TOKEN_ID = 3;
36 const int64_t TEST_SINK_TOKEN_ID = 4;
37 const int32_t TEST_USER_ID_ONE = 1;
38 const int32_t TEST_USER_ID_TWO = 2;
39 const int32_t TEST_USER_ID_THREE = 3;
40 const uint32_t TEST_ERROR_USER_ID = -1;
41 const uint32_t CRED_ID_STR_LEN = 300;
42 
43 typedef struct {
44     bool isLocal;
45     int32_t userId;
46     char udid[UDID_BUF_LEN];
47     char credId[CRED_ID_STR_LEN];
48     char shareCredId[CRED_ID_STR_LEN];
49     char accountUid[ACCOUNT_UID_STR_LEN];
50 } SoftBusAclInfo;
51 
52 class AuthDeviceProfileTest : public testing::Test {
53 public:
54     static void SetUpTestCase();
55     static void TearDownTestCase();
56     void SetUp();
57     void TearDown();
58     int32_t SetAclInfo(AuthACLInfo *aclInfo);
59     int32_t SetSoftBusAclInfo(SoftBusAclInfo *info, int32_t userId);
60 };
61 
SetUpTestCase()62 void AuthDeviceProfileTest::SetUpTestCase() { }
63 
TearDownTestCase()64 void AuthDeviceProfileTest::TearDownTestCase() { }
65 
SetUp()66 void AuthDeviceProfileTest::SetUp() { }
67 
TearDown()68 void AuthDeviceProfileTest::TearDown() { }
69 
SetAclInfo(AuthACLInfo * aclInfo)70 int32_t AuthDeviceProfileTest::SetAclInfo(AuthACLInfo *aclInfo)
71 {
72     if (aclInfo == nullptr) {
73         AUTH_LOGE(AUTH_TEST, "aclInfo is null.");
74         return SOFTBUS_INVALID_PARAM;
75     }
76 
77     aclInfo->isServer = true;
78     aclInfo->sourceUserId = TEST_SOURCE_USER_ID;
79     aclInfo->sinkUserId = TEST_SINK_USER_ID;
80     aclInfo->sourceTokenId = TEST_SOURCE_TOKEN_ID;
81     aclInfo->sinkTokenId = TEST_SINK_TOKEN_ID;
82     if (strcpy_s(aclInfo->sourceUdid, UDID_BUF_LEN, "ab") != EOK) {
83         AUTH_LOGE(AUTH_TEST, "set sourceUdid fail.");
84         return SOFTBUS_STRCPY_ERR;
85     }
86     if (strcpy_s(aclInfo->sinkUdid, UDID_BUF_LEN, "cd") != EOK) {
87         AUTH_LOGE(AUTH_TEST, "set sinkUdid fail.");
88         return SOFTBUS_STRCPY_ERR;
89     }
90     if (strcpy_s(aclInfo->sourceAccountId, ACCOUNT_ID_BUF_LEN, "ef") != EOK) {
91         AUTH_LOGE(AUTH_TEST, "set sourceAccountId fail.");
92         return SOFTBUS_STRCPY_ERR;
93     }
94     if (strcpy_s(aclInfo->sinkAccountId, ACCOUNT_ID_BUF_LEN, "gh") != EOK) {
95         AUTH_LOGE(AUTH_TEST, "set sinkAccountId fail.");
96         return SOFTBUS_STRCPY_ERR;
97     }
98     return SOFTBUS_OK;
99 }
100 
SetSoftBusAclInfo(SoftBusAclInfo * info,int32_t userId)101 int32_t AuthDeviceProfileTest::SetSoftBusAclInfo(SoftBusAclInfo *info, int32_t userId)
102 {
103     if (info == nullptr) {
104         AUTH_LOGE(AUTH_TEST, "info is null.");
105         return SOFTBUS_INVALID_PARAM;
106     }
107 
108     bool isLocal = true;
109     std::string udid = "ab";
110     std::string credId = "cd";
111     std::string shareCredId = "ef";
112     std::string accountUid = "gh";
113     switch (userId) {
114         case TEST_USER_ID_TWO:
115             isLocal = false;
116             udid = "12";
117             credId = "34";
118             shareCredId = "56";
119             accountUid = "78";
120             break;
121         case TEST_USER_ID_THREE:
122             udid = "ij";
123             credId = "kl";
124             shareCredId = "mn";
125             accountUid = "op";
126             break;
127         default:
128             break;
129     }
130     info->userId = userId;
131     info->isLocal = isLocal;
132     if (strcpy_s(info->udid, UDID_BUF_LEN, udid.c_str()) != EOK) {
133         AUTH_LOGE(AUTH_TEST, "set udid fail.");
134         return SOFTBUS_STRCPY_ERR;
135     }
136     if (strcpy_s(info->credId, CRED_ID_STR_LEN, credId.c_str()) != EOK) {
137         AUTH_LOGE(AUTH_TEST, "set credId fail.");
138         return SOFTBUS_STRCPY_ERR;
139     }
140     if (strcpy_s(info->shareCredId, CRED_ID_STR_LEN, shareCredId.c_str()) != EOK) {
141         AUTH_LOGE(AUTH_TEST, "set shareCredId fail.");
142         return SOFTBUS_STRCPY_ERR;
143     }
144     if (strcpy_s(info->accountUid, ACCOUNT_UID_STR_LEN, accountUid.c_str()) != EOK) {
145         AUTH_LOGE(AUTH_TEST, "set accountUid fail.");
146         return SOFTBUS_STRCPY_ERR;
147     }
148     return SOFTBUS_OK;
149 }
150 
151 /*
152  * @tc.name: IS_POTENTIAL_TRUSTED_DEVCIE_TEST_003
153  * @tc.desc:
154  * @tc.type: FUNC
155  * @tc.require:
156  */
157 HWTEST_F(AuthDeviceProfileTest, IS_POTENTIAL_DEVCIE_TEST_003, TestSize.Level1)
158 {
159     const char *deviceIdHash = nullptr;
160     bool ret = IsPotentialTrustedDeviceDp(deviceIdHash, true);
161     EXPECT_FALSE(ret);
162     deviceIdHash = "dev/ice%Id()Hash()";
163     int64_t localAccountId = TEST_ACCOUNT_ID;
164     int64_t peerAccountId = TEST_ACCOUNT_ID;
165     ret = IsPotentialTrustedDeviceDp(deviceIdHash, true);
166     EXPECT_FALSE(ret);
167     DumpAccountId(localAccountId, peerAccountId);
168 }
169 
170 /*
171  * @tc.name: IS_POTENTIAL_TRUSTED_DEVCIE_TEST_004
172  * @tc.desc:add ut for DelNotTrustDevice and UpdateDpSameAccount
173  * @tc.type: FUNC
174  * @tc.require:
175  */
176 HWTEST_F(AuthDeviceProfileTest, IS_POTENTIAL_DEVCIE_TEST_004, TestSize.Level1)
177 {
178     const char *deviceIdHash = nullptr;
179     deviceIdHash = "dev/ice%Id()Hash()";
180     int32_t peerUserId = -1;
181     int64_t accountId = 100;
182     SessionKey sessionKey;
183     (void)memset_s(&sessionKey, sizeof(SessionKey), 0, sizeof(SessionKey));
184     DelNotTrustDevice(nullptr);
185     UpdateDpAclParams aclParams = {
186         .accountId = accountId,
187         .deviceId = nullptr,
188         .peerUserId = peerUserId
189     };
190     UpdateDpSameAccount(&aclParams, sessionKey, true, ACL_WRITE_DEFAULT);
191     bool ret = IsPotentialTrustedDeviceDp(deviceIdHash, true);
192     EXPECT_EQ(ret, false);
193 }
194 
195 /*
196  * @tc.name: IS_NOT_TRUSTED_DEVCIE_TEST_001
197  * @tc.desc: Insert not truste device
198  * @tc.type: FUNC
199  * @tc.require:
200  */
201 HWTEST_F(AuthDeviceProfileTest, IS_NOT_TRUSTED_DEVCIE_TEST_001, TestSize.Level1)
202 {
203     const char udid[] = "testUdid";
204     char hashStr[CUST_UDID_LEN + 1] = { 0 };
205     int32_t ret = strcpy_s(hashStr, CUST_UDID_LEN, TEST_UDID_HASH);
206     EXPECT_EQ(ret, EOK);
207     InsertNotTrustDevice(hashStr);
208     bool result = IsNotTrustDevice(hashStr);
209     EXPECT_TRUE(result);
210     AuthDeviceProfileInterfaceMock mock;
211     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
212     EXPECT_CALL(mock, ConvertBytesToHexString).WillOnce(Return(SOFTBUS_INVALID_PARAM));
213     DelNotTrustDevice(udid);
214     EXPECT_CALL(mock, ConvertBytesToHexString).WillOnce(Return(SOFTBUS_OK));
215     DelNotTrustDevice(udid);
216 }
217 
218 /*
219  * @tc.name: IS_NOT_TRUSTED_DEVCIE_TEST_002
220  * @tc.desc: Do not insert not trust device
221  * @tc.type: FUNC
222  * @tc.require:
223  */
224 HWTEST_F(AuthDeviceProfileTest, IS_NOT_TRUSTED_DEVCIE_TEST_002, TestSize.Level1)
225 {
226     std::string deviceIdHash = "testDeviceHash";
227     std::string peerUdid = "peerUdid";
228     int32_t peerUserId = 1;
229     int32_t sessionKeyId = 1;
230     AuthDeviceProfileInterfaceMock mock;
231     EXPECT_CALL(mock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_INVALID_PARAM));
232     EXPECT_CALL(mock, SoftBusGetSysTimeMs).WillRepeatedly(Return(0));
233     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_USER_ID_ONE));
234     InsertDpSameAccountAcl(peerUdid, peerUserId, sessionKeyId);
235     EXPECT_CALL(mock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
236     InsertDpSameAccountAcl(peerUdid, peerUserId, sessionKeyId);
237     bool result = IsNotTrustDevice(deviceIdHash);
238     EXPECT_FALSE(result);
239 }
240 
241 /*
242  * @tc.name: GET_ACL_LOCAL_USERID_TEST_001
243  * @tc.desc: 1.get accessee userId.2.get accesser userId
244  * @tc.type: FUNC
245  * @tc.require:
246  */
247 HWTEST_F(AuthDeviceProfileTest, GET_ACL_LOCAL_USERID_TEST_001, TestSize.Level1)
248 {
249     OHOS::DistributedDeviceProfile::AccessControlProfile trustDevice;
250     int32_t ret = GetAclLocalUserId(trustDevice);
251     EXPECT_EQ(ret, -1);
252 
253     std::string deviceId = "abcdef";
254     int32_t userId = 6;
255     DistributedDeviceProfile::Accessee accessee;
256     accessee.SetAccesseeDeviceId(deviceId);
257     trustDevice.SetAccessee(accessee);
258     DistributedDeviceProfile::Accesser accesser;
259     accesser.SetAccesserUserId(userId);
260     trustDevice.SetAccesser(accesser);
261     trustDevice.SetTrustDeviceId(deviceId);
262     ret = GetAclLocalUserId(trustDevice);
263     EXPECT_EQ(ret, userId);
264 }
265 
266 /*
267  * @tc.name: GET_ACL_PEER_USERID_TEST_001
268  * @tc.desc: 1.get accessee userId.2.get accesser userId
269  * @tc.type: FUNC
270  * @tc.require:
271  */
272 HWTEST_F(AuthDeviceProfileTest, GET_ACL_PEER_USERID_TEST_001, TestSize.Level1)
273 {
274     OHOS::DistributedDeviceProfile::AccessControlProfile trustDevice;
275     std::string deviceId = "1234567";
276     trustDevice.SetTrustDeviceId(deviceId);
277     int32_t ret = GetAclPeerUserId(trustDevice);
278     EXPECT_EQ(ret, -1);
279 
280     deviceId = "abcdef";
281     int32_t userId = 6;
282     DistributedDeviceProfile::Accessee accessee;
283     accessee.SetAccesseeDeviceId(deviceId);
284     accessee.SetAccesseeUserId(userId);
285     trustDevice.SetAccessee(accessee);
286     trustDevice.SetTrustDeviceId(deviceId);
287     ret = GetAclPeerUserId(trustDevice);
288     EXPECT_EQ(ret, userId);
289 }
290 
291 /*
292  * @tc.name: GET_STRING_HASH_001
293  * @tc.desc: test generate hash fail and success.
294  * @tc.type: FUNC
295  * @tc.require:
296  */
297 HWTEST_F(AuthDeviceProfileTest, GET_STRING_HASH_001, TestSize.Level1)
298 {
299     std::string str = "";
300     char hashStrBuf[SHA_256_HEX_HASH_LEN] = { 0 };
301     int32_t len = 32;
302     AuthDeviceProfileInterfaceMock mock;
303     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillOnce(Return(SOFTBUS_ENCRYPT_ERR));
304     int32_t ret = GetStringHash(str, hashStrBuf, len);
305     EXPECT_EQ(ret, SOFTBUS_NETWORK_GENERATE_STR_HASH_ERR);
306     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
307     EXPECT_CALL(mock, ConvertBytesToHexString).WillOnce(Return(SOFTBUS_NETWORK_BYTES_TO_HEX_STR_ERR));
308     ret = GetStringHash(str, hashStrBuf, len);
309     EXPECT_EQ(ret, SOFTBUS_NETWORK_BYTES_TO_HEX_STR_ERR);
310     EXPECT_CALL(mock, ConvertBytesToHexString).WillOnce(Return(SOFTBUS_OK));
311     str = "abcdef123456";
312     ret = GetStringHash(str, hashStrBuf, len);
313     EXPECT_EQ(ret, SOFTBUS_OK);
314 }
315 
316 /*
317  * @tc.name: DP_HAS_ACCESS_CONTROL_PROFILE_TEST_001
318  * @tc.desc: udid is nullptr
319  * @tc.type: FUNC
320  * @tc.require:
321  */
322 HWTEST_F(AuthDeviceProfileTest, DP_HAS_ACCESS_CONTROL_PROFILE_TEST_001, TestSize.Level1)
323 {
324     bool result = DpHasAccessControlProfile(nullptr, false, 0);
325     EXPECT_FALSE(result);
326 }
327 
328 /*
329  * @tc.name: DP_HAS_ACCESS_CONTROL_PROFILE_TEST_002
330  * @tc.desc: aclProfiles is empty
331  * @tc.type: FUNC
332  * @tc.require:
333  */
334 HWTEST_F(AuthDeviceProfileTest, DP_HAS_ACCESS_CONTROL_PROFILE_TEST_002, TestSize.Level1)
335 {
336     const char udid[] = "testUdid";
337     bool result = DpHasAccessControlProfile(udid, false, 0);
338     EXPECT_FALSE(result);
339     result = DpHasAccessControlProfile(udid, true, 0);
340     EXPECT_FALSE(result);
341 }
342 
343 /*
344  * @tc.name: IS_SAME_ACCOUNT_TEST_001
345  * @tc.desc: LnnGetLocalNum64Info fail
346  * @tc.type: FUNC
347  * @tc.require:
348  */
349 HWTEST_F(AuthDeviceProfileTest, IS_SAME_ACCOUNT_TEST_001, TestSize.Level1)
350 {
351     AuthDeviceProfileInterfaceMock mock;
352     EXPECT_CALL(mock, LnnGetLocalNum64Info).WillOnce(Return(SOFTBUS_NETWORK_NOT_FOUND));
353     bool result = IsSameAccount(TEST_ACCOUNT_ID);
354     EXPECT_FALSE(result);
355 }
356 
357 /*
358  * @tc.name: IS_SAME_ACCOUNT_TEST_002
359  * @tc.desc: accountId does not equal localAccountId
360  * @tc.type: FUNC
361  * @tc.require:
362  */
363 HWTEST_F(AuthDeviceProfileTest, IS_SAME_ACCOUNT_TEST_002, TestSize.Level1)
364 {
365     int64_t accountId = TEST_ACCOUNT_ID;
366     AuthDeviceProfileInterfaceMock mock;
367     EXPECT_CALL(mock, LnnGetLocalNum64Info).WillRepeatedly(Return(SOFTBUS_OK));
368     EXPECT_CALL(mock, LnnGetLocalNum64Info).WillOnce(DoAll(SetArgPointee<1>(TEST_ACCOUNT_ID + 1), Return(SOFTBUS_OK)));
369     bool result = IsSameAccount(accountId);
370     EXPECT_FALSE(result);
371     OHOS::DistributedDeviceProfile::AccessControlProfile trustDevices;
372     std::string peerUdid = TEST_UDID;
373     int32_t localUserId = TEST_LOCAL_USER_ID;
374     int32_t peerUserId = TEST_SOURCE_USER_ID;
375     DumpDpAclInfo(peerUdid, localUserId, peerUserId, trustDevices);
376     EXPECT_CALL(mock, LnnGetLocalNum64Info).WillOnce(DoAll(SetArgPointee<1>(TEST_ACCOUNT_ID), Return(SOFTBUS_OK)));
377     EXPECT_CALL(mock, LnnIsDefaultOhosAccount).WillOnce(Return(false));
378     result = IsSameAccount(accountId);
379     EXPECT_TRUE(result);
380 }
381 
382 /*
383  * @tc.name: IS_SAME_ACCOUNT_TEST_003
384  * @tc.desc: accountId is default ohos account
385  * @tc.type: FUNC
386  * @tc.require:
387  */
388 HWTEST_F(AuthDeviceProfileTest, IS_SAME_ACCOUNT_TEST_003, TestSize.Level1)
389 {
390     int64_t accountId = TEST_ACCOUNT_ID;
391     AuthDeviceProfileInterfaceMock mock;
392     EXPECT_CALL(mock, LnnGetLocalNum64Info).WillRepeatedly(DoAll(SetArgPointee<1>(TEST_ACCOUNT_ID),
393         Return(SOFTBUS_OK)));
394     EXPECT_CALL(mock, LnnIsDefaultOhosAccount).WillOnce(Return(false));
395     bool result = IsSameAccount(accountId);
396     EXPECT_TRUE(result);
397 }
398 
399 /*
400  * @tc.name: GET_SESSION_KEY_PROFILE_TEST_001
401  * @tc.desc: sessionKey is nullptr
402  * @tc.type: FUNC
403  * @tc.require:
404  */
405 HWTEST_F(AuthDeviceProfileTest, GET_SESSION_KEY_PROFILE_TEST_001, TestSize.Level1)
406 {
407     uint32_t length = 0;
408     bool result = GetSessionKeyProfile(TEST_SESSION_KEY_ID, nullptr, &length);
409     EXPECT_FALSE(result);
410 }
411 
412 /*
413  * @tc.name: GET_SESSION_KEY_PROFILE_TEST_002
414  * @tc.desc: length is nullptr
415  * @tc.type: FUNC
416  * @tc.require:
417  */
418 HWTEST_F(AuthDeviceProfileTest, GET_SESSION_KEY_PROFILE_TEST_002, TestSize.Level1)
419 {
420     uint8_t sessionKey = 0;
421     bool result = GetSessionKeyProfile(TEST_SESSION_KEY_ID, &sessionKey, nullptr);
422     EXPECT_FALSE(result);
423 }
424 
425 /*
426  * @tc.name: GET_SESSION_KEY_PROFILE_TEST_003
427  * @tc.desc: GetActiveOsAccountIds fail
428  * @tc.type: FUNC
429  * @tc.require:
430  */
431 HWTEST_F(AuthDeviceProfileTest, GET_SESSION_KEY_PROFILE_TEST_003, TestSize.Level1)
432 {
433     uint8_t sessionKey = 0;
434     uint32_t length = 0;
435     AuthDeviceProfileInterfaceMock mock;
436     EXPECT_CALL(mock, GetActiveOsAccountIds).WillOnce(Return(TEST_ERROR_USER_ID));
437     bool result = GetSessionKeyProfile(TEST_SESSION_KEY_ID, &sessionKey, &length);
438     EXPECT_FALSE(result);
439     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_USER_ID_ONE));
440     result = GetSessionKeyProfile(TEST_SESSION_KEY_ID, &sessionKey, &length);
441     EXPECT_FALSE(result);
442 }
443 
444 /*
445  * @tc.name: UPDATE_DP_SAME_ACCOUNT_ACL_TEST_001
446  * @tc.desc: sessionKey is nullptr
447  * @tc.type: FUNC
448  * @tc.require:
449  */
450 HWTEST_F(AuthDeviceProfileTest, UPDATE_DP_SAME_ACCOUNT_ACL_TEST_001, TestSize.Level1)
451 {
452     std::string peerUdid = TEST_UDID;
453     int32_t peerUserId = TEST_LOCAL_USER_ID;
454     int32_t sessionKeyId = TEST_SESSION_KEY_ID;
455     int32_t ret = UpdateDpSameAccountAcl(peerUdid, 0, sessionKeyId);
456     EXPECT_EQ(ret, GET_ALL_ACL_FAIL);
457     ret = UpdateDpSameAccountAcl(peerUdid, peerUserId, sessionKeyId);
458     EXPECT_EQ(ret, GET_ALL_ACL_FAIL);
459 }
460 
461 /*
462  * @tc.name: IS_TRUST_DEVICE_TEST_001
463  * @tc.desc: device is not trusted
464  * @tc.type: FUNC
465  * @tc.require:
466  */
467 HWTEST_F(AuthDeviceProfileTest, IS_TRUST_DEVICE_TEST_001, TestSize.Level1)
468 {
469     std::vector<OHOS::DistributedDeviceProfile::AccessControlProfile> trustDevices;
470     const char *deviceIdHash = "deviceIdHash";
471     const char *anonyDeviceIdHash = "anonyDeviceIdHash";
472     bool isOnlyPointToPoint = true;
473     AuthDeviceProfileInterfaceMock mock;
474     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_USER_ID_ONE));
475     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
476     EXPECT_CALL(mock, ConvertBytesToHexString).WillRepeatedly(Return(SOFTBUS_OK));
477     bool result = IsTrustDevice(trustDevices, deviceIdHash, anonyDeviceIdHash, isOnlyPointToPoint);
478     EXPECT_FALSE(result);
479 
480     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile0;
481     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
482     aclProfile0.SetBindType(bindType);
483     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile1;
484     bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
485     aclProfile1.SetBindType(bindType);
486     uint32_t deviceIdType = (uint32_t)OHOS::DistributedDeviceProfile::DeviceIdType::UUID;
487     aclProfile1.SetDeviceIdType(deviceIdType);
488     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile2;
489     aclProfile2.SetBindType(bindType);
490     deviceIdType = (uint32_t)OHOS::DistributedDeviceProfile::DeviceIdType::UDID;
491     aclProfile2.SetDeviceIdType(deviceIdType);
492     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile3;
493     aclProfile3.SetBindType(bindType);
494     aclProfile3.SetDeviceIdType(deviceIdType);
495     std::string deviceId = "1234567";
496     aclProfile3.SetTrustDeviceId(deviceId);
497     int status = (uint32_t)OHOS::DistributedDeviceProfile::Status::INACTIVE;
498     aclProfile3.SetStatus(status);
499     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile4;
500     aclProfile4.SetBindType(bindType);
501     aclProfile4.SetDeviceIdType(deviceIdType);
502     aclProfile4.SetTrustDeviceId(deviceId);
503     status = (uint32_t)OHOS::DistributedDeviceProfile::Status::ACTIVE;
504     aclProfile4.SetStatus(status);
505     trustDevices.push_back(aclProfile0);
506     trustDevices.push_back(aclProfile1);
507     trustDevices.push_back(aclProfile2);
508     trustDevices.push_back(aclProfile3);
509     trustDevices.push_back(aclProfile4);
510     result = IsTrustDevice(trustDevices, deviceIdHash, anonyDeviceIdHash, isOnlyPointToPoint);
511     EXPECT_FALSE(result);
512 }
513 
514 /*
515  * @tc.name: IS_TRUST_DEVICE_TEST_002
516  * @tc.desc: device is not trusted
517  * @tc.type: FUNC
518  * @tc.require:
519  */
520 HWTEST_F(AuthDeviceProfileTest, IS_TRUST_DEVICE_TEST_002, TestSize.Level1)
521 {
522     std::vector<OHOS::DistributedDeviceProfile::AccessControlProfile> trustDevices;
523     const char *deviceIdHash = "deviceIdHash";
524     const char *anonyDeviceIdHash = "anonyDeviceIdHash";
525     bool isOnlyPointToPoint = false;
526     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
527     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
528     aclProfile.SetBindType(bindType);
529     uint32_t deviceIdType = (uint32_t)OHOS::DistributedDeviceProfile::DeviceIdType::UDID;
530     aclProfile.SetDeviceIdType(deviceIdType);
531     std::string deviceId = "1234567";
532     aclProfile.SetTrustDeviceId(deviceId);
533     int32_t status = (uint32_t)OHOS::DistributedDeviceProfile::Status::ACTIVE;
534     aclProfile.SetStatus(status);
535     int32_t userId = 100;
536     DistributedDeviceProfile::Accessee accessee;
537     accessee.SetAccesseeDeviceId(deviceId);
538     aclProfile.SetAccessee(accessee);
539     DistributedDeviceProfile::Accesser accesser;
540     accesser.SetAccesserUserId(userId);
541     aclProfile.SetAccesser(accesser);
542     trustDevices.push_back(aclProfile);
543     AuthDeviceProfileInterfaceMock mock;
544     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_USER_ID_ONE));
545     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
546     EXPECT_CALL(mock, ConvertBytesToHexString).WillRepeatedly(Return(SOFTBUS_OK));
547     bool result = IsTrustDevice(trustDevices, deviceIdHash, anonyDeviceIdHash, isOnlyPointToPoint);
548     EXPECT_FALSE(result);
549 }
550 
551 /*
552  * @tc.name: IS_TRUST_DEVICE_TEST_003
553  * @tc.desc: device is trusted
554  * @tc.type: FUNC
555  * @tc.require:
556  */
557 HWTEST_F(AuthDeviceProfileTest, IS_TRUST_DEVICE_TEST_003, TestSize.Level1)
558 {
559     std::vector<OHOS::DistributedDeviceProfile::AccessControlProfile> trustDevices;
560     const char *deviceIdHash = "8bb0cf6eb9b17d0f";
561     const char *anonyDeviceIdHash = "anonyDeviceIdHash";
562     bool isOnlyPointToPoint = false;
563     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
564     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
565     aclProfile.SetBindType(bindType);
566     uint32_t deviceIdType = (uint32_t)OHOS::DistributedDeviceProfile::DeviceIdType::UDID;
567     aclProfile.SetDeviceIdType(deviceIdType);
568     std::string deviceId = "1234567";
569     aclProfile.SetTrustDeviceId(deviceId);
570     int32_t status = (uint32_t)OHOS::DistributedDeviceProfile::Status::ACTIVE;
571     aclProfile.SetStatus(status);
572     int32_t userId = 100;
573     DistributedDeviceProfile::Accessee accessee;
574     accessee.SetAccesseeDeviceId(deviceId);
575     aclProfile.SetAccessee(accessee);
576     DistributedDeviceProfile::Accesser accesser;
577     accesser.SetAccesserUserId(userId);
578     aclProfile.SetAccesser(accesser);
579     trustDevices.push_back(aclProfile);
580     AuthDeviceProfileInterfaceMock mock;
581     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_USER_ID_ONE));
582     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
583     EXPECT_CALL(mock, ConvertBytesToHexString).WillRepeatedly(Return(SOFTBUS_OK));
584     bool result = IsTrustDevice(trustDevices, deviceIdHash, anonyDeviceIdHash, isOnlyPointToPoint);
585     EXPECT_FALSE(result);
586 }
587 
588 /*
589  * @tc.name: COMPARE_ACL_WITH_PEER_DEVICE_INFO_TEST_001
590  * @tc.desc: LnnGetLocalStrInfo fail.
591  * @tc.type: FUNC
592  * @tc.require:
593  */
594 HWTEST_F(AuthDeviceProfileTest, COMPARE_ACL_WITH_PEER_DEVICE_INFO_TEST_001, TestSize.Level1)
595 {
596     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
597     const char *peerAccountHash = "8bb0cf6eb9b17d0f";
598     const char *peerUdid = "1234567890";
599     int32_t peerUserId = 1;
600     AuthDeviceProfileInterfaceMock mock;
601     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_LOCAL_USER_ID));
602     EXPECT_CALL(mock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_NETWORK_NOT_FOUND));
603     bool result = CompareAclWithPeerDeviceInfo(aclProfile, peerAccountHash, peerUdid, peerUserId);
604     EXPECT_FALSE(result);
605     EXPECT_CALL(mock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
606     EXPECT_CALL(mock, LnnGetLocalByteInfo).WillOnce(Return(SOFTBUS_NETWORK_NOT_FOUND));
607     result = CompareAclWithPeerDeviceInfo(aclProfile, peerAccountHash, peerUdid, peerUserId);
608     EXPECT_FALSE(result);
609     EXPECT_CALL(mock, LnnGetLocalByteInfo).WillRepeatedly(Return(SOFTBUS_OK));
610     EXPECT_CALL(mock, ConvertBytesToHexString).WillOnce(Return(SOFTBUS_INVALID_PARAM));
611     result = CompareAclWithPeerDeviceInfo(aclProfile, peerAccountHash, peerUdid, peerUserId);
612     EXPECT_FALSE(result);
613 }
614 
615 /*
616  * @tc.name: COMPARE_ACL_WITH_PEER_DEVICE_INFO_TEST_002
617  * @tc.desc: accountId is default.
618  * @tc.type: FUNC
619  * @tc.require:
620  */
621 HWTEST_F(AuthDeviceProfileTest, COMPARE_ACL_WITH_PEER_DEVICE_INFO_TEST_002, TestSize.Level1)
622 {
623     AuthDeviceProfileInterfaceMock mock;
624     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
625     const char *peerAccountHash = "8bb0cf6eb9b17d0f";
626     const char *peerUdid = "1234567890";
627     int32_t peerUserId = 1;
628     std::string accountId = "ohosAnonymousUid";
629     DistributedDeviceProfile::Accessee accessee;
630     accessee.SetAccesseeAccountId(accountId);
631     aclProfile.SetAccessee(accessee);
632     DistributedDeviceProfile::Accesser accesser;
633     accesser.SetAccesserAccountId(accountId);
634     aclProfile.SetAccesser(accesser);
635     EXPECT_CALL(mock, GetActiveOsAccountIds).WillRepeatedly(Return(TEST_LOCAL_USER_ID));
636     EXPECT_CALL(mock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
637     EXPECT_CALL(mock, LnnGetLocalByteInfo).WillRepeatedly(Return(SOFTBUS_OK));
638     EXPECT_CALL(mock, ConvertBytesToHexString).WillRepeatedly(Return(SOFTBUS_OK));
639     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
640     bool result = CompareAclWithPeerDeviceInfo(aclProfile, peerAccountHash, peerUdid, peerUserId);
641     EXPECT_FALSE(result);
642     std::string accountId1 = "8bb0cf6eb9b17d0f";
643     accessee.SetAccesseeAccountId(accountId);
644     aclProfile.SetAccessee(accessee);
645     accesser.SetAccesserAccountId(accountId);
646     aclProfile.SetAccesser(accesser);
647     result = CompareAclWithPeerDeviceInfo(aclProfile, peerAccountHash, peerUdid, peerUserId);
648     EXPECT_FALSE(result);
649 }
650 
651 /*
652  * @tc.name: IS_TRUSTED_DEVICE_FROM_ACCESS_TEST_003
653  * @tc.desc: device is trust from access
654  * @tc.type: FUNC
655  * @tc.require:
656  */
657 HWTEST_F(AuthDeviceProfileTest, IS_TRUSTED_DEVICE_FROM_ACCESS_TEST_003, TestSize.Level1)
658 {
659     const char *accountHash = nullptr;
660     const char *udid = nullptr;
661     bool ret = IsTrustedDeviceFromAccess(accountHash, udid, 100);
662     EXPECT_EQ(ret, false);
663     accountHash = "dev/ice%Id()Hash()";
664     udid = "dev/ice%Id()Hash()";
665     ret = IsTrustedDeviceFromAccess(accountHash, udid, 100);
666     EXPECT_EQ(ret, false);
667     int32_t peerUserId = -1;
668     int64_t accountId = 100;
669     SessionKey sessionKey;
670     (void)memset_s(&sessionKey, sizeof(SessionKey), 0, sizeof(SessionKey));
671     DelNotTrustDevice(nullptr);
672     UpdateDpAclParams aclParams = {
673         .accountId = accountId,
674         .deviceId = nullptr,
675         .peerUserId = peerUserId
676     };
677     UpdateDpSameAccount(&aclParams, sessionKey, true, ACL_NOT_WRITE);
678     UpdateDpSameAccount(&aclParams, sessionKey, true, ACL_WRITE_DEFAULT);
679     ret = IsTrustedDeviceFromAccess(accountHash, udid, 100);
680     EXPECT_EQ(ret, false);
681 }
682 
683 /*
684  * @tc.name: PUT_DP_ACL_UK_BY_USER_ID_TEST_001
685  * @tc.desc: sessionKey or sessionKeyId is nullptr.
686  * @tc.type: FUNC
687  * @tc.require:
688  */
689 HWTEST_F(AuthDeviceProfileTest, PUT_DP_ACL_UK_BY_USER_ID_TEST_001, TestSize.Level1)
690 {
691     int32_t userId = 1;
692     uint32_t sessionKeyLen = 32;
693     UpdateDpAclResult ret = PutDpAclUkByUserId(userId, nullptr, sessionKeyLen, nullptr);
694     EXPECT_EQ(ret, GET_ALL_ACL_FAIL);
695 
696     uint8_t sessionKey = 2;
697     ret = PutDpAclUkByUserId(userId, &sessionKey, sessionKeyLen, nullptr);
698     EXPECT_EQ(ret, GET_ALL_ACL_FAIL);
699 }
700 
701 /*
702  * @tc.name: COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_001
703  * @tc.desc: isSameSide is true.
704  * @tc.type: FUNC
705  * @tc.require:
706  */
707 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_001, TestSize.Level1)
708 {
709     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
710     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
711     aclProfile.SetBindType(bindType);
712     AuthACLInfo aclInfo;
713     int32_t result = SetAclInfo(&aclInfo);
714     ASSERT_EQ(result, SOFTBUS_OK);
715     bool isSameSide = true;
716     bool ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
717     EXPECT_FALSE(ret);
718 
719     bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
720     aclProfile.SetBindType(bindType);
721     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
722     EXPECT_FALSE(ret);
723 
724     DistributedDeviceProfile::Accesser accesser;
725     accesser.SetAccesserDeviceId("ab");
726     aclProfile.SetAccesser(accesser);
727     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
728     EXPECT_FALSE(ret);
729 
730     DistributedDeviceProfile::Accessee accessee;
731     accessee.SetAccesseeDeviceId("cd");
732     aclProfile.SetAccessee(accessee);
733     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
734     EXPECT_FALSE(ret);
735 
736     accesser.SetAccesserAccountId("ef");
737     aclProfile.SetAccesser(accesser);
738     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
739     EXPECT_FALSE(ret);
740 
741     accessee.SetAccesseeAccountId("gh");
742     aclProfile.SetAccessee(accessee);
743     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
744     EXPECT_FALSE(ret);
745 }
746 
747 /*
748  * @tc.name: COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_002
749  * @tc.desc: isSameSide is true.
750  * @tc.type: FUNC
751  * @tc.require:
752  */
753 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_002, TestSize.Level1)
754 {
755     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
756     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
757     aclProfile.SetBindType(bindType);
758     AuthACLInfo aclInfo;
759     int32_t result = SetAclInfo(&aclInfo);
760     ASSERT_EQ(result, SOFTBUS_OK);
761     bool isSameSide = true;
762     bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
763     aclProfile.SetBindType(bindType);
764     DistributedDeviceProfile::Accesser accesser;
765     accesser.SetAccesserDeviceId("ab");
766     accesser.SetAccesserAccountId("ef");
767     accesser.SetAccesserUserId(1);
768     aclProfile.SetAccesser(accesser);
769     DistributedDeviceProfile::Accessee accessee;
770     accessee.SetAccesseeDeviceId("cd");
771     accessee.SetAccesseeAccountId("gh");
772     aclProfile.SetAccessee(accessee);
773     bool ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
774     EXPECT_FALSE(ret);
775 
776     accessee.SetAccesseeUserId(2);
777     aclProfile.SetAccessee(accessee);
778     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
779     EXPECT_TRUE(ret);
780 
781     accessee.SetAccesseeAccountId("ohosAnonymousUid");
782     aclProfile.SetAccessee(accessee);
783     result = strcpy_s(aclInfo.sinkAccountId, ACCOUNT_ID_BUF_LEN, "ohosAnonymousUid");
784     EXPECT_EQ(result, EOK);
785     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
786     EXPECT_FALSE(ret);
787 
788     accesser.SetAccesserAccountId("ohosAnonymousUid");
789     aclProfile.SetAccesser(accesser);
790     result = strcpy_s(aclInfo.sourceAccountId, ACCOUNT_ID_BUF_LEN, "ohosAnonymousUid");
791     EXPECT_EQ(result, EOK);
792     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
793     EXPECT_FALSE(ret);
794 }
795 
796 /*
797  * @tc.name: COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_003
798  * @tc.desc: isSameSide is false.
799  * @tc.type: FUNC
800  * @tc.require:
801  */
802 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_003, TestSize.Level1)
803 {
804     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
805     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
806     aclProfile.SetBindType(bindType);
807     AuthACLInfo aclInfo;
808     int32_t result = SetAclInfo(&aclInfo);
809     ASSERT_EQ(result, SOFTBUS_OK);
810     bool isSameSide = false;
811     bool ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
812     EXPECT_FALSE(ret);
813 
814     DistributedDeviceProfile::Accesser accesser;
815     accesser.SetAccesserDeviceId("cd");
816     aclProfile.SetAccesser(accesser);
817     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
818     EXPECT_FALSE(ret);
819 
820     DistributedDeviceProfile::Accessee accessee;
821     accessee.SetAccesseeDeviceId("ab");
822     aclProfile.SetAccessee(accessee);
823     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
824     EXPECT_FALSE(ret);
825 
826     accesser.SetAccesserAccountId("gh");
827     aclProfile.SetAccessee(accessee);
828     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
829     EXPECT_FALSE(ret);
830 
831     accessee.SetAccesseeAccountId("ef");
832     aclProfile.SetAccessee(accessee);
833     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
834     EXPECT_FALSE(ret);
835 
836     accesser.SetAccesserUserId(2);
837     aclProfile.SetAccesser(accesser);
838     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
839     EXPECT_FALSE(ret);
840 }
841 
842 /*
843  * @tc.name: COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_004
844  * @tc.desc: isSameSide is false.
845  * @tc.type: FUNC
846  * @tc.require:
847  */
848 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_SAME_ACCOUNT_TEST_004, TestSize.Level1)
849 {
850     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
851     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
852     aclProfile.SetBindType(bindType);
853     AuthACLInfo aclInfo;
854     int32_t result = SetAclInfo(&aclInfo);
855     ASSERT_EQ(result, SOFTBUS_OK);
856     bool isSameSide = false;
857     DistributedDeviceProfile::Accesser accesser;
858     accesser.SetAccesserDeviceId("cd");
859     accesser.SetAccesserAccountId("gh");
860     accesser.SetAccesserUserId(2);
861     aclProfile.SetAccesser(accesser);
862     DistributedDeviceProfile::Accessee accessee;
863     accessee.SetAccesseeDeviceId("ab");
864     accessee.SetAccesseeAccountId("ef");
865     accessee.SetAccesseeUserId(1);
866     aclProfile.SetAccessee(accessee);
867     bool ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
868     EXPECT_TRUE(ret);
869 
870     accessee.SetAccesseeAccountId("ohosAnonymousUid");
871     aclProfile.SetAccessee(accessee);
872     result = strcpy_s(aclInfo.sourceAccountId, ACCOUNT_ID_BUF_LEN, "ohosAnonymousUid");
873     EXPECT_EQ(result, EOK);
874     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
875     EXPECT_FALSE(ret);
876 
877     accesser.SetAccesserAccountId("ohosAnonymousUid");
878     aclProfile.SetAccesser(accesser);
879     result = strcpy_s(aclInfo.sinkAccountId, ACCOUNT_ID_BUF_LEN, "ohosAnonymousUid");
880     EXPECT_EQ(result, EOK);
881     ret = CompareAssetAclSameAccount(aclProfile, &aclInfo, isSameSide);
882     EXPECT_FALSE(ret);
883 }
884 
885 /*
886  * @tc.name: COMPARE_ASSET_ACL_DIFF_ACCOUNT_WITH_USER_LEVEL_TEST_001
887  * @tc.desc: isSameSide is true.
888  * @tc.type: FUNC
889  * @tc.require:
890  */
891 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_DIFF_ACCOUNT_WITH_USER_LEVEL_TEST_001, TestSize.Level1)
892 {
893     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
894     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::SERVICE;
895     aclProfile.SetBindLevel(bindLevel);
896     AuthACLInfo aclInfo;
897     int32_t result = SetAclInfo(&aclInfo);
898     ASSERT_EQ(result, SOFTBUS_OK);
899     bool isSameSide = true;
900     bool ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
901     EXPECT_FALSE(ret);
902 
903     bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::USER;
904     aclProfile.SetBindLevel(bindLevel);
905     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
906     EXPECT_FALSE(ret);
907 
908     DistributedDeviceProfile::Accesser accesser;
909     accesser.SetAccesserDeviceId("ab");
910     aclProfile.SetAccesser(accesser);
911     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
912     EXPECT_FALSE(ret);
913 
914     DistributedDeviceProfile::Accessee accessee;
915     accessee.SetAccesseeDeviceId("cd");
916     aclProfile.SetAccessee(accessee);
917     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
918     EXPECT_FALSE(ret);
919 
920     accesser.SetAccesserUserId(1);
921     aclProfile.SetAccesser(accesser);
922     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
923     EXPECT_FALSE(ret);
924 
925     accessee.SetAccesseeUserId(2);
926     aclProfile.SetAccessee(accessee);
927     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
928     EXPECT_TRUE(ret);
929 }
930 
931 /*
932  * @tc.name: COMPARE_ASSET_ACL_DIFF_ACCOUNT_WITH_USER_LEVEL_TEST_002
933  * @tc.desc: isSameSide is true.
934  * @tc.type: FUNC
935  * @tc.require:
936  */
937 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_DIFF_ACCOUNT_WITH_USER_LEVEL_TEST_002, TestSize.Level1)
938 {
939     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
940     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::USER;
941     aclProfile.SetBindLevel(bindLevel);
942     AuthACLInfo aclInfo;
943     int32_t result = SetAclInfo(&aclInfo);
944     ASSERT_EQ(result, SOFTBUS_OK);
945     bool isSameSide = false;
946     bool ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
947     EXPECT_FALSE(ret);
948 
949     DistributedDeviceProfile::Accesser accesser;
950     accesser.SetAccesserDeviceId("cd");
951     aclProfile.SetAccesser(accesser);
952     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
953     EXPECT_FALSE(ret);
954 
955     DistributedDeviceProfile::Accessee accessee;
956     accessee.SetAccesseeDeviceId("ab");
957     aclProfile.SetAccessee(accessee);
958     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
959     EXPECT_FALSE(ret);
960 
961     accesser.SetAccesserUserId(2);
962     aclProfile.SetAccesser(accesser);
963     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
964     EXPECT_FALSE(ret);
965 
966     accessee.SetAccesseeUserId(1);
967     aclProfile.SetAccessee(accessee);
968     ret = CompareAssetAclDiffAccountWithUserLevel(aclProfile, &aclInfo, isSameSide);
969     EXPECT_TRUE(ret);
970 }
971 
972 /*
973  * @tc.name: COMPARE_ASSET_ACL_DIFF_ACCOUNT_001
974  * @tc.desc: isSameSide is true.
975  * @tc.type: FUNC
976  * @tc.require:
977  */
978 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_DIFF_ACCOUNT_001, TestSize.Level1)
979 {
980     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
981     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
982     aclProfile.SetBindType(bindType);
983     AuthACLInfo aclInfo;
984     int32_t result = SetAclInfo(&aclInfo);
985     ASSERT_EQ(result, SOFTBUS_OK);
986     bool isSameSide = true;
987     bool ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
988     EXPECT_FALSE(ret);
989 
990     bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
991     aclProfile.SetBindType(bindType);
992     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
993     EXPECT_FALSE(ret);
994 
995     bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::POINT_TO_POINT;
996     aclProfile.SetBindType(bindType);
997     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::USER;
998     aclProfile.SetBindLevel(bindLevel);
999     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1000     EXPECT_FALSE(ret);
1001 
1002     bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::SERVICE;
1003     aclProfile.SetBindLevel(bindLevel);
1004     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1005     EXPECT_FALSE(ret);
1006 
1007     DistributedDeviceProfile::Accesser accesser;
1008     accesser.SetAccesserDeviceId("ab");
1009     aclProfile.SetAccesser(accesser);
1010     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1011     EXPECT_FALSE(ret);
1012 
1013     DistributedDeviceProfile::Accessee accessee;
1014     accessee.SetAccesseeDeviceId("cd");
1015     aclProfile.SetAccessee(accessee);
1016     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1017     EXPECT_FALSE(ret);
1018 
1019     accesser.SetAccesserUserId(1);
1020     aclProfile.SetAccesser(accesser);
1021     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1022     EXPECT_FALSE(ret);
1023 }
1024 
1025 /*
1026  * @tc.name: COMPARE_ASSET_ACL_DIFF_ACCOUNT_002
1027  * @tc.desc: isSameSide is true.
1028  * @tc.type: FUNC
1029  * @tc.require:
1030  */
1031 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_DIFF_ACCOUNT_002, TestSize.Level1)
1032 {
1033     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1034     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::POINT_TO_POINT;
1035     aclProfile.SetBindType(bindType);
1036     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::SERVICE;
1037     aclProfile.SetBindLevel(bindLevel);
1038     AuthACLInfo aclInfo;
1039     int32_t result = SetAclInfo(&aclInfo);
1040     ASSERT_EQ(result, SOFTBUS_OK);
1041     bool isSameSide = true;
1042     DistributedDeviceProfile::Accesser accesser;
1043     accesser.SetAccesserDeviceId("ab");
1044     accesser.SetAccesserUserId(1);
1045     aclProfile.SetAccesser(accesser);
1046     DistributedDeviceProfile::Accessee accessee;
1047     accessee.SetAccesseeDeviceId("cd");
1048     accessee.SetAccesseeUserId(2);
1049     aclProfile.SetAccessee(accessee);
1050     bool ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1051     EXPECT_FALSE(ret);
1052 
1053     accesser.SetAccesserTokenId(3);
1054     aclProfile.SetAccesser(accesser);
1055     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1056     EXPECT_FALSE(ret);
1057 
1058     accessee.SetAccesseeTokenId(4);
1059     aclProfile.SetAccessee(accessee);
1060     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1061     EXPECT_TRUE(ret);
1062 }
1063 
1064 /*
1065  * @tc.name: COMPARE_ASSET_ACL_DIFF_ACCOUNT_003
1066  * @tc.desc: isSameSide is true.
1067  * @tc.type: FUNC
1068  * @tc.require:
1069  */
1070 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ACL_DIFF_ACCOUNT_003, TestSize.Level1)
1071 {
1072     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1073     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::POINT_TO_POINT;
1074     aclProfile.SetBindType(bindType);
1075     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::SERVICE;
1076     aclProfile.SetBindLevel(bindLevel);
1077     AuthACLInfo aclInfo;
1078     int32_t result = SetAclInfo(&aclInfo);
1079     ASSERT_EQ(result, SOFTBUS_OK);
1080     bool isSameSide = false;
1081     bool ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1082     EXPECT_FALSE(ret);
1083 
1084     DistributedDeviceProfile::Accesser accesser;
1085     accesser.SetAccesserDeviceId("cd");
1086     aclProfile.SetAccesser(accesser);
1087     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1088     EXPECT_FALSE(ret);
1089 
1090     DistributedDeviceProfile::Accessee accessee;
1091     accessee.SetAccesseeDeviceId("ab");
1092     aclProfile.SetAccessee(accessee);
1093     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1094     EXPECT_FALSE(ret);
1095 
1096     accesser.SetAccesserUserId(2);
1097     aclProfile.SetAccesser(accesser);
1098     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1099     EXPECT_FALSE(ret);
1100 
1101     accessee.SetAccesseeUserId(1);
1102     aclProfile.SetAccessee(accessee);
1103     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1104     EXPECT_FALSE(ret);
1105 
1106     accesser.SetAccesserTokenId(4);
1107     aclProfile.SetAccesser(accesser);
1108     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1109     EXPECT_FALSE(ret);
1110 
1111     accessee.SetAccesseeTokenId(3);
1112     aclProfile.SetAccessee(accessee);
1113     ret = CompareAssetAclDiffAccount(aclProfile, &aclInfo, isSameSide);
1114     EXPECT_TRUE(ret);
1115 }
1116 
1117 /*
1118  * @tc.name: COMPARE_ASSET_ALL_ACL_TEST_001
1119  * @tc.desc: isSameAccount is true.
1120  * @tc.type: FUNC
1121  * @tc.require:
1122  */
1123 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ALL_ACL_TEST_001, TestSize.Level1)
1124 {
1125     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1126     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SHARE;
1127     aclProfile.SetBindType(bindType);
1128     AuthACLInfo aclInfo;
1129     int32_t result = SetAclInfo(&aclInfo);
1130     ASSERT_EQ(result, SOFTBUS_OK);
1131     bool isSameSide = true;
1132     bool isSameAccount = true;
1133     bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::SAME_ACCOUNT;
1134     aclProfile.SetBindType(bindType);
1135     DistributedDeviceProfile::Accesser accesser;
1136     accesser.SetAccesserDeviceId("ab");
1137     accesser.SetAccesserAccountId("ef");
1138     accesser.SetAccesserUserId(1);
1139     aclProfile.SetAccesser(accesser);
1140     DistributedDeviceProfile::Accessee accessee;
1141     accessee.SetAccesseeDeviceId("cd");
1142     accessee.SetAccesseeAccountId("gh");
1143     aclProfile.SetAccessee(accessee);
1144     bool ret = CompareAssetAllAcl(aclProfile, &aclInfo, isSameSide, isSameAccount);
1145     EXPECT_FALSE(ret);
1146 
1147     accessee.SetAccesseeUserId(2);
1148     aclProfile.SetAccessee(accessee);
1149     ret = CompareAssetAllAcl(aclProfile, &aclInfo, isSameSide, isSameAccount);
1150     EXPECT_TRUE(ret);
1151 }
1152 
1153 /*
1154  * @tc.name: COMPARE_ASSET_ALL_ACL_TEST_002
1155  * @tc.desc: isSameAccount is false.
1156  * @tc.type: FUNC
1157  * @tc.require:
1158  */
1159 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ALL_ACL_TEST_002, TestSize.Level1)
1160 {
1161     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1162     AuthACLInfo aclInfo;
1163     int32_t result = SetAclInfo(&aclInfo);
1164     ASSERT_EQ(result, SOFTBUS_OK);
1165     bool isSameSide = true;
1166     bool isSameAccount = false;
1167     bool ret = CompareAssetAllAcl(aclProfile, &aclInfo, isSameSide, isSameAccount);
1168     EXPECT_FALSE(ret);
1169 
1170     uint32_t bindType = (uint32_t)OHOS::DistributedDeviceProfile::BindType::POINT_TO_POINT;
1171     aclProfile.SetBindType(bindType);
1172     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::SERVICE;
1173     aclProfile.SetBindLevel(bindLevel);
1174     DistributedDeviceProfile::Accesser accesser;
1175     accesser.SetAccesserDeviceId("ab");
1176     accesser.SetAccesserUserId(1);
1177     accesser.SetAccesserTokenId(3);
1178     aclProfile.SetAccesser(accesser);
1179     DistributedDeviceProfile::Accessee accessee;
1180     accessee.SetAccesseeDeviceId("cd");
1181     accessee.SetAccesseeUserId(2);
1182     accessee.SetAccesseeTokenId(4);
1183     aclProfile.SetAccessee(accessee);
1184     ret = CompareAssetAllAcl(aclProfile, &aclInfo, isSameSide, isSameAccount);
1185     EXPECT_TRUE(ret);
1186 }
1187 
1188 /*
1189  * @tc.name: COMPARE_ASSET_ALL_ACL_TEST_003
1190  * @tc.desc: isSameAccount is false.
1191  * @tc.type: FUNC
1192  * @tc.require:
1193  */
1194 HWTEST_F(AuthDeviceProfileTest, COMPARE_ASSET_ALL_ACL_TEST_003, TestSize.Level1)
1195 {
1196     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1197     uint32_t bindLevel = (uint32_t)OHOS::DistributedDeviceProfile::BindLevel::USER;
1198     aclProfile.SetBindLevel(bindLevel);
1199     AuthACLInfo aclInfo;
1200     int32_t result = SetAclInfo(&aclInfo);
1201     ASSERT_EQ(result, SOFTBUS_OK);
1202     DistributedDeviceProfile::Accesser accesser;
1203     accesser.SetAccesserDeviceId("ab");
1204     accesser.SetAccesserUserId(1);
1205     aclProfile.SetAccesser(accesser);
1206     DistributedDeviceProfile::Accessee accessee;
1207     accessee.SetAccesseeDeviceId("cd");
1208     accessee.SetAccesseeUserId(2);
1209     aclProfile.SetAccessee(accessee);
1210     bool isSameSide = true;
1211     bool isSameAccount = false;
1212     bool ret = CompareAssetAllAcl(aclProfile, &aclInfo, isSameSide, isSameAccount);
1213     EXPECT_TRUE(ret);
1214 }
1215 
1216 /*
1217  * @tc.name: GET_LOCAL_UK_ID_FROM_ACCESS_TEST_001
1218  * @tc.desc: isServer is true or false.
1219  * @tc.type: FUNC
1220  * @tc.require:
1221  */
1222 HWTEST_F(AuthDeviceProfileTest, GET_LOCAL_UK_ID_FROM_ACCESS_TEST_001, TestSize.Level1)
1223 {
1224     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1225     AuthACLInfo aclInfo;
1226     int32_t result = SetAclInfo(&aclInfo);
1227     ASSERT_EQ(result, SOFTBUS_OK);
1228     DistributedDeviceProfile::Accesser accesser;
1229     accesser.SetAccesserDeviceId("ab");
1230     accesser.SetAccesserSessionKeyId(1);
1231     accesser.SetAccesserSKTimeStamp(135);
1232     aclProfile.SetAccesser(accesser);
1233     DistributedDeviceProfile::Accessee accessee;
1234     accessee.SetAccesseeDeviceId("cd");
1235     accessee.SetAccesseeSessionKeyId(2);
1236     accessee.SetAccesseeSKTimeStamp(246);
1237     aclProfile.SetAccessee(accessee);
1238     int32_t ukId = 0;
1239     uint64_t time = 0;
1240     GetLocalUkIdFromAccess(aclProfile, &aclInfo, &ukId, &time);
1241     EXPECT_EQ(ukId, 1);
1242     EXPECT_EQ(time, 135);
1243 
1244     accesser.SetAccesserDeviceId("abcd");
1245     aclProfile.SetAccesser(accesser);
1246     GetLocalUkIdFromAccess(aclProfile, &aclInfo, &ukId, &time);
1247     EXPECT_EQ(ukId, 1);
1248     EXPECT_EQ(time, 135);
1249 
1250     aclInfo.isServer = false;
1251     GetLocalUkIdFromAccess(aclProfile, &aclInfo, &ukId, &time);
1252     EXPECT_EQ(ukId, 2);
1253     EXPECT_EQ(time, 246);
1254 }
1255 
1256 /*
1257  * @tc.name: UPDATE_ACCESS_PROFILE_SESSION_KEY_ID_TEST_001
1258  * @tc.desc: Set ukid as default value.
1259  * @tc.type: FUNC
1260  * @tc.require:
1261  */
1262 HWTEST_F(AuthDeviceProfileTest, UPDATE_ACCESS_PROFILE_SESSION_KEY_ID_TEST_001, TestSize.Level1)
1263 {
1264     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1265     int32_t ukId = 10;
1266     UpdateAccessProfileSessionKeyId(aclProfile, &ukId);
1267     EXPECT_EQ(ukId, -1);
1268 }
1269 
1270 /*
1271  * @tc.name: GET_ACCESS_UK_ID_SAME_ACCOUNT_TEST_001
1272  * @tc.desc: acl or ukid or time is nullptr.
1273  * @tc.type: FUNC
1274  * @tc.require:
1275  */
1276 HWTEST_F(AuthDeviceProfileTest, GET_ACCESS_UK_ID_SAME_ACCOUNT_TEST_001, TestSize.Level1)
1277 {
1278     AuthACLInfo aclInfo;
1279     int32_t ukId = 0;
1280     uint64_t time = 0;
1281     int32_t ret = GetAccessUkIdSameAccount(nullptr, &ukId, &time);
1282     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1283 
1284     ret = GetAccessUkIdSameAccount(&aclInfo, nullptr, &time);
1285     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1286 
1287     ret = GetAccessUkIdSameAccount(&aclInfo, &ukId, nullptr);
1288     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1289 }
1290 
1291 /*
1292  * @tc.name: GET_ACCESS_UK_ID_DIFF_ACCOUNT_WITH_USER_LEVEL_TEST_001
1293  * @tc.desc: acl or ukid or time is nullptr.
1294  * @tc.type: FUNC
1295  * @tc.require:
1296  */
1297 HWTEST_F(AuthDeviceProfileTest, GET_ACCESS_UK_ID_DIFF_ACCOUNT_WITH_USER_LEVEL_TEST_001, TestSize.Level1)
1298 {
1299     AuthACLInfo aclInfo;
1300     int32_t ukId = 0;
1301     uint64_t time = 0;
1302     int32_t ret = GetAccessUkIdDiffAccountWithUserLevel(nullptr, &ukId, &time);
1303     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1304 
1305     ret = GetAccessUkIdDiffAccountWithUserLevel(&aclInfo, nullptr, &time);
1306     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1307 
1308     ret = GetAccessUkIdDiffAccountWithUserLevel(&aclInfo, &ukId, nullptr);
1309     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1310 }
1311 
1312 /*
1313  * @tc.name: GET_ACCESS_UK_ID_DIFF_ACCOUNT_TEST_001
1314  * @tc.desc: acl or ukid or time is nullptr.
1315  * @tc.type: FUNC
1316  * @tc.require:
1317  */
1318 HWTEST_F(AuthDeviceProfileTest, GET_ACCESS_UK_ID_DIFF_ACCOUNT_TEST_001, TestSize.Level1)
1319 {
1320     AuthACLInfo aclInfo;
1321     int32_t ukId = 0;
1322     uint64_t time = 0;
1323     int32_t ret = GetAccessUkIdDiffAccount(nullptr, &ukId, &time);
1324     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1325     ret = GetAccessUkIdDiffAccount(&aclInfo, nullptr, &time);
1326     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1327     ret = GetAccessUkIdDiffAccount(&aclInfo, &ukId, nullptr);
1328     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1329 }
1330 
1331 /*
1332  * @tc.name: GET_ACCESS_UK_BY_UK_ID_TEST_001
1333  * @tc.desc: uk is nullptr.
1334  * @tc.type: FUNC
1335  * @tc.require:
1336  */
1337 HWTEST_F(AuthDeviceProfileTest, GET_ACCESS_UK_BY_UK_ID_TEST_001, TestSize.Level1)
1338 {
1339     int32_t sessionKeyId = 0;
1340     uint32_t ukLen = 10;
1341     int32_t ret = GetAccessUkByUkId(sessionKeyId, nullptr, ukLen);
1342     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1343 }
1344 
1345 /*
1346  * @tc.name: IS_SK_ID_INVALID_INNER_TEST_001
1347  * @tc.desc: AccountId is default.
1348  * @tc.type: FUNC
1349  * @tc.require:
1350  */
1351 HWTEST_F(AuthDeviceProfileTest, IS_SK_ID_INVALID_INNER_TEST_001, TestSize.Level1)
1352 {
1353     int32_t sessionKeyId = 1;
1354     const char *accountHash = "1a2b3c4d5e6f";
1355     const char *udidShortHash = "a1b2c3d4e5f6";
1356     int32_t userId = 2;
1357     OHOS::DistributedDeviceProfile::AccessControlProfile aclProfile;
1358     AuthDeviceProfileInterfaceMock mock;
1359     EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK));
1360     EXPECT_CALL(mock, ConvertBytesToHexString).WillRepeatedly(Return(SOFTBUS_OK));
1361     bool ret = IsSKIdInvalidInner(sessionKeyId, accountHash, udidShortHash, userId, aclProfile);
1362     EXPECT_TRUE(ret);
1363 
1364     DistributedDeviceProfile::Accesser accesser;
1365     accesser.SetAccesserDeviceId("ab");
1366     accesser.SetAccesserAccountId("ohosAnonymousUid");
1367     accesser.SetAccesserSessionKeyId(1);
1368     accesser.SetAccesserUserId(2);
1369     aclProfile.SetAccesser(accesser);
1370     DistributedDeviceProfile::Accessee accessee;
1371     accessee.SetAccesseeDeviceId("cd");
1372     accessee.SetAccesseeAccountId("ohosAnonymousUid");
1373     accessee.SetAccesseeSessionKeyId(3);
1374     accessee.SetAccesseeUserId(6);
1375     aclProfile.SetAccessee(accessee);
1376     ret = IsSKIdInvalidInner(sessionKeyId, accountHash, udidShortHash, userId, aclProfile);
1377     EXPECT_TRUE(ret);
1378 
1379     sessionKeyId = 3;
1380     ret = IsSKIdInvalidInner(sessionKeyId, accountHash, udidShortHash, userId, aclProfile);
1381     EXPECT_TRUE(ret);
1382 }
1383 
1384 /*
1385  * @tc.name: IS_SK_ID_INVALID_TEST_001
1386  * @tc.desc: accountHash or udidShortHash is nullptr.
1387  * @tc.type: FUNC
1388  * @tc.require:
1389  */
1390 HWTEST_F(AuthDeviceProfileTest, IS_SK_ID_INVALID_TEST_001, TestSize.Level1)
1391 {
1392     int32_t sessionKeyId = 1;
1393     const char *accountHash = "1a2b3c4d5e6f";
1394     int32_t userId = 2;
1395     bool ret = IsSKIdInvalid(sessionKeyId, nullptr, nullptr, userId);
1396     EXPECT_FALSE(ret);
1397     ret = IsSKIdInvalid(sessionKeyId, accountHash, nullptr, userId);
1398     EXPECT_FALSE(ret);
1399 }
1400 
1401 /*
1402  * @tc.name: IS_SK_ID_INVALID_TEST_002
1403  * @tc.desc: 1.accountHash length error.2.udidShortHash length error
1404  * @tc.type: FUNC
1405  * @tc.require:
1406  */
1407 HWTEST_F(AuthDeviceProfileTest, IS_SK_ID_INVALID_TEST_002, TestSize.Level1)
1408 {
1409     int32_t sessionKeyId = 1;
1410     const char *accountHash = "1a2b3c4d5e6f";
1411     const char *udidShortHash = "a1b2c3d4e5f6";
1412     int32_t userId = 2;
1413     bool ret = IsSKIdInvalid(sessionKeyId, accountHash, udidShortHash, userId);
1414     EXPECT_FALSE(ret);
1415 
1416     const char *testUdidShortHash = "a1b2c3d4e5f6a1b2c3d4e5f6";
1417     ret = IsSKIdInvalid(sessionKeyId, accountHash, testUdidShortHash, userId);
1418     EXPECT_FALSE(ret);
1419 }
1420 
1421 /*
1422  * @tc.name: SELECT_ALL_ACL_TEST_001
1423  * @tc.desc: trustedInfoArray or num is nullptr.
1424  * @tc.type: FUNC
1425  * @tc.require:
1426  */
1427 HWTEST_F(AuthDeviceProfileTest, SELECT_ALL_ACL_TEST_001, TestSize.Level1)
1428 {
1429     int32_t ret = SelectAllAcl(nullptr, nullptr);
1430     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1431 
1432     uint32_t num = 1;
1433     ret = SelectAllAcl(nullptr, &num);
1434     EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
1435 }
1436 } // namespace OHOS