• 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 <hdf_base.h>
17 #include "iam_hat_test.h"
18 #include "fingerprint_auth_hdi.h"
19 
20 #define LOG_LABEL OHOS::UserIam::Common::LABEL_FINGERPRINT_AUTH_IMPL
21 
22 using namespace std;
23 using namespace testing::ext;
24 using namespace OHOS::UserIam::Common;
25 using namespace OHOS::HDI::FingerprintAuth::V1_0;
26 
27 static OHOS::Parcel parcel;
28 
SetUpTestCase()29 void FingerPrintTypeTest::SetUpTestCase()
30 {
31 }
32 
TearDownTestCase()33 void FingerPrintTypeTest::TearDownTestCase()
34 {
35 }
36 
SetUp()37 void FingerPrintTypeTest::SetUp()
38 {
39 }
40 
TearDown()41 void FingerPrintTypeTest::TearDown()
42 {
43 }
44 
45 /**
46  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0201
47  * @tc.name: Test AuthType
48  * @tc.size: MediumTest
49  * @tc.type: Function
50  * @tc.level: Level1
51  */
52 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0201, Function | MediumTest | Level1)
53 {
54     cout << "start test AuthType" << endl;
55     AuthType pin = PIN;
56     AuthType face = FACE;
57     AuthType fingerprint = FINGERPRINT;
58     EXPECT_EQ(pin, 1);
59     EXPECT_EQ(face, 2);
60     EXPECT_EQ(fingerprint, 4);
61 }
62 
63 /**
64  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0202
65  * @tc.name: Test ExecutorRole
66  * @tc.size: MediumTest
67  * @tc.type: Function
68  * @tc.level: Level1
69  */
70 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0202, Function | MediumTest | Level1)
71 {
72     cout << "start test ExecutorRole" << endl;
73     ExecutorRole collector = COLLECTOR;
74     ExecutorRole verifier = VERIFIER;
75     ExecutorRole all_in_one = ALL_IN_ONE;
76     EXPECT_EQ(collector, 1);
77     EXPECT_EQ(verifier, 2);
78     EXPECT_EQ(all_in_one, 3);
79 }
80 
81 /**
82  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0203
83  * @tc.name: Test ExecutorSecureLevel
84  * @tc.size: MediumTest
85  * @tc.type: Function
86  * @tc.level: Level1
87  */
88 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0203, Function | MediumTest | Level1)
89 {
90     cout << "start test ExecutorSecureLevel" << endl;
91     ExecutorSecureLevel esl0 = ESL0;
92     ExecutorSecureLevel esl1 = ESL1;
93     ExecutorSecureLevel esl2 = ESL2;
94     ExecutorSecureLevel esl3 = ESL3;
95     EXPECT_EQ(esl0, 0);
96     EXPECT_EQ(esl1, 1);
97     EXPECT_EQ(esl2, 2);
98     EXPECT_EQ(esl3, 3);
99 }
100 
101 /**
102  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0204
103  * @tc.name: Test CommandId
104  * @tc.size: MediumTest
105  * @tc.type: Function
106  * @tc.level: Level1
107  */
108 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0204, Function | MediumTest | Level1)
109 {
110     cout << "start test CommandId" << endl;
111     CommandId lock_template = LOCK_TEMPLATE;
112     CommandId unlock_template = UNLOCK_TEMPLATE;
113     CommandId vendor_command_begin = VENDOR_COMMAND_BEGIN;
114     EXPECT_EQ(lock_template, 1);
115     EXPECT_EQ(unlock_template, 2);
116     EXPECT_EQ(vendor_command_begin, 10000);
117 }
118 
119 /**
120  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0205
121  * @tc.name: Test FingerprintTipsCode
122  * @tc.size: MediumTest
123  * @tc.type: Function
124  * @tc.level: Level1
125  */
126 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0205, Function | MediumTest | Level1)
127 {
128     cout << "start test FingerprintTipsCode" << endl;
129     FingerprintTipsCode f_good = FINGERPRINT_AUTH_TIP_GOOD;
130     FingerprintTipsCode f_dirty = FINGERPRINT_AUTH_TIP_DIRTY;
131     FingerprintTipsCode f_insufficient = FINGERPRINT_AUTH_TIP_INSUFFICIENT;
132     FingerprintTipsCode f_partial = FINGERPRINT_AUTH_TIP_PARTIAL;
133     FingerprintTipsCode f_fast = FINGERPRINT_AUTH_TIP_TOO_FAST;
134     FingerprintTipsCode f_slow = FINGERPRINT_AUTH_TIP_TOO_SLOW;
135     FingerprintTipsCode f_begin = VENDOR_FINGERPRINT_AUTH_TIP_BEGIN;
136     EXPECT_EQ(f_good, 0);
137     EXPECT_EQ(f_dirty, 1);
138     EXPECT_EQ(f_insufficient, 2);
139     EXPECT_EQ(f_partial, 3);
140     EXPECT_EQ(f_fast, 4);
141     EXPECT_EQ(f_slow, 5);
142     EXPECT_EQ(f_begin, 10000);
143 }