--- /dev/null
+/*
+ * 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.
+ */
+
+#include <app_install_helper.h>
+#include <dpl/test/test_runner.h>
+#include <scoped_installer.h>
+#include <temp_test_user.h>
+#include <label_generator.h>
+#include <sm_commons.h>
+
+using namespace SecurityManagerTest;
+
+RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_PATHS)
+
+static void checkPaths(const AppInstallHelper &app, AppInstallHelper::RootType type) {
+ check_path(app.getPrivateDir(0, type), generatePathRWLabel(app.getPkgId()));
+ check_path(app.getPrivateRODir(0, type), generatePathROLabel(app.getPkgId()), false);
+ check_path(app.getPublicDir(type), getPublicPathLabel());
+}
+
+RUNNER_TEST(security_manager_101_paths_global_extended)
+{
+ AppInstallHelper app("sm_test_101");
+ app.createPrivateDir(0, AppInstallHelper::RootType::EXTENDED);
+ app.createPrivateRODir(0, AppInstallHelper::RootType::EXTENDED);
+ app.createPublicDir(AppInstallHelper::RootType::EXTENDED);
+
+ ScopedInstaller install(app);
+
+ checkPaths(app, AppInstallHelper::RootType::EXTENDED);
+}
+
+RUNNER_TEST(security_manager_102_paths_local_extended)
+{
+ TemporaryTestUser user("sm_test_102", GUM_USERTYPE_NORMAL);
+ user.create();
+
+ AppInstallHelper app("sm_test_102", user.getUid());
+ app.createPrivateDir(0, AppInstallHelper::RootType::EXTENDED);
+ app.createPrivateRODir(0, AppInstallHelper::RootType::EXTENDED);
+ app.createPublicDir(AppInstallHelper::RootType::EXTENDED);
+
+ ScopedInstaller install(app);
+
+ checkPaths(app, AppInstallHelper::RootType::EXTENDED);
+}
+
+RUNNER_TEST(security_manager_103_paths_global_skel)
+{
+ AppInstallHelper app("sm_test_103");
+ app.createPrivateDir(0, AppInstallHelper::RootType::SKEL);
+ app.createPrivateRODir(0, AppInstallHelper::RootType::SKEL);
+ app.createPublicDir(AppInstallHelper::RootType::SKEL);
+
+ ScopedInstaller install(app);
+
+ check_path(app.getPrivateDir(0, AppInstallHelper::RootType::SKEL), generatePathRWLabel(app.getPkgId()));
+ // Below doesn't work, because /etc/skel/apps_rw has transmute and label "User::Home", to which "System::Privileged" has a 't' access
+ //check_path(app.getPrivateRODir(0, AppInstallHelper::RootType::SKEL), generatePathROLabel(app.getPkgId()), false);
+ check_path(app.getPublicDir(AppInstallHelper::RootType::SKEL), getPublicPathLabel());
+}
+
+RUNNER_TEST(security_manager_104_paths_local_skel)
+{
+ TemporaryTestUser user("sm_test_104", GUM_USERTYPE_NORMAL);
+ user.create();
+
+ AppInstallHelper app("sm_test_104", user.getUid());
+ app.createPrivateDir(0, AppInstallHelper::RootType::SKEL);
+
+ InstallRequest req;
+ req.setAppId(app.getAppId());
+ req.setPkgId(app.getPkgId());
+ req.setUid(app.getUID());
+ req.addPath(app.getPrivateDir(0, AppInstallHelper::RootType::SKEL), SECURITY_MANAGER_PATH_RW);
+ Api::install(req, SECURITY_MANAGER_ERROR_NOT_PATH_OWNER);
+}
+