%{_bindir}/%{lib_name}-test-launcher
%{_bindir}/%{lib_name}-test-clauncher
%{_bindir}/%{lib_name}-test-internal
+%{_bindir}/%{lib_name}-test-ssl
%{_bindir}/%{lib_name}-test-init.sh
%{tanchor_test}
%{tanchor_test}/certs
test-util.cpp
test-capi-launcher.cpp)
SET(INTERNAL_SRCS main.cpp
- test-curl.cpp
test-util.cpp
test-certificate.cpp
-
${TANCHOR_SRC}/certificate.cpp)
+SET(SSL_SRCS main.cpp
+ test-curl.cpp
+ test-util.cpp)
SET(TEST_INSTALLER ${TARGET_TANCHOR_TEST}-installer)
SET(TEST_LAUNCHER ${TARGET_TANCHOR_TEST}-launcher)
SET(TEST_CLAUNCHER ${TARGET_TANCHOR_TEST}-clauncher)
SET(TEST_INTERNAL ${TARGET_TANCHOR_TEST}-internal)
+SET(TEST_SSL ${TARGET_TANCHOR_TEST}-ssl)
BUILD_TEST(${TEST_INSTALLER} "${INSTALLER_SRCS}")
BUILD_TEST(${TEST_LAUNCHER} "${LAUNCHER_SRCS}")
BUILD_TEST(${TEST_CLAUNCHER} "${CAPI_LAUNCHER_SRCS}")
BUILD_TEST(${TEST_INTERNAL} "${INTERNAL_SRCS}")
+BUILD_TEST(${TEST_SSL} "${SSL_SRCS}")
ADD_SUBDIRECTORY(res)
ADD_SUBDIRECTORY(script)
* @brief Unit test program of Curl
*/
+#include <tanchor/trust-anchor.hxx>
+
#include <klay/testbench.h>
+#include <unistd.h>
+
#include <iostream>
-#include <stdexcept>
#include "test-util.hxx"
#include "test-resource.hxx"
if (ret != 0)
std::cout << "Check wifi connection.." << std::endl;
}
+
+TESTCASE(TRUST_ANCHOR_LAUNCH)
+{
+ tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR);
+ int ret = ta.install(false);
+ TEST_EXPECT(true, ret == 0);
+
+ std::cout << "##########################################" << std::endl;
+ std::cout << "## Before trust-anchor launch#############" << std::endl;
+ std::cout << "##########################################" << std::endl;
+ ret = test::util::connectSSL("https://google.com");
+ TEST_EXPECT(true, ret == 0);
+
+ // pre-condition
+ int pid = fork();
+ TEST_EXPECT(true, pid >= 0);
+
+ if (pid == 0) {
+ ret = ta.launch(false);
+ TEST_EXPECT(true, ret == 0);
+
+ // check SSL communication
+ std::cout << "##########################################" << std::endl;
+ std::cout << "## After trust-anchor launch(APP)#########" << std::endl;
+ std::cout << "##########################################" << std::endl;
+ ret = test::util::connectSSL("https://google.com");
+ TEST_EXPECT(false, ret == 0);
+
+ exit(0);
+ } else {
+ std::cout << "##########################################" << std::endl;
+ std::cout << "## After trust-anchor launch(parent)######" << std::endl;
+ std::cout << "##########################################" << std::endl;
+ ret = test::util::connectSSL("https://google.com");
+ TEST_EXPECT(true, ret == 0);
+ }
+}
+
+TESTCASE(TRUST_ANCHOR_LAUNCH_WITH_SYS)
+{
+ tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR);
+ int ret = ta.install(true);
+ TEST_EXPECT(true, ret == 0);
+
+ std::cout << "##########################################" << std::endl;
+ std::cout << "## Before trust-anchor launch#############" << std::endl;
+ std::cout << "##########################################" << std::endl;
+ ret = test::util::connectSSL("https://google.com");
+ TEST_EXPECT(true, ret == 0);
+
+ // pre-condition
+ int pid = fork();
+ TEST_EXPECT(true, pid >= 0);
+
+ if (pid == 0) {
+ ret = ta.launch(true);
+ TEST_EXPECT(true, ret == 0);
+
+ // check SSL communication
+ std::cout << "###########################################" << std::endl;
+ std::cout << "## After trust-anchor launch(APP) with SYS#" << std::endl;
+ std::cout << "###########################################" << std::endl;
+ ret = test::util::connectSSL("https://google.com");
+ TEST_EXPECT(true, ret == 0);
+
+ exit(0);
+ } else {
+ std::cout << "##########################################" << std::endl;
+ std::cout << "## After trust-anchor launch(parent)######" << std::endl;
+ std::cout << "##########################################" << std::endl;
+ ret = test::util::connectSSL("https://google.com");
+ TEST_EXPECT(true, ret == 0);
+ }
+}
tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR);
int ret = ta.install(false);
-
- std::cout << "##########################################" << std::endl;
- std::cout << "## Before trust-anchor launch#############" << std::endl;
- std::cout << "##########################################" << std::endl;
- ret = test::util::connectSSL("https://google.com");
TEST_EXPECT(true, ret == 0);
// pre-condition
auto afterCatChild = test::util::cat(TZ_SYS_RO_CA_BUNDLE);
TEST_EXPECT(true, beforeCat != afterCatChild);
- // check SSL communication
- std::cout << "##########################################" << std::endl;
- std::cout << "## After trust-anchor launch(APP)#########" << std::endl;
- std::cout << "##########################################" << std::endl;
- ret = test::util::connectSSL("https://google.com");
- TEST_EXPECT(false, ret == 0);
-
exit(0);
} else {
auto afterLsParent = test::util::ls(TZ_SYS_RO_CA_CERTS);
auto afterCatParent = test::util::cat(TZ_SYS_RO_CA_BUNDLE);
TEST_EXPECT(true, beforeCat == afterCatParent);
-
- std::cout << "##########################################" << std::endl;
- std::cout << "## After trust-anchor launch(parent)######" << std::endl;
- std::cout << "##########################################" << std::endl;
- ret = test::util::connectSSL("https://google.com");
- TEST_EXPECT(true, ret == 0);
}
}
tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR);
int ret = ta.install(true);
-
- std::cout << "##########################################" << std::endl;
- std::cout << "## Before trust-anchor launch#############" << std::endl;
- std::cout << "##########################################" << std::endl;
- ret = test::util::connectSSL("https://google.com");
TEST_EXPECT(true, ret == 0);
// pre-condition
auto afterCatChild = test::util::cat(TZ_SYS_RO_CA_BUNDLE);
TEST_EXPECT(true, beforeCat != afterCatChild);
- // check SSL communication
- std::cout << "###########################################" << std::endl;
- std::cout << "## After trust-anchor launch(APP) with SYS#" << std::endl;
- std::cout << "###########################################" << std::endl;
- ret = test::util::connectSSL("https://google.com");
- TEST_EXPECT(true, ret == 0);
-
exit(0);
} else {
auto afterLsParent = test::util::ls(TZ_SYS_RO_CA_CERTS);
auto afterCatParent = test::util::cat(TZ_SYS_RO_CA_BUNDLE);
TEST_EXPECT(true, beforeCat == afterCatParent);
-
- std::cout << "##########################################" << std::endl;
- std::cout << "## After trust-anchor launch(parent)######" << std::endl;
- std::cout << "##########################################" << std::endl;
- ret = test::util::connectSSL("https://google.com");
- TEST_EXPECT(true, ret == 0);
}
}
curl_easy_setopt(curl.get(), CURLOPT_URL, addr.c_str());
CURLcode res = curl_easy_perform(curl.get());
- if(res != CURLE_OK) {
+ if (res != CURLE_OK) {
std::cout << "Failed to connect failed: "
<< curl_easy_strerror(res) << std::endl;
return -1;