/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <sm_api.h>
#include <temp_test_user.h>
#include <synchronization_pipe.h>
+ #include <dpl/test/safe_cleanup.h>
class ScopedInstaller {
public:
ScopedInstaller(const AppInstallHelper &app, bool requestUid = true)
: m_appId(app.getAppId()),
m_uid(app.getUID()),
+ m_installType(app.getInstallType()),
m_shouldUninstall(true),
m_requestUid(requestUid),
m_creatorPid(getpid())
for (const auto& typePaths : app.getFilesMap())
for (const auto& path : typePaths.second)
instReq.addPath(path, typePaths.first);
- for (const auto &priv : app.getPrivileges()) {
+ for (const auto &priv : app.getPrivileges())
instReq.addPrivilege(priv.c_str());
- }
+ for (const auto &priv : app.getAppDefinedPrivileges())
+ instReq.addAppDefinedPrivilege(priv);
+
SecurityManagerTest::Api::install(instReq);
}
ScopedInstaller(ScopedInstaller &&other)
: m_appId(std::move(other.m_appId)),
m_uid(other.m_uid),
+ m_installType(other.m_installType),
m_shouldUninstall(other.m_shouldUninstall),
m_requestUid(other.m_requestUid),
m_creatorPid(other.m_creatorPid)
virtual ~ScopedInstaller() {
if (m_creatorPid == getpid())
- uninstallApp();
+ {
+ SafeCleanup::run([this]{ uninstallApp(); });
+ }
}
void uninstallApp() {
uninstReq.setAppId(m_appId);
if (m_requestUid)
uninstReq.setUid(m_uid);
-
+ if (m_installType != SM_APP_INSTALL_NONE)
+ uninstReq.setInstallType(m_installType);
SecurityManagerTest::Api::uninstall(uninstReq);
m_shouldUninstall = false;
}
protected:
std::string m_appId;
uid_t m_uid;
+ app_install_type m_installType;
bool m_shouldUninstall;
bool m_requestUid;
pid_t m_creatorPid;
install(users[1], pkgId[0], appId[0], version[0], author[0], hybrid[1], SECURITY_MANAGER_ERROR_INPUT_PARAM);
// uid_1, pkg_0, app_0, version_0, author_1, not hybrid -> fail (author of app_0 must be the same)
install(users[1], pkgId[0], appId[0], version[0], author[1], hybrid[0], SECURITY_MANAGER_ERROR_INPUT_PARAM);
- // uid_1, pkg_0, app_0, version_1, author_0, not hybrid -> fail (version of app_0 must be the same)
- install(users[1], pkgId[0], appId[0], version[1], author[0], hybrid[0], SECURITY_MANAGER_ERROR_INPUT_PARAM);
+ // uid_1, pkg_0, app_0, version_1, author_0, not hybrid -> ok (version upgrade)
+ install(users[1], pkgId[0], appId[0], version[1], author[0], hybrid[0], SECURITY_MANAGER_SUCCESS);
// uid_1, pkg_1, app_0, version_0, author_0, not hybrid -> fail (pkg of app_0 must be the same)
install(users[1], pkgId[1], appId[0], version[0], author[0], hybrid[0], SECURITY_MANAGER_ERROR_INPUT_PARAM);
// uid_0, pkg_0, app_0, version_0, author_0, not hybrid -> ok (the same app again)
install(users[0], pkgId[0], appId[0], version[0], author[0], hybrid[0], SECURITY_MANAGER_SUCCESS, false);
// uid_0, pkg_1, app_0, version_0, author_0, not hybrid -> fail (app_name + uid must be unique)
install(users[0], pkgId[1], appId[0], version[0], author[0], hybrid[0], SECURITY_MANAGER_ERROR_INPUT_PARAM);
- // uid_0, pkg_0, app_0, version_1, author_0, not hybrid -> fail (app_name + uid must be unique)
- install(users[0], pkgId[0], appId[0], version[1], author[0], hybrid[0], SECURITY_MANAGER_ERROR_INPUT_PARAM);
// uid_0, pkg_0, app_0, version_0, author_1, not hybrid -> fail (app_name + uid must be unique)
install(users[0], pkgId[0], appId[0], version[0], author[1], hybrid[0], SECURITY_MANAGER_ERROR_INPUT_PARAM);
}
{
// FIXME - whitebox - cynara
const char *const MAIN_BUCKET = "MAIN";
- const char *const MANIFESTS_BUCKET = "MANIFESTS";
+ const char *const MANIFESTS_GLOBAL_BUCKET = "MANIFESTS_GLOBAL";
+ const char *const MANIFESTS_LOCAL_BUCKET = "MANIFESTS_LOCAL";
const char *const ADMIN_BUCKET = "ADMIN";
const char *const USER_TYPE_NORMAL_BUCKET = "USER_TYPE_NORMAL";
CynaraTestAdmin::Admin admin;
CynaraTestAdmin::CynaraPoliciesContainer emptyContainer;
admin.listPolicies(MAIN_BUCKET, CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, emptyContainer, CYNARA_API_SUCCESS);
- admin.listPolicies(MANIFESTS_BUCKET, CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, emptyContainer, CYNARA_API_SUCCESS);
+ admin.listPolicies(MANIFESTS_GLOBAL_BUCKET, CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, emptyContainer, CYNARA_API_SUCCESS);
+ admin.listPolicies(MANIFESTS_LOCAL_BUCKET, CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, emptyContainer, CYNARA_API_SUCCESS);
admin.listPolicies(CYNARA_ADMIN_DEFAULT_BUCKET, CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, emptyContainer, CYNARA_API_SUCCESS);
admin.listPolicies(ADMIN_BUCKET, CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, emptyContainer, CYNARA_API_SUCCESS);
}