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 "hks_others_test.h"
19 
20 #include "hks_api.h"
21 #include "hks_param.h"
22 #include "hks_type.h"
23 
24 #include "securec.h"
25 
26 using namespace testing::ext;
27 namespace {
28 #ifndef _CUT_AUTHENTICATE_
29 class HksOthersTest : public testing::Test {
30 public:
31     static void SetUpTestCase(void);
32 
33     static void TearDownTestCase(void);
34 
35     void SetUp();
36 
37     void TearDown();
38 };
39 
SetUpTestCase(void)40 void HksOthersTest::SetUpTestCase(void)
41 {
42 }
43 
TearDownTestCase(void)44 void HksOthersTest::TearDownTestCase(void)
45 {
46 }
47 
SetUp()48 void HksOthersTest::SetUp()
49 {
50     EXPECT_EQ(HksInitialize(), 0);
51 }
52 
TearDown()53 void HksOthersTest::TearDown()
54 {
55 }
56 
57 /**
58  * @tc.name: HksOthersTest.HksOthersTest001
59  * @tc.desc: The static function will return true;
60  * @tc.type: FUNC
61  */
HWTEST_F(HksOthersTest, HksOthersTest001, TestSize.Level1)62 HWTEST_F(HksOthersTest, HksOthersTest001, TestSize.Level1)
63 {
64     int32_t ret = HksGetKeyParamSet(NULL, NULL, NULL);
65     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  */
HWTEST_F(HksOthersTest, HksOthersTest002, TestSize.Level1)73 HWTEST_F(HksOthersTest, HksOthersTest002, TestSize.Level1)
74 {
75     int32_t ret = HksGetKeyInfoList(NULL, NULL, NULL);
76     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  */
HWTEST_F(HksOthersTest, HksOthersTest003, TestSize.Level1)84 HWTEST_F(HksOthersTest, HksOthersTest003, TestSize.Level1)
85 {
86     int32_t ret = HksAttestKey(NULL, NULL, NULL);
87     ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
88 }
89 
90 /**
91  * @tc.name: HksOthersTest.HksOthersTest004
92  * @tc.desc: The static function will return true;
93  * @tc.type: FUNC
94  */
HWTEST_F(HksOthersTest, HksOthersTest004, TestSize.Level1)95 HWTEST_F(HksOthersTest, HksOthersTest004, TestSize.Level1)
96 {
97     int32_t ret = HksGetCertificateChain(NULL, NULL, NULL);
98     ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
99 }
100 
101 /**
102  * @tc.name: HksOthersTest.HksOthersTest005
103  * @tc.desc: The static function will return true;
104  * @tc.type: FUNC
105  */
HWTEST_F(HksOthersTest, HksOthersTest005, TestSize.Level1)106 HWTEST_F(HksOthersTest, HksOthersTest005, TestSize.Level1)
107 {
108     int32_t ret = HksWrapKey(NULL, NULL, NULL, NULL);
109     ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
110 }
111 
112 /**
113  * @tc.name: HksOthersTest.HksOthersTest006
114  * @tc.desc: The static function will return true;
115  * @tc.type: FUNC
116  */
HWTEST_F(HksOthersTest, HksOthersTest006, TestSize.Level1)117 HWTEST_F(HksOthersTest, HksOthersTest006, TestSize.Level1)
118 {
119     int32_t ret = HksUnwrapKey(NULL, NULL, NULL, NULL);
120     ASSERT_TRUE(ret == HKS_ERROR_API_NOT_SUPPORTED);
121 }
122 
123 /**
124  * @tc.name: HksOthersTest.HksOthersTest006
125  * @tc.desc: The static function will return true;
126  * @tc.type: FUNC
127  */
HWTEST_F(HksOthersTest, HksOthersTest007, TestSize.Level1)128 HWTEST_F(HksOthersTest, HksOthersTest007, TestSize.Level1)
129 {
130     int32_t ret = HksGetSdkVersion(NULL);
131     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  */
HWTEST_F(HksOthersTest, HksOthersTest008, TestSize.Level1)139 HWTEST_F(HksOthersTest, HksOthersTest008, TestSize.Level1)
140 {
141     int32_t ret = HksInitialize();
142     ASSERT_TRUE(ret == HKS_SUCCESS);
143 }
144 #endif /* _CUT_AUTHENTICATE_ */
145 }