• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "permission_validator.h"
19 #include "utils/crypto.h"
20 
21 using namespace testing::ext;
22 using namespace OHOS::DistributedKv;
23 using namespace OHOS::DistributedData;
24 
25 class PermissionValidatorTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
32 
SetUpTestCase(void)33 void PermissionValidatorTest::SetUpTestCase(void)
34 {}
35 
TearDownTestCase(void)36 void PermissionValidatorTest::TearDownTestCase(void)
37 {}
38 
SetUp(void)39 void PermissionValidatorTest::SetUp(void)
40 {}
41 
TearDown(void)42 void PermissionValidatorTest::TearDown(void)
43 {}
44 
45 /**
46   * @tc.name: TestPermissionValidate001
47   * @tc.desc: test if CheckPermission can return correct permission.
48   * @tc.type: FUNC
49   * @tc.require: AR000CQDUT
50   * @tc.author: liqiao
51   */
52 HWTEST_F(PermissionValidatorTest, TestPermissionValidate001, TestSize.Level0)
53 {
54     uint32_t tokenId = 0;
55     EXPECT_FALSE(PermissionValidator::GetInstance().CheckSyncPermission(tokenId));
56 }
57 
58 /**
59   * @tc.name: TestPermissionValidate003
60   * @tc.desc: test if account id sha256.
61   * @tc.type: FUNC
62   * @tc.require: AR000DPSH0 AR000DPSEC
63   * @tc.author: liqiao
64   */
65 HWTEST_F(PermissionValidatorTest, TestPermissionValidate002, TestSize.Level0)
66 {
67     std::string userId = "ohos";
68     EXPECT_NE(Crypto::Sha256("ohos"), userId);
69 }
70