--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "cert-svc/ccert.h"
+#include "test_common.h"
+#include "test_constant.h"
+#include "test_macros.h"
+#include "vcore/Client.h"
+#include <cstring>
+
+static const std::string ValidGname = "9737fca362f1e671c1ca21a8e9a7a01e9acda93f";
+static const std::string CommonName = "TEST_PEM_CLIENT";
+
+const std::string LargeString = createLargeString(VCORE_MAX_FILENAME_SIZE + 1);
+
+BOOST_AUTO_TEST_SUITE(VCORE_CLIENT_TEST)
+
+POSITIVE_TEST_CASE(T_vcore_client_install_certificate_to_store)
+{
+ int result;
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ PemCertInfo::CertPEM.c_str(),
+ static_cast<size_t>(PemCertInfo::CertPEM.size()),
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+}
+
+NEGATIVE_TEST_CASE(T_vcore_client_install_certificate_to_store_wrong_argument)
+{
+ int result;
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ NULL,
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_FAIL);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ PemCertInfo::CertPEM.c_str(),
+ 0,
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_FAIL);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ LargeString.c_str(),
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ PemCertInfo::CertPEM.c_str(),
+ static_cast<size_t>(PemCertInfo::CertPEM.size()),
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ LargeString.c_str(),
+ NULL,
+ NULL,
+ PemCertInfo::CertPEM.c_str(),
+ static_cast<size_t>(PemCertInfo::CertPEM.size()),
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ LargeString.c_str(),
+ NULL,
+ PemCertInfo::CertPEM.c_str(),
+ static_cast<size_t>(PemCertInfo::CertPEM.size()),
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ NULL,
+ LargeString.c_str(),
+ PemCertInfo::CertPEM.c_str(),
+ static_cast<size_t>(PemCertInfo::CertPEM.size()),
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ PemCertInfo::CertPEM.c_str(),
+ static_cast<size_t>(PemCertInfo::CertPEM.size()),
+ INVALID_DATA);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_BAD_ALLOC);
+
+ const std::string LargeCert = createLargeString(VCORE_MAX_SEND_DATA_SIZE + 1);
+ result = vcore_client_install_certificate_to_store(
+ VPN_STORE,
+ ValidGname.c_str(),
+ CommonName.c_str(),
+ NULL,
+ NULL,
+ LargeCert.c_str(),
+ static_cast<size_t>(VCORE_MAX_SEND_DATA_SIZE + 1),
+ PEM_CRT);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file