From: Zofia Abramowska Date: Thu, 15 Sep 2016 13:14:15 +0000 (+0200) Subject: SM: Adjust trusted sharing tests to nonhybrid apps X-Git-Tag: security-manager_5.5_testing~20^2~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0bbad44210469d5107c455a8a8c12b9eb19d3ae;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git SM: Adjust trusted sharing tests to nonhybrid apps Change-Id: If39ea63f87150a49285e4b4f5b044f193e72eeab --- diff --git a/src/security-manager-tests/test_cases_trusted_sharing.cpp b/src/security-manager-tests/test_cases_trusted_sharing.cpp index 6993816..6f24ac4 100644 --- a/src/security-manager-tests/test_cases_trusted_sharing.cpp +++ b/src/security-manager-tests/test_cases_trusted_sharing.cpp @@ -133,7 +133,6 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) check_exact_access("User", trusted_label, system_access); check_exact_access(generateProcessLabel(provider.getAppId(), provider.getPkgId()), trusted_label, trusted_access); - check_exact_access(generatePathRWLabel(provider.getPkgId()), trusted_label, ""); // install trusted app InstallRequest trustedApp; @@ -145,7 +144,6 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) // check rules check_exact_access(generateProcessLabel(user.getAppId(), user.getPkgId()), trusted_label, trusted_access); - check_exact_access(generatePathRWLabel(user.getPkgId()), trusted_label, ""); // install untrusted app InstallRequest untrustedApp; @@ -156,7 +154,6 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) // check rules check_exact_access(generateProcessLabel(untrusted.getAppId(), untrusted.getPkgId()), trusted_label, ""); - check_exact_access(generatePathRWLabel(untrusted.getPkgId()), trusted_label, ""); // uninstall trusting app Api::uninstall(trustingApp); @@ -166,10 +163,8 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) check_exact_access("User", trusted_label, system_access); check_exact_access(generateProcessLabel(provider.getAppId(), provider.getPkgId()), trusted_label, ""); - check_exact_access(generatePathRWLabel(provider.getPkgId()), trusted_label, ""); check_exact_access(generateProcessLabel(user.getAppId(), user.getPkgId()), trusted_label, trusted_access); - check_exact_access(generatePathRWLabel(user.getPkgId()), trusted_label, ""); Api::uninstall(trustedApp); @@ -178,7 +173,6 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path) check_exact_access("User", trusted_label, ""); check_exact_access(generateProcessLabel(user.getAppId(), user.getPkgId()), trusted_label, ""); - check_exact_access(generatePathRWLabel(user.getPkgId()), trusted_label, ""); Api::uninstall(untrustedApp); } @@ -239,16 +233,13 @@ RUNNER_TEST(security_manager_45_test_authorId_identificator_creation) RUNNER_ASSERT(authorDb1 != authorDb2); } - -RUNNER_TEST(security_manager_46_pkgId_deinstalation_test) -{ - /* Description: - * Lets assume that app1 and app2 are part of pkg1. - * Deinstalation of app1 mustnot remove rules: - * System PKG1Label rwxatl - * User PKGLabel rwxatl - */ - +/* Description: + * Lets assume that app1 and app2 are part of pkg1. + * Deinstalation of app1 mustnot remove rules: + * System PKG1Label rwxatl + * User PKGLabel rwxatl + */ +void test_46_pkgId_deinstallation(bool isHybrid) { std::vector helper {{"a46", "a46"}, {"b46", "a46"}}; auto &trusted1 = helper[0]; auto &trusted2 = helper[1]; @@ -265,6 +256,8 @@ RUNNER_TEST(security_manager_46_pkgId_deinstalation_test) trustingApp.setAppId(trusted1.getAppId()); trustingApp.setPkgId(trusted1.getPkgId()); trustingApp.setAuthorId(authorId1); + if (isHybrid) + trustingApp.setHybrid(); trustingApp.addPath(trusted1.getTrustedDir().c_str(), SECURITY_MANAGER_PATH_TRUSTED_RW); Api::install(trustingApp); @@ -272,34 +265,68 @@ RUNNER_TEST(security_manager_46_pkgId_deinstalation_test) trustingApp2.setAppId(trusted2.getAppId()); trustingApp2.setPkgId(trusted2.getPkgId()); trustingApp2.setAuthorId(authorId1); + if (isHybrid) + trustingApp2.setHybrid(); Api::install(trustingApp2); - check_exact_access("System", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), - "rwxl"); - check_exact_access("User", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), - "rwxl"); + check_exact_access("System", generatePathRWLabel(trusted1.getPkgId()), "rwxatl"); check_exact_access("User", generatePathRWLabel(trusted1.getPkgId()), "rwxatl"); - check_exact_access("System", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()), - "rwxl"); - check_exact_access("User", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()), - "rwxl"); + if (isHybrid) { + // Nonhybrid apps have the same label for process and private files + check_exact_access("System", + generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId(), isHybrid), + "rwxl"); + check_exact_access("User", + generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId(), isHybrid), + "rwxl"); + check_exact_access("System", + generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId(), isHybrid), + "rwxl"); + check_exact_access("User", + generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId(), isHybrid), + "rwxl"); + } Api::uninstall(trustingApp2); - check_exact_access("System", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), - "rwxl"); - check_exact_access("User", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), - "rwxl"); check_exact_access("System", generatePathRWLabel(trusted1.getPkgId()), "rwxatl"); check_exact_access("User", generatePathRWLabel(trusted1.getPkgId()), "rwxatl"); - check_exact_access("System", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()), ""); - check_exact_access("User", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()), ""); + + if (isHybrid) { + // Nonhybrid apps from the same package share process label + check_exact_access("System", + generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId(), isHybrid), + "rwxl"); + check_exact_access("User", + generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId(), isHybrid), + "rwxl"); + check_exact_access("System", + generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId(), isHybrid), + ""); + check_exact_access("User", + generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId(), isHybrid), + ""); + } Api::uninstall(trustingApp); - check_exact_access("System", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), ""); - check_exact_access("User", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), ""); + check_exact_access("System", + generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId(), isHybrid), + ""); + check_exact_access("User", + generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId(), isHybrid), + ""); check_exact_access("System", generatePathRWLabel(trusted1.getPkgId()), ""); check_exact_access("User", generatePathRWLabel(trusted1.getPkgId()), ""); } + +RUNNER_TEST(security_manager_46_pkgId_deinstalation_test_hybrid) +{ + test_46_pkgId_deinstallation(true); +} + +RUNNER_TEST(security_manager_46_pkgId_deinstalation_test_nonhybrid) +{ + test_46_pkgId_deinstallation(false); +}