1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include "file_permission_manager.h"
18 using namespace testing::ext;
19 namespace OHOS {
20 namespace AAFwk {
21 class FilePermissionManagerTest : public testing::Test {
22 public:
23 static void SetUpTestCase();
24 static void TearDownTestCase();
25 void SetUp();
26 void TearDown();
27 };
28
SetUpTestCase()29 void FilePermissionManagerTest::SetUpTestCase()
30 {}
31
TearDownTestCase()32 void FilePermissionManagerTest::TearDownTestCase()
33 {}
34
SetUp()35 void FilePermissionManagerTest::SetUp()
36 {}
37
TearDown()38 void FilePermissionManagerTest::TearDown()
39 {}
40 /*
41 * Feature: CheckUriPersistentPermission
42 * Function: CheckUriPersistentPermission
43 * SubFunction: NA
44 * FunctionPoints: UPMSUtils CheckUriPersistentPermission
45 */
46 HWTEST_F(FilePermissionManagerTest, CheckUriPersistentPermission_001, TestSize.Level1)
47 {
48 std::vector<Uri> uriVec;
49 uint32_t callerTokenId = 0;
50 uint32_t flag = 0;
51 std::vector<PolicyInfo> pathPolicies;
52 auto ret = FilePermissionManager::CheckUriPersistentPermission(uriVec, callerTokenId, flag, pathPolicies, "");
53 bool res = false;
54 if (ret.empty()) {
55 res = true;
56 }
57 EXPECT_EQ(res, true);
58 }
59
60 /*
61 * Feature: GetPathPolicyInfoFromUri
62 * Function: GetPathPolicyInfoFromUri
63 * SubFunction: NA
64 * FunctionPoints: UPMSUtils GetPathPolicyInfoFromUri
65 */
66 HWTEST_F(FilePermissionManagerTest, GetPathPolicyInfoFromUri_001, TestSize.Level1)
67 {
68 Uri uri("file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt");
69 uint32_t flag = 0;
70 auto ret = FilePermissionManager::GetPathPolicyInfoFromUri(uri, flag);
71 bool strRes = false;
72 if (!ret.path.empty()) {
73 strRes = true;
74 }
75 EXPECT_EQ(strRes, true);
76 }
77
78 }
79 }