Add dummy unit test for AppCustomTrustAnchor 21/109721/2
authorsangwan.kwon <sangwan.kwon@samsung.com>
Wed, 11 Jan 2017 09:04:29 +0000 (18:04 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Wed, 11 Jan 2017 09:12:52 +0000 (18:12 +0900)
Change-Id: Iec6e7e367cfe4cbc6e690a52afd8e2a3dbc5bc55
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
tests/CMakeLists.txt
tests/transec/CMakeLists.txt [new file with mode: 0644]
tests/transec/main.cpp [new file with mode: 0644]
tests/transec/test-app-custom-trust-anchor.cpp [new file with mode: 0644]

index 5950646..7118186 100644 (file)
@@ -17,6 +17,7 @@ SET(TARGET_CAPI_TEST "cert-svc-tests-capi")
 SET(TARGET_PKCS12_TEST "cert-svc-tests-pkcs12")
 SET(TARGET_VCORE_TEST "cert-svc-tests-vcore")
 SET(TARGET_PLUGIN_SAMPLE "cert-svc-validator-plugin")
+SET(TARGET_TRANSEC_TEST "cert-svc-tests-transec")
 
 PKG_CHECK_MODULES(TEST_DEP
     REQUIRED
@@ -54,3 +55,4 @@ ADD_SUBDIRECTORY(pkcs12)
 ADD_SUBDIRECTORY(vcore)
 ADD_SUBDIRECTORY(plugin)
 ADD_SUBDIRECTORY(upgrade)
+ADD_SUBDIRECTORY(transec)
diff --git a/tests/transec/CMakeLists.txt b/tests/transec/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ed5ae88
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright (c) 2017 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.
+#
+# @file        CMakeLists.txt
+# @author      Sangwan Kwon (sangwan.kwon@samsung.com)
+# @breif
+#
+SET(TEST_SRCS
+       main.cpp
+       test-app-custom-trust-anchor.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       SYSTEM
+       ${PROJECT_SOURCE_DIR}/src/transec
+)
+
+ADD_EXECUTABLE(${TARGET_TRANSEC_TEST}
+       ${TEST_SRCS}
+       ${DPL_TEST_SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_TRANSEC_TEST}
+       ${TARGET_VCORE_LIB}
+       ${TARGET_TRANSEC_LIB}
+       ${TEST_DEP_LIBRARIES}
+)
+
+INSTALL(TARGETS
+                       ${TARGET_TRANSEC_TEST}
+               DESTINATION
+                       ${BIN_DIR}
+               PERMISSIONS
+                       OWNER_READ
+                       OWNER_WRITE
+                       OWNER_EXECUTE
+                       GROUP_READ
+                       GROUP_EXECUTE
+                       WORLD_READ
+                       WORLD_EXECUTE
+)
diff --git a/tests/transec/main.cpp b/tests/transec/main.cpp
new file mode 100644 (file)
index 0000000..3b1a265
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+/*
+ * @file        main.cpp
+ * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main
+ */
+
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+       VcoreDPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+       return 0;
+}
+
diff --git a/tests/transec/test-app-custom-trust-anchor.cpp b/tests/transec/test-app-custom-trust-anchor.cpp
new file mode 100644 (file)
index 0000000..93df5c5
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2017 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.
+ */
+/*
+ * @file        test-app-custom-trust-anchor.cpp
+ * @author      Sangwan Kwon (sangwan.kwon@samsung.com)
+ * @version     0.1
+ * @brief       Unit test program of AppCustomTrustAnchor
+ */
+
+#include <dpl/test/test_runner.h>
+
+#include <AppCustomTrustAnchor.h>
+
+#define DUMMY_PKG_ID "dummmy-pkg-id"
+#define DUMMY_CERTS_DIR "/home/dummy"
+#define DUMMY_UID 5001
+
+RUNNER_TEST_GROUP_INIT(T0400_API_ACTA)
+
+using namespace transec;
+
+RUNNER_TEST(T0401_ACTA_INSTALL_GLOBAL_APP_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.install(false);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA install should be success.");
+}
+
+RUNNER_TEST(T0402_ACTA_INSTALL_GLOBAL_APP_WITH_SYS_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.install(true);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA install should be success.");
+}
+
+RUNNER_TEST(T0403_ACTA_INSTALL_USER_APP_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.install(false);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA install should be success.");
+}
+
+RUNNER_TEST(T0404_ACTA_INSTALL_USER_APP_WITH_SYS_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.install(true);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA install should be success.");
+}
+
+RUNNER_TEST(T0405_ACTA_INSTALL_GLOBAL_APP_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.install(false);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA install should be fail.");
+}
+
+RUNNER_TEST(T0406_ACTA_INSTALL_GLOBAL_APP_WITH_SYS_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.install(true);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA install should be fail.");
+}
+
+RUNNER_TEST(T0407_ACTA_INSTALL_USER_APP_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.install(false);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA install should be fail.");
+}
+
+RUNNER_TEST(T0408_ACTA_INSTALL_USER_APP_WITH_SYS_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.install(true);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA install should be fail.");
+}
+
+RUNNER_TEST(T0421_ACTA_UNINSTALL_GLOBAL_APP_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.uninstall();
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA uninstall should be success.");
+}
+
+RUNNER_TEST(T0422_ACTA_UNINSTALL_USER_APP_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.uninstall();
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA uninstall should be success.");
+}
+
+RUNNER_TEST(T0423_ACTA_UNINSTALL_GLOBAL_APP_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.uninstall();
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA uninstall should be fail.");
+}
+
+RUNNER_TEST(T0424_ACTA_INSTALL_USER_APP_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.uninstall();
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA uninstall should be fail.");
+}
+
+RUNNER_TEST(T0441_ACTA_LAUNCH_GLOBAL_APP_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.launch(false);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA launch should be success.");
+}
+
+RUNNER_TEST(T0442_ACTA_LAUNCH_GLOBAL_APP_WITH_SYS_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.launch(true);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA launch should be success.");
+}
+
+RUNNER_TEST(T0443_ACTA_LAUNCH_USER_APP_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.launch(false);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA launch should be success.");
+}
+
+RUNNER_TEST(T0444_ACTA_INSTALL_USER_APP_WITH_SYS_POSITIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.launch(true);
+       RUNNER_ASSERT_MSG(ret == 0, "ACTA launch should be success.");
+}
+
+RUNNER_TEST(T0445_ACTA_LAUNCH_GLOBAL_APP_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.launch(false);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA launch should be fail.");
+}
+
+RUNNER_TEST(T0446_ACTA_LAUNCH_GLOBAL_APP_WITH_SYS_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR);
+       int ret = acta.launch(true);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA launch should be fail.");
+}
+
+RUNNER_TEST(T0447_ACTA_LAUNCH_USER_APP_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.launch(false);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA launch should be fail.");
+}
+
+RUNNER_TEST(T0448_ACTA_LAUNCH_USER_APP_WITH_SYS_NEGATIVE)
+{
+       AppCustomTrustAnchor acta(DUMMY_PKG_ID, DUMMY_CERTS_DIR, DUMMY_UID);
+       int ret = acta.launch(true);
+       RUNNER_ASSERT_MSG(ret != 0, "ACTA launch should be fail.");
+}