1 /*
2  * Copyright (c) 2023 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 #include "dlp_cert_parcel_test.h"
16 #include <string>
17 #include "dlp_permission_log.h"
18 
19 namespace OHOS {
20 namespace Security {
21 namespace DlpPermission {
22 using namespace testing::ext;
23 using namespace OHOS;
24 using namespace OHOS::Security::DlpPermission;
25 
26 namespace {
27 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
28     LOG_CORE, SECURITY_DOMAIN_DLP_PERMISSION, "DlpCertParcelTest"};
29 }
30 
SetUpTestCase()31 void DlpCertParcelTest::SetUpTestCase() {}
32 
TearDownTestCase()33 void DlpCertParcelTest::TearDownTestCase() {}
34 
SetUp()35 void DlpCertParcelTest::SetUp() {}
36 
TearDown()37 void DlpCertParcelTest::TearDown() {}
38 
39 /**
40  * @tc.name: DlpCertParcelTest001
41  * @tc.desc: CertParcel test
42  * @tc.type: FUNC
43  * @tc.require:
44  */
45 HWTEST_F(DlpCertParcelTest, CertParcel001, TestSize.Level1)
46 {
47     DLP_LOG_INFO(LABEL, "CertParcel001");
48     CertParcel info;
49     Parcel out;
50 
51     EXPECT_EQ(true, info.Marshalling(out));
52     auto result =  CertParcel::Unmarshalling(out);
53     ASSERT_NE(result, nullptr);
54 }
55 
56 /**
57  * @tc.name: DlpCertParcelTest002
58  * @tc.desc: DlpPolicyParcel test
59  * @tc.type: FUNC
60  * @tc.require:
61  */
62 HWTEST_F(DlpCertParcelTest, DlpCertParcelTest002, TestSize.Level1)
63 {
64     DLP_LOG_INFO(LABEL, "CertParcel002");
65     CertParcel info;
66     info.cert = {1, 2, 3};
67     Parcel out;
68 
69     EXPECT_EQ(true, info.Marshalling(out));
70     auto result =  CertParcel::Unmarshalling(out);
71     ASSERT_NE(result, nullptr);
72 }
73 
74 /**
75  * @tc.name: DlpCertParcelTest003
76  * @tc.desc: DlpSandboxCallbackInfoParcel test
77  * @tc.type: FUNC
78  * @tc.require:
79  */
80 HWTEST_F(DlpCertParcelTest, DlpCertParcelTest003, TestSize.Level1)
81 {
82     CertParcel info;
83     info.cert = {1, 2, 3};
84     info.offlineCert = {1, 2, 3};
85     Parcel out;
86 
87     EXPECT_EQ(true, info.Marshalling(out));
88     auto result = CertParcel::Unmarshalling(out);
89     ASSERT_NE(result, nullptr);
90 }
91 }  // namespace DlpPermission
92 }  // namespace Security
93 }  // namespace OHOS
94