* limitations under the License.
*/
#include <cstdint>
+#include <string>
+#include <app_install_helper.h>
#include <dpl/test/test_runner.h>
+#include <scoped_installer.h>
#include <sm_api.h>
#include <sm_commons.h>
#include <temp_test_user.h>
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);
+ AppInstallHelper app("sm_test_54", user.getUid());
+ app.createInstallDir();
+ app.createPrivateDir();
PathsRequest req;
req.setPkgId("non-existing-pkg-id");
req.setUid(user.getUid());
- req.addPath(path, SECURITY_MANAGER_PATH_RW);
+ req.addPath(app.getPrivateDir(), 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);
+ AppInstallHelper app("sm_test_55", user.getUid());
+ app.createInstallDir();
+ app.createPrivateDir();
PathsRequest req;
req.setPkgId("");
req.setUid(user.getUid());
- req.addPath(path, SECURITY_MANAGER_PATH_RW);
+ req.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
Api::registerPaths(req, (lib_retcode)SECURITY_MANAGER_ERROR_REQ_NOT_COMPLETE);
}
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());
+ AppInstallHelper app("sm_test_57", user.getUid());
+ ScopedInstaller appInstall(app);
+ app.createInstallDir();
+ app.createPrivateDir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
+ preq.setPkgId(app.getPkgId());
preq.setUid(-1);
preq.setInstallType(SM_APP_INSTALL_LOCAL);
- preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+ preq.addPath(app.getPrivateDir(), 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());
+ AppInstallHelper app("sm_test_58", user.getUid());
PathsRequest req;
- req.setPkgId(sm_pkg_id);
+ req.setPkgId(app.getPkgId());
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());
+ AppInstallHelper app("sm_test_59", user.getUid());
+ ScopedInstaller appInstall(app);
+ app.createInstallDir();
+ app.createPrivateDir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
+ preq.setPkgId(app.getPkgId());
preq.setUid(user.getUid());
- preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+ preq.addPath(app.getPrivateDir(), 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");
+ AppInstallHelper app("sm_test_60", user.getUid());
+ app.createInstallDir();
+ ScopedInstaller appInstall(app);
+ RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(user.getUid(), user.getGid()) == 0,
+ "drop_root_privileges failed");
+ app.createPrivateDir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
+ preq.setPkgId(app.getPkgId());
preq.setUid(user.getUid());
- preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+ preq.addPath(app.getPrivateDir(), 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);
+ AppInstallHelper app("sm_test_61", user2.getUid());
+ ScopedInstaller appInstall(app);
- removeTestDirs(user2, sm_app_id, sm_pkg_id);
- createTestDirs(user2, sm_app_id, sm_pkg_id);
+ app.createInstallDir();
+ app.createPrivateDir();
- install_app(sm_app_id, sm_pkg_id, user2.getUid());
+ pid_t pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid != -1, "Fork failed");
+ if (pid == 0) { // child
+ RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(user1.getUid(), user1.getGid()) == 0,
+ "drop_root_privileges failed");
- int result = drop_root_privileges(user1.getUid(), user1.getGid());
- RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
+ PathsRequest preq;
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(user2.getUid());
+ preq.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
- 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);
+ Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
+ } else {
+ waitPid(pid);
+ }
}
-void testPathOutside(const std::string& pkgId, uid_t uid, const std::string& path)
+static void checkOutsidePath(const std::string& pkgId, uid_t uid, const std::string& path)
{
PathsRequest preq;
preq.setPkgId(pkgId);
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());
+ AppInstallHelper app("sm_test_62", user1.getUid());
+ AppInstallHelper differentUserApp("sm_test_62", user2.getUid());
+ AppInstallHelper unknownApp("sm_test_62_unknown", 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);
+ ScopedInstaller appInstall(app);
- 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());
+ checkOutsidePath(app.getPkgId(), app.getUID(), unknownApp.getPrivateDir());
+ checkOutsidePath(app.getPkgId(), app.getUID(), differentUserApp.getPrivateDir());
+ checkOutsidePath(app.getPkgId(), app.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";
-
+RUNNER_CHILD_TEST(security_manager_63a_path_req_as_user)
+{
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);
+ AppInstallHelper app("sm_test_63", user.getUid());
+ ScopedInstaller appInstall(app);
- install_app(sm_app_id, sm_pkg_id, user.getUid());
+ app.createInstallDir();
+ app.createPrivateDir();
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);
-}
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.setInstallType(SM_APP_INSTALL_GLOBAL);
+ preq.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
-RUNNER_CHILD_TEST(security_manager_63a_path_req_as_user)
-{
- testPathsReqAsUser(SM_APP_INSTALL_GLOBAL,
- (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
+ Api::registerPaths(preq, 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);
+ TemporaryTestUser user("sm_test_63_user_name", GUM_USERTYPE_NORMAL, false);
+ user.create();
+
+ AppInstallHelper app("sm_test_63", user.getUid());
+ ScopedInstaller appInstall(app);
+
+ app.createInstallDir();
+ app.createPrivateDir();
+
+ int result = drop_root_privileges(user.getUid(), user.getGid());
+ RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
+
+ PathsRequest preq;
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.setInstallType(SM_APP_INSTALL_PRELOADED);
+ preq.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
+
+ Api::registerPaths(preq, SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
}
-void testPathsReqLocal(uid_t uid, gid_t gid)
+RUNNER_TEST(security_manager_64a_path_req_as_local_as_root)
{
- 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);
+ AppInstallHelper app("sm_test_64", user.getUid());
+ app.createInstallDir();
+ ScopedInstaller appInstall(app);
- 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");
+ app.createPrivateDir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
- preq.setUid(user.getUid());
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
preq.setInstallType(SM_APP_INSTALL_LOCAL);
- preq.addPath(path, SECURITY_MANAGER_PATH_RW);
+ preq.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
}
-
-RUNNER_CHILD_TEST(security_manager_64a_path_req_as_local_as_root)
+RUNNER_CHILD_TEST(security_manager_64b_path_req_as_local_as_global_user)
{
- testPathsReqLocal(0, 0);
-}
+ TemporaryTestUser user("sm_test_64_user_name", GUM_USERTYPE_NORMAL, false);
+ user.create();
-RUNNER_CHILD_TEST(security_manager_64b_path_req_as_local_asuser)
-{
- testPathsReqLocal(TzPlatformConfig::getGlobalUserId(), TzPlatformConfig::getGlobalGroupId());
+ AppInstallHelper app("sm_test_64", user.getUid());
+ app.createInstallDir();
+ ScopedInstaller appInstall(app);
+
+ app.createPrivateDir();
+
+ RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(TzPlatformConfig::getGlobalUserId(),
+ TzPlatformConfig::getGlobalGroupId()) == 0,
+ "drop_root_privileges failed");
+
+ PathsRequest preq;
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.setInstallType(SM_APP_INSTALL_LOCAL);
+ preq.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
+
+ Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
}
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";
+ AppInstallHelper app("sm_test_66");
- std::string SM_RW_PATH = genRWPath(66);
- std::string SM_RO_PATH = genROPath(66);
- std::string SM_PUBLIC_RO_PATH = genPublicROPath(66);
+ ScopedInstaller appInstall(app);
- prepare_app_env(66);
-
- install_app(sm_app_id, sm_pkg_id);
+ app.createInstallDir();
+ app.createPrivateDir();
+ app.createPrivateRODir();
+ app.createPublicDir();
+ app.createSharedRODir();
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);
+ preq.setPkgId(app.getPkgId());
+ preq.addPath(app.getPrivateDir(), SECURITY_MANAGER_PATH_RW);
+ preq.addPath(app.getPrivateRODir(), SECURITY_MANAGER_PATH_RO);
+ preq.addPath(app.getPublicDir(), SECURITY_MANAGER_PATH_PUBLIC_RO);
+ preq.addPath(app.getSharedRODir(), SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
Api::registerPaths(preq);
- uninstall_app(sm_app_id, sm_pkg_id, true);
+ check_path(app.getPrivateDir(), generatePathRWLabel(app.getPkgId()));
+ check_path(app.getPrivateRODir(), generatePathROLabel(app.getPkgId()), false);
+ check_path(app.getPublicDir(), getPublicPathLabel());
+ check_path(app.getSharedRODir(), generatePathSharedROLabel(app.getPkgId()));
}
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);
+ AppInstallHelper app("sm_test_67", user.getUid());
+ app.setVersion("3.0");
+ ScopedInstaller appInstall(app);
- InstallRequest ireq;
- ireq.setAppId(sm_app_id);
- ireq.setPkgId(sm_pkg_id);
- ireq.setUid(user.getUid());
- ireq.setAppTizenVersion("3.0");
- Api::install(ireq);
+ app.createInstallDir();
+ app.createSharedRODir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
- preq.setUid(user.getUid());
- preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.addPath(app.getSharedRODir(), SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
- Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_SUCCESS);
+ Api::registerPaths(preq);
+ check_path(app.getSharedRODir(), generatePathSharedROLabel(app.getPkgId()));
}
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);
+ AppInstallHelper app("sm_test_68", user.getUid());
+ app.setVersion("2.4");
+ ScopedInstaller appInstall(app);
- InstallRequest ireq;
- ireq.setAppId(sm_app_id);
- ireq.setPkgId(sm_pkg_id);
- ireq.setUid(user.getUid());
- ireq.setAppTizenVersion("2.4");
- Api::install(ireq);
+ app.createInstallDir();
+ app.createSharedRODir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
- preq.setUid(user.getUid());
- preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.addPath(app.getSharedRODir(), SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
Api::registerPaths(preq);
-
- // check labels
- check_path(path, generatePathRWLabel(sm_pkg_id) + "::SharedRO");
+ check_path(app.getSharedRODir(), generatePathSharedROLabel(app.getPkgId()));
}
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);
+ AppInstallHelper app("sm_test_69", user.getUid());
+ ScopedInstaller appInstall(app);
- install_app(sm_app_id, sm_pkg_id, user.getUid());
+ app.createInstallDir();
+ app.createTrustedDir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
- preq.setUid(user.getUid());
- preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.addPath(app.getTrustedDir(), 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);
+ AppInstallHelper app("sm_test_70", user.getUid());
+ app.setAuthor("sm_test_70_author");
+ ScopedInstaller appInstall(app);
- InstallRequest ireq;
- ireq.setAppId(sm_app_id);
- ireq.setPkgId(sm_pkg_id);
- ireq.setUid(user.getUid());
- ireq.setAuthorId(author_id);
- Api::install(ireq);
+ app.createInstallDir();
+ app.createTrustedDir();
PathsRequest preq;
- preq.setPkgId(sm_pkg_id);
- preq.setUid(user.getUid());
- preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
+ preq.setPkgId(app.getPkgId());
+ preq.setUid(app.getUID());
+ preq.addPath(app.getTrustedDir(), 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));
+ int64_t authorDb = dbtest.get_author_id(app.getAuthor());
+ check_path(app.getTrustedDir(), generatePathTrustedLabel(authorDb));
}