#include <utility>
#include <vector>
+#include <app_install_helper.h>
#include <cynara_test_admin.h>
#include <dpl/test/test_runner.h>
#include <memory.h>
RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_admin)
{
- const char *const update_app_id = "security_manager_15_update_app_id";
+ AppInstallHelper app("security_manager_15_update");
const char *const update_privilege = "http://tizen.org/privilege/led";
const char *const check_start_bucket = "ADMIN";
const std::string username("sm_test_15_username");
TemporaryTestUser user(username, GUM_USERTYPE_ADMIN, false);
user.create();
+ app.createInstallDir();
+ InstallRequest inst;
+ inst.setAppId(app.getAppId());
+ inst.setPkgId(app.getPkgId());
+ Api::install(inst);
+
pid = fork();
RUNNER_ASSERT_MSG(pid >= 0, "fork failed");
if (pid != 0)//parent process
waitPid(pid);
- admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
+ admin.adminCheck(check_start_bucket, false, app.generateAppLabel().c_str(),
std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
}
if(pid == 0)
result = drop_root_privileges(msg.uid, msg.gid);
RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
- // FIXME - Application has to be installed for it to have policy set in SM
- PolicyEntry entry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
+ PolicyEntry entry(app.getAppId(), std::to_string(static_cast<int>(msg.uid)), update_privilege);
entry.setMaxLevel("Allow");
addPolicyRequest.addEntry(entry);
RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_admin_wildcard)
{
const char *const update_other_app_id = "security_manager_15_update_other_app_id";
+ const char *const update_other_pkg_id = "security_manager_15_update_other_pkg_id";
const char *const update_privilege = "http://tizen.org/privilege/led";
const char *const check_start_bucket = "ADMIN";
const std::string username("sm_test_15_username");
waitPid(pid);
- admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_other_app_id, "").c_str(),
+ admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_other_app_id, update_other_pkg_id).c_str(),
std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
}
if(pid == 0)
RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_self)
{
- const char *const update_app_id = "security_manager_15_update_app_id";
+ AppInstallHelper app("security_manager_15_update");
const char *const update_privilege = "http://tizen.org/privilege/led";
const char *const check_start_bucket = "";
const std::string username("sm_test_15_username");
TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, false);
user.create();
+ app.createInstallDir();
+ InstallRequest inst;
+ inst.setAppId(app.getAppId());
+ inst.setPkgId(app.getPkgId());
+ Api::install(inst);
+
pid = fork();
RUNNER_ASSERT_MSG(pid >= 0, "fork failed");
if (pid != 0)//parent process
waitPid(pid);
- admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
+ admin.adminCheck(check_start_bucket, false, app.generateAppLabel().c_str(),
std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
}
if(pid == 0)
result = drop_root_privileges(msg.uid, msg.gid);
RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
- // FIXME - Application has to be installed for it to have policy set in SM
- PolicyEntry entry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
+ PolicyEntry entry(app.getAppId(), std::to_string(static_cast<int>(msg.uid)), update_privilege);
entry.setLevel("Allow");
addPolicyRequest.addEntry(entry);
RUNNER_CHILD_TEST(security_manager_17_privacy_manager_delete_policy_for_self)
{
- const char *const update_app_id = "security_manager_17_update_app_id";
+ AppInstallHelper app("security_manager_17_update");
const char *const update_privilege = "http://tizen.org/privilege/led";
const char *const check_start_bucket = "";
const std::string username("sm_test_17_username");
TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, false);
user.create();
+ app.createInstallDir();
+ InstallRequest inst;
+ inst.setAppId(app.getAppId());
+ inst.setPkgId(app.getPkgId());
+ Api::install(inst);
+
pid[0] = fork();
RUNNER_ASSERT_MSG(pid[0] >= 0, "fork failed");
if (pid[0] != 0)//parent process
waitPid(pid[0]);
- admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
+ admin.adminCheck(check_start_bucket, false, app.generateAppLabel().c_str(),
std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
pid[1] = fork();
waitPid(pid[1]);
- admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
+ admin.adminCheck(check_start_bucket, false, app.generateAppLabel().c_str(),
std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_DENY, nullptr);
}
if(pid[1] == 0)
// delete this entry
PolicyRequest deletePolicyRequest;
- // FIXME - Application has to be installed for it to have policy set in SM
- PolicyEntry deleteEntry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
+ PolicyEntry deleteEntry(app.getAppId(), std::to_string(static_cast<int>(msg.uid)), update_privilege);
deleteEntry.setLevel(SECURITY_MANAGER_DELETE);
deletePolicyRequest.addEntry(deleteEntry);
result = drop_root_privileges(msg.uid, msg.gid);
RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
- // FIXME - Application has to be installed for it to have policy set in SM
- PolicyEntry entry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
+ PolicyEntry entry(app.getAppId(), std::to_string(static_cast<int>(msg.uid)), update_privilege);
entry.setLevel("Allow");
addPolicyRequest.addEntry(entry);