From: Tomasz Swierczek Date: Wed, 1 Jun 2016 17:37:54 +0000 (+0200) Subject: Adjusted privilege-related tests to privacy privileges X-Git-Tag: security-manager_5.5_testing~20^2~80 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88ba967394fcb2a00100416fbd460528e47deff5;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Adjusted privilege-related tests to privacy privileges Change-Id: I008235e8a58be9a8d58aadaf21b66ffe898f8203 --- diff --git a/src/security-manager-tests/security_manager_tests.cpp b/src/security-manager-tests/security_manager_tests.cpp index 6506b5ad..b20979a4 100644 --- a/src/security-manager-tests/security_manager_tests.cpp +++ b/src/security-manager-tests/security_manager_tests.cpp @@ -52,7 +52,7 @@ DEFINE_SMARTPTR(cap_free, _cap_struct, CapsSetsUniquePtr); DEFINE_SMARTPTR(tzplatform_context_destroy, tzplatform_context, TzPlatformContextPtr); static const privileges_t SM_ALLOWED_PRIVILEGES = { - "http://tizen.org/privilege/location", + "http://tizen.org/privilege/display", "http://tizen.org/privilege/nfc" }; @@ -132,14 +132,14 @@ static const std::map MANY_APPS_PKGS = { static const std::vector MANY_APPS_PRIVILEGES = { { "http://tizen.org/privilege/internet", - "http://tizen.org/privilege/location" + "http://tizen.org/privilege/display" }, { "http://tizen.org/privilege/telephony", - "http://tizen.org/privilege/camera" + "http://tizen.org/privilege/datasharing" }, { - "http://tizen.org/privilege/contact.read", + "http://tizen.org/privilege/content.write", "http://tizen.org/privilege/led", "http://tizen.org/privilege/email" }, @@ -147,11 +147,11 @@ static const std::vector MANY_APPS_PRIVILEGES = { "http://tizen.org/privilege/led", "http://tizen.org/privilege/email", "http://tizen.org/privilege/telephony", - "http://tizen.org/privilege/camera" + "http://tizen.org/privilege/datasharing" }, { "http://tizen.org/privilege/internet", - "http://tizen.org/privilege/location", + "http://tizen.org/privilege/display", "http://tizen.org/privilege/led", "http://tizen.org/privilege/email" } @@ -1507,10 +1507,6 @@ RUNNER_CHILD_TEST(security_manager_13_privacy_manager_fetch_policy_after_update_ PolicyEntry filter; PolicyRequest policyRequest; - //this call should succeed as the calling user is privileged - Api::getPolicyForSelf(filter, policyEntries); - - RUNNER_ASSERT_MSG(policyEntries.size() == 0, "Policy is not empty"); PolicyEntry policyEntry( MANY_APPS[0], @@ -1523,15 +1519,13 @@ RUNNER_CHILD_TEST(security_manager_13_privacy_manager_fetch_policy_after_update_ policyEntry = PolicyEntry( MANY_APPS[1], std::to_string(pw->pw_uid), - "http://tizen.org/privilege/location" + "http://tizen.org/privilege/display" ); policyEntry.setLevel("Deny"); policyRequest.addEntry(policyEntry); Api::sendPolicy(policyRequest); - Api::getPolicyForSelf(filter, policyEntries); - RUNNER_ASSERT_MSG(policyEntries.size() == 2, "Number of policies doesn't match - should be: 2 and is " << policyEntries.size()); exit(0); } else { //parent process sync[0].claimParentEp(); @@ -1556,7 +1550,7 @@ RUNNER_CHILD_TEST(security_manager_13_privacy_manager_fetch_policy_after_update_ //U2 requests contents of U1 privacy manager - should fail Api::getPolicyForSelf(filter, policyEntries); - RUNNER_ASSERT_MSG(policyEntries.size() == 0, "Policy is not empty"); + RUNNER_ASSERT_MSG(policyEntries.size() == 0, "Policy is not empty, but is " << policyEntries.size()); filter = PolicyEntry( SECURITY_MANAGER_ANY, @@ -1568,7 +1562,7 @@ RUNNER_CHILD_TEST(security_manager_13_privacy_manager_fetch_policy_after_update_ //U2 requests contents of ADMIN bucket - should fail Api::getPolicyForAdmin(filter, policyEntries, SECURITY_MANAGER_ERROR_ACCESS_DENIED); - RUNNER_ASSERT_MSG(policyEntries.size() == 0, "Policy is not empty"); + RUNNER_ASSERT_MSG(policyEntries.size() == 0, "Policy is not empty, but is " << policyEntries.size()); exit(0); } else { //parent sync[1].claimParentEp(); @@ -1703,7 +1697,7 @@ RUNNER_CHILD_TEST(security_manager_14_privacy_manager_fetch_and_update_policy_fo //this call should succeed as the calling user is privileged Api::getPolicyForSelf(filter, policyEntries); - RUNNER_ASSERT_MSG(policyEntries.size() == 0, "Policy is not empty"); + unsigned int policyNum = policyEntries.size(); PolicyEntry policyEntry( SECURITY_MANAGER_ANY, @@ -1716,7 +1710,7 @@ RUNNER_CHILD_TEST(security_manager_14_privacy_manager_fetch_and_update_policy_fo policyEntry = PolicyEntry( SECURITY_MANAGER_ANY, SECURITY_MANAGER_ANY, - "http://tizen.org/privilege/location" + "http://tizen.org/privilege/display" ); policyEntry.setMaxLevel("Deny"); @@ -1724,7 +1718,8 @@ RUNNER_CHILD_TEST(security_manager_14_privacy_manager_fetch_and_update_policy_fo Api::sendPolicy(*policyRequest); Api::getPolicyForAdmin(filter, policyEntries); - RUNNER_ASSERT_MSG(policyEntries.size() == 2, "Number of policies doesn't match - should be: 2 and is " << policyEntries.size()); + RUNNER_ASSERT_MSG(policyEntries.size() == policyNum + 2, "Number of policies doesn't match - should be: " + << policyNum + 2 << " and is " << policyEntries.size()); delete policyRequest; policyRequest = new PolicyRequest(); @@ -1739,7 +1734,7 @@ RUNNER_CHILD_TEST(security_manager_14_privacy_manager_fetch_and_update_policy_fo policyEntry = PolicyEntry( SECURITY_MANAGER_ANY, SECURITY_MANAGER_ANY, - "http://tizen.org/privilege/location" + "http://tizen.org/privilege/display" ); policyEntry.setMaxLevel(SECURITY_MANAGER_DELETE); @@ -2009,13 +2004,13 @@ RUNNER_CHILD_TEST(security_manager_16_policy_levels_get) result = drop_root_privileges(msg.uid, msg.gid); RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed"); - // without plugins there should only be 2 policies - Allow and Deny + // 3 should be there when ask-user is installed ret = security_manager_policy_levels_get(&levels, &count); RUNNER_ASSERT_MSG((lib_retcode)ret == SECURITY_MANAGER_SUCCESS, "Invlid return code: " << ret); - RUNNER_ASSERT_MSG(count == 2, "Invalid number of policy levels. Should be 2, instead there is: " << static_cast(count)); + RUNNER_ASSERT_MSG(count == 3, "Invalid number of policy levels. Should be 3, instead there is: " << static_cast(count)); deny_policy = std::string(levels[0]); allow_policy = std::string(levels[count-1]); @@ -2368,8 +2363,8 @@ RUNNER_CHILD_TEST(security_manager_21_security_manager_admin_deny_user_priv) PRIVILEGE_MANAGER_ADMIN_PRIVILEGE}; privileges_t manifest_privs = { "http://tizen.org/privilege/internet", - "http://tizen.org/privilege/camera"}; - privileges_t real_privs_allow = {"http://tizen.org/privilege/camera"}; + "http://tizen.org/privilege/datasharing"}; + privileges_t real_privs_allow = {"http://tizen.org/privilege/datasharing"}; privileges_t real_privs_deny = {"http://tizen.org/privilege/internet"}; const std::string pirivman_id = "sm_test_13_ADMIN_APP";