From: Bartlomiej Grzelewski Date: Tue, 2 Feb 2016 11:53:37 +0000 (+0100) Subject: [SM] Changes in InstallRequest API. X-Git-Tag: security-manager_5.5_testing~109^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ac130b00800a9eab870ebfff23e06026a442dbb;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git [SM] Changes in InstallRequest API. Replace "const char *" with std::string type. Change-Id: I955f850ea1f09e310fbd0ae7775c84fe6f15c2e5 --- diff --git a/src/security-manager-tests/common/sm_request.cpp b/src/security-manager-tests/common/sm_request.cpp index 69d1a4d1..b8fc114d 100644 --- a/src/security-manager-tests/common/sm_request.cpp +++ b/src/security-manager-tests/common/sm_request.cpp @@ -23,8 +23,6 @@ namespace SecurityManagerTest { InstallRequest::InstallRequest() : m_req(nullptr) , m_tizenVer("3.0") - , m_appId(nullptr) - , m_pkgId(nullptr) , m_uid(false, 0) { int result = security_manager_app_inst_req_new(&m_req); @@ -38,37 +36,37 @@ InstallRequest::~InstallRequest() security_manager_app_inst_req_free(m_req); } -void InstallRequest::setAppTizenVersion(const char * tizenVer, lib_retcode expectedResult) +void InstallRequest::setAppTizenVersion(std::string tizenVer, lib_retcode expectedResult) { - int result = security_manager_app_inst_req_set_target_version(m_req, tizenVer); + int result = security_manager_app_inst_req_set_target_version(m_req, tizenVer.c_str()); RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult, "setting app id returned wrong value." << " Tizen version: " << tizenVer << ";" << " Result: " << result << ";" << " Expected result: " << expectedResult); - m_tizenVer = std::string(tizenVer); + m_tizenVer = std::move(tizenVer); } -void InstallRequest::setAppId(const char *appId, lib_retcode expectedResult) +void InstallRequest::setAppId(std::string appId, lib_retcode expectedResult) { - int result = security_manager_app_inst_req_set_app_id(m_req, appId); + int result = security_manager_app_inst_req_set_app_id(m_req, appId.c_str()); RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult, "setting app id returned wrong value." << " App id: " << appId << ";" << " Result: " << result << ";" << " Expected result: " << expectedResult); - m_appId = strdup(appId); + m_appId = std::move(appId); } -void InstallRequest::setPkgId(const char *pkgId, lib_retcode expectedResult) +void InstallRequest::setPkgId(std::string pkgId, lib_retcode expectedResult) { - int result = security_manager_app_inst_req_set_pkg_id(m_req, pkgId); + int result = security_manager_app_inst_req_set_pkg_id(m_req, pkgId.c_str()); RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult, "setting pkg id returned wrong value." << " Pkg id: " << pkgId << ";" << " Result: " << result << ";" << " Expected result: " << expectedResult); - m_pkgId = strdup(pkgId); + m_pkgId = std::move(pkgId); } void InstallRequest::addPrivilege(const char *privilege, lib_retcode expectedResult) @@ -82,16 +80,16 @@ void InstallRequest::addPrivilege(const char *privilege, lib_retcode expectedRes m_privileges.push_back(strdup(privilege)); } -void InstallRequest::addPath(const char *path, app_install_path_type pathType, lib_retcode expectedResult) +void InstallRequest::addPath(std::string path, app_install_path_type pathType, lib_retcode expectedResult) { - int result = security_manager_app_inst_req_add_path(m_req, path, pathType); + int result = security_manager_app_inst_req_add_path(m_req, path.c_str(), pathType); RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult, "adding path returned wrong value." << " Path: " << path << ";" << " Path type: " << pathType << ";" << " Result: " << result << ";" << " Expected result: " << expectedResult); - m_paths.push_back(std::pair(path, pathType)); + m_paths.emplace_back(std::pair(std::move(path), pathType)); } void InstallRequest::setUid(const uid_t uid, lib_retcode expectedResult) @@ -106,26 +104,22 @@ void InstallRequest::setUid(const uid_t uid, lib_retcode expectedResult) m_uid.second = uid; } -void InstallRequest::setAuthorId(const char *authorId, lib_retcode expectedResult) +void InstallRequest::setAuthorId(std::string authorId, lib_retcode expectedResult) { - m_authorId.clear(); - if(authorId) - m_authorId.assign(authorId); - - int result = security_manager_app_inst_req_set_author_id(m_req, authorId); + int result = security_manager_app_inst_req_set_author_id(m_req, authorId.c_str()); RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult, "setting author id returned wrong value." << " Author id: " << m_authorId << ";" << " Result: " << result << ";" << " Expected result: " << expectedResult); - + m_authorId = std::move(authorId); } std::ostream& operator<<(std::ostream &os, const InstallRequest &request) { - if (request.m_appId != nullptr) + if (!request.m_appId.empty()) os << "app id: " << request.m_appId << "; "; - if (request.m_pkgId != nullptr) + if (!request.m_pkgId.empty()) os << "pkg id: " << request.m_pkgId << "; "; if (!request.m_privileges.empty()) { os << "privileges: [ " << request.m_privileges[0]; diff --git a/src/security-manager-tests/common/sm_request.h b/src/security-manager-tests/common/sm_request.h index 9ad42047..08dd4777 100644 --- a/src/security-manager-tests/common/sm_request.h +++ b/src/security-manager-tests/common/sm_request.h @@ -35,17 +35,18 @@ public: InstallRequest& operator=(const InstallRequest&) = delete; ~InstallRequest(); - void setAppTizenVersion(const char *tizenVer, - lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); - void setAppId(const char *appId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); - void setPkgId(const char *pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); + void setAppTizenVersion(std::string tizenVer, + lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); + void setAppId(std::string appId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); + void setPkgId(std::string pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); void addPrivilege(const char *privilege, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); - void addPath(const char *path, app_install_path_type pathType, + void addPath(std::string path, app_install_path_type pathType, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS); void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS); - void setAuthorId(const char *authorId, lib_retcode expectedResult= SECURITY_MANAGER_SUCCESS); + void setAuthorId(std::string authorId, lib_retcode expectedResult= SECURITY_MANAGER_SUCCESS); std::string getAppTizenVersion() const { return m_tizenVer; } + app_inst_req *get() { return m_req; } const app_inst_req *get() const { return m_req; } friend std::ostream& operator<<(std::ostream &, const InstallRequest&); @@ -53,8 +54,8 @@ private: app_inst_req *m_req; std::string m_tizenVer; - const char *m_appId; - const char *m_pkgId; + std::string m_appId; + std::string m_pkgId; std::string m_authorId; std::vector m_privileges; std::vector > m_paths; diff --git a/src/security-manager-tests/security_manager_tests.cpp b/src/security-manager-tests/security_manager_tests.cpp index e01fe679..34fa989e 100644 --- a/src/security-manager-tests/security_manager_tests.cpp +++ b/src/security-manager-tests/security_manager_tests.cpp @@ -639,9 +639,9 @@ RUNNER_TEST(security_manager_02_app_install_uninstall_full) requestInst.setPkgId(sm_pkg_id); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[0].c_str()); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[1].c_str()); - requestInst.addPath(SM_RW_PATH.c_str(), SECURITY_MANAGER_PATH_RW); - requestInst.addPath(SM_RO_PATH.c_str(), SECURITY_MANAGER_PATH_RO); - requestInst.addPath(SM_PUBLIC_RO_PATH.c_str(), SECURITY_MANAGER_PATH_PUBLIC_RO); + requestInst.addPath(SM_RW_PATH, SECURITY_MANAGER_PATH_RW); + requestInst.addPath(SM_RO_PATH, SECURITY_MANAGER_PATH_RO); + requestInst.addPath(SM_PUBLIC_RO_PATH, SECURITY_MANAGER_PATH_PUBLIC_RO); Api::install(requestInst); @@ -2628,10 +2628,10 @@ RUNNER_TEST(security_manager_27a_API2X_app_install) requestInst.setPkgId(sm_pkg_shared_id); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[0].c_str()); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[1].c_str()); - requestInst.addPath(SM_RW_PATH.c_str(), SECURITY_MANAGER_PATH_RW); - requestInst.addPath(SM_RO_PATH.c_str(), SECURITY_MANAGER_PATH_RO); - requestInst.addPath(SM_PUBLIC_RO_PATH.c_str(), SECURITY_MANAGER_PATH_PUBLIC_RO); - requestInst.addPath(SM_OWNER_RW_OTHERS_RO_PATH.c_str(), SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO); + requestInst.addPath(SM_RW_PATH, SECURITY_MANAGER_PATH_RW); + requestInst.addPath(SM_RO_PATH, SECURITY_MANAGER_PATH_RO); + requestInst.addPath(SM_PUBLIC_RO_PATH, SECURITY_MANAGER_PATH_PUBLIC_RO); + requestInst.addPath(SM_OWNER_RW_OTHERS_RO_PATH, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO); requestInst.setAppTizenVersion("2.4"); Api::install(requestInst); } @@ -2643,7 +2643,7 @@ RUNNER_TEST(security_manager_27a_API2X_app_install) requestInst.setPkgId(sm_pkg_shared_id); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[0].c_str()); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[1].c_str()); - requestInst.addPath(SM_OWNER_RW_OTHERS_RO_PATH.c_str(), SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO); + requestInst.addPath(SM_OWNER_RW_OTHERS_RO_PATH, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO); requestInst.setAppTizenVersion("2.4"); Api::install(requestInst); } @@ -2732,10 +2732,10 @@ RUNNER_TEST(security_manager_27j_API30_app_install) requestInst.setPkgId(sm_pkg_shared_id); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[0].c_str()); requestInst.addPrivilege(SM_ALLOWED_PRIVILEGES[1].c_str()); - requestInst.addPath(SM_RW_PATH.c_str(), SECURITY_MANAGER_PATH_RW); - requestInst.addPath(SM_RO_PATH.c_str(), SECURITY_MANAGER_PATH_RO); - requestInst.addPath(SM_PUBLIC_RO_PATH.c_str(), SECURITY_MANAGER_PATH_PUBLIC_RO); - requestInst.addPath(SM_OWNER_RW_OTHERS_RO_PATH.c_str(), SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO); + requestInst.addPath(SM_RW_PATH, SECURITY_MANAGER_PATH_RW); + requestInst.addPath(SM_RO_PATH, SECURITY_MANAGER_PATH_RO); + requestInst.addPath(SM_PUBLIC_RO_PATH, SECURITY_MANAGER_PATH_PUBLIC_RO); + requestInst.addPath(SM_OWNER_RW_OTHERS_RO_PATH, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO); requestInst.setAppTizenVersion("3.0"); Api::install(requestInst); @@ -2790,7 +2790,7 @@ RUNNER_TEST(security_manager_27p_API30_app_uninstall) // install other apps for(const auto &app : MANY_APPS_PKGS) { InstallRequest requestUninst; - requestUninst.setAppId(app.first.c_str()); + requestUninst.setAppId(app.first); Api::uninstall(requestUninst); }; @@ -2896,8 +2896,8 @@ RUNNER_TEST(security_manager_30e_unknown_target) owner.revokeRules(); owner.createInstallDir(); InstallRequest ownerInst; - ownerInst.setAppId(owner.getAppId().c_str()); - ownerInst.setPkgId(owner.getPkgId().c_str()); + ownerInst.setAppId(owner.getAppId()); + ownerInst.setPkgId(owner.getPkgId()); Api::install(ownerInst); SharingRequest request; @@ -2917,16 +2917,16 @@ RUNNER_TEST(security_manager_30f_bad_paths) owner.revokeRules(); owner.createInstallDir(); InstallRequest ownerInst; - ownerInst.setAppId(owner.getAppId().c_str()); - ownerInst.setPkgId(owner.getPkgId().c_str()); + ownerInst.setAppId(owner.getAppId()); + ownerInst.setPkgId(owner.getPkgId()); Api::install(ownerInst); AppInstallHelper target("secondInstalledApp"); target.revokeRules(); target.createInstallDir(); InstallRequest targetInst; - targetInst.setAppId(target.getAppId().c_str()); - targetInst.setPkgId(target.getPkgId().c_str()); + targetInst.setAppId(target.getAppId()); + targetInst.setPkgId(target.getPkgId()); Api::install(targetInst); SharingRequest request; @@ -2957,20 +2957,20 @@ RUNNER_TEST(security_manager_31_simple_share) owner.createSharedFile(); InstallRequest ownerReq; - ownerReq.setAppId(owner.getAppId().c_str()); - ownerReq.setPkgId(owner.getPkgId().c_str()); - ownerReq.addPath(owner.getSharedPath().c_str(), SECURITY_MANAGER_PATH_RW); + ownerReq.setAppId(owner.getAppId()); + ownerReq.setPkgId(owner.getPkgId()); + ownerReq.addPath(owner.getSharedPath(), SECURITY_MANAGER_PATH_RW); int result = nftw(owner.getInstallDir().c_str(), &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); RUNNER_ASSERT_MSG(result == 0, "Unable to remove Smack labels in " << owner.getInstallDir()); Api::install(ownerReq); InstallRequest targetReq; - targetReq.setAppId(target.getAppId().c_str()); - targetReq.setPkgId(target.getAppId().c_str()); + targetReq.setAppId(target.getAppId()); + targetReq.setPkgId(target.getAppId()); Api::install(targetReq); SharingRequest share1; - std::string sharedPath = owner.getSharedPath().c_str(); + std::string sharedPath = owner.getSharedPath(); share1.setOwnerAppId(owner.getAppId()); share1.setTargetAppId(target.getAppId()); const char *path[] = {sharedPath.c_str()}; @@ -3011,21 +3011,21 @@ RUNNER_TEST(security_manager_32_double_share) owner.createSharedFile(); InstallRequest ownerReq; - ownerReq.setAppId(owner.getAppId().c_str()); - ownerReq.setPkgId(owner.getPkgId().c_str()); - ownerReq.addPath(owner.getSharedPath().c_str(), SECURITY_MANAGER_PATH_RW); + ownerReq.setAppId(owner.getAppId()); + ownerReq.setPkgId(owner.getPkgId()); + ownerReq.addPath(owner.getSharedPath(), SECURITY_MANAGER_PATH_RW); int result = nftw(owner.getInstallDir().c_str(), &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); RUNNER_ASSERT_MSG(result == 0, "Unable to remove Smack labels in " << owner.getInstallDir()); Api::install(ownerReq); InstallRequest targetReq; - targetReq.setAppId(target.getAppId().c_str()); - targetReq.setPkgId(target.getAppId().c_str()); + targetReq.setAppId(target.getAppId()); + targetReq.setPkgId(target.getAppId()); Api::install(targetReq); SharingRequest share1; - std::string sharedPath = owner.getSharedPath(0).c_str(); + std::string sharedPath = owner.getSharedPath(0); share1.setOwnerAppId(owner.getAppId()); share1.setTargetAppId(target.getAppId()); const char *path[] = {sharedPath.c_str()}; @@ -3078,23 +3078,23 @@ RUNNER_TEST(security_manager_33_share_two_with_one) owner.createSharedFile(1); InstallRequest ownerReq; - ownerReq.setAppId(owner.getAppId().c_str()); - ownerReq.setPkgId(owner.getPkgId().c_str()); - ownerReq.addPath(owner.getSharedPath(0).c_str(), SECURITY_MANAGER_PATH_RW); - ownerReq.addPath(owner.getSharedPath(1).c_str(), SECURITY_MANAGER_PATH_RW); + ownerReq.setAppId(owner.getAppId()); + ownerReq.setPkgId(owner.getPkgId()); + ownerReq.addPath(owner.getSharedPath(0), SECURITY_MANAGER_PATH_RW); + ownerReq.addPath(owner.getSharedPath(1), SECURITY_MANAGER_PATH_RW); int result = nftw(owner.getInstallDir().c_str(), &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); RUNNER_ASSERT_MSG(result == 0, "Unable to remove Smack labels in " << owner.getInstallDir()); Api::install(ownerReq); InstallRequest targetReq; - targetReq.setAppId(target.getAppId().c_str()); - targetReq.setPkgId(target.getAppId().c_str()); + targetReq.setAppId(target.getAppId()); + targetReq.setPkgId(target.getAppId()); Api::install(targetReq); SharingRequest share1, share2; - std::string sharedPath1 = owner.getSharedPath(0).c_str(); - std::string sharedPath2 = owner.getSharedPath(1).c_str(); + std::string sharedPath1 = owner.getSharedPath(0); + std::string sharedPath2 = owner.getSharedPath(1); share1.setOwnerAppId(owner.getAppId()); share2.setOwnerAppId(owner.getAppId()); share1.setTargetAppId(target.getAppId()); @@ -3167,17 +3167,17 @@ RUNNER_TEST(security_manager_34_share_one_with_two) owner.createSharedFile(); InstallRequest ownerReq; - ownerReq.setAppId(owner.getAppId().c_str()); - ownerReq.setPkgId(owner.getPkgId().c_str()); - ownerReq.addPath(owner.getSharedPath().c_str(), SECURITY_MANAGER_PATH_RW); + ownerReq.setAppId(owner.getAppId()); + ownerReq.setPkgId(owner.getPkgId()); + ownerReq.addPath(owner.getSharedPath(), SECURITY_MANAGER_PATH_RW); int result = nftw(owner.getInstallDir().c_str(), &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); RUNNER_ASSERT_MSG(result == 0, "Unable to remove Smack labels in " << owner.getInstallDir()); Api::install(ownerReq); for (size_t i = 1; i < helper.size(); i++) { InstallRequest targetReq; - targetReq.setAppId(helper[i].getAppId().c_str()); - targetReq.setPkgId(helper[i].getAppId().c_str()); + targetReq.setAppId(helper[i].getAppId()); + targetReq.setPkgId(helper[i].getAppId()); Api::install(targetReq); } @@ -3226,8 +3226,8 @@ RUNNER_TEST(security_manager_34_share_one_with_two) Api::uninstall(ownerReq); for (size_t i = 1; i < helper.size(); i++) { InstallRequest targetReq; - targetReq.setAppId(helper[i].getAppId().c_str()); - targetReq.setPkgId(helper[i].getAppId().c_str()); + targetReq.setAppId(helper[i].getAppId()); + targetReq.setPkgId(helper[i].getAppId()); Api::uninstall(targetReq); } } @@ -3249,10 +3249,10 @@ RUNNER_TEST(security_manager_35_share_two_with_two) owner.createSharedFile(1); InstallRequest ownerReq; - ownerReq.setAppId(owner.getAppId().c_str()); - ownerReq.setPkgId(owner.getPkgId().c_str()); - ownerReq.addPath(owner.getSharedPath(0).c_str(), SECURITY_MANAGER_PATH_RW); - ownerReq.addPath(owner.getSharedPath(1).c_str(), SECURITY_MANAGER_PATH_RW); + ownerReq.setAppId(owner.getAppId()); + ownerReq.setPkgId(owner.getPkgId()); + ownerReq.addPath(owner.getSharedPath(0), SECURITY_MANAGER_PATH_RW); + ownerReq.addPath(owner.getSharedPath(1), SECURITY_MANAGER_PATH_RW); int result = nftw(owner.getInstallDir().c_str(), &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); RUNNER_ASSERT_MSG(result == 0, "Unable to remove Smack labels in " << owner.getInstallDir()); @@ -3260,8 +3260,8 @@ RUNNER_TEST(security_manager_35_share_two_with_two) for (size_t i = 1; i < helper.size(); i++) { InstallRequest targetReq; - targetReq.setAppId(helper[i].getAppId().c_str()); - targetReq.setPkgId(helper[i].getAppId().c_str()); + targetReq.setAppId(helper[i].getAppId()); + targetReq.setPkgId(helper[i].getAppId()); Api::install(targetReq); } @@ -3324,8 +3324,8 @@ RUNNER_TEST(security_manager_35_share_two_with_two) Api::uninstall(ownerReq); for (size_t i = 1; i < helper.size(); i++) { InstallRequest targetReq; - targetReq.setAppId(helper[i].getAppId().c_str()); - targetReq.setPkgId(helper[i].getAppId().c_str()); + targetReq.setAppId(helper[i].getAppId()); + targetReq.setPkgId(helper[i].getAppId()); Api::uninstall(targetReq); } } @@ -3333,8 +3333,12 @@ RUNNER_TEST(security_manager_35_share_two_with_two) RUNNER_TEST(security_manager_40_set_wrong_author_id) { InstallRequest requestInst; - requestInst.setAuthorId(NULL, SECURITY_MANAGER_ERROR_INPUT_PARAM); - requestInst.setAuthorId("", SECURITY_MANAGER_ERROR_INPUT_PARAM); + + RUNNER_ASSERT(SECURITY_MANAGER_ERROR_INPUT_PARAM == + security_manager_app_inst_req_set_author_id(requestInst.get(), NULL)); + + RUNNER_ASSERT(SECURITY_MANAGER_ERROR_INPUT_PARAM == + security_manager_app_inst_req_set_author_id(requestInst.get(), "")); } RUNNER_TEST(security_manager_41_set_author_id_multiple_times) @@ -3343,7 +3347,7 @@ RUNNER_TEST(security_manager_41_set_author_id_multiple_times) std::string authorId = "some-author-id" + std::to_string(i); InstallRequest requestInst; - requestInst.setAuthorId(authorId.c_str()); + requestInst.setAuthorId(authorId); } } @@ -3374,8 +3378,8 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) // install app with shared/trusted dir InstallRequest trustingApp; - trustingApp.setAppId(provider.getAppId().c_str()); - trustingApp.setPkgId(provider.getPkgId().c_str()); + trustingApp.setAppId(provider.getAppId()); + trustingApp.setPkgId(provider.getPkgId()); trustingApp.setAuthorId("author id to be overwritten"); trustingApp.setAuthorId(author_id); trustingApp.addPath(provider.getTrustedDir().c_str(), SECURITY_MANAGER_PATH_TRUSTED_RW); @@ -3394,31 +3398,31 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for " << SM_TRUSTED_PATH); // check rules - check_exact_access("System", trusted_label.c_str(), system_access); - check_exact_access("User", trusted_label.c_str(), system_access); - check_exact_access(generateAppLabel(provider.getAppId().c_str()), trusted_label, trusted_access); - check_exact_access(generatePkgLabel(provider.getPkgId().c_str()), trusted_label, ""); + check_exact_access("System", trusted_label, system_access); + check_exact_access("User", trusted_label, system_access); + check_exact_access(generateAppLabel(provider.getAppId()), trusted_label, trusted_access); + check_exact_access(generatePkgLabel(provider.getPkgId()), trusted_label, ""); // install trusted app InstallRequest trustedApp; - trustedApp.setAppId(user.getAppId().c_str()); - trustedApp.setPkgId(user.getPkgId().c_str()); + trustedApp.setAppId(user.getAppId()); + trustedApp.setPkgId(user.getPkgId()); trustedApp.setAuthorId(author_id); Api::install(trustedApp); // check rules - check_exact_access(generateAppLabel(user.getAppId().c_str()), trusted_label, trusted_access); - check_exact_access(generatePkgLabel(user.getPkgId().c_str()), trusted_label, ""); + check_exact_access(generateAppLabel(user.getAppId()), trusted_label, trusted_access); + check_exact_access(generatePkgLabel(user.getPkgId()), trusted_label, ""); // install untrusted app InstallRequest untrustedApp; - untrustedApp.setAppId(untrusted.getAppId().c_str()); - untrustedApp.setPkgId(untrusted.getPkgId().c_str()); + untrustedApp.setAppId(untrusted.getAppId()); + untrustedApp.setPkgId(untrusted.getPkgId()); Api::install(untrustedApp); // check rules - check_exact_access(generateAppLabel(untrusted.getAppId().c_str()), trusted_label, ""); - check_exact_access(generatePkgLabel(untrusted.getPkgId().c_str()), trusted_label, ""); + check_exact_access(generateAppLabel(untrusted.getAppId()), trusted_label, ""); + check_exact_access(generatePkgLabel(untrusted.getPkgId()), trusted_label, ""); // uninstall trusting app Api::uninstall(trustingApp); @@ -3426,18 +3430,18 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) // there's still one app with author id, rules should be kept check_exact_access("System", trusted_label, system_access); check_exact_access("User", trusted_label, system_access); - check_exact_access(generateAppLabel(provider.getAppId().c_str()), trusted_label, ""); - check_exact_access(generatePkgLabel(provider.getPkgId().c_str()), trusted_label, ""); - check_exact_access(generateAppLabel(user.getAppId().c_str()), trusted_label, trusted_access); - check_exact_access(generatePkgLabel(user.getPkgId().c_str()), trusted_label, ""); + check_exact_access(generateAppLabel(provider.getAppId()), trusted_label, ""); + check_exact_access(generatePkgLabel(provider.getPkgId()), trusted_label, ""); + check_exact_access(generateAppLabel(user.getAppId()), trusted_label, trusted_access); + check_exact_access(generatePkgLabel(user.getPkgId()), trusted_label, ""); Api::uninstall(trustedApp); // no more apps with author id check_exact_access("System", trusted_label, ""); check_exact_access("User", trusted_label, ""); - check_exact_access(generateAppLabel(user.getAppId().c_str()), trusted_label, ""); - check_exact_access(generatePkgLabel(user.getPkgId().c_str()), trusted_label, ""); + check_exact_access(generateAppLabel(user.getAppId()), trusted_label, ""); + check_exact_access(generatePkgLabel(user.getPkgId()), trusted_label, ""); Api::uninstall(untrustedApp); } @@ -3451,10 +3455,9 @@ RUNNER_TEST(security_manager_44_app_install_with_trusted_path_no_author_id) // install app with shared/trusted dir but without authors id InstallRequest app; - app.setAppId(help.getAppId().c_str()); - app.setPkgId(help.getPkgId().c_str()); - app.addPath(help.getTrustedDir().c_str(), - SECURITY_MANAGER_PATH_TRUSTED_RW); + app.setAppId(help.getAppId()); + app.setPkgId(help.getPkgId()); + app.addPath(help.getTrustedDir(), SECURITY_MANAGER_PATH_TRUSTED_RW); Api::install(app, SECURITY_MANAGER_ERROR_INPUT_PARAM); }