1 /*
2 * Copyright (C) 2024 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 "update_pin_param_test.h"
17
18 #include "iam_common_defines.h"
19 #include "iam_ptr.h"
20 #include "update_pin_param_impl.h"
21
22 namespace OHOS {
23 namespace UserIam {
24 namespace UserAuth {
25 using namespace testing;
26 using namespace testing::ext;
SetUpTestCase()27 void UpdatePinParamTest::SetUpTestCase()
28 {
29 }
30
TearDownTestCase()31 void UpdatePinParamTest::TearDownTestCase()
32 {
33 }
34
SetUp()35 void UpdatePinParamTest::SetUp()
36 {
37 }
38
TearDown()39 void UpdatePinParamTest::TearDown()
40 {
41 }
42
43 HWTEST_F(UpdatePinParamTest, UpdatePinParam001, TestSize.Level0)
44 {
45 uint64_t credentialId = 1;
46 std::vector<uint8_t> oldRootSecret = { 2, 3, 4 };
47 std::vector<uint8_t> rootSecret = { 3, 4, 5 };
48 std::vector<uint8_t> authToken = { 4, 5, 6 };
49 auto pinInfo = Common::MakeShared<UpdatePinParamImpl>(credentialId, oldRootSecret, rootSecret, authToken);
50 EXPECT_NE(pinInfo, nullptr);
51 uint64_t testCredentialId = pinInfo->GetOldCredentialId();
52 EXPECT_EQ(credentialId, testCredentialId);
53 std::vector<uint8_t> testOldRootSecret = pinInfo->GetOldRootSecret();
54 EXPECT_THAT(testOldRootSecret, ElementsAre(2, 3, 4));
55 std::vector<uint8_t> testRootSecret = pinInfo->GetRootSecret();
56 EXPECT_THAT(testRootSecret, ElementsAre(3, 4, 5));
57 std::vector<uint8_t> testAuthToken = pinInfo->GetAuthToken();
58 EXPECT_THAT(testAuthToken, ElementsAre(4, 5, 6));
59 }
60
61 } // namespace UserAuth
62 } // namespace UserIam
63 } // namespace OHOS