• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "secure_user_info_test.h"
17 
18 #include "iam_common_defines.h"
19 #include "secure_user_info_impl.h"
20 
21 namespace OHOS {
22 namespace UserIam {
23 namespace UserAuth {
24 using namespace testing;
25 using namespace testing::ext;
26 
SetUpTestCase()27 void SecureUserInfoTest::SetUpTestCase()
28 {
29 }
30 
TearDownTestCase()31 void SecureUserInfoTest::TearDownTestCase()
32 {
33 }
34 
SetUp()35 void SecureUserInfoTest::SetUp()
36 {
37 }
38 
TearDown()39 void SecureUserInfoTest::TearDown()
40 {
41 }
42 
43 HWTEST_F(SecureUserInfoTest, GetUserId, TestSize.Level0)
44 {
45     constexpr int32_t userId = 100;
46     constexpr PinSubType pinSubType = PIN_MIXED;
47     constexpr uint64_t secUserId = 200;
48     std::vector<std::shared_ptr<EnrolledInfo>> info = {nullptr};
49     SecureUserInfoImpl secureUserInfoImpl(userId, pinSubType, secUserId, info);
50     int32_t ret = secureUserInfoImpl.GetUserId();
51     EXPECT_EQ(ret, userId);
52 }
53 
54 HWTEST_F(SecureUserInfoTest, GetPinSubType, TestSize.Level0)
55 {
56     constexpr int32_t userId = 100;
57     constexpr PinSubType pinSubType = PIN_MIXED;
58     constexpr uint64_t secUserId = 200;
59     std::vector<std::shared_ptr<EnrolledInfo>> info = {nullptr};
60     SecureUserInfoImpl secureUserInfoImpl(userId, pinSubType, secUserId, info);
61     EXPECT_EQ(secureUserInfoImpl.GetPinSubType(), pinSubType);
62 }
63 
64 HWTEST_F(SecureUserInfoTest, GetSecUserId, TestSize.Level0)
65 {
66     constexpr int32_t userId = 100;
67     constexpr PinSubType pinSubType = PIN_MIXED;
68     constexpr uint64_t secUserId = 200;
69     std::vector<std::shared_ptr<EnrolledInfo>> info = {nullptr};
70     SecureUserInfoImpl secureUserInfoImpl(userId, pinSubType, secUserId, info);
71     uint64_t ret = secureUserInfoImpl.GetSecUserId();
72     EXPECT_EQ(ret, secUserId);
73 }
74 
75 HWTEST_F(SecureUserInfoTest, GetEnrolledInfo, TestSize.Level0)
76 {
77     constexpr int32_t userId = 100;
78     constexpr PinSubType pinSubType = PIN_MIXED;
79     constexpr uint64_t secUserId = 200;
80     std::vector<std::shared_ptr<EnrolledInfo>> info = {nullptr};
81     SecureUserInfoImpl secureUserInfoImpl(userId, pinSubType, secUserId, info);
82     auto ret = secureUserInfoImpl.GetEnrolledInfo();
83     EXPECT_EQ(ret, info);
84 }
85 } // namespace UserAuth
86 } // namespace UserIam
87 } // namespace OHOS
88