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 "key_mgr_test.h"
17
18 #include "ed25519_key.h"
19
20 namespace OHOS {
21 namespace UserIam {
22 namespace UserAuth {
23 using namespace testing;
24 using namespace testing::ext;
SetUpTestCase()25 void KeyMgrTest::SetUpTestCase()
26 {
27 }
28
TearDownTestCase()29 void KeyMgrTest::TearDownTestCase()
30 {
31 }
32
SetUp()33 void KeyMgrTest::SetUp()
34 {
35 }
36
TearDown()37 void KeyMgrTest::TearDown()
38 {
39 }
40
41 HWTEST_F(KeyMgrTest, TestGenerateKeyPair, TestSize.Level0)
42 {
43 EXPECT_EQ(GenerateKeyPair(), RESULT_SUCCESS);
44 DestoryEd25519KeyPair();
45 }
46
47 HWTEST_F(KeyMgrTest, TestGetPriKey, TestSize.Level0)
48 {
49 EXPECT_EQ(GetPriKey(), nullptr);
50 EXPECT_EQ(GenerateKeyPair(), RESULT_SUCCESS);
51 EXPECT_NE(GetPriKey(), nullptr);
52 DestoryEd25519KeyPair();
53 }
54
55 HWTEST_F(KeyMgrTest, TestGetPubKey, TestSize.Level0)
56 {
57 EXPECT_EQ(GetPubKey(), nullptr);
58 EXPECT_EQ(GenerateKeyPair(), RESULT_SUCCESS);
59 EXPECT_NE(GetPubKey(), nullptr);
60 DestoryEd25519KeyPair();
61 }
62
63 HWTEST_F(KeyMgrTest, TestExecutorMsgSign, TestSize.Level0)
64 {
65 EXPECT_EQ(ExecutorMsgSign(nullptr), nullptr);
66 EXPECT_EQ(GenerateKeyPair(), RESULT_SUCCESS);
67 EXPECT_EQ(ExecutorMsgSign(nullptr), nullptr);
68 }
69 } // namespace UserAuth
70 } // namespace UserIam
71 } // namespace OHOS
72