11e934351Sopenharmony_ci/*
21e934351Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
31e934351Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41e934351Sopenharmony_ci * you may not use this file except in compliance with the License.
51e934351Sopenharmony_ci * You may obtain a copy of the License at
61e934351Sopenharmony_ci *
71e934351Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81e934351Sopenharmony_ci *
91e934351Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101e934351Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111e934351Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121e934351Sopenharmony_ci * See the License for the specific language governing permissions and
131e934351Sopenharmony_ci * limitations under the License.
141e934351Sopenharmony_ci */
151e934351Sopenharmony_ci
161e934351Sopenharmony_ci#ifndef TLS_UTILS_TEST_H
171e934351Sopenharmony_ci#define TLS_UTILS_TEST_H
181e934351Sopenharmony_ci
191e934351Sopenharmony_ci#include <fstream>
201e934351Sopenharmony_ci#include <gtest/gtest.h>
211e934351Sopenharmony_ci#include <iostream>
221e934351Sopenharmony_ci#include <openssl/rsa.h>
231e934351Sopenharmony_ci#include <openssl/ssl.h>
241e934351Sopenharmony_ci#include <sstream>
251e934351Sopenharmony_ci#include <string>
261e934351Sopenharmony_ci#include <string_view>
271e934351Sopenharmony_ci#include <unistd.h>
281e934351Sopenharmony_ci#include <vector>
291e934351Sopenharmony_ci
301e934351Sopenharmony_cinamespace OHOS {
311e934351Sopenharmony_cinamespace NetStack {
321e934351Sopenharmony_cinamespace TlsSocket {
331e934351Sopenharmony_ciconst std::string_view PRIVATE_KEY_PEM = "/data/ClientCert/client_rsa_private.pem.unsecure";
341e934351Sopenharmony_ciconst std::string_view CA_DER = "/data/ClientCert/ca.crt";
351e934351Sopenharmony_ciconst std::string_view CLIENT_CRT = "/data/ClientCert/client.crt";
361e934351Sopenharmony_ciconst std::string_view IP_ADDRESS = "/data/Ip/address.txt";
371e934351Sopenharmony_ciconst std::string_view PORT = "/data/Ip/port.txt";
381e934351Sopenharmony_ciconst std::string_view PRIVATE_KEY_PEM_CHAIN = "/data/ClientCertChain/privekey.pem.unsecure";
391e934351Sopenharmony_ciconst std::string_view CA_PATH_CHAIN = "/data/ClientCertChain/cacert.crt";
401e934351Sopenharmony_ciconst std::string_view MID_CA_PATH_CHAIN = "/data/ClientCertChain/caMidcert.crt";
411e934351Sopenharmony_ciconst std::string_view CLIENT_CRT_CHAIN = "/data/ClientCertChain/secondServer.crt";
421e934351Sopenharmony_ciconst std::string_view ROOT_CA_PATH_CHAIN = "/data/ClientCertChain/RootCa.pem";
431e934351Sopenharmony_ciconst std::string_view MID_CA_CHAIN = "/data/ClientCertChain/MidCa.pem";
441e934351Sopenharmony_ci
451e934351Sopenharmony_ciclass TlsUtilsTest {
461e934351Sopenharmony_cipublic:
471e934351Sopenharmony_ci    TlsUtilsTest();
481e934351Sopenharmony_ci    ~TlsUtilsTest();
491e934351Sopenharmony_ci
501e934351Sopenharmony_ci    static std::string ChangeToFile(const std::string_view fileName);
511e934351Sopenharmony_ci    static std::string GetIp(std::string ip);
521e934351Sopenharmony_ci    static bool CheckCaFileExistence(const char *function);
531e934351Sopenharmony_ci    static bool CheckCaPathChainExistence(const char *function);
541e934351Sopenharmony_ci};
551e934351Sopenharmony_ci
561e934351Sopenharmony_ciclass TlsSocketTest : public testing::Test {
571e934351Sopenharmony_cipublic:
581e934351Sopenharmony_ci    static void SetUpTestCase() {}
591e934351Sopenharmony_ci
601e934351Sopenharmony_ci    static void TearDownTestCase() {}
611e934351Sopenharmony_ci
621e934351Sopenharmony_ci    virtual void SetUp() {}
631e934351Sopenharmony_ci
641e934351Sopenharmony_ci    virtual void TearDown() {}
651e934351Sopenharmony_ci};
661e934351Sopenharmony_ci} // namespace TlsSocket
671e934351Sopenharmony_ci} // namespace NetStack
681e934351Sopenharmony_ci} // namespace OHOS
691e934351Sopenharmony_ci#endif // TLS_UTILS_TEST_H
70