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 delete result;
55 }
56
57 /**
58 * @tc.name: DlpCertParcelTest002
59 * @tc.desc: DlpPolicyParcel test
60 * @tc.type: FUNC
61 * @tc.require:
62 */
63 HWTEST_F(DlpCertParcelTest, DlpCertParcelTest002, TestSize.Level1)
64 {
65 DLP_LOG_INFO(LABEL, "CertParcel002");
66 CertParcel info;
67 info.cert = {1, 2, 3};
68 Parcel out;
69
70 EXPECT_EQ(true, info.Marshalling(out));
71 auto result = CertParcel::Unmarshalling(out);
72 ASSERT_NE(result, nullptr);
73 delete result;
74 }
75
76 /**
77 * @tc.name: DlpCertParcelTest003
78 * @tc.desc: DlpSandboxCallbackInfoParcel test
79 * @tc.type: FUNC
80 * @tc.require:
81 */
82 HWTEST_F(DlpCertParcelTest, DlpCertParcelTest003, TestSize.Level1)
83 {
84 CertParcel info;
85 info.cert = {1, 2, 3};
86 info.offlineCert = {1, 2, 3};
87 Parcel out;
88
89 EXPECT_EQ(true, info.Marshalling(out));
90 auto result = CertParcel::Unmarshalling(out);
91 ASSERT_NE(result, nullptr);
92 delete result;
93 }
94 } // namespace DlpPermission
95 } // namespace Security
96 } // namespace OHOS
97