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 #ifndef _CUT_AUTHENTICATE_
17 
18 #include "hks_others_test.h"
19 #include "hks_test_adapt_for_de.h"
20 
21 #include <hctest.h>
22 #include "hi_watchdog.h"
23 #include "hks_api.h"
24 #include "hks_param.h"
25 #include "hks_type.h"
26 
27 /*
28  * @tc.register: register a test suit named "CalcMultiTest"
29  * @param: test subsystem name
30  * @param: c_example module name
31  * @param: CalcMultiTest test suit name
32  */
33 LITE_TEST_SUIT(husk, huks_lite, HksOthersTest);
34 
35 /**
36  * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
37  * @return: true——setup success
38  */
HksOthersTestSetUp()39 static BOOL HksOthersTestSetUp()
40 {
41     LiteTestPrint("setup\n");
42     hi_watchdog_disable();
43     TEST_ASSERT_TRUE(HksInitialize() == 0);
44     return TRUE;
45 }
46 
47 /**
48  * @tc.teardown: define a setup for test suit, format:"CalcMultiTest + TearDown"
49  * @return: true——teardown success
50  */
HksOthersTestTearDown()51 static BOOL HksOthersTestTearDown()
52 {
53     LiteTestPrint("tearDown\n");
54     hi_watchdog_enable();
55     return TRUE;
56 }
57 
58 /**
59  * @tc.name: HksOthersTest.HksOthersTest001
60  * @tc.desc: The static function will return true;
61  * @tc.type: FUNC
62  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest001,Level1)63 LITE_TEST_CASE(HksOthersTest, HksOthersTest001, Level1)
64 {
65     int32_t ret = HksGetKeyParamSetForDe(NULL, NULL, NULL);
66     TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
67 }
68 
69 /**
70  * @tc.name: HksOthersTest.HksOthersTest002
71  * @tc.desc: The static function will return true;
72  * @tc.type: FUNC
73  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest002,Level1)74 LITE_TEST_CASE(HksOthersTest, HksOthersTest002, Level1)
75 {
76     int32_t ret = HksGetKeyInfoListForDe(NULL, NULL, NULL);
77     TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
78 }
79 
80 /**
81  * @tc.name: HksOthersTest.HksOthersTest003
82  * @tc.desc: The static function will return true;
83  * @tc.type: FUNC
84  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest003,Level1)85 LITE_TEST_CASE(HksOthersTest, HksOthersTest003, Level1)
86 {
87     int32_t ret = HksAttestKeyForDe(NULL, NULL, NULL);
88     TEST_ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
89 }
90 
91 /**
92  * @tc.name: HksOthersTest.HksOthersTest004
93  * @tc.desc: The static function will return true;
94  * @tc.type: FUNC
95  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest004,Level1)96 LITE_TEST_CASE(HksOthersTest, HksOthersTest004, Level1)
97 {
98     int32_t ret = HksGetCertificateChain(NULL, NULL, NULL);
99     TEST_ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
100 }
101 
102 /**
103  * @tc.name: HksOthersTest.HksOthersTest005
104  * @tc.desc: The static function will return true;
105  * @tc.type: FUNC
106  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest005,Level1)107 LITE_TEST_CASE(HksOthersTest, HksOthersTest005, Level1)
108 {
109     int32_t ret = HksWrapKey(NULL, NULL, NULL, NULL);
110     TEST_ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
111 }
112 
113 /**
114  * @tc.name: HksOthersTest.HksOthersTest006
115  * @tc.desc: The static function will return true;
116  * @tc.type: FUNC
117  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest006,Level1)118 LITE_TEST_CASE(HksOthersTest, HksOthersTest006, Level1)
119 {
120     int32_t ret = HksUnwrapKey(NULL, NULL, NULL, NULL);
121     TEST_ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
122 }
123 
124 /**
125  * @tc.name: HksOthersTest.HksOthersTest006
126  * @tc.desc: The static function will return true;
127  * @tc.type: FUNC
128  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest007,Level1)129 LITE_TEST_CASE(HksOthersTest, HksOthersTest007, Level1)
130 {
131     int32_t ret = HksGetSdkVersion(NULL);
132     TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
133 }
134 
135 /**
136  * @tc.name: HksOthersTest.HksOthersTest008
137  * @tc.desc: The static function will return true;
138  * @tc.type: FUNC
139  */
LITE_TEST_CASE(HksOthersTest,HksOthersTest008,Level1)140 LITE_TEST_CASE(HksOthersTest, HksOthersTest008, Level1)
141 {
142     int32_t ret = HksInitialize();
143     TEST_ASSERT_TRUE(ret == HKS_SUCCESS);
144 }
145 RUN_TEST_SUITE(HksOthersTest);
146 
147 #endif /* _CUT_AUTHENTICATE_ */
148