1 /* 2 * Copyright (c) 2022-2023 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_permission_manager.h" 17 #include "accesstoken_kit.h" 18 #include "nativetoken_kit.h" 19 #include "token_setproc.h" 20 21 namespace OHOS { 22 namespace DistributedHardware { SetUp()23 void PremissionManagerTest::SetUp() 24 { 25 uint64_t tokenId; 26 const char *perms[2]; 27 perms[0] = "ohos.permission.ACCESS_SERVICE_DM"; 28 perms[1] = "ohos.permission.DISTRIBUTED_DATASYNC"; 29 NativeTokenInfoParams infoInstance = { 30 .dcapsNum = 0, 31 .permsNum = 2, 32 .aclsNum = 0, 33 .dcaps = NULL, 34 .perms = perms, 35 .acls = NULL, 36 .processName = "dsoftbus_service", 37 .aplStr = "system_core", 38 }; 39 tokenId = GetAccessTokenId(&infoInstance); 40 SetSelfTokenID(tokenId); 41 OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); 42 } 43 TearDown()44 void PremissionManagerTest::TearDown() 45 { 46 } 47 SetUpTestCase()48 void PremissionManagerTest::SetUpTestCase() 49 { 50 } 51 TearDownTestCase()52 void PremissionManagerTest::TearDownTestCase() 53 { 54 } 55 56 namespace { 57 58 /** 59 * @tc.name: PinAuthUi::CheckPermission_001 60 * @tc.desc: the return value is true 61 * @tc.type: FUNC 62 * @tc.require: AR000GHSJK 63 */ 64 HWTEST_F(PremissionManagerTest, CheckPermission_001, testing::ext::TestSize.Level0) 65 { 66 bool ret = PermissionManager::GetInstance().CheckPermission(); 67 ASSERT_EQ(ret, true); 68 } 69 } 70 } // namespace DistributedHardware 71 } // namespace OHOS