1 /*
2 * Copyright (c) 2022 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
18 #include "netmanager_base_permission.h"
19
20 namespace OHOS {
21 namespace NetManagerStandard {
22 namespace {
23 using namespace testing::ext;
24 } // namespace
25
26 class NetManagerPermissionTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase()34 void NetManagerPermissionTest::SetUpTestCase() {}
35
TearDownTestCase()36 void NetManagerPermissionTest::TearDownTestCase() {}
37
SetUp()38 void NetManagerPermissionTest::SetUp() {}
39
TearDown()40 void NetManagerPermissionTest::TearDown() {}
41
42 HWTEST_F(NetManagerPermissionTest, CheckPermissionTest001, TestSize.Level1)
43 {
44 auto ret = NetManagerPermission::CheckPermission({});
45 EXPECT_FALSE(ret);
46 }
47
48 HWTEST_F(NetManagerPermissionTest, CheckPermissionWithCacheTest001, TestSize.Level1)
49 {
50 auto ret = NetManagerPermission::CheckPermissionWithCache({});
51 EXPECT_FALSE(ret);
52 }
53
54 HWTEST_F(NetManagerPermissionTest, IsSystemCallerTest001, TestSize.Level1)
55 {
56 auto ret = NetManagerPermission::IsSystemCaller();
57 EXPECT_TRUE(ret);
58 }
59
60 HWTEST_F(NetManagerPermissionTest, CheckNetSysInternalPermissionTest001, TestSize.Level1)
61 {
62 auto ret = NetManagerPermission::CheckNetSysInternalPermission({});
63 EXPECT_FALSE(ret);
64 }
65
66 HWTEST_F(NetManagerPermissionTest, CheckNetSysInternalPermissionTest002, TestSize.Level1)
67 {
68 auto ret = NetManagerPermission::CheckNetSysInternalPermission({"ohos.permission.MANAGE_VPN"});
69 EXPECT_FALSE(ret);
70 }
71 } // namespace NetManagerStandard
72 } // namespace OHOS