1 /*
2 * Copyright (c) 2021-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 "account_error_no.h"
19 #include "account_log_wrapper.h"
20 #include "account_permission_manager.h"
21
22 using namespace testing::ext;
23 using namespace OHOS;
24 using namespace OHOS::AccountSA;
25
26 class AccountPermissionManagerModuleTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29 static void TearDownTestCase(void);
30 void SetUp(void) override;
31 void TearDown(void) override;
32 };
33
SetUpTestCase(void)34 void AccountPermissionManagerModuleTest::SetUpTestCase(void)
35 {}
36
TearDownTestCase(void)37 void AccountPermissionManagerModuleTest::TearDownTestCase(void)
38 {}
39
SetUp(void)40 void AccountPermissionManagerModuleTest::SetUp(void) __attribute__((no_sanitize("cfi")))
41 {
42 testing::UnitTest *test = testing::UnitTest::GetInstance();
43 ASSERT_NE(test, nullptr);
44 const testing::TestInfo *testinfo = test->current_test_info();
45 ASSERT_NE(testinfo, nullptr);
46 string testCaseName = string(testinfo->name());
47 ACCOUNT_LOGI("[SetUp] %{public}s start", testCaseName.c_str());
48 }
49
TearDown(void)50 void AccountPermissionManagerModuleTest::TearDown(void)
51 {}
52
53 /**
54 * @tc.name: AccountPermissionManager_VerifyPermission_0100
55 * @tc.desc: Verify permission with valid data.
56 * @tc.type: FUNC
57 * @tc.require: SR000GGVFR
58 */
59 HWTEST_F(AccountPermissionManagerModuleTest, AccountPermissionManager_VerifyPermission_0100, TestSize.Level0)
60 {
61 const std::string DISTRIBUTED_DATASYNC = "ohos.permission.DISTRIBUTED_DATASYNC";
62 ErrCode result = AccountPermissionManager::VerifyPermission(DISTRIBUTED_DATASYNC);
63 EXPECT_EQ(result, ERR_ACCOUNT_COMMON_PERMISSION_DENIED);
64 }
65