SET(TARGET_SEC_SRV_CLIENT_SMACK_TESTS "security-server-tests-client-smack")
SET(TARGET_SEC_SRV_TC_SERVER_TESTS "security-server-tests-server")
SET(TARGET_SEC_SRV_PWD_TESTS "security-server-tests-password")
+SET(TARGET_SEC_SRV_PRIVILEGE_TESTS "security-server-tests-privilege")
SET(TARGET_SEC_SRV_STRESS_TESTS "security-server-tests-stress")
SET(TARGET_SEC_SRV_MT_TESTS "security-server-tests-mt")
SET(TARGET_SEC_SRV_DBUS_TESTS "security-server-tests-dbus")
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_clean_env.cpp
)
+SET(SEC_SRV_PRIVILEGE_SOURCES
+ ${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_privilege.cpp
+ ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp
+ )
+
SET(SEC_SRV_STRESS_SOURCES
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_stress.cpp
)
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/tests/common/
${PROJECT_SOURCE_DIR}/tests/security-server-tests/common/
+ ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/common/
)
ADD_DEFINITIONS("-I/usr/include/dbus-1.0/dbus")
ADD_EXECUTABLE(${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} ${SEC_SRV_CLIENT_SMACK_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_TC_SERVER_TESTS} ${SEC_SRV_TC_SERVER_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_PWD_TESTS} ${SEC_SRV_PWD_SOURCES})
+ADD_EXECUTABLE(${TARGET_SEC_SRV_PRIVILEGE_TESTS} ${SEC_SRV_PRIVILEGE_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_STRESS_TESTS} ${SEC_SRV_STRESS_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_MT_TESTS} ${SEC_SRV_MT_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_DBUS_TESTS} ${SEC_SRV_DBUS_SOURCES})
${SEC_SRV_TESTS_DEP_LIBRARIES}
tests-common)
+TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_PRIVILEGE_TESTS}
+ ${SEC_SRV_TESTS_DEP_LIBRARIES}
+ tests-common)
+
TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_STRESS_TESTS}
${SEC_SRV_TESTS_DEP_LIBRARIES}
tests-common)
INSTALL(TARGETS ${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_TC_SERVER_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_PWD_TESTS} DESTINATION /usr/bin)
+INSTALL(TARGETS ${TARGET_SEC_SRV_PRIVILEGE_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_STRESS_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_MT_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_DBUS_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_MEASURER} DESTINATION /usr/bin)
+
+INSTALL(FILES
+ ${PROJECT_SOURCE_DIR}/tests/security-server-tests/WRT_sstp_test_rules1.smack
+ DESTINATION /usr/share/privilege-control/
+)
+
+INSTALL(FILES
+ ${PROJECT_SOURCE_DIR}/tests/security-server-tests/WRT_sstp_test_rules2.smack
+ DESTINATION /usr/share/privilege-control/
+)
--- /dev/null
+#include <dpl/test/test_runner.h>
+
+#include <summary_collector.h>
+
+#include <libprivilege-control_test_common.h>
+
+#include <security-server.h>
+#include <privilege-control.h>
+
+const char *SSTP_APP_ID = "sstp_test_app";
+const char *SSTP_OTHER_LABEL = "sstp_test_other_label";
+
+const char *SSTP_PERMS[] = {
+ "sstp_test_rules1",
+ "sstp_test_rules2",
+ NULL
+};
+
+const char *SSTP_PERMS1[] = {
+ SSTP_PERMS[0],
+ NULL
+};
+
+const char *SSTP_PERMS2[] = {
+ SSTP_PERMS[1],
+ NULL
+};
+
+void check_security_server_app_has_privilege(const char *app_label,
+ const char *permission,
+ int is_enabled_expected)
+{
+ int result;
+ int is_enabled;
+
+ result = security_server_app_has_privilege(app_label, APP_TYPE_WGT, permission, &is_enabled);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error calling security_server_app_has_privilege. Result: " << result);
+
+ RUNNER_ASSERT_MSG_BT(is_enabled == is_enabled_expected,
+ "Result of security_server_app_has_privilege should be: " << is_enabled_expected);
+}
+
+RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_PRIVILEGE);
+
+RUNNER_TEST(sstp_01_security_server_app_has_privilege)
+{
+ int result;
+
+ DB_BEGIN
+
+ result = perm_app_uninstall(SSTP_APP_ID);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error uninstalling app. Result" << result);
+
+ result = perm_app_install(SSTP_APP_ID);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error installing app. Result" << result);
+
+ result = perm_app_disable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error disabling app r and no r permissions. Result: " << result);
+
+ DB_END
+
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[1], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[1], 0);
+
+ DB_BEGIN
+
+ result = perm_app_enable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS1, false);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error registering app r permissions. Result: " << result);
+
+ DB_END
+
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[0], 1);
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[1], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[1], 0);
+
+ DB_BEGIN
+
+ result = perm_app_enable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS2, false);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error registering app r permissions. Result: " << result);
+
+ DB_END
+
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[0], 1);
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[1], 1);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[1], 0);
+
+ DB_BEGIN
+
+ result = perm_app_disable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS1);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error disabling app r and no r permissions. Result: " << result);
+
+ DB_END
+
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[1], 1);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[1], 0);
+
+ DB_BEGIN
+
+ result = perm_app_disable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS2);
+ RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+ "Error disabling app r and no r permissions. Result: " << result);
+
+ DB_END
+
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(USER_APP_ID, SSTP_PERMS[1], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[0], 0);
+ check_security_server_app_has_privilege(SSTP_OTHER_LABEL, SSTP_PERMS[1], 0);
+}
+
+int main(int argc, char *argv[])
+{
+ SummaryCollector::Register();
+ return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}