SM: Code cleanup - separate register paths tests 33/85533/1
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 25 Aug 2016 14:30:19 +0000 (16:30 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Thu, 25 Aug 2016 14:39:49 +0000 (16:39 +0200)
Change-Id: I63b833b6a39f285708c207b2607a9e7e2e1c3823

src/security-manager-tests/CMakeLists.txt
src/security-manager-tests/common/sm_commons.h
src/security-manager-tests/security_manager_tests.cpp
src/security-manager-tests/test_cases_register_paths.cpp [new file with mode: 0644]

index b51304f..c17b71a 100644 (file)
@@ -44,6 +44,7 @@ SET(SEC_MGR_SOURCES
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_dyntransition.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_privacy_manager.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_private_sharing.cpp
+    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_register_paths.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_trusted_sharing.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/security_manager_tests.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_api.cpp
index b2296ca..ec0210b 100644 (file)
 
 #pragma once
 
+#include <ftw.h>
 #include <string>
 #include <sys/capability.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 #include <vector>
 
index 20aa252..5ecfda0 100644 (file)
  *    limitations under the License.
  */
 
+#include <cstdlib>
 #include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <sys/inotify.h>
-#include <sys/ioctl.h>
-#include <sys/prctl.h>
-#include <sys/smack.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <ctime>
-
-#include <algorithm>
 #include <fstream>
+#include <map>
 #include <regex>
+#include <stdio.h>
 #include <string>
+#include <sys/smack.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include <unordered_set>
 
-#include <ftw.h>
-#include <grp.h>
-#include <poll.h>
-
-#include <access_provider.h>
-#include <app_install_helper.h>
 #include <cynara_test_admin.h>
-#include <cynara_test_client.h>
-#include <dpl/log/log.h>
 #include <dpl/test/test_runner.h>
-#include <memory.h>
-#include <passwd_access.h>
-#include <service_manager.h>
 #include <sm_api.h>
 #include <sm_commons.h>
 #include <sm_db.h>
+#include <sm_policy_request.h>
 #include <sm_request.h>
-#include <sm_user_request.h>
-#include <synchronization_pipe.h>
 #include <temp_test_user.h>
 #include <tests_common.h>
 #include <tzplatform.h>
-#include <uds.h>
 
 using namespace SecurityManagerTest;
 
@@ -209,7 +188,6 @@ RUNNER_CHILD_TEST(security_manager_21_security_manager_admin_deny_user_priv)
     }
 }
 
-
 RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_CMD)
 
 RUNNER_TEST(security_manager_19_security_manager_cmd_install)
@@ -583,7 +561,6 @@ RUNNER_TEST(security_manager_27p_API30_app_uninstall)
     };
 }
 
-
 RUNNER_CHILD_TEST(security_manager_53_app_has_privilege)
 {
     const char *const sm_app_id = "sm_test_53_app";
@@ -864,414 +841,6 @@ RUNNER_TEST(security_manager_50_app_install_constraint_check)
     install(users[0], pkgId[0], appId[0], version[0], author[1], SECURITY_MANAGER_ERROR_INPUT_PARAM);
 }
 
-RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_REGISTER_PATH)
-
-RUNNER_TEST(security_manager_54_path_req_no_pkg)
-{
-    const char *const sm_app_id = "sm_test_54_app_id";
-    const char *const sm_pkg_id = "sm_test_54_pkg_id";
-
-    TemporaryTestUser user("sm_test_54_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    PathsRequest req;
-    req.setPkgId("non-existing-pkg-id");
-    req.setUid(user.getUid());
-    req.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(req, (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
-}
-
-RUNNER_TEST(security_manager_55_path_req_empty_pkg)
-{
-    const char *const sm_app_id = "sm_test_55_app_id";
-    const char *const sm_pkg_id = "sm_test_55_pkg_id";
-
-    TemporaryTestUser user("sm_test_55_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    PathsRequest req;
-    req.setPkgId("");
-    req.setUid(user.getUid());
-    req.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(req, (lib_retcode)SECURITY_MANAGER_ERROR_REQ_NOT_COMPLETE);
-}
-
-RUNNER_TEST(security_manager_56_path_req_wrong_type)
-{
-    PathsRequest req;
-    req.setInstallType(SM_APP_INSTALL_END,
-                       (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
-    req.setInstallType((app_install_type)(SM_APP_INSTALL_NONE-1),
-                       (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
-}
-
-RUNNER_TEST(security_manager_57_path_req_wrong_uid)
-{
-    const char *const sm_app_id = "sm_test_57_app_id";
-    const char *const sm_pkg_id = "sm_test_57_pkg_id";
-
-    TemporaryTestUser user("sm_test_57_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(-1);
-    preq.setInstallType(SM_APP_INSTALL_LOCAL);
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_SERVER_ERROR);
-}
-
-RUNNER_TEST(security_manager_58_path_req_empty_paths)
-{
-    const char *const sm_app_id = "sm_test_58_app_id";
-    const char *const sm_pkg_id = "sm_test_58_pkg_id";
-
-    TemporaryTestUser user("sm_test_58_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    PathsRequest req;
-    req.setPkgId(sm_pkg_id);
-    req.setUid(user.getUid());
-    Api::registerPaths(req);
-}
-
-RUNNER_TEST(security_manager_59_path_req_as_root_positive)
-{
-    const char *const sm_app_id = "sm_test_59_app_id";
-    const char *const sm_pkg_id = "sm_test_59_pkg_id";
-
-    TemporaryTestUser user("sm_test_59_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
-}
-
-RUNNER_CHILD_TEST(security_manager_60_path_req_as_user_positive)
-{
-    const char *const sm_app_id = "sm_test_60_app_id";
-    const char *const sm_pkg_id = "sm_test_60_pkg_id";
-
-    TemporaryTestUser user("sm_test_60_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    int result = drop_root_privileges(user.getUid(), user.getGid());
-    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
-}
-
-RUNNER_CHILD_TEST(security_manager_61_path_req_different_user)
-{
-    const char *const sm_app_id = "sm_test_61_app_id";
-    const char *const sm_pkg_id = "sm_test_61_pkg_id";
-
-    TemporaryTestUser user1("sm_test_61_1_user_name", GUM_USERTYPE_NORMAL, false);
-    user1.create();
-    TemporaryTestUser user2("sm_test_61_2_user_name", GUM_USERTYPE_NORMAL, false);
-    user2.create();
-
-    std::string path = TzPlatformConfig::appDirPath(user2, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user2, sm_app_id, sm_pkg_id);
-    createTestDirs(user2, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user2.getUid());
-
-    int result = drop_root_privileges(user1.getUid(), user1.getGid());
-    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user2.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
-}
-
-void testPathOutside(const std::string& pkgId, uid_t uid, const std::string& path)
-{
-    PathsRequest preq;
-    preq.setPkgId(pkgId);
-    preq.setUid(uid);
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
-}
-
-RUNNER_TEST(security_manager_62_path_req_path_outside)
-{
-    const char *const sm_app_id = "sm_test_62_app_id";
-    const char *const sm_pkg_id = "sm_test_62_pkg_id";
-
-    TemporaryTestUser user1("sm_test_62_1_user_name", GUM_USERTYPE_NORMAL, false);
-    user1.create();
-    TemporaryTestUser user2("sm_test_62_2_user_name", GUM_USERTYPE_NORMAL, false);
-    user2.create();
-
-    install_app(sm_app_id, sm_pkg_id, user1.getUid());
-
-    removeTestDirs(user1, sm_app_id, sm_pkg_id);
-    removeTestDirs(user2, sm_app_id, sm_pkg_id);
-    createTestDirs(user1, sm_app_id, sm_pkg_id);
-    createTestDirs(user2, sm_app_id, sm_pkg_id);
-
-    testPathOutside(sm_pkg_id, user1.getUid(),
-                    TzPlatformConfig::appDirPath(user2, sm_app_id, sm_pkg_id));
-    testPathOutside(sm_pkg_id, user1.getUid(),
-                    TzPlatformConfig::appDirPath(user1, sm_app_id, "sm_test_62_non_existing_pkg_id"));
-    testPathOutside(sm_pkg_id, user1.getUid(), std::string("/home/") + user1.getUserName());
-}
-
-void testPathsReqAsUser(const enum app_install_type &type, lib_retcode expectedResult) {
-    const char *const sm_app_id = "sm_test_63_app_id";
-    const char *const sm_pkg_id = "sm_test_63_pkg_id";
-
-    TemporaryTestUser user("sm_test_63_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    int result = drop_root_privileges(user.getUid(), user.getGid());
-    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.setInstallType(type);
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, expectedResult);
-}
-
-RUNNER_CHILD_TEST(security_manager_63a_path_req_as_user)
-{
-    testPathsReqAsUser(SM_APP_INSTALL_GLOBAL,
-                           (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
-}
-
-RUNNER_CHILD_TEST(security_manager_63b_path_req_preloaded_as_user)
-{
-    testPathsReqAsUser(SM_APP_INSTALL_PRELOADED,
-                           (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
-}
-
-void testPathsReqLocal(uid_t uid, gid_t gid)
-{
-    const char *const sm_app_id = "sm_test_64_app_id";
-    const char *const sm_pkg_id = "sm_test_64_pkg_id";
-
-    TemporaryTestUser user("sm_test_64_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    int result = drop_root_privileges(uid, gid);
-    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.setInstallType(SM_APP_INSTALL_LOCAL);
-    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
-}
-
-
-RUNNER_CHILD_TEST(security_manager_64a_path_req_as_local_as_root)
-{
-    testPathsReqLocal(0, 0);
-}
-
-RUNNER_CHILD_TEST(security_manager_64b_path_req_as_local_asuser)
-{
-    testPathsReqLocal(TzPlatformConfig::getGlobalUserId(), TzPlatformConfig::getGlobalGroupId());
-}
-
-RUNNER_TEST(security_manager_66_path_req_check_labels)
-{
-    const char *const sm_app_id = "sm_test_66_app_id_full";
-    const char *const sm_pkg_id = "sm_test_66_pkg_id_full";
-
-    std::string SM_RW_PATH = genRWPath(66);
-    std::string SM_RO_PATH = genROPath(66);
-    std::string SM_PUBLIC_RO_PATH = genPublicROPath(66);
-
-    prepare_app_env(66);
-
-    install_app(sm_app_id, sm_pkg_id);
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.addPath(SM_RW_PATH, SECURITY_MANAGER_PATH_RW);
-    preq.addPath(SM_RO_PATH, SECURITY_MANAGER_PATH_RO);
-    preq.addPath(SM_PUBLIC_RO_PATH, SECURITY_MANAGER_PATH_PUBLIC_RO);
-    Api::registerPaths(preq);
-
-    uninstall_app(sm_app_id, sm_pkg_id, true);
-}
-
-RUNNER_TEST(security_manager_67_path_req_shared_ro_3_0)
-{
-    const char *const sm_app_id = "sm_test_67_app_id";
-    const char *const sm_pkg_id = "sm_test_67_pkg_id";
-
-    TemporaryTestUser user("sm_test_67_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    InstallRequest ireq;
-    ireq.setAppId(sm_app_id);
-    ireq.setPkgId(sm_pkg_id);
-    ireq.setUid(user.getUid());
-    ireq.setAppTizenVersion("3.0");
-    Api::install(ireq);
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
-}
-
-RUNNER_TEST(security_manager_68_path_req_shared_ro_2_X)
-{
-    const char *const sm_app_id = "sm_test_68_app_id";
-    const char *const sm_pkg_id = "sm_test_68_pkg_id";
-
-    TemporaryTestUser user("sm_test_68_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    InstallRequest ireq;
-    ireq.setAppId(sm_app_id);
-    ireq.setPkgId(sm_pkg_id);
-    ireq.setUid(user.getUid());
-    ireq.setAppTizenVersion("2.4");
-    Api::install(ireq);
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
-
-    Api::registerPaths(preq);
-
-    // check labels
-    check_path(path, generatePkgLabel(sm_pkg_id) + "::SharedRO");
-}
-
-RUNNER_TEST(security_manager_69_path_req_trusted_rw_no_author)
-{
-    const char *const sm_app_id = "sm_test_69_app_id";
-    const char *const sm_pkg_id = "sm_test_69_pkg_id";
-
-    TemporaryTestUser user("sm_test_69_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    install_app(sm_app_id, sm_pkg_id, user.getUid());
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
-
-    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
-}
-
-RUNNER_TEST(security_manager_70_path_req_trusted_rw_positive)
-{
-    const char *const sm_app_id = "sm_test_70_app_id";
-    const char *const sm_pkg_id = "sm_test_70_pkg_id";
-    const char *const author_id = "sm_test_70_author_id";
-
-    TemporaryTestUser user("sm_test_70_user_name", GUM_USERTYPE_NORMAL, false);
-    user.create();
-    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
-
-    removeTestDirs(user, sm_app_id, sm_pkg_id);
-    createTestDirs(user, sm_app_id, sm_pkg_id);
-
-    InstallRequest ireq;
-    ireq.setAppId(sm_app_id);
-    ireq.setPkgId(sm_pkg_id);
-    ireq.setUid(user.getUid());
-    ireq.setAuthorId(author_id);
-    Api::install(ireq);
-
-    PathsRequest preq;
-    preq.setPkgId(sm_pkg_id);
-    preq.setUid(user.getUid());
-    preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
-
-    Api::registerPaths(preq);
-
-    // check labels
-    TestSecurityManagerDatabase dbtest;
-    int64_t authorDb = dbtest.get_author_id(author_id);
-    check_path(path, std::string("User::Author::") + std::to_string(authorDb));
-}
-
 int main(int argc, char *argv[])
 {
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
diff --git a/src/security-manager-tests/test_cases_register_paths.cpp b/src/security-manager-tests/test_cases_register_paths.cpp
new file mode 100644 (file)
index 0000000..252d440
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+ * 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.
+ */
+#include <cstdint>
+
+#include <dpl/test/test_runner.h>
+#include <sm_api.h>
+#include <sm_commons.h>
+#include <temp_test_user.h>
+#include <tests_common.h>
+#include <tzplatform.h>
+
+using namespace SecurityManagerTest;
+
+RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_REGISTER_PATH)
+
+RUNNER_TEST(security_manager_54_path_req_no_pkg)
+{
+    const char *const sm_app_id = "sm_test_54_app_id";
+    const char *const sm_pkg_id = "sm_test_54_pkg_id";
+
+    TemporaryTestUser user("sm_test_54_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    PathsRequest req;
+    req.setPkgId("non-existing-pkg-id");
+    req.setUid(user.getUid());
+    req.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(req, (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
+}
+
+RUNNER_TEST(security_manager_55_path_req_empty_pkg)
+{
+    const char *const sm_app_id = "sm_test_55_app_id";
+    const char *const sm_pkg_id = "sm_test_55_pkg_id";
+
+    TemporaryTestUser user("sm_test_55_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    PathsRequest req;
+    req.setPkgId("");
+    req.setUid(user.getUid());
+    req.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(req, (lib_retcode)SECURITY_MANAGER_ERROR_REQ_NOT_COMPLETE);
+}
+
+RUNNER_TEST(security_manager_56_path_req_wrong_type)
+{
+    PathsRequest req;
+    req.setInstallType(SM_APP_INSTALL_END,
+                       (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
+    req.setInstallType((app_install_type)(SM_APP_INSTALL_NONE-1),
+                       (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
+}
+
+RUNNER_TEST(security_manager_57_path_req_wrong_uid)
+{
+    const char *const sm_app_id = "sm_test_57_app_id";
+    const char *const sm_pkg_id = "sm_test_57_pkg_id";
+
+    TemporaryTestUser user("sm_test_57_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(-1);
+    preq.setInstallType(SM_APP_INSTALL_LOCAL);
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_SERVER_ERROR);
+}
+
+RUNNER_TEST(security_manager_58_path_req_empty_paths)
+{
+    const char *const sm_app_id = "sm_test_58_app_id";
+    const char *const sm_pkg_id = "sm_test_58_pkg_id";
+
+    TemporaryTestUser user("sm_test_58_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    PathsRequest req;
+    req.setPkgId(sm_pkg_id);
+    req.setUid(user.getUid());
+    Api::registerPaths(req);
+}
+
+RUNNER_TEST(security_manager_59_path_req_as_root_positive)
+{
+    const char *const sm_app_id = "sm_test_59_app_id";
+    const char *const sm_pkg_id = "sm_test_59_pkg_id";
+
+    TemporaryTestUser user("sm_test_59_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
+}
+
+RUNNER_CHILD_TEST(security_manager_60_path_req_as_user_positive)
+{
+    const char *const sm_app_id = "sm_test_60_app_id";
+    const char *const sm_pkg_id = "sm_test_60_pkg_id";
+
+    TemporaryTestUser user("sm_test_60_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    int result = drop_root_privileges(user.getUid(), user.getGid());
+    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
+}
+
+RUNNER_CHILD_TEST(security_manager_61_path_req_different_user)
+{
+    const char *const sm_app_id = "sm_test_61_app_id";
+    const char *const sm_pkg_id = "sm_test_61_pkg_id";
+
+    TemporaryTestUser user1("sm_test_61_1_user_name", GUM_USERTYPE_NORMAL, false);
+    user1.create();
+    TemporaryTestUser user2("sm_test_61_2_user_name", GUM_USERTYPE_NORMAL, false);
+    user2.create();
+
+    std::string path = TzPlatformConfig::appDirPath(user2, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user2, sm_app_id, sm_pkg_id);
+    createTestDirs(user2, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user2.getUid());
+
+    int result = drop_root_privileges(user1.getUid(), user1.getGid());
+    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user2.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
+}
+
+void testPathOutside(const std::string& pkgId, uid_t uid, const std::string& path)
+{
+    PathsRequest preq;
+    preq.setPkgId(pkgId);
+    preq.setUid(uid);
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
+}
+
+RUNNER_TEST(security_manager_62_path_req_path_outside)
+{
+    const char *const sm_app_id = "sm_test_62_app_id";
+    const char *const sm_pkg_id = "sm_test_62_pkg_id";
+
+    TemporaryTestUser user1("sm_test_62_1_user_name", GUM_USERTYPE_NORMAL, false);
+    user1.create();
+    TemporaryTestUser user2("sm_test_62_2_user_name", GUM_USERTYPE_NORMAL, false);
+    user2.create();
+
+    install_app(sm_app_id, sm_pkg_id, user1.getUid());
+
+    removeTestDirs(user1, sm_app_id, sm_pkg_id);
+    removeTestDirs(user2, sm_app_id, sm_pkg_id);
+    createTestDirs(user1, sm_app_id, sm_pkg_id);
+    createTestDirs(user2, sm_app_id, sm_pkg_id);
+
+    testPathOutside(sm_pkg_id, user1.getUid(),
+                    TzPlatformConfig::appDirPath(user2, sm_app_id, sm_pkg_id));
+    testPathOutside(sm_pkg_id, user1.getUid(),
+                    TzPlatformConfig::appDirPath(user1, sm_app_id, "sm_test_62_non_existing_pkg_id"));
+    testPathOutside(sm_pkg_id, user1.getUid(), std::string("/home/") + user1.getUserName());
+}
+
+void testPathsReqAsUser(const enum app_install_type &type, lib_retcode expectedResult) {
+    const char *const sm_app_id = "sm_test_63_app_id";
+    const char *const sm_pkg_id = "sm_test_63_pkg_id";
+
+    TemporaryTestUser user("sm_test_63_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    int result = drop_root_privileges(user.getUid(), user.getGid());
+    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.setInstallType(type);
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, expectedResult);
+}
+
+RUNNER_CHILD_TEST(security_manager_63a_path_req_as_user)
+{
+    testPathsReqAsUser(SM_APP_INSTALL_GLOBAL,
+                           (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
+}
+
+RUNNER_CHILD_TEST(security_manager_63b_path_req_preloaded_as_user)
+{
+    testPathsReqAsUser(SM_APP_INSTALL_PRELOADED,
+                           (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
+}
+
+void testPathsReqLocal(uid_t uid, gid_t gid)
+{
+    const char *const sm_app_id = "sm_test_64_app_id";
+    const char *const sm_pkg_id = "sm_test_64_pkg_id";
+
+    TemporaryTestUser user("sm_test_64_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    int result = drop_root_privileges(uid, gid);
+    RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.setInstallType(SM_APP_INSTALL_LOCAL);
+    preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
+}
+
+
+RUNNER_CHILD_TEST(security_manager_64a_path_req_as_local_as_root)
+{
+    testPathsReqLocal(0, 0);
+}
+
+RUNNER_CHILD_TEST(security_manager_64b_path_req_as_local_asuser)
+{
+    testPathsReqLocal(TzPlatformConfig::getGlobalUserId(), TzPlatformConfig::getGlobalGroupId());
+}
+
+RUNNER_TEST(security_manager_66_path_req_check_labels)
+{
+    const char *const sm_app_id = "sm_test_66_app_id_full";
+    const char *const sm_pkg_id = "sm_test_66_pkg_id_full";
+
+    std::string SM_RW_PATH = genRWPath(66);
+    std::string SM_RO_PATH = genROPath(66);
+    std::string SM_PUBLIC_RO_PATH = genPublicROPath(66);
+
+    prepare_app_env(66);
+
+    install_app(sm_app_id, sm_pkg_id);
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.addPath(SM_RW_PATH, SECURITY_MANAGER_PATH_RW);
+    preq.addPath(SM_RO_PATH, SECURITY_MANAGER_PATH_RO);
+    preq.addPath(SM_PUBLIC_RO_PATH, SECURITY_MANAGER_PATH_PUBLIC_RO);
+    Api::registerPaths(preq);
+
+    uninstall_app(sm_app_id, sm_pkg_id, true);
+}
+
+RUNNER_TEST(security_manager_67_path_req_shared_ro_3_0)
+{
+    const char *const sm_app_id = "sm_test_67_app_id";
+    const char *const sm_pkg_id = "sm_test_67_pkg_id";
+
+    TemporaryTestUser user("sm_test_67_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    InstallRequest ireq;
+    ireq.setAppId(sm_app_id);
+    ireq.setPkgId(sm_pkg_id);
+    ireq.setUid(user.getUid());
+    ireq.setAppTizenVersion("3.0");
+    Api::install(ireq);
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
+}
+
+RUNNER_TEST(security_manager_68_path_req_shared_ro_2_X)
+{
+    const char *const sm_app_id = "sm_test_68_app_id";
+    const char *const sm_pkg_id = "sm_test_68_pkg_id";
+
+    TemporaryTestUser user("sm_test_68_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    InstallRequest ireq;
+    ireq.setAppId(sm_app_id);
+    ireq.setPkgId(sm_pkg_id);
+    ireq.setUid(user.getUid());
+    ireq.setAppTizenVersion("2.4");
+    Api::install(ireq);
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
+
+    Api::registerPaths(preq);
+
+    // check labels
+    check_path(path, generatePkgLabel(sm_pkg_id) + "::SharedRO");
+}
+
+RUNNER_TEST(security_manager_69_path_req_trusted_rw_no_author)
+{
+    const char *const sm_app_id = "sm_test_69_app_id";
+    const char *const sm_pkg_id = "sm_test_69_pkg_id";
+
+    TemporaryTestUser user("sm_test_69_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
+}
+
+RUNNER_TEST(security_manager_70_path_req_trusted_rw_positive)
+{
+    const char *const sm_app_id = "sm_test_70_app_id";
+    const char *const sm_pkg_id = "sm_test_70_pkg_id";
+    const char *const author_id = "sm_test_70_author_id";
+
+    TemporaryTestUser user("sm_test_70_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = TzPlatformConfig::appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    InstallRequest ireq;
+    ireq.setAppId(sm_app_id);
+    ireq.setPkgId(sm_pkg_id);
+    ireq.setUid(user.getUid());
+    ireq.setAuthorId(author_id);
+    Api::install(ireq);
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
+
+    Api::registerPaths(preq);
+
+    // check labels
+    TestSecurityManagerDatabase dbtest;
+    int64_t authorDb = dbtest.get_author_id(author_id);
+    check_path(path, std::string("User::Author::") + std::to_string(authorDb));
+}