mirror of
https://gitee.com/openharmony/security_appverify
synced 2024-11-27 00:31:03 +00:00
TicketVerifyTest tdd新增
Signed-off-by: Lotol <linxiangzhi@huawei.com> Change-Id: Ieb56cc7e5d2d6c0e7be9384a98925a0c075d991d
This commit is contained in:
parent
10e10b448a
commit
7121108d19
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021 - 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@ -41,6 +41,7 @@ ohos_unittest("verify_test") {
|
||||
"unittest/src/hap_verify_v2_test.cpp",
|
||||
"unittest/src/provision_verify_test.cpp",
|
||||
"unittest/src/random_access_file_test.cpp",
|
||||
"unittest/src/ticket_verify_test.cpp",
|
||||
"unittest/src/trusted_root_ca_test.cpp",
|
||||
"unittest/src/trusted_ticket_test.cpp",
|
||||
]
|
||||
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HAP_BYTE_BUFFER_TEST_H
|
||||
#define HAP_BYTE_BUFFER_TEST_H
|
||||
int CheckTicketSource001(void);
|
||||
int CheckTicketSource002(void);
|
||||
int CheckTicketSource003(void);
|
||||
int CheckTicketSource004(void);
|
||||
#endif // HAP_BYTE_BUFFER_TEST_H
|
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hap_byte_buffer_test.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "ticket/ticket_verify.h"
|
||||
#include "securec.h"
|
||||
|
||||
#include "hap_signing_block_utils_test.h"
|
||||
#include "test_const.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::Security::Verify;
|
||||
namespace {
|
||||
const std::string BUNDLE_NAME = "com.ohos.test";
|
||||
const std::string OVER_MAX_PATH_SIZE(4096, 'x');
|
||||
const std::string VERIFY_ERR = "verify_err";
|
||||
const std::string VERIFY_TEST = "verify_test";
|
||||
class TicketVerifyTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
|
||||
static void TearDownTestCase(void);
|
||||
|
||||
void SetUp();
|
||||
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void TicketVerifyTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
|
||||
void TicketVerifyTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
|
||||
void TicketVerifyTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void TicketVerifyTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Test TicketVerify Constructor and overload function.
|
||||
* @tc.desc: The static function will return an object of TicketVerify;
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F (TicketVerifyTest, CheckTicketSource001, TestSize.Level1)
|
||||
{
|
||||
ProvisionInfo profileInfo;
|
||||
profileInfo.bundleInfo.bundleName = OVER_MAX_PATH_SIZE;
|
||||
auto res = CheckTicketSource(profileInfo);
|
||||
ASSERT_EQ(res, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Test TicketVerify Constructor and overload function.
|
||||
* @tc.desc: The static function will return an object of TicketVerify;
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F (TicketVerifyTest, CheckTicketSource002, TestSize.Level1)
|
||||
{
|
||||
ProvisionInfo profileInfo;
|
||||
profileInfo.bundleInfo.bundleName = BUNDLE_NAME;
|
||||
auto res = CheckTicketSource(profileInfo);
|
||||
ASSERT_EQ(res, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Test TicketVerify Constructor and overload function.
|
||||
* @tc.desc: The static function will return an object of TicketVerify;
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F (TicketVerifyTest, CheckTicketSource003, TestSize.Level1)
|
||||
{
|
||||
ProvisionInfo profileInfo;
|
||||
profileInfo.bundleInfo.bundleName = VERIFY_TEST;
|
||||
auto res = CheckTicketSource(profileInfo);
|
||||
ASSERT_EQ(res, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Test TicketVerify Constructor and overload function.
|
||||
* @tc.desc: The static function will return an object of TicketVerify;
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F (TicketVerifyTest, CheckTicketSource004, TestSize.Level1)
|
||||
{
|
||||
ProvisionInfo profileInfo;
|
||||
profileInfo.bundleInfo.bundleName = VERIFY_ERR;
|
||||
auto res = CheckTicketSource(profileInfo);
|
||||
ASSERT_EQ(res, false);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
<!-- Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
@ -15,6 +15,8 @@
|
||||
<configuration ver="2.0">
|
||||
<target name="verify_test" timeout="3000">
|
||||
<preparer>
|
||||
<option name="push" value="verify_err.p7b -> /data/update/ticket/" src="res" />
|
||||
<option name="push" value="verify_test.p7b -> /data/update/ticket/" src="res" />
|
||||
</preparer>
|
||||
<cleaner>
|
||||
</cleaner>
|
||||
|
0
test/resource/appverify/verify_err.p7b
Normal file
0
test/resource/appverify/verify_err.p7b
Normal file
BIN
test/resource/appverify/verify_test.p7b
Normal file
BIN
test/resource/appverify/verify_test.p7b
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user