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