# Targets definition
-SET(TARGET_SEC_SRV_CLIENT_TESTS "security-server-tests-client")
SET(TARGET_SEC_SRV_CLIENT_SMACK_TESTS "security-server-tests-client-smack")
SET(TARGET_SEC_SRV_LABEL_TESTS "security-server-tests-label")
SET(TARGET_SEC_SRV_PID_TESTS "security-server-tests-pid-reuser")
# Sources definition
-SET(SEC_SRV_CLIENT_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_client.cpp
- )
-
SET(SEC_SRV_CLIENT_SMACK_SOURCES
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_client_smack.cpp
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_mockup.cpp
#LINK_DIRECTORIES(${SEC_SRV_PKGS_LIBRARY_DIRS})
-ADD_EXECUTABLE(${TARGET_SEC_SRV_CLIENT_TESTS} ${SEC_SRV_CLIENT_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} ${SEC_SRV_CLIENT_SMACK_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_LABEL_TESTS} ${SEC_SRV_LABEL_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_PID_TESTS} ${SEC_SRV_PID_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_PWD_TESTS} ${SEC_SRV_PWD_SOURCES})
-TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_CLIENT_TESTS}
- ${SEC_SRV_TESTS_DEP_LIBRARIES})
-
TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_CLIENT_SMACK_TESTS}
${SEC_SRV_TESTS_DEP_LIBRARIES})
# Installation
-INSTALL(TARGETS ${TARGET_SEC_SRV_CLIENT_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_LABEL_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_PID_TESTS} DESTINATION /usr/bin)
+++ /dev/null
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- */
-/*
- * @file security_server_tests_client.cpp
- * @author Bumjin Im (bj.im@samsung.com)
- * @author Mariusz Domanski (m.domanski@samsung.com)
- * @version 1.0
- * @brief Test cases for security server client
- */
-
-#include <dpl/test/test_runner.h>
-#include <dlog.h>
-#include "security_server_tests_client.h"
-
-RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_CLIENT)
-
-RUNNER_TEST(tc_security_server_get_cookie_size)
-{
- int ret = security_server_get_cookie_size();
- LOGD("ret = %d", ret);
- RUNNER_ASSERT(ret == 20);
-}
-
-RUNNER_TEST(tc_security_server_request_cookie_normal_case)
-{
- int ret = security_server_request_cookie(cookie, 20);
- LOGD("ret = %d", ret);
- RUNNER_ASSERT(ret == SECURITY_SERVER_API_SUCCESS);
-}
-
-RUNNER_TEST(tc_security_server_request_cookie_too_small_buffer_size)
-{
- int ret = security_server_request_cookie(cookie, 10);
- LOGD("ret = %d", ret);
- RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL);
-}
-
-RUNNER_TEST(tc_security_server_check_privilege_client_is_not_allowed)
-{
- int ret = security_server_check_privilege(cookie, g_permissions[0]);
- LOGD("ret = %d", ret);
- RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_AUTHENTICATION_FAILED);
-}
-
-RUNNER_TEST(tc_security_server_get_gid_client_is_not_allowed)
-{
- int ret = security_server_get_gid("telephony");
- LOGD("ret = %d", ret);
- RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_AUTHENTICATION_FAILED);
-}
-
-RUNNER_TEST(tc_security_server_get_object_name_client_is_not_allowed)
-{
- int ret = security_server_get_object_name(g_groups[0], tmpchar,
- sizeof(tmpchar));
- LOGD("ret = %d", ret);
- RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_AUTHENTICATION_FAILED);
-}
-
-RUNNER_TEST(tc_requesting_access_to_test_server_via_security_server)
-{
- for(i=0;i<g_perm_num;i++)
- {
- sock_fd = connect_to_testserver();
- if(sock_fd < 1)
- {
- LOGD("sock_fd = %d", sock_fd);
- RUNNER_ASSERT_MSG(false, "Socket connection error");
- }
- LOGD("%d: requesting %d permission...sockfd=%d\n", i, g_permissions[i],
- sock_fd);
- int ret = send_request(sock_fd, (unsigned char *) cookie,
- g_permissions[i]);
-
- if(ret != 0)
- {
- close(sock_fd);
- LOGD("ret = %d", ret);
- RUNNER_ASSERT_MSG(false, "send failed");
- }
-
- ret = recv_result(sock_fd);
- close(sock_fd);
- sock_fd = 0;
- if(ret == SECURITY_SERVER_API_SUCCESS)
- {
- LOGD("Permission granted\n");
- }
- else if(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- LOGD("Permission denied\n\n");
- RUNNER_ASSERT_MSG(false, "Permission denied");
- }
- else
- {
- LOGD("ret = %d", ret);
- RUNNER_ASSERT_MSG(false, "Recv error");
- }
- }
-}
-
-RUNNER_TEST(tc_requesting_cookie_for_same_pid_with_different_path)
-{
- LOGI(" Exiting this process to cycle different process as same PID.\n");
- LOGI(" Please look at the test server's terminal for the result\n");
- cur_pid = getpid();
- sock_fd = connect_to_testserver();
- if(sock_fd < 1)
- {
- RUNNER_ASSERT_MSG(false, "Socket connection error");
- }
-
- unsigned char buf[32] = {255, 255, 255, 255, };
- int size;
-
- memcpy(buf + 4, cookie, 20);
- memcpy(buf + 24, &cur_pid, sizeof(int));
- int ret = getuid();
- memcpy(buf + 28, &ret, sizeof(int));
-
- size = write(sock_fd, buf, 32);
- if(size < 32)
- {
- close(sock_fd);
- LOGD("size = %d", size);
- RUNNER_ASSERT_MSG(false, "Cannot send");
- }
- if(sock_fd > 0)
- close(sock_fd);
-}
-
-
-int main(int argc, char *argv[])
-{
- /* needed for dlog to work properly
- * during tests guid changes and dlog looses permission to write logs
- * printing log now opens file descriptor with proper privileges */
- LOGD("%s starts", argv[0]);
-
- g_group_num = 0;
- g_perm_num = 0;
-
- int ret = getuid();
- if(ret != 0)
- {
- printf("You must be root to test. Current UID: %d\nExiting...\n", ret);
- exit(1);
- }
-
- int argcc = 15;
- char *argvv[] = {argv[0], "-u", "5000",
- "-g", "6001", "6002", "6003", "6004", "6005", "6006", "6007",
- "-p", "6001", "6002", "6010"};
-
- system("touch /opt/home/root/pid_cycle");
- privilege_control(argcc, argvv);
-
- LOGI("Strting test. My PID is %d", getpid());
-
- int status =
- DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-
- if(g_groups != NULL)
- free(g_groups);
- if(g_permissions != NULL)
- free(g_permissions);
- return status;
-}