Move scoped installer to global commons 46/148746/2
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 7 Sep 2017 15:01:49 +0000 (17:01 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Fri, 15 Sep 2017 18:42:19 +0000 (20:42 +0200)
Change-Id: I9effa1a4cb6669f591d8d6ab7d2c39a1e6a7ba32

36 files changed:
src/common/CMakeLists.txt
src/common/app_def_privilege.h [new file with mode: 0644]
src/common/app_install_helper.cpp [new file with mode: 0644]
src/common/app_install_helper.h [new file with mode: 0644]
src/common/sm_api.cpp [new file with mode: 0644]
src/common/sm_api.h [new file with mode: 0644]
src/common/sm_label_monitor.cpp [new file with mode: 0644]
src/common/sm_label_monitor.h [new file with mode: 0644]
src/common/sm_policy_request.cpp [new file with mode: 0644]
src/common/sm_policy_request.h [new file with mode: 0644]
src/common/sm_request.cpp [new file with mode: 0644]
src/common/sm_request.h [new file with mode: 0644]
src/common/sm_sharing_request.cpp [new file with mode: 0644]
src/common/sm_sharing_request.h [new file with mode: 0644]
src/common/sm_user_request.cpp [new file with mode: 0644]
src/common/sm_user_request.h [new file with mode: 0644]
src/common/tzplatform.cpp [new file with mode: 0644]
src/common/tzplatform.h [new file with mode: 0644]
src/security-manager-tests/CMakeLists.txt
src/security-manager-tests/common/app_def_privilege.h [deleted file]
src/security-manager-tests/common/app_install_helper.cpp [deleted file]
src/security-manager-tests/common/app_install_helper.h [deleted file]
src/security-manager-tests/common/sm_api.cpp [deleted file]
src/security-manager-tests/common/sm_api.h [deleted file]
src/security-manager-tests/common/sm_label_monitor.cpp [deleted file]
src/security-manager-tests/common/sm_label_monitor.h [deleted file]
src/security-manager-tests/common/sm_policy_request.cpp [deleted file]
src/security-manager-tests/common/sm_policy_request.h [deleted file]
src/security-manager-tests/common/sm_request.cpp [deleted file]
src/security-manager-tests/common/sm_request.h [deleted file]
src/security-manager-tests/common/sm_sharing_request.cpp [deleted file]
src/security-manager-tests/common/sm_sharing_request.h [deleted file]
src/security-manager-tests/common/sm_user_request.cpp [deleted file]
src/security-manager-tests/common/sm_user_request.h [deleted file]
src/security-manager-tests/common/tzplatform.cpp [deleted file]
src/security-manager-tests/common/tzplatform.h [deleted file]

index cfb01ee7009ae08599963953e698a423de877253..0bfeb9bb310572923f1fcef5aa54cae459e21fed 100644 (file)
@@ -11,6 +11,7 @@ PKG_CHECK_MODULES(COMMON_TARGET_DEP
     cynara-creds-socket
     cynara-creds-dbus
     cynara-creds-gdbus
+    security-manager
     REQUIRED
     )
 
@@ -34,6 +35,14 @@ SET(COMMON_TARGET_TEST_SOURCES
     ${PROJECT_SOURCE_DIR}/src/common/temp_test_user.cpp
     ${PROJECT_SOURCE_DIR}/src/common/cynara_helpers_creds.cpp
     ${PROJECT_SOURCE_DIR}/src/common/label_generator.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/app_install_helper.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/sm_api.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/sm_label_monitor.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/sm_request.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/sm_sharing_request.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/sm_user_request.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/sm_policy_request.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/tzplatform.cpp
     )
 
 #system and local includes
diff --git a/src/common/app_def_privilege.h b/src/common/app_def_privilege.h
new file mode 100644 (file)
index 0000000..6d00972
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014-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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+#pragma once
+
+#include <string>
+#include <utility>
+#include <vector>
+#include <tuple>
+
+#include <security-manager-types.h>
+#include <dpl/test/test_runner.h>
+
+class Privilege {
+public:
+    enum Type {
+        UNSET,
+        UNTRUSTED,
+        LICENSED,
+    };
+
+    Privilege(std::string systemPrivilege, Type type = UNSET, std::string license = std::string())
+      : m_name(std::move(systemPrivilege))
+      , m_type(type)
+      , m_license(std::move(license))
+    {}
+
+    Privilege(std::string licensedPrivilege, std::string license)
+      : m_name(std::move(licensedPrivilege))
+      , m_type(LICENSED)
+      , m_license(std::move(license))
+    {}
+
+    bool isUnset() const { return m_type == UNSET; }
+    bool isUntrusted() const { return m_type == UNTRUSTED; }
+    bool isLicensed() const { return m_type == LICENSED; }
+
+    int getType() const { return m_type; }
+    app_defined_privilege_type getSMType () const {
+        RUNNER_ASSERT(m_type != UNSET);
+        if (isLicensed()) return SM_APP_DEFINED_PRIVILEGE_TYPE_LICENSED;
+        return SM_APP_DEFINED_PRIVILEGE_TYPE_UNTRUSTED;
+    }
+
+    const std::string& getName() const { return m_name; }
+    const std::string& getLicense() const { return m_license; }
+
+    const char *getNameC() const { return m_name.c_str(); }
+    const char *getLicenseC() const { return m_license.c_str(); }
+
+    operator const char *() const { return m_name.c_str(); }
+
+    operator std::string() const { return m_name; }
+
+private:
+    std::string m_name;
+    Type m_type;
+    std::string m_license;
+};
+
+typedef std::vector<Privilege> PrivilegeVector;
+
diff --git a/src/common/app_install_helper.cpp b/src/common/app_install_helper.cpp
new file mode 100644 (file)
index 0000000..b9f3073
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2014-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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <fcntl.h>
+#include <map>
+#include <string>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/smack.h>
+#include <unistd.h>
+#include <utility>
+
+#include <security-manager-types.h>
+
+#include <dpl/test/test_runner.h>
+#include <tzplatform.h>
+#include <label_generator.h>
+
+#include "app_install_helper.h"
+
+AppInstallHelper::AppInstallHelper(AppInstallHelper &&other)
+    : m_appName(std::move(other.m_appName)), m_pkgName(std::move(other.m_pkgName)),
+      m_isLocal(other.m_isLocal), m_uidGid(other.m_uidGid),
+      m_version(std::move(other.m_version)), m_installType(other.m_installType),
+      m_isHybrid(other.m_isHybrid), m_installDir(std::move(other.m_installDir)),
+      m_dirTypeMap(std::move(other.m_dirTypeMap)),
+      m_fileTypeMap(std::move(other.m_fileTypeMap)),
+      m_privileges(std::move(other.m_privileges)),
+      m_appDefinedPrivileges(std::move(other.m_appDefinedPrivileges)),
+      m_author(std::move(other.m_author)),
+      m_creatorPid(other.m_creatorPid)
+{
+    other.m_creatorPid = -1;
+}
+
+std::string AppInstallHelper::getInstallDir() const {
+    return m_installDir + getPkgId();
+}
+
+std::string AppInstallHelper::getTrustedDir(int i) const {
+    return getInstallDir() + "/trustedDir" + std::to_string(i);
+}
+
+std::string AppInstallHelper::getPrivateDir(int i) const {
+    return getInstallDir() + "/app_dir" + std::to_string(i) +"/";
+}
+
+std::string AppInstallHelper::getPrivateRODir(int i) const {
+    return getInstallDir() + "/app_dir_ro" + std::to_string(i) +"/";
+}
+
+std::string AppInstallHelper::getPublicDir() const {
+    return getInstallDir() + "/app_public_ro/";
+}
+
+std::string AppInstallHelper::getPrivatePath(int i) const {
+    return getPrivateDir() + "shareme" + std::to_string(i);
+}
+
+std::string AppInstallHelper::getSharedRODir(int i) const {
+    return getInstallDir() + "/app_dir_rw_others_ro" + std::to_string(i) +"/";
+}
+
+std::string AppInstallHelper::getAppId() const {
+    return m_appName + "_app_id";
+}
+
+std::string AppInstallHelper::getPkgId() const {
+    return m_pkgName + "_pkg_id";
+}
+
+void AppInstallHelper::setVersion(const std::string &version) {
+    m_version = version;
+}
+
+std::string AppInstallHelper::getVersion() const {
+    return m_version;
+}
+
+int AppInstallHelper::getUID() const {
+    return m_uidGid;
+}
+
+int AppInstallHelper::getGID() const {
+    return m_uidGid;
+}
+
+void AppInstallHelper::createInstallDir() {
+    create(mkdir, getInstallDir());
+    m_isInstallDirCreated = true;
+}
+
+void AppInstallHelper::createTrustedDir(int i) {
+    if (create(mkdir, getTrustedDir(i)))
+        m_dirTypeMap[SECURITY_MANAGER_PATH_TRUSTED_RW].emplace_back(getTrustedDir(i));
+}
+
+void AppInstallHelper::createPrivateDir(int i) {
+    if (create(mkdir, getPrivateDir(i)))
+        m_dirTypeMap[SECURITY_MANAGER_PATH_RW].emplace_back(getPrivateDir(i));
+}
+
+void AppInstallHelper::createPublicDir() {
+    if (mkdir(getPublicDir().c_str(), 0777) == 0) {
+        m_dirTypeMap[SECURITY_MANAGER_PATH_PUBLIC_RO].emplace_back(getPublicDir());
+    }
+}
+
+void AppInstallHelper::createPrivateFile(int i) {
+    // This is intentional, let all private file be in one directory
+    createPrivateDir();
+    if (create(creat, getPrivatePath(i)))
+        m_fileTypeMap[SECURITY_MANAGER_PATH_RW].emplace_back(getPrivatePath(i));
+}
+
+void AppInstallHelper::createSharedRODir(int i) {
+    if (create(mkdir, getSharedRODir(i)))
+        m_dirTypeMap[SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO].emplace_back(getSharedRODir(i));
+}
+
+void AppInstallHelper::createPrivateRODir(int i) {
+    if (create(mkdir, getPrivateRODir(i)))
+        m_dirTypeMap[SECURITY_MANAGER_PATH_RO].emplace_back(getPrivateRODir(i));
+}
+
+void AppInstallHelper::setHybrid() {
+    m_isHybrid = true;
+}
+
+bool AppInstallHelper::getIsHybrid() const {
+    return m_isHybrid;
+}
+
+void AppInstallHelper::addPrivileges(const std::vector<std::string> &privileges) {
+    for (auto &p : privileges) {
+        addPrivilege(Privilege(p));
+    }
+}
+
+std::vector<std::string> AppInstallHelper::getPrivilegesNames() const {
+    std::vector<std::string> privileges;
+    for (auto &p : m_privileges) {
+        privileges.push_back(p.getName());
+    }
+    return privileges;
+}
+
+void AppInstallHelper::addPrivilege(Privilege privilege) {
+    m_privileges.push_back(std::move(privilege));
+}
+
+void AppInstallHelper::addPrivileges(const PrivilegeVector &privileges) {
+    std::copy(privileges.begin(), privileges.end(), std::back_inserter(m_privileges));
+}
+
+const PrivilegeVector& AppInstallHelper::getPrivileges() const {
+    return m_privileges;
+}
+
+void AppInstallHelper::addAppDefinedPrivilege(Privilege privilege) {
+    m_appDefinedPrivileges.push_back(std::move(privilege));
+}
+
+const PrivilegeVector& AppInstallHelper::getAppDefinedPrivileges() const {
+    return m_appDefinedPrivileges;
+}
+
+void AppInstallHelper::revokeRules() const {
+    RUNNER_ASSERT_MSG(
+        0 == smack_revoke_subject(generateAppLabel().c_str()),
+        "Revoking smack subject failed");
+}
+
+std::string AppInstallHelper::generateAppLabel() const {
+    return generateProcessLabel(getAppId(), getPkgId(), getIsHybrid());
+}
+
+std::string AppInstallHelper::generatePkgLabel() const {
+    return generatePathRWLabel(getPkgId());
+}
+
+const AppInstallHelper::TypePathsMap& AppInstallHelper::getDirsMap() const {
+    return m_dirTypeMap;
+}
+
+const AppInstallHelper::TypePathsMap& AppInstallHelper::getFilesMap() const {
+    return m_fileTypeMap;
+}
+
+void AppInstallHelper::removePaths() {
+    for (const auto &oneTypePaths : m_dirTypeMap)
+            for (const auto& path : oneTypePaths.second)
+                rmdir(path.c_str());
+
+    m_dirTypeMap.clear();
+
+    for (const auto &oneTypePaths : m_fileTypeMap)
+            for (const auto& path : oneTypePaths.second)
+                unlink(path.c_str());
+
+    m_fileTypeMap.clear();
+
+    rmdir(getInstallDir().c_str());
+    m_isInstallDirCreated = false;
+}
+
+void AppInstallHelper::setInstallPath() {
+    if (m_isLocal)
+        m_installDir = TzPlatformConfig::appDirPath(getUID());
+    else
+        m_installDir = TzPlatformConfig::globalAppDir() + "/";
+}
+
+bool AppInstallHelper::create(std::function<int(const char*, mode_t)> &&creatFun, const std::string &path) {
+    if (!m_isInstallDirCreated && path != getInstallDir())
+        createInstallDir();
+    if (creatFun(path.c_str(), 0751) == 0) {
+       // Local paths need user change
+       if (!m_isLocal || chown(path.c_str(), m_uidGid, m_uidGid) == 0)
+                return true;
+       }
+    return false;
+}
+
+void AppInstallHelper::setAuthor(const std::string &author) {
+    m_author = author;
+}
+std::string AppInstallHelper::getAuthor() const {
+    return m_author;
+}
+
+void AppInstallHelper::setInstallType(app_install_type type) {
+    m_installType = type;
+}
+app_install_type AppInstallHelper::getInstallType() const {
+    return m_installType;
+}
+
diff --git a/src/common/app_install_helper.h b/src/common/app_install_helper.h
new file mode 100644 (file)
index 0000000..a514238
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2014-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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+#pragma once
+
+#include <fcntl.h>
+#include <functional>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <security-manager-types.h>
+#include <app_def_privilege.h>
+
+struct AppInstallHelper {
+
+    using TypePathsMap = std::map<app_install_path_type, std::vector<std::string>>;
+    AppInstallHelper(const std::string &appNamePrefix,
+                     const std::string &pkgNamePrefix,
+                     bool isLocal,
+                     uid_t uid,
+                     std::string version = std::string())
+      : m_appName(appNamePrefix), m_pkgName(pkgNamePrefix), m_isLocal(isLocal), m_uidGid(uid), m_version(version),
+        m_installType(SM_APP_INSTALL_NONE), m_isHybrid(false), m_isInstallDirCreated(false), m_creatorPid(getpid())
+    {
+        setInstallPath();
+    }
+
+    AppInstallHelper(const std::string &appNamePrefix,
+                     const std::string &pkgNamePrefix,
+                     uid_t uid)
+      : AppInstallHelper(appNamePrefix, pkgNamePrefix, false, uid)
+    {}
+
+    AppInstallHelper(const std::string &namePrefix)
+      : AppInstallHelper(namePrefix, namePrefix, false, geteuid())
+    {}
+
+    AppInstallHelper(const std::string &appNamePrefix, const std::string &pkgNamePrefix)
+      : AppInstallHelper(appNamePrefix, pkgNamePrefix, false, geteuid())
+    {}
+
+    AppInstallHelper(const std::string &namePrefix, uid_t uid)
+      : AppInstallHelper(namePrefix, namePrefix, true, uid)
+    {}
+
+    AppInstallHelper(const std::string &appNamePrefix, const std::string &pkgNamePrefix, uid_t uid,
+                     const std::string &version)
+      : AppInstallHelper(appNamePrefix, pkgNamePrefix, true, uid, version)
+    {}
+
+    AppInstallHelper(const std::string &namePrefix, uid_t uid, const std::string &version)
+      : AppInstallHelper(namePrefix, namePrefix, true, uid, version)
+    {}
+
+    AppInstallHelper(const AppInstallHelper &other) = default;
+    AppInstallHelper& operator=(const AppInstallHelper &other) = delete;
+    AppInstallHelper(AppInstallHelper &&other);
+
+    // App info getters and setters
+    std::string getAppId() const;
+    std::string getPkgId() const;
+    int getUID() const;
+    int getGID() const;
+    void setVersion(const std::string &version);
+    std::string getVersion() const;
+    void setAuthor(const std::string &author);
+    std::string getAuthor() const;
+    void setInstallType(app_install_type type);
+    app_install_type getInstallType() const;
+    void setHybrid();
+    bool getIsHybrid() const;
+
+    // Path types creation and removal on file system
+    void createInstallDir();
+    void createTrustedDir(int i = 0);
+    void createPrivateDir(int i = 0);
+    void createPublicDir();
+    void createPrivateFile(int i = 0);
+    void createSharedRODir(int i = 0);
+    void createPrivateRODir(int i = 0);
+    void removePaths();
+
+    // Path getters
+    std::string getInstallDir() const;
+    std::string getTrustedDir(int i = 0) const;
+    std::string getPrivateDir(int i = 0) const;
+    std::string getPrivateRODir(int i = 0) const;
+    std::string getPublicDir() const;
+    std::string getPrivatePath(int i = 0) const;
+    std::string getSharedRODir(int i = 0) const;
+    const TypePathsMap& getDirsMap() const;
+    const TypePathsMap& getFilesMap() const;
+
+    // Privileges
+    std::vector<std::string> getPrivilegesNames() const;             // deprecated
+    void addPrivileges(const std::vector<std::string> &privileges);  // deprecated
+    void addPrivilege(Privilege privilege);
+    void addPrivileges(const PrivilegeVector &privileges);
+    const PrivilegeVector& getPrivileges() const;
+
+    void addAppDefinedPrivilege(Privilege privilege);
+    const PrivilegeVector& getAppDefinedPrivileges() const;
+
+    // Smack
+    std::string generateAppLabel() const;
+    std::string generatePkgLabel() const;
+    void revokeRules() const;
+    virtual ~AppInstallHelper() {
+        if (m_creatorPid == getpid())
+            removePaths();
+    }
+
+protected:
+    void setInstallPath();
+    bool create(std::function<int(const char*, mode_t)> &&creatFun, const std::string &path);
+    std::string m_appName;
+    std::string m_pkgName;
+    bool m_isLocal;
+    int m_uidGid;
+    std::string m_version;
+    app_install_type m_installType;
+    bool m_isHybrid;
+    std::string m_installDir;
+    bool m_isInstallDirCreated;
+    TypePathsMap m_dirTypeMap;
+    TypePathsMap m_fileTypeMap;
+    PrivilegeVector m_privileges;
+    PrivilegeVector m_appDefinedPrivileges;
+    std::string m_author;
+
+    pid_t m_creatorPid;
+};
diff --git a/src/common/sm_api.cpp b/src/common/sm_api.cpp
new file mode 100644 (file)
index 0000000..d7ab650
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ * Copyright (c) 2014-2015 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <sm_api.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+namespace Api {
+
+void install(const InstallRequest &request, lib_retcode expectedResult)
+{
+    int result = security_manager_app_install(request.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "installing app returned wrong value."
+                          << " InstallRequest: [ " << request << "];"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void uninstall(const InstallRequest &request, lib_retcode expectedResult)
+{
+    int result = security_manager_app_uninstall(request.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "uninstalling app returned wrong value."
+                          << " InstallRequest: [ " << request << "];"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+std::string getPkgId(const std::string &appId, lib_retcode expectedResult)
+{
+    char *pkgId = nullptr;
+    int result = security_manager_get_app_pkgid(&pkgId, appId.c_str());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "getting pkg id from app id returned wrong value."
+                          << " App id: " << appId << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    if (expectedResult != SECURITY_MANAGER_SUCCESS)
+        return std::string();
+
+    RUNNER_ASSERT_MSG(pkgId != nullptr, "getting pkg id did not allocate memory");
+    std::string str(pkgId);
+    free(pkgId);
+    return str;
+}
+
+void setProcessLabel(const std::string &appId, lib_retcode expectedResult)
+{
+    int result = security_manager_set_process_label_from_appid(appId.c_str());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting process label from app id returned wrong value."
+                          << " App id: " << appId << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void setProcessGroups(const std::string &appId, lib_retcode expectedResult)
+{
+    int result = security_manager_set_process_groups_from_appid(appId.c_str());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting process groups from app id returned wrong value."
+                          << " App id: " << appId << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void dropProcessPrivileges(lib_retcode expectedResult)
+{
+    int result = security_manager_drop_process_privileges();
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "dropping process privileges returned wrong value."
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void prepareApp(const std::string &appId, lib_retcode expectedResult)
+{
+    int result = security_manager_prepare_app(appId.c_str());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "preparing app returned wrong value."
+                          << " App id: " << appId << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void addUser(const UserRequest &request, lib_retcode expectedResult)
+{
+    int result = security_manager_user_add(request.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "adding user returned wrong value."
+                          << " UserRequest: [ " << request << "];"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void deleteUser(const UserRequest &request, lib_retcode expectedResult)
+{
+    int result = security_manager_user_delete(request.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "deleting user returned wrong value."
+                          << " UserRequest: [ " << request << "];"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void sendPolicy(const PolicyRequest &request, lib_retcode expectedResult)
+{
+    int result = security_manager_policy_update_send(request.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                          "sending policy update for self returned wrong value."
+                          << " PolicyRequest: [ " << request << "];"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void getConfiguredPolicy(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult, bool forAdmin)
+{
+    policy_entry **pp_privs_policy = NULL;
+    size_t policy_size = 0;
+    int result;
+
+    if (forAdmin) {
+        result = security_manager_get_configured_policy_for_admin(filter.get(), &pp_privs_policy, &policy_size);
+    } else {
+        result = security_manager_get_configured_policy_for_self(filter.get(), &pp_privs_policy, &policy_size);
+    };
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "Unexpected result for filter: " << filter << std::endl
+                          << " Result: " << result << ";");
+
+    for (unsigned int i = 0; i < policy_size; ++i) {
+        PolicyEntry pe(*pp_privs_policy[i]);
+        policyEntries.push_back(pe);
+    };
+}
+
+void getPolicy(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult)
+{
+    policy_entry **pp_privs_policy = NULL;
+    size_t policy_size = 0;
+    int result;
+
+    result = security_manager_get_policy(filter.get(), &pp_privs_policy, &policy_size);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "Unexpected result" << std::endl
+                          << " Result: " << result << ";");
+    for (unsigned int i = 0; i < policy_size; ++i) {
+        PolicyEntry pe(*pp_privs_policy[i]);
+        policyEntries.push_back(pe);
+    };
+}
+
+void applySharing(const SharingRequest &req, lib_retcode expectedResult) {
+    int result = security_manager_private_sharing_apply(req.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "Unexpected result from security_manager_private_sharing_apply" << std::endl
+                          << " Result: " << result << ";");
+}
+
+void dropSharing(const SharingRequest &req, lib_retcode expectedResult) {
+    int result = security_manager_private_sharing_drop(req.get());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "Unexpected result from security_manager_private_sharing_drop" << std::endl
+                          << " Result: " << result << ";");
+}
+
+void getPolicyForSelf(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult)
+{
+    getConfiguredPolicy(filter, policyEntries, expectedResult, false);
+}
+
+void getPolicyForAdmin(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult)
+{
+    getConfiguredPolicy(filter, policyEntries, expectedResult, true);
+}
+
+void getPkgIdBySocket(int socketFd, std::string *pkgId, std::string *appId, lib_retcode expectedResult)
+{
+    char *pkg_Id = nullptr;
+    char *app_Id = nullptr;
+
+    int result = security_manager_identify_app_from_socket(socketFd,
+                    pkgId == nullptr ? nullptr : &pkg_Id,
+                    appId == nullptr ? nullptr : &app_Id);
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "getting pkg id from socket returned wrong value."
+                          << " socket: " << socketFd << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+
+    if (pkg_Id) {
+        *pkgId = pkg_Id;
+        free(pkg_Id);
+    }
+
+    if (app_Id) {
+        *appId = app_Id;
+        free(app_Id);
+    }
+}
+
+void getPkgIdByPid(pid_t pid, std::string *pkgId, std::string *appId, lib_retcode expectedResult)
+{
+    char *pkg_Id = nullptr;
+    char *app_Id = nullptr;
+
+    int result = security_manager_identify_app_from_pid(pid,
+                    pkgId == nullptr ? nullptr : &pkg_Id,
+                    appId == nullptr ? nullptr : &app_Id);
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "getting pkg id from pid returned wrong value."
+                          << " pid: " << pid << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+
+    if (pkg_Id) {
+        *pkgId = pkg_Id;
+        free(pkg_Id);
+    }
+
+    if (app_Id) {
+        *appId = app_Id;
+        free(app_Id);
+    }
+}
+
+void getPkgIdByCynaraClient(const std::string &client, std::string *pkgId, std::string *appId,
+                            lib_retcode expectedResult)
+{
+    char *pkg_Id = nullptr;
+    char *app_Id = nullptr;
+
+    int result = security_manager_identify_app_from_cynara_client(client.c_str(),
+                    pkgId == nullptr ? nullptr : &pkg_Id,
+                    appId == nullptr ? nullptr : &app_Id);
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "getting pkg id from pid returned wrong value."
+                          << " client: " << client << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+
+    if (pkg_Id) {
+        *pkgId = pkg_Id;
+        free(pkg_Id);
+    }
+
+    if (app_Id) {
+        *appId = app_Id;
+        free(app_Id);
+    }
+}
+
+void appHasPrivilege(const std::string &appId, const std::string &privilege, uid_t user,
+                     int &value, lib_retcode expectedResult)
+{
+    int result = security_manager_app_has_privilege(appId.c_str(), privilege.c_str(), user, &value);
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "checking application privilege returned wrong result."
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void getSecurityManagerGroups(gid_t **groups, size_t *groups_count, lib_retcode expectedResult)
+{
+  int result = security_manager_groups_get(groups, groups_count);
+  RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
+                    "Unexpected result in security_manager_groups_get()" << std::endl
+                    << " Result: " << result << " Expected: " << expectedResult);
+}
+
+void registerPaths(const PathsRequest& req, lib_retcode expectedResult)
+{
+    int result = security_manager_paths_register(req.get());
+    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
+                      "Unexpected result in security_manager_paths_register()" << std::endl
+                      << " Result: " << result << " Expected: " << expectedResult);
+}
+
+void labelsMonitorGetFd(const LabelMonitor &monitor, int *fd, lib_retcode expectedResult)
+{
+    int result = security_manager_app_labels_monitor_get_fd(monitor.get(), fd);
+    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
+                      "Unexpected result in security_manager_app_labels_monitor_get_fd()"
+                          << std::endl << " Result: " << result << " Expected: "
+                          << expectedResult);
+};
+
+void labelsProcess(const LabelMonitor &monitor, lib_retcode expectedResult)
+{
+    int result = security_manager_app_labels_monitor_process(monitor.get());
+    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
+                      "Unexpected result in security_manager_app_labels_monitor_process()"
+                          << std::endl << " Result: " << result << " Expected: "
+                          << expectedResult);
+}
+
+} // namespace Api
+
+} // namespace SecurityManagerTest
diff --git a/src/common/sm_api.h b/src/common/sm_api.h
new file mode 100644 (file)
index 0000000..ca1fb6d
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014-2015 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_API
+#define SECURITY_MANAGER_TEST_API
+
+#include <sm_label_monitor.h>
+#include <sm_policy_request.h>
+#include <sm_request.h>
+#include <sm_sharing_request.h>
+#include <sm_user_request.h>
+
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+namespace Api {
+
+void install(const InstallRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void uninstall(const InstallRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+std::string getPkgId(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void setProcessLabel(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void setProcessGroups(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void dropProcessPrivileges(lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void prepareApp(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void addUser(const UserRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void deleteUser(const UserRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void sendPolicy(const PolicyRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getPolicy(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getPolicyForSelf(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getPolicyForAdmin(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void applySharing(const SharingRequest &req, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void dropSharing(const SharingRequest &req, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getPkgIdBySocket(int socketFd, std::string *pkgId, std::string *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getPkgIdByPid(pid_t pid, std::string *pkgId, std::string *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getPkgIdByCynaraClient(const std::string &client, std::string *pkgId, std::string *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void appHasPrivilege(const std::string &appId, const std::string &privilege, uid_t user, int &value, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void getSecurityManagerGroups(gid_t **groups, size_t *groups_count, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void registerPaths(const PathsRequest& req, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void labelsMonitorGetFd(const LabelMonitor &monitor, int *fd, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void labelsProcess(const LabelMonitor &monitor, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+
+} // namespace Api
+
+} // namespace SecurityManagerTest
+#endif // SECURITY_MANAGER_TEST_API
diff --git a/src/common/sm_label_monitor.cpp b/src/common/sm_label_monitor.cpp
new file mode 100644 (file)
index 0000000..6d648fe
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include "sm_label_monitor.h"
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+LabelMonitor::LabelMonitor()
+    : m_monitor(nullptr)
+{
+    int result = security_manager_app_labels_monitor_init(&m_monitor);
+    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == SECURITY_MANAGER_SUCCESS,
+                      "security_manager_app_labels_monitor_init failed with " << result);
+    RUNNER_ASSERT_MSG(m_monitor != nullptr,
+                      "security_manager_app_labels_monitor_init didn't allocate memory");
+}
+
+LabelMonitor::~LabelMonitor()
+{
+    security_manager_app_labels_monitor_finish(m_monitor);
+}
+
+} // namespace SecurityManagerTest
diff --git a/src/common/sm_label_monitor.h b/src/common/sm_label_monitor.h
new file mode 100644 (file)
index 0000000..ee82863
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#pragma once
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+class LabelMonitor
+{
+public:
+    LabelMonitor();
+    LabelMonitor(const LabelMonitor&) = delete;
+    LabelMonitor& operator=(const LabelMonitor&) = delete;
+    ~LabelMonitor();
+
+    app_labels_monitor *get() const { return m_monitor; }
+private:
+    app_labels_monitor *m_monitor;
+};
+
+} // namespace SecurityManagerTest
+
diff --git a/src/common/sm_policy_request.cpp b/src/common/sm_policy_request.cpp
new file mode 100644 (file)
index 0000000..debda17
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2015 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <sm_policy_request.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+PolicyEntry::PolicyEntry()
+    : m_appId(true, std::string(SECURITY_MANAGER_ANY))
+    , m_user(true, std::string(SECURITY_MANAGER_ANY))
+    , m_privilege(true, std::string(SECURITY_MANAGER_ANY))
+    , m_currentLevel(false, std::string(""))
+    , m_maxLevel(false, std::string(""))
+{
+    int result = security_manager_policy_entry_new(&m_entry);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new policy entry failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_entry != nullptr, "creation of new policy entry did not allocate memory");
+
+    security_manager_policy_entry_set_application(m_entry, m_appId.second.c_str());
+    security_manager_policy_entry_set_user(m_entry, m_user.second.c_str());
+    security_manager_policy_entry_set_privilege(m_entry, m_privilege.second.c_str());
+}
+
+PolicyEntry::PolicyEntry(const std::string &appId, const std::string &user,
+        const std::string &privilege)
+    : m_appId(true, std::string(appId))
+    , m_user(true, std::string(user))
+    , m_privilege(true, std::string(privilege))
+    , m_currentLevel(false, std::string(""))
+    , m_maxLevel(false, std::string(""))
+{
+    int result = security_manager_policy_entry_new(&m_entry);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new policy entry failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_entry != nullptr, "creation of new policy entry did not allocate memory");
+
+    security_manager_policy_entry_set_user(m_entry, m_user.second.c_str());
+    security_manager_policy_entry_set_application(m_entry, m_appId.second.c_str());
+    security_manager_policy_entry_set_privilege(m_entry, m_privilege.second.c_str());
+}
+
+PolicyEntry::PolicyEntry(policy_entry &entry): m_entry(&entry)
+{
+    m_appId.first = true;
+    m_appId.second = std::string(security_manager_policy_entry_get_application(m_entry));
+
+    m_user.first = true;
+    m_user.second = std::string(security_manager_policy_entry_get_user(m_entry));
+
+    m_privilege.first = true;
+    m_privilege.second = std::string(security_manager_policy_entry_get_privilege(m_entry));
+
+    m_currentLevel.first = true;
+    m_currentLevel.second = std::string(security_manager_policy_entry_get_level(m_entry));
+
+    m_maxLevel.first = true;
+    m_maxLevel.second = std::string(security_manager_policy_entry_get_max_level(m_entry));
+};
+
+void PolicyEntry::setLevel(const std::string &level)
+{
+    m_currentLevel.first = true;
+    m_currentLevel.second = level;
+    security_manager_policy_entry_set_level(m_entry, level.c_str());
+    m_maxLevel.first = true;
+    m_maxLevel.second = std::string(security_manager_policy_entry_get_max_level(m_entry));
+};
+
+void PolicyEntry::setMaxLevel(const std::string &level)
+{
+    m_maxLevel.first = true;
+    m_maxLevel.second = level;
+    security_manager_policy_entry_admin_set_level(m_entry, level.c_str());
+    m_currentLevel.first = true;
+    m_currentLevel.second = std::string(security_manager_policy_entry_get_level(m_entry));
+};
+
+
+std::ostream& operator<<(std::ostream &os, const PolicyEntry &request)
+{
+    if (request.m_appId.first)
+            os << "appId: " << request.m_appId.second << "; ";
+
+    if (request.m_user.first)
+            os << "user: " << request.m_user.second << "; ";
+
+    if (request.m_privilege.first)
+            os << "privilege: " << request.m_privilege.second << "; ";
+
+    if (request.m_currentLevel.first)
+            os << "current: " << request.m_currentLevel.second << "; ";
+
+    if (request.m_maxLevel.first)
+            os << "max: " << request.m_maxLevel.second << "; ";
+
+    return os;
+}
+
+PolicyEntry::~PolicyEntry()
+{
+}
+
+void PolicyEntry::free(void)
+{
+    security_manager_policy_entry_free(m_entry);
+}
+
+bool PolicyEntry::operator==(const PolicyEntry &other) const
+{
+    auto cmp = [](const std::pair<bool, std::string> &a, const std::pair<bool, std::string> &b)->bool
+    {
+        return (a.first) ? (b.first && a.second == b.second) : !b.first;
+    };
+
+    return (
+        cmp(m_appId, other.m_appId) &&
+        cmp(m_user, other.m_user) &&
+        cmp(m_privilege, other.m_privilege) &&
+        cmp(m_currentLevel, other.m_currentLevel) &&
+        cmp(m_maxLevel, other.m_maxLevel));
+}
+
+std::string PolicyEntry::toString() const
+{
+    std::stringstream ss;
+    auto append = [&](const std::pair<bool, std::string> &x)
+    {
+        if (x.first)
+            ss << x.second;
+        ss << '\0';
+    };
+
+    append(m_appId);
+    append(m_user);
+    append(m_privilege);
+    append(m_currentLevel);
+    append(m_maxLevel);
+
+    return ss.str();
+}
+
+PolicyRequest::PolicyRequest()
+    : m_req(nullptr),
+      m_entries()
+{
+    int result = security_manager_policy_update_req_new(&m_req);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new policy request failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new policy request did not allocate memory");
+}
+
+PolicyRequest::~PolicyRequest()
+{
+    for(std::vector<PolicyEntry>::iterator it = m_entries.begin(); it != m_entries.end(); ++it) {
+        it->free();
+    }
+    security_manager_policy_update_req_free(m_req);
+}
+
+void PolicyRequest::addEntry(PolicyEntry &entry,
+        lib_retcode expectedResult)
+{
+    int result = 0;
+
+    result = security_manager_policy_update_req_add_entry(m_req, entry.get());
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                     "adding policy entry to request returned wrong value."
+                          << " entry: " << entry << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+
+    m_entries.push_back(entry);
+}
+
+std::ostream& operator<<(std::ostream &os, const PolicyRequest &request)
+{
+    if (request.m_entries.size() != 0)
+    {
+        os << "PolicyRequest m_entries size: " << request.m_entries.size() << "; ";
+
+        for(unsigned int i = 0; i != request.m_entries.size(); i++) {
+           os << "entry " << i << ": " << request.m_entries[i] << "; ";
+       }
+    }
+
+    return os;
+}
+
+} // namespace SecurityManagerTest
diff --git a/src/common/sm_policy_request.h b/src/common/sm_policy_request.h
new file mode 100644 (file)
index 0000000..4c12102
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_POLICYREQUEST
+#define SECURITY_MANAGER_TEST_POLICYREQUEST
+
+#include <iostream>
+#include <sys/types.h>
+#include <utility>
+#include <vector>
+
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+class PolicyEntry
+{
+public:
+    PolicyEntry();
+
+    PolicyEntry(const std::string &appId,
+                const std::string &user,
+                const std::string &privilege
+                );
+    ~PolicyEntry();
+
+    PolicyEntry(policy_entry &entry);
+
+    policy_entry *get() const { return m_entry; }
+    std::string getUser() const         { return m_user.second; }
+    std::string getAppId() const        { return m_appId.second; }
+    std::string getPrivilege() const    { return m_privilege.second; }
+    std::string getCurrentLevel() const { return m_currentLevel.second; }
+    std::string getMaxLevel() const     { return m_maxLevel.second; }
+    void setLevel(const std::string &level);
+    void setMaxLevel(const std::string &level);
+    void free(void);
+
+    friend std::ostream& operator<<(std::ostream &, const PolicyEntry&);
+    bool operator==(const PolicyEntry &) const;
+    std::string toString() const;
+
+private:
+    policy_entry *m_entry;
+    std::pair<bool, std::string> m_appId;
+    std::pair<bool, std::string> m_user;
+    std::pair<bool, std::string> m_privilege;
+    std::pair<bool, std::string> m_currentLevel;
+    std::pair<bool, std::string> m_maxLevel;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PolicyEntry &request);
+
+class PolicyRequest
+{
+public:
+    PolicyRequest();
+    PolicyRequest(const PolicyRequest&) = delete;
+    PolicyRequest& operator=(const PolicyRequest&) = delete;
+    ~PolicyRequest();
+
+    void addEntry(PolicyEntry &entry, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+
+    policy_update_req *get() const { return m_req; }
+    friend std::ostream& operator<<(std::ostream &, const PolicyRequest&);
+
+private:
+    policy_update_req *m_req;
+    std::vector<PolicyEntry> m_entries;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PolicyRequest &request);
+
+} // namespace SecurityManagerTest
+
+namespace std {
+
+template<>
+struct hash<SecurityManagerTest::PolicyEntry> {
+    size_t operator()(const SecurityManagerTest::PolicyEntry &x) const { return hash<string>()(x.toString()); }
+};
+
+} // namespace std
+
+#endif // SECURITY_MANAGER_TEST_USERREQUEST
diff --git a/src/common/sm_request.cpp b/src/common/sm_request.cpp
new file mode 100644 (file)
index 0000000..6e06150
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2014-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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <sm_request.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+void prepare_request(InstallRequest &request,
+                     const std::string &app_id,
+                     const std::string &pkg_id,
+                     app_install_path_type pathType,
+                     const std::string &path,
+                     uid_t uid)
+{
+    request.setAppId(app_id);
+    request.setPkgId(pkg_id);
+    request.addPath(path, pathType);
+
+    if (uid != 0)
+        request.setUid(uid);
+}
+
+InstallRequest::InstallRequest()
+    : m_req(nullptr)
+    , m_tizenVer("3.0")
+    , m_uid(false, 0)
+{
+    int result = security_manager_app_inst_req_new(&m_req);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new request failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
+}
+
+InstallRequest::~InstallRequest()
+{
+    security_manager_app_inst_req_free(m_req);
+}
+
+void InstallRequest::setAppTizenVersion(std::string tizenVer, lib_retcode expectedResult)
+{
+    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::move(tizenVer);
+}
+
+void InstallRequest::setAppId(std::string appId, lib_retcode expectedResult)
+{
+    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 = std::move(appId);
+}
+
+void InstallRequest::setPkgId(std::string pkgId, lib_retcode expectedResult)
+{
+    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 = std::move(pkgId);
+}
+
+void InstallRequest::addPrivilege(Privilege privilege, lib_retcode expectedResult)
+{
+    int result = security_manager_app_inst_req_add_client_privilege(m_req,
+                                                                    privilege,
+                                                                    privilege.getLicenseC());
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "adding privilege returned wrong value."
+                          << " Privilege: " << privilege.getName() << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    m_privileges.push_back(std::move(privilege));
+}
+
+void InstallRequest::addAppDefinedPrivilege(Privilege privilege, lib_retcode expectedResult)
+{
+    int result = security_manager_app_inst_req_add_app_defined_privilege(
+                    m_req,
+                    privilege,
+                    privilege.getSMType(),
+                    privilege.getLicenseC());
+
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "adding app defined privilege returned wrong value."
+                          << " Privilege: " << privilege.getName() << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    m_appDefinedPrivileges.push_back(std::move(privilege));
+}
+
+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.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.emplace_back(std::pair<std::string, app_install_path_type>(std::move(path), pathType));
+}
+
+void InstallRequest::setUid(const uid_t uid, lib_retcode expectedResult)
+{
+    int result = security_manager_app_inst_req_set_uid(m_req, uid);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting uid returned wrong value."
+                          << " Uid: " << uid << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    m_uid.first = true;
+    m_uid.second = uid;
+}
+
+void InstallRequest::setAuthorId(std::string authorId, lib_retcode expectedResult)
+{
+    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);
+}
+
+void InstallRequest::setInstallType(const enum app_install_type &type, lib_retcode expectedResult)
+{
+    int result = security_manager_app_inst_req_set_install_type(m_req, type);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting install type returned wrong value."
+                          << " Install type: " << type << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+void InstallRequest::setHybrid(lib_retcode expectedResult)
+{
+    int result = security_manager_app_inst_req_set_hybrid(m_req);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                       "setting security_manager_app_inst_req_set_hybrid returned wrong value."
+                       << " Result: " << result << ";"
+                       << " Expected result: " << expectedResult);
+}
+
+std::ostream& operator<<(std::ostream &os, const InstallRequest &request)
+{
+    if (!request.m_appId.empty())
+        os << "app id: " << request.m_appId << "; ";
+    if (!request.m_pkgId.empty())
+        os << "pkg id: " << request.m_pkgId << "; ";
+    if (!request.m_privileges.empty()) {
+        os << "privileges: [ "  << "< " << request.m_privileges[0].getName() << "; "
+                                        << request.m_privileges[0].getLicense() << " >";
+        for (size_t i = 1; i < request.m_privileges.size(); ++i) {
+            os << "; <" << request.m_privileges[i].getName() << "; "
+                        << request.m_privileges[i].getLicense() << " >";
+        }
+        os << " ]";
+    }
+    if (!request.m_appDefinedPrivileges.empty()) {
+        os << "app defined privileges: [ "  << "< "
+           << request.m_appDefinedPrivileges[0].getName() << "; "
+           << request.m_appDefinedPrivileges[0].getType() << "; "
+           << request.m_appDefinedPrivileges[0].getLicense() << " >";
+
+        for (size_t i = 1; i < request.m_appDefinedPrivileges.size(); ++i) {
+            os << "; <" << request.m_appDefinedPrivileges[i].getName() << "; "
+                        << request.m_appDefinedPrivileges[i].getType() << "; "
+                        << request.m_appDefinedPrivileges[i].getLicense() << " >";
+        }
+        os << " ]";
+    }
+
+    if (!request.m_paths.empty()) {
+        os << "paths: [ " << "< " << request.m_paths[0].first << "; "
+                                  << request.m_paths[0].second << " >";
+        for (size_t i=1; i < request.m_paths.size(); ++i) {
+            os << "; < " << request.m_paths[i].first << "; "
+                         << request.m_paths[i].second << " >";
+        }
+        os << " ]";
+    }
+    if (request.m_uid.first)
+        os << "uid: " << request.m_uid.second << "; ";
+    if (!request.m_authorId.empty()) {
+        os << "author id: " << request.m_authorId << "; ";
+    }
+    return os;
+}
+
+PathsRequest::PathsRequest()
+    : m_req(nullptr)
+    , m_uid(false, 0)
+{
+    int result = security_manager_path_req_new(&m_req);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new request failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
+}
+
+PathsRequest::~PathsRequest()
+{
+    security_manager_path_req_free(m_req);
+}
+
+void PathsRequest::setPkgId(std::string pkgId, lib_retcode expectedResult)
+{
+    int result = security_manager_path_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 = std::move(pkgId);
+}
+
+void PathsRequest::addPath(std::string path, app_install_path_type pathType, lib_retcode expectedResult)
+{
+    int result = security_manager_path_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.emplace_back(std::pair<std::string, app_install_path_type>(std::move(path), pathType));
+}
+
+void PathsRequest::setUid(const uid_t uid, lib_retcode expectedResult)
+{
+    int result = security_manager_path_req_set_uid(m_req, uid);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting uid returned wrong value."
+                          << " Uid: " << uid << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    m_uid.first = true;
+    m_uid.second = uid;
+}
+
+void PathsRequest::setInstallType(const enum app_install_type &type, lib_retcode expectedResult)
+{
+    int result = security_manager_path_req_set_install_type(m_req, type);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting install type returned wrong value."
+                          << " Install type: " << type << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+}
+
+std::ostream& operator<<(std::ostream &os, const PathsRequest &request)
+{
+    if (!request.m_pkgId.empty())
+        os << "pkg id: " << request.m_pkgId << "; ";
+    if (!request.m_paths.empty()) {
+        os << "paths: [ " << "< " << request.m_paths[0].first << "; "
+                                  << request.m_paths[0].second << " >";
+        for (size_t i=1; i < request.m_paths.size(); ++i) {
+            os << "; < " << request.m_paths[i].first << "; "
+                         << request.m_paths[i].second << " >";
+        }
+        os << " ]";
+    }
+    if (request.m_uid.first)
+        os << "uid: " << request.m_uid.second << "; ";
+    return os;
+}
+
+} // namespace SecurityManagerTest
diff --git a/src/common/sm_request.h b/src/common/sm_request.h
new file mode 100644 (file)
index 0000000..7d74f64
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2014-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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_INSTALLREQUEST
+#define SECURITY_MANAGER_TEST_INSTALLREQUEST
+
+#include <iostream>
+#include <string>
+#include <sys/types.h>
+#include <utility>
+#include <vector>
+
+#include <security-manager.h>
+#include <app_def_privilege.h>
+
+namespace SecurityManagerTest {
+class InstallRequest;
+void prepare_request(InstallRequest &request,
+                     const std::string &app_id,
+                     const std::string &pkg_id,
+                     app_install_path_type pathType,
+                     const std::string &path,
+                     uid_t uid);
+class InstallRequest
+{
+public:
+    InstallRequest();
+    InstallRequest(const InstallRequest&) = delete;
+    InstallRequest& operator=(const InstallRequest&) = delete;
+    InstallRequest(InstallRequest &&other)
+        : m_req(std::move(other.m_req)),
+          m_appId(std::move(other.m_appId)),
+          m_pkgId(std::move(other.m_pkgId)),
+          m_authorId(std::move(other.m_authorId)),
+          m_privileges(std::move(other.m_privileges)),
+          m_paths(std::move(other.m_paths)),
+          m_uid(std::move(other.m_uid))
+    {
+        other.m_req = nullptr;
+        other.m_uid.first = false;
+        other.m_uid.second = 0;
+    }
+    ~InstallRequest();
+
+    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(Privilege privilege, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+    void addAppDefinedPrivilege(Privilege privilege, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+    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(std::string authorId, lib_retcode expectedResult= SECURITY_MANAGER_SUCCESS);
+    void setInstallType(const enum app_install_type &type, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+    void setHybrid(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&);
+
+private:
+    app_inst_req *m_req;
+
+    std::string m_tizenVer;
+    std::string m_appId;
+    std::string m_pkgId;
+    std::string m_authorId;
+    PrivilegeVector m_privileges;
+    PrivilegeVector m_appDefinedPrivileges;
+    std::vector<std::pair<std::string, app_install_path_type> > m_paths;
+    std::pair<bool, uid_t> m_uid;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::InstallRequest &request);
+
+class PathsRequest
+{
+public:
+    PathsRequest();
+    PathsRequest(const PathsRequest&) = delete;
+    PathsRequest& operator=(const PathsRequest&) = delete;
+    ~PathsRequest();
+
+    void setPkgId(std::string pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+    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 setInstallType(const enum app_install_type &type, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+
+    //app_inst_req *get() { return m_req; }
+    const path_req *get() const { return m_req; }
+    friend std::ostream& operator<<(std::ostream &, const PathsRequest&);
+
+private:
+    path_req *m_req;
+
+    std::string m_pkgId;
+    std::vector<std::pair<std::string, app_install_path_type> > m_paths;
+    std::pair<bool, uid_t> m_uid;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PathsRequest &request);
+
+} // namespace SecurityManagerTest
+
+#endif // SECURITY_MANAGER_TEST_INSTALLREQUEST
diff --git a/src/common/sm_sharing_request.cpp b/src/common/sm_sharing_request.cpp
new file mode 100644 (file)
index 0000000..3e361ec
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2014-2016 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <sm_sharing_request.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+SharingRequest::SharingRequest()
+    : m_req(nullptr)
+{
+    int result = security_manager_private_sharing_req_new(&m_req);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new request failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
+}
+
+SharingRequest::~SharingRequest()
+{
+    security_manager_private_sharing_req_free(m_req);
+}
+
+void SharingRequest::setOwnerAppId(const std::string &appId, lib_retcode expectedResult)
+{
+    int result = security_manager_private_sharing_req_set_owner_appid(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 = appId;
+}
+
+void SharingRequest::setTargetAppId(const std::string &appId, lib_retcode expectedResult)
+{
+    int result = security_manager_private_sharing_req_set_target_appid(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 = appId;
+}
+
+void SharingRequest::addPaths(const char **paths, size_t pathCount, lib_retcode expectedResult)
+{
+    int result = security_manager_private_sharing_req_add_paths(m_req, paths, pathCount);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "adding path returned wrong value."
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    for (size_t i = 0; i < pathCount; i++) {
+        m_paths.push_back(paths[i]);
+    }
+}
+
+std::ostream& operator<<(std::ostream &os, const SharingRequest &request)
+{
+
+    os << "app id: " << request.m_appId << "; ";
+    os << "pkg id: " << request.m_pkgId << "; ";
+
+    if (!request.m_paths.empty()) {
+        os << "paths: [ " << "< " << request.m_paths[0] << ">";
+        for (size_t i=1; i < request.m_paths.size(); ++i) {
+            os << "; < " << request.m_paths[i] << ">";
+        }
+        os << " ]";
+    }
+    return os;
+}
+
+} // namespace SecurityManagerTest
diff --git a/src/common/sm_sharing_request.h b/src/common/sm_sharing_request.h
new file mode 100644 (file)
index 0000000..e7f4107
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014-2016 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_SHARINGREQUEST
+#define SECURITY_MANAGER_TEST_SHARINGREQUEST
+
+#include <iostream>
+#include <string>
+#include <sys/types.h>
+#include <utility>
+#include <vector>
+
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+class SharingRequest
+{
+public:
+    SharingRequest();
+    SharingRequest(const SharingRequest&) = delete;
+    SharingRequest& operator=(const SharingRequest&) = delete;
+    ~SharingRequest();
+
+    void setOwnerAppId(const std::string &appId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+    void setTargetAppId(const std::string &pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+    void addPaths(const char **paths, size_t path_count,
+                 lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+    const private_sharing_req *get() const { return m_req; }
+    friend std::ostream& operator<<(std::ostream &, const SharingRequest&);
+
+private:
+    private_sharing_req *m_req;
+
+    std::string m_appId;
+    std::string m_pkgId;
+    std::vector<std::string> m_paths;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::SharingRequest &request);
+
+} // namespace SecurityManagerTest
+
+#endif // SECURITY_MANAGER_TEST_SHARINGREQUEST
diff --git a/src/common/sm_user_request.cpp b/src/common/sm_user_request.cpp
new file mode 100644 (file)
index 0000000..4b176c3
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <sm_user_request.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+UserRequest::UserRequest()
+    : m_req(nullptr)
+    , m_uid(false, 0)
+    , m_utype(false, static_cast<security_manager_user_type>(0))
+{
+    int result = security_manager_user_req_new(&m_req);
+    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+                      "creation of new request failed. Result: " << result);
+    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
+}
+
+UserRequest::~UserRequest()
+{
+    security_manager_user_req_free(m_req);
+}
+
+void UserRequest::setUid(const uid_t uid, lib_retcode expectedResult)
+{
+    int result = security_manager_user_req_set_uid(m_req, uid);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                     "setting uid returned wrong value."
+                          << " Uid: " << uid << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    m_uid.first = true;
+    m_uid.second = uid;
+}
+
+void UserRequest::setUserType(const security_manager_user_type utype, lib_retcode expectedResult)
+{
+    int result = security_manager_user_req_set_user_type(m_req, utype);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                     "setting user type returned wrong value."
+                          << " User type: " << utype << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+    m_utype.first = true;
+    m_utype.second = utype;
+}
+
+std::ostream& operator<<(std::ostream &os, const UserRequest &request)
+{
+    if (request.m_uid.first)
+        os << "uid: " << request.m_uid.second << "; ";
+
+    if (request.m_utype.first)
+        os << "utype: " << request.m_utype.second << "; ";
+
+    return os;
+}
+
+} // namespace SecurityManagerTest
diff --git a/src/common/sm_user_request.h b/src/common/sm_user_request.h
new file mode 100644 (file)
index 0000000..64da559
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_USERREQUEST
+#define SECURITY_MANAGER_TEST_USERREQUEST
+
+#include <iostream>
+#include <sys/types.h>
+#include <utility>
+
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+class UserRequest
+{
+public:
+    UserRequest();
+    UserRequest(const UserRequest&) = delete;
+    UserRequest& operator=(const UserRequest&) = delete;
+    ~UserRequest();
+
+    void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+    void setUserType(const security_manager_user_type utype,
+                     lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+
+    const user_req *get() const { return m_req; }
+    friend std::ostream& operator<<(std::ostream &, const UserRequest&);
+
+private:
+    user_req *m_req;
+
+    std::pair<bool, uid_t> m_uid;
+    std::pair<bool, security_manager_user_type> m_utype;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::UserRequest &request);
+
+} // namespace SecurityManagerTest
+
+#endif // SECURITY_MANAGER_TEST_USERREQUEST
diff --git a/src/common/tzplatform.cpp b/src/common/tzplatform.cpp
new file mode 100644 (file)
index 0000000..3d3dce7
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <pwd.h>
+#include <sys/types.h>
+
+#include <dpl/test/test_runner.h>
+#include <memory.h>
+#include <temp_test_user.h>
+#include <tzplatform.h>
+
+namespace TzPlatformConfig {
+
+DEFINE_SMARTPTR(tzplatform_context_destroy, tzplatform_context, TzPlatformContextPtr);
+
+uid_t getGlobalUserId(void)
+{
+    return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+}
+
+uid_t getGlobalGroupId(void)
+{
+    gid_t global_uid = getGlobalUserId();
+    errno = 0;
+    passwd* pw = getpwuid(global_uid);
+    RUNNER_ASSERT_ERRNO_MSG(pw, "getpwuid() failed.");
+    return pw->pw_gid;
+}
+
+const std::string appDirPath(const TemporaryTestUser &user, const std::string &appId,
+                             const std::string &pkgId)
+{
+    return appDirPath(user.getUid()) + pkgId + "/" + appId;
+}
+
+const std::string appDirPath(uid_t uid)
+{
+    struct tzplatform_context *tzCtxPtr = nullptr;
+
+    RUNNER_ASSERT(0 == tzplatform_context_create(&tzCtxPtr));
+    TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
+
+    RUNNER_ASSERT_MSG(0 == tzplatform_context_set_user(tzCtxPtr, uid),
+                      "Unable to set user with uid <" << uid << "> for tzplatform context");
+
+    const char *appDir = tzplatform_context_getenv(tzCtxPtr,
+                                getGlobalUserId() == uid ? TZ_SYS_RW_APP : TZ_USER_APP);
+    RUNNER_ASSERT_MSG(nullptr != appDir,
+                      "tzplatform_context_getenv failed"
+                          << "for getting sys rw app of user with uid<" << uid << ">");
+
+    return std::string(appDir) + "/";
+}
+
+const std::string globalAppDir()
+{
+    struct tzplatform_context *tzCtxPtr = nullptr;
+
+    RUNNER_ASSERT_MSG(0 == tzplatform_context_create(&tzCtxPtr), "Couldn't create tzplatform context");
+    TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
+
+    const char *appDir = tzplatform_context_getenv(tzCtxPtr, TZ_SYS_RW_APP);
+    RUNNER_ASSERT_MSG(nullptr != appDir,
+                      "tzplatform_context_getenv failed for getting sys rw app");
+    return appDir;
+}
+
+const std::string getPath(enum tzplatform_variable id) {
+    struct tzplatform_context *tzCtxPtr = nullptr;
+
+    RUNNER_ASSERT_MSG(0 == tzplatform_context_create(&tzCtxPtr), "Couldn't create tzplatform context");
+    TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
+
+    const char *path = tzplatform_context_getenv(tzCtxPtr, id);
+    RUNNER_ASSERT_MSG(nullptr != path,
+                          "tzplatform_context_getenv failed for getting " << static_cast<int>(id));
+    return path;
+}
+
+}
+
diff --git a/src/common/tzplatform.h b/src/common/tzplatform.h
new file mode 100644 (file)
index 0000000..fff4f5e
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#pragma once
+
+#include <string>
+
+#include <tzplatform_config.h>
+
+#include <temp_test_user.h>
+
+namespace TzPlatformConfig {
+
+const std::string getPath(enum tzplatform_variable id);
+
+uid_t getGlobalUserId(void);
+
+uid_t getGlobalGroupId(void);
+
+const std::string appDirPath(const TemporaryTestUser &user, const std::string &appId,
+                             const std::string &pkgId);
+
+const std::string globalAppDir();
+
+const std::string appDirPath(uid_t uid);
+}
+
index 54c7ae40ffd89b78954c5f0dc0a33768ff07021c..9d9bcf810baf71fb9971e28e07acf22665a2aade 100644 (file)
@@ -54,16 +54,8 @@ SET(SEC_MGR_SOURCES
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_trusted_sharing.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/test_cases_prepare_app.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/security_manager_tests.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/app_install_helper.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/policy_configuration.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_api.cpp
     ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_commons.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_label_monitor.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_request.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_sharing_request.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_user_request.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_policy_request.cpp
-    ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/tzplatform.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_client.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_admin.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/plugins/plugins.cpp
diff --git a/src/security-manager-tests/common/app_def_privilege.h b/src/security-manager-tests/common/app_def_privilege.h
deleted file mode 100644 (file)
index 6d00972..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2014-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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-#pragma once
-
-#include <string>
-#include <utility>
-#include <vector>
-#include <tuple>
-
-#include <security-manager-types.h>
-#include <dpl/test/test_runner.h>
-
-class Privilege {
-public:
-    enum Type {
-        UNSET,
-        UNTRUSTED,
-        LICENSED,
-    };
-
-    Privilege(std::string systemPrivilege, Type type = UNSET, std::string license = std::string())
-      : m_name(std::move(systemPrivilege))
-      , m_type(type)
-      , m_license(std::move(license))
-    {}
-
-    Privilege(std::string licensedPrivilege, std::string license)
-      : m_name(std::move(licensedPrivilege))
-      , m_type(LICENSED)
-      , m_license(std::move(license))
-    {}
-
-    bool isUnset() const { return m_type == UNSET; }
-    bool isUntrusted() const { return m_type == UNTRUSTED; }
-    bool isLicensed() const { return m_type == LICENSED; }
-
-    int getType() const { return m_type; }
-    app_defined_privilege_type getSMType () const {
-        RUNNER_ASSERT(m_type != UNSET);
-        if (isLicensed()) return SM_APP_DEFINED_PRIVILEGE_TYPE_LICENSED;
-        return SM_APP_DEFINED_PRIVILEGE_TYPE_UNTRUSTED;
-    }
-
-    const std::string& getName() const { return m_name; }
-    const std::string& getLicense() const { return m_license; }
-
-    const char *getNameC() const { return m_name.c_str(); }
-    const char *getLicenseC() const { return m_license.c_str(); }
-
-    operator const char *() const { return m_name.c_str(); }
-
-    operator std::string() const { return m_name; }
-
-private:
-    std::string m_name;
-    Type m_type;
-    std::string m_license;
-};
-
-typedef std::vector<Privilege> PrivilegeVector;
-
diff --git a/src/security-manager-tests/common/app_install_helper.cpp b/src/security-manager-tests/common/app_install_helper.cpp
deleted file mode 100644 (file)
index b9f3073..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2014-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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <fcntl.h>
-#include <map>
-#include <string>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/smack.h>
-#include <unistd.h>
-#include <utility>
-
-#include <security-manager-types.h>
-
-#include <dpl/test/test_runner.h>
-#include <tzplatform.h>
-#include <label_generator.h>
-
-#include "app_install_helper.h"
-
-AppInstallHelper::AppInstallHelper(AppInstallHelper &&other)
-    : m_appName(std::move(other.m_appName)), m_pkgName(std::move(other.m_pkgName)),
-      m_isLocal(other.m_isLocal), m_uidGid(other.m_uidGid),
-      m_version(std::move(other.m_version)), m_installType(other.m_installType),
-      m_isHybrid(other.m_isHybrid), m_installDir(std::move(other.m_installDir)),
-      m_dirTypeMap(std::move(other.m_dirTypeMap)),
-      m_fileTypeMap(std::move(other.m_fileTypeMap)),
-      m_privileges(std::move(other.m_privileges)),
-      m_appDefinedPrivileges(std::move(other.m_appDefinedPrivileges)),
-      m_author(std::move(other.m_author)),
-      m_creatorPid(other.m_creatorPid)
-{
-    other.m_creatorPid = -1;
-}
-
-std::string AppInstallHelper::getInstallDir() const {
-    return m_installDir + getPkgId();
-}
-
-std::string AppInstallHelper::getTrustedDir(int i) const {
-    return getInstallDir() + "/trustedDir" + std::to_string(i);
-}
-
-std::string AppInstallHelper::getPrivateDir(int i) const {
-    return getInstallDir() + "/app_dir" + std::to_string(i) +"/";
-}
-
-std::string AppInstallHelper::getPrivateRODir(int i) const {
-    return getInstallDir() + "/app_dir_ro" + std::to_string(i) +"/";
-}
-
-std::string AppInstallHelper::getPublicDir() const {
-    return getInstallDir() + "/app_public_ro/";
-}
-
-std::string AppInstallHelper::getPrivatePath(int i) const {
-    return getPrivateDir() + "shareme" + std::to_string(i);
-}
-
-std::string AppInstallHelper::getSharedRODir(int i) const {
-    return getInstallDir() + "/app_dir_rw_others_ro" + std::to_string(i) +"/";
-}
-
-std::string AppInstallHelper::getAppId() const {
-    return m_appName + "_app_id";
-}
-
-std::string AppInstallHelper::getPkgId() const {
-    return m_pkgName + "_pkg_id";
-}
-
-void AppInstallHelper::setVersion(const std::string &version) {
-    m_version = version;
-}
-
-std::string AppInstallHelper::getVersion() const {
-    return m_version;
-}
-
-int AppInstallHelper::getUID() const {
-    return m_uidGid;
-}
-
-int AppInstallHelper::getGID() const {
-    return m_uidGid;
-}
-
-void AppInstallHelper::createInstallDir() {
-    create(mkdir, getInstallDir());
-    m_isInstallDirCreated = true;
-}
-
-void AppInstallHelper::createTrustedDir(int i) {
-    if (create(mkdir, getTrustedDir(i)))
-        m_dirTypeMap[SECURITY_MANAGER_PATH_TRUSTED_RW].emplace_back(getTrustedDir(i));
-}
-
-void AppInstallHelper::createPrivateDir(int i) {
-    if (create(mkdir, getPrivateDir(i)))
-        m_dirTypeMap[SECURITY_MANAGER_PATH_RW].emplace_back(getPrivateDir(i));
-}
-
-void AppInstallHelper::createPublicDir() {
-    if (mkdir(getPublicDir().c_str(), 0777) == 0) {
-        m_dirTypeMap[SECURITY_MANAGER_PATH_PUBLIC_RO].emplace_back(getPublicDir());
-    }
-}
-
-void AppInstallHelper::createPrivateFile(int i) {
-    // This is intentional, let all private file be in one directory
-    createPrivateDir();
-    if (create(creat, getPrivatePath(i)))
-        m_fileTypeMap[SECURITY_MANAGER_PATH_RW].emplace_back(getPrivatePath(i));
-}
-
-void AppInstallHelper::createSharedRODir(int i) {
-    if (create(mkdir, getSharedRODir(i)))
-        m_dirTypeMap[SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO].emplace_back(getSharedRODir(i));
-}
-
-void AppInstallHelper::createPrivateRODir(int i) {
-    if (create(mkdir, getPrivateRODir(i)))
-        m_dirTypeMap[SECURITY_MANAGER_PATH_RO].emplace_back(getPrivateRODir(i));
-}
-
-void AppInstallHelper::setHybrid() {
-    m_isHybrid = true;
-}
-
-bool AppInstallHelper::getIsHybrid() const {
-    return m_isHybrid;
-}
-
-void AppInstallHelper::addPrivileges(const std::vector<std::string> &privileges) {
-    for (auto &p : privileges) {
-        addPrivilege(Privilege(p));
-    }
-}
-
-std::vector<std::string> AppInstallHelper::getPrivilegesNames() const {
-    std::vector<std::string> privileges;
-    for (auto &p : m_privileges) {
-        privileges.push_back(p.getName());
-    }
-    return privileges;
-}
-
-void AppInstallHelper::addPrivilege(Privilege privilege) {
-    m_privileges.push_back(std::move(privilege));
-}
-
-void AppInstallHelper::addPrivileges(const PrivilegeVector &privileges) {
-    std::copy(privileges.begin(), privileges.end(), std::back_inserter(m_privileges));
-}
-
-const PrivilegeVector& AppInstallHelper::getPrivileges() const {
-    return m_privileges;
-}
-
-void AppInstallHelper::addAppDefinedPrivilege(Privilege privilege) {
-    m_appDefinedPrivileges.push_back(std::move(privilege));
-}
-
-const PrivilegeVector& AppInstallHelper::getAppDefinedPrivileges() const {
-    return m_appDefinedPrivileges;
-}
-
-void AppInstallHelper::revokeRules() const {
-    RUNNER_ASSERT_MSG(
-        0 == smack_revoke_subject(generateAppLabel().c_str()),
-        "Revoking smack subject failed");
-}
-
-std::string AppInstallHelper::generateAppLabel() const {
-    return generateProcessLabel(getAppId(), getPkgId(), getIsHybrid());
-}
-
-std::string AppInstallHelper::generatePkgLabel() const {
-    return generatePathRWLabel(getPkgId());
-}
-
-const AppInstallHelper::TypePathsMap& AppInstallHelper::getDirsMap() const {
-    return m_dirTypeMap;
-}
-
-const AppInstallHelper::TypePathsMap& AppInstallHelper::getFilesMap() const {
-    return m_fileTypeMap;
-}
-
-void AppInstallHelper::removePaths() {
-    for (const auto &oneTypePaths : m_dirTypeMap)
-            for (const auto& path : oneTypePaths.second)
-                rmdir(path.c_str());
-
-    m_dirTypeMap.clear();
-
-    for (const auto &oneTypePaths : m_fileTypeMap)
-            for (const auto& path : oneTypePaths.second)
-                unlink(path.c_str());
-
-    m_fileTypeMap.clear();
-
-    rmdir(getInstallDir().c_str());
-    m_isInstallDirCreated = false;
-}
-
-void AppInstallHelper::setInstallPath() {
-    if (m_isLocal)
-        m_installDir = TzPlatformConfig::appDirPath(getUID());
-    else
-        m_installDir = TzPlatformConfig::globalAppDir() + "/";
-}
-
-bool AppInstallHelper::create(std::function<int(const char*, mode_t)> &&creatFun, const std::string &path) {
-    if (!m_isInstallDirCreated && path != getInstallDir())
-        createInstallDir();
-    if (creatFun(path.c_str(), 0751) == 0) {
-       // Local paths need user change
-       if (!m_isLocal || chown(path.c_str(), m_uidGid, m_uidGid) == 0)
-                return true;
-       }
-    return false;
-}
-
-void AppInstallHelper::setAuthor(const std::string &author) {
-    m_author = author;
-}
-std::string AppInstallHelper::getAuthor() const {
-    return m_author;
-}
-
-void AppInstallHelper::setInstallType(app_install_type type) {
-    m_installType = type;
-}
-app_install_type AppInstallHelper::getInstallType() const {
-    return m_installType;
-}
-
diff --git a/src/security-manager-tests/common/app_install_helper.h b/src/security-manager-tests/common/app_install_helper.h
deleted file mode 100644 (file)
index a514238..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2014-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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-#pragma once
-
-#include <fcntl.h>
-#include <functional>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <security-manager-types.h>
-#include <app_def_privilege.h>
-
-struct AppInstallHelper {
-
-    using TypePathsMap = std::map<app_install_path_type, std::vector<std::string>>;
-    AppInstallHelper(const std::string &appNamePrefix,
-                     const std::string &pkgNamePrefix,
-                     bool isLocal,
-                     uid_t uid,
-                     std::string version = std::string())
-      : m_appName(appNamePrefix), m_pkgName(pkgNamePrefix), m_isLocal(isLocal), m_uidGid(uid), m_version(version),
-        m_installType(SM_APP_INSTALL_NONE), m_isHybrid(false), m_isInstallDirCreated(false), m_creatorPid(getpid())
-    {
-        setInstallPath();
-    }
-
-    AppInstallHelper(const std::string &appNamePrefix,
-                     const std::string &pkgNamePrefix,
-                     uid_t uid)
-      : AppInstallHelper(appNamePrefix, pkgNamePrefix, false, uid)
-    {}
-
-    AppInstallHelper(const std::string &namePrefix)
-      : AppInstallHelper(namePrefix, namePrefix, false, geteuid())
-    {}
-
-    AppInstallHelper(const std::string &appNamePrefix, const std::string &pkgNamePrefix)
-      : AppInstallHelper(appNamePrefix, pkgNamePrefix, false, geteuid())
-    {}
-
-    AppInstallHelper(const std::string &namePrefix, uid_t uid)
-      : AppInstallHelper(namePrefix, namePrefix, true, uid)
-    {}
-
-    AppInstallHelper(const std::string &appNamePrefix, const std::string &pkgNamePrefix, uid_t uid,
-                     const std::string &version)
-      : AppInstallHelper(appNamePrefix, pkgNamePrefix, true, uid, version)
-    {}
-
-    AppInstallHelper(const std::string &namePrefix, uid_t uid, const std::string &version)
-      : AppInstallHelper(namePrefix, namePrefix, true, uid, version)
-    {}
-
-    AppInstallHelper(const AppInstallHelper &other) = default;
-    AppInstallHelper& operator=(const AppInstallHelper &other) = delete;
-    AppInstallHelper(AppInstallHelper &&other);
-
-    // App info getters and setters
-    std::string getAppId() const;
-    std::string getPkgId() const;
-    int getUID() const;
-    int getGID() const;
-    void setVersion(const std::string &version);
-    std::string getVersion() const;
-    void setAuthor(const std::string &author);
-    std::string getAuthor() const;
-    void setInstallType(app_install_type type);
-    app_install_type getInstallType() const;
-    void setHybrid();
-    bool getIsHybrid() const;
-
-    // Path types creation and removal on file system
-    void createInstallDir();
-    void createTrustedDir(int i = 0);
-    void createPrivateDir(int i = 0);
-    void createPublicDir();
-    void createPrivateFile(int i = 0);
-    void createSharedRODir(int i = 0);
-    void createPrivateRODir(int i = 0);
-    void removePaths();
-
-    // Path getters
-    std::string getInstallDir() const;
-    std::string getTrustedDir(int i = 0) const;
-    std::string getPrivateDir(int i = 0) const;
-    std::string getPrivateRODir(int i = 0) const;
-    std::string getPublicDir() const;
-    std::string getPrivatePath(int i = 0) const;
-    std::string getSharedRODir(int i = 0) const;
-    const TypePathsMap& getDirsMap() const;
-    const TypePathsMap& getFilesMap() const;
-
-    // Privileges
-    std::vector<std::string> getPrivilegesNames() const;             // deprecated
-    void addPrivileges(const std::vector<std::string> &privileges);  // deprecated
-    void addPrivilege(Privilege privilege);
-    void addPrivileges(const PrivilegeVector &privileges);
-    const PrivilegeVector& getPrivileges() const;
-
-    void addAppDefinedPrivilege(Privilege privilege);
-    const PrivilegeVector& getAppDefinedPrivileges() const;
-
-    // Smack
-    std::string generateAppLabel() const;
-    std::string generatePkgLabel() const;
-    void revokeRules() const;
-    virtual ~AppInstallHelper() {
-        if (m_creatorPid == getpid())
-            removePaths();
-    }
-
-protected:
-    void setInstallPath();
-    bool create(std::function<int(const char*, mode_t)> &&creatFun, const std::string &path);
-    std::string m_appName;
-    std::string m_pkgName;
-    bool m_isLocal;
-    int m_uidGid;
-    std::string m_version;
-    app_install_type m_installType;
-    bool m_isHybrid;
-    std::string m_installDir;
-    bool m_isInstallDirCreated;
-    TypePathsMap m_dirTypeMap;
-    TypePathsMap m_fileTypeMap;
-    PrivilegeVector m_privileges;
-    PrivilegeVector m_appDefinedPrivileges;
-    std::string m_author;
-
-    pid_t m_creatorPid;
-};
diff --git a/src/security-manager-tests/common/sm_api.cpp b/src/security-manager-tests/common/sm_api.cpp
deleted file mode 100644 (file)
index d7ab650..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 2014-2015 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <sm_api.h>
-
-#include <dpl/test/test_runner.h>
-
-namespace SecurityManagerTest {
-
-namespace Api {
-
-void install(const InstallRequest &request, lib_retcode expectedResult)
-{
-    int result = security_manager_app_install(request.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "installing app returned wrong value."
-                          << " InstallRequest: [ " << request << "];"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void uninstall(const InstallRequest &request, lib_retcode expectedResult)
-{
-    int result = security_manager_app_uninstall(request.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "uninstalling app returned wrong value."
-                          << " InstallRequest: [ " << request << "];"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-std::string getPkgId(const std::string &appId, lib_retcode expectedResult)
-{
-    char *pkgId = nullptr;
-    int result = security_manager_get_app_pkgid(&pkgId, appId.c_str());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "getting pkg id from app id returned wrong value."
-                          << " App id: " << appId << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    if (expectedResult != SECURITY_MANAGER_SUCCESS)
-        return std::string();
-
-    RUNNER_ASSERT_MSG(pkgId != nullptr, "getting pkg id did not allocate memory");
-    std::string str(pkgId);
-    free(pkgId);
-    return str;
-}
-
-void setProcessLabel(const std::string &appId, lib_retcode expectedResult)
-{
-    int result = security_manager_set_process_label_from_appid(appId.c_str());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "setting process label from app id returned wrong value."
-                          << " App id: " << appId << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void setProcessGroups(const std::string &appId, lib_retcode expectedResult)
-{
-    int result = security_manager_set_process_groups_from_appid(appId.c_str());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "setting process groups from app id returned wrong value."
-                          << " App id: " << appId << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void dropProcessPrivileges(lib_retcode expectedResult)
-{
-    int result = security_manager_drop_process_privileges();
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "dropping process privileges returned wrong value."
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void prepareApp(const std::string &appId, lib_retcode expectedResult)
-{
-    int result = security_manager_prepare_app(appId.c_str());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "preparing app returned wrong value."
-                          << " App id: " << appId << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void addUser(const UserRequest &request, lib_retcode expectedResult)
-{
-    int result = security_manager_user_add(request.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "adding user returned wrong value."
-                          << " UserRequest: [ " << request << "];"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void deleteUser(const UserRequest &request, lib_retcode expectedResult)
-{
-    int result = security_manager_user_delete(request.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "deleting user returned wrong value."
-                          << " UserRequest: [ " << request << "];"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void sendPolicy(const PolicyRequest &request, lib_retcode expectedResult)
-{
-    int result = security_manager_policy_update_send(request.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                          "sending policy update for self returned wrong value."
-                          << " PolicyRequest: [ " << request << "];"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void getConfiguredPolicy(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult, bool forAdmin)
-{
-    policy_entry **pp_privs_policy = NULL;
-    size_t policy_size = 0;
-    int result;
-
-    if (forAdmin) {
-        result = security_manager_get_configured_policy_for_admin(filter.get(), &pp_privs_policy, &policy_size);
-    } else {
-        result = security_manager_get_configured_policy_for_self(filter.get(), &pp_privs_policy, &policy_size);
-    };
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "Unexpected result for filter: " << filter << std::endl
-                          << " Result: " << result << ";");
-
-    for (unsigned int i = 0; i < policy_size; ++i) {
-        PolicyEntry pe(*pp_privs_policy[i]);
-        policyEntries.push_back(pe);
-    };
-}
-
-void getPolicy(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult)
-{
-    policy_entry **pp_privs_policy = NULL;
-    size_t policy_size = 0;
-    int result;
-
-    result = security_manager_get_policy(filter.get(), &pp_privs_policy, &policy_size);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "Unexpected result" << std::endl
-                          << " Result: " << result << ";");
-    for (unsigned int i = 0; i < policy_size; ++i) {
-        PolicyEntry pe(*pp_privs_policy[i]);
-        policyEntries.push_back(pe);
-    };
-}
-
-void applySharing(const SharingRequest &req, lib_retcode expectedResult) {
-    int result = security_manager_private_sharing_apply(req.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "Unexpected result from security_manager_private_sharing_apply" << std::endl
-                          << " Result: " << result << ";");
-}
-
-void dropSharing(const SharingRequest &req, lib_retcode expectedResult) {
-    int result = security_manager_private_sharing_drop(req.get());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "Unexpected result from security_manager_private_sharing_drop" << std::endl
-                          << " Result: " << result << ";");
-}
-
-void getPolicyForSelf(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult)
-{
-    getConfiguredPolicy(filter, policyEntries, expectedResult, false);
-}
-
-void getPolicyForAdmin(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult)
-{
-    getConfiguredPolicy(filter, policyEntries, expectedResult, true);
-}
-
-void getPkgIdBySocket(int socketFd, std::string *pkgId, std::string *appId, lib_retcode expectedResult)
-{
-    char *pkg_Id = nullptr;
-    char *app_Id = nullptr;
-
-    int result = security_manager_identify_app_from_socket(socketFd,
-                    pkgId == nullptr ? nullptr : &pkg_Id,
-                    appId == nullptr ? nullptr : &app_Id);
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "getting pkg id from socket returned wrong value."
-                          << " socket: " << socketFd << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-
-    if (pkg_Id) {
-        *pkgId = pkg_Id;
-        free(pkg_Id);
-    }
-
-    if (app_Id) {
-        *appId = app_Id;
-        free(app_Id);
-    }
-}
-
-void getPkgIdByPid(pid_t pid, std::string *pkgId, std::string *appId, lib_retcode expectedResult)
-{
-    char *pkg_Id = nullptr;
-    char *app_Id = nullptr;
-
-    int result = security_manager_identify_app_from_pid(pid,
-                    pkgId == nullptr ? nullptr : &pkg_Id,
-                    appId == nullptr ? nullptr : &app_Id);
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "getting pkg id from pid returned wrong value."
-                          << " pid: " << pid << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-
-    if (pkg_Id) {
-        *pkgId = pkg_Id;
-        free(pkg_Id);
-    }
-
-    if (app_Id) {
-        *appId = app_Id;
-        free(app_Id);
-    }
-}
-
-void getPkgIdByCynaraClient(const std::string &client, std::string *pkgId, std::string *appId,
-                            lib_retcode expectedResult)
-{
-    char *pkg_Id = nullptr;
-    char *app_Id = nullptr;
-
-    int result = security_manager_identify_app_from_cynara_client(client.c_str(),
-                    pkgId == nullptr ? nullptr : &pkg_Id,
-                    appId == nullptr ? nullptr : &app_Id);
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "getting pkg id from pid returned wrong value."
-                          << " client: " << client << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-
-    if (pkg_Id) {
-        *pkgId = pkg_Id;
-        free(pkg_Id);
-    }
-
-    if (app_Id) {
-        *appId = app_Id;
-        free(app_Id);
-    }
-}
-
-void appHasPrivilege(const std::string &appId, const std::string &privilege, uid_t user,
-                     int &value, lib_retcode expectedResult)
-{
-    int result = security_manager_app_has_privilege(appId.c_str(), privilege.c_str(), user, &value);
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "checking application privilege returned wrong result."
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void getSecurityManagerGroups(gid_t **groups, size_t *groups_count, lib_retcode expectedResult)
-{
-  int result = security_manager_groups_get(groups, groups_count);
-  RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
-                    "Unexpected result in security_manager_groups_get()" << std::endl
-                    << " Result: " << result << " Expected: " << expectedResult);
-}
-
-void registerPaths(const PathsRequest& req, lib_retcode expectedResult)
-{
-    int result = security_manager_paths_register(req.get());
-    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
-                      "Unexpected result in security_manager_paths_register()" << std::endl
-                      << " Result: " << result << " Expected: " << expectedResult);
-}
-
-void labelsMonitorGetFd(const LabelMonitor &monitor, int *fd, lib_retcode expectedResult)
-{
-    int result = security_manager_app_labels_monitor_get_fd(monitor.get(), fd);
-    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
-                      "Unexpected result in security_manager_app_labels_monitor_get_fd()"
-                          << std::endl << " Result: " << result << " Expected: "
-                          << expectedResult);
-};
-
-void labelsProcess(const LabelMonitor &monitor, lib_retcode expectedResult)
-{
-    int result = security_manager_app_labels_monitor_process(monitor.get());
-    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == expectedResult,
-                      "Unexpected result in security_manager_app_labels_monitor_process()"
-                          << std::endl << " Result: " << result << " Expected: "
-                          << expectedResult);
-}
-
-} // namespace Api
-
-} // namespace SecurityManagerTest
diff --git a/src/security-manager-tests/common/sm_api.h b/src/security-manager-tests/common/sm_api.h
deleted file mode 100644 (file)
index ca1fb6d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2014-2015 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef SECURITY_MANAGER_TEST_API
-#define SECURITY_MANAGER_TEST_API
-
-#include <sm_label_monitor.h>
-#include <sm_policy_request.h>
-#include <sm_request.h>
-#include <sm_sharing_request.h>
-#include <sm_user_request.h>
-
-#include <security-manager.h>
-
-namespace SecurityManagerTest {
-
-namespace Api {
-
-void install(const InstallRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void uninstall(const InstallRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-std::string getPkgId(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void setProcessLabel(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void setProcessGroups(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void dropProcessPrivileges(lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void prepareApp(const std::string &appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void addUser(const UserRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void deleteUser(const UserRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void sendPolicy(const PolicyRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getPolicy(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getPolicyForSelf(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getPolicyForAdmin(const PolicyEntry &filter, std::vector<PolicyEntry> &policyEntries, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void applySharing(const SharingRequest &req, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void dropSharing(const SharingRequest &req, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getPkgIdBySocket(int socketFd, std::string *pkgId, std::string *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getPkgIdByPid(pid_t pid, std::string *pkgId, std::string *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getPkgIdByCynaraClient(const std::string &client, std::string *pkgId, std::string *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void appHasPrivilege(const std::string &appId, const std::string &privilege, uid_t user, int &value, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void getSecurityManagerGroups(gid_t **groups, size_t *groups_count, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void registerPaths(const PathsRequest& req, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void labelsMonitorGetFd(const LabelMonitor &monitor, int *fd, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-void labelsProcess(const LabelMonitor &monitor, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-
-} // namespace Api
-
-} // namespace SecurityManagerTest
-#endif // SECURITY_MANAGER_TEST_API
diff --git a/src/security-manager-tests/common/sm_label_monitor.cpp b/src/security-manager-tests/common/sm_label_monitor.cpp
deleted file mode 100644 (file)
index 6d648fe..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2016 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include "sm_label_monitor.h"
-
-#include <dpl/test/test_runner.h>
-
-namespace SecurityManagerTest {
-
-LabelMonitor::LabelMonitor()
-    : m_monitor(nullptr)
-{
-    int result = security_manager_app_labels_monitor_init(&m_monitor);
-    RUNNER_ASSERT_MSG(static_cast<lib_retcode>(result) == SECURITY_MANAGER_SUCCESS,
-                      "security_manager_app_labels_monitor_init failed with " << result);
-    RUNNER_ASSERT_MSG(m_monitor != nullptr,
-                      "security_manager_app_labels_monitor_init didn't allocate memory");
-}
-
-LabelMonitor::~LabelMonitor()
-{
-    security_manager_app_labels_monitor_finish(m_monitor);
-}
-
-} // namespace SecurityManagerTest
diff --git a/src/security-manager-tests/common/sm_label_monitor.h b/src/security-manager-tests/common/sm_label_monitor.h
deleted file mode 100644 (file)
index ee82863..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2016 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#pragma once
-#include <security-manager.h>
-
-namespace SecurityManagerTest {
-
-class LabelMonitor
-{
-public:
-    LabelMonitor();
-    LabelMonitor(const LabelMonitor&) = delete;
-    LabelMonitor& operator=(const LabelMonitor&) = delete;
-    ~LabelMonitor();
-
-    app_labels_monitor *get() const { return m_monitor; }
-private:
-    app_labels_monitor *m_monitor;
-};
-
-} // namespace SecurityManagerTest
-
diff --git a/src/security-manager-tests/common/sm_policy_request.cpp b/src/security-manager-tests/common/sm_policy_request.cpp
deleted file mode 100644 (file)
index debda17..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <sm_policy_request.h>
-
-#include <dpl/test/test_runner.h>
-
-namespace SecurityManagerTest {
-
-PolicyEntry::PolicyEntry()
-    : m_appId(true, std::string(SECURITY_MANAGER_ANY))
-    , m_user(true, std::string(SECURITY_MANAGER_ANY))
-    , m_privilege(true, std::string(SECURITY_MANAGER_ANY))
-    , m_currentLevel(false, std::string(""))
-    , m_maxLevel(false, std::string(""))
-{
-    int result = security_manager_policy_entry_new(&m_entry);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new policy entry failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_entry != nullptr, "creation of new policy entry did not allocate memory");
-
-    security_manager_policy_entry_set_application(m_entry, m_appId.second.c_str());
-    security_manager_policy_entry_set_user(m_entry, m_user.second.c_str());
-    security_manager_policy_entry_set_privilege(m_entry, m_privilege.second.c_str());
-}
-
-PolicyEntry::PolicyEntry(const std::string &appId, const std::string &user,
-        const std::string &privilege)
-    : m_appId(true, std::string(appId))
-    , m_user(true, std::string(user))
-    , m_privilege(true, std::string(privilege))
-    , m_currentLevel(false, std::string(""))
-    , m_maxLevel(false, std::string(""))
-{
-    int result = security_manager_policy_entry_new(&m_entry);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new policy entry failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_entry != nullptr, "creation of new policy entry did not allocate memory");
-
-    security_manager_policy_entry_set_user(m_entry, m_user.second.c_str());
-    security_manager_policy_entry_set_application(m_entry, m_appId.second.c_str());
-    security_manager_policy_entry_set_privilege(m_entry, m_privilege.second.c_str());
-}
-
-PolicyEntry::PolicyEntry(policy_entry &entry): m_entry(&entry)
-{
-    m_appId.first = true;
-    m_appId.second = std::string(security_manager_policy_entry_get_application(m_entry));
-
-    m_user.first = true;
-    m_user.second = std::string(security_manager_policy_entry_get_user(m_entry));
-
-    m_privilege.first = true;
-    m_privilege.second = std::string(security_manager_policy_entry_get_privilege(m_entry));
-
-    m_currentLevel.first = true;
-    m_currentLevel.second = std::string(security_manager_policy_entry_get_level(m_entry));
-
-    m_maxLevel.first = true;
-    m_maxLevel.second = std::string(security_manager_policy_entry_get_max_level(m_entry));
-};
-
-void PolicyEntry::setLevel(const std::string &level)
-{
-    m_currentLevel.first = true;
-    m_currentLevel.second = level;
-    security_manager_policy_entry_set_level(m_entry, level.c_str());
-    m_maxLevel.first = true;
-    m_maxLevel.second = std::string(security_manager_policy_entry_get_max_level(m_entry));
-};
-
-void PolicyEntry::setMaxLevel(const std::string &level)
-{
-    m_maxLevel.first = true;
-    m_maxLevel.second = level;
-    security_manager_policy_entry_admin_set_level(m_entry, level.c_str());
-    m_currentLevel.first = true;
-    m_currentLevel.second = std::string(security_manager_policy_entry_get_level(m_entry));
-};
-
-
-std::ostream& operator<<(std::ostream &os, const PolicyEntry &request)
-{
-    if (request.m_appId.first)
-            os << "appId: " << request.m_appId.second << "; ";
-
-    if (request.m_user.first)
-            os << "user: " << request.m_user.second << "; ";
-
-    if (request.m_privilege.first)
-            os << "privilege: " << request.m_privilege.second << "; ";
-
-    if (request.m_currentLevel.first)
-            os << "current: " << request.m_currentLevel.second << "; ";
-
-    if (request.m_maxLevel.first)
-            os << "max: " << request.m_maxLevel.second << "; ";
-
-    return os;
-}
-
-PolicyEntry::~PolicyEntry()
-{
-}
-
-void PolicyEntry::free(void)
-{
-    security_manager_policy_entry_free(m_entry);
-}
-
-bool PolicyEntry::operator==(const PolicyEntry &other) const
-{
-    auto cmp = [](const std::pair<bool, std::string> &a, const std::pair<bool, std::string> &b)->bool
-    {
-        return (a.first) ? (b.first && a.second == b.second) : !b.first;
-    };
-
-    return (
-        cmp(m_appId, other.m_appId) &&
-        cmp(m_user, other.m_user) &&
-        cmp(m_privilege, other.m_privilege) &&
-        cmp(m_currentLevel, other.m_currentLevel) &&
-        cmp(m_maxLevel, other.m_maxLevel));
-}
-
-std::string PolicyEntry::toString() const
-{
-    std::stringstream ss;
-    auto append = [&](const std::pair<bool, std::string> &x)
-    {
-        if (x.first)
-            ss << x.second;
-        ss << '\0';
-    };
-
-    append(m_appId);
-    append(m_user);
-    append(m_privilege);
-    append(m_currentLevel);
-    append(m_maxLevel);
-
-    return ss.str();
-}
-
-PolicyRequest::PolicyRequest()
-    : m_req(nullptr),
-      m_entries()
-{
-    int result = security_manager_policy_update_req_new(&m_req);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new policy request failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new policy request did not allocate memory");
-}
-
-PolicyRequest::~PolicyRequest()
-{
-    for(std::vector<PolicyEntry>::iterator it = m_entries.begin(); it != m_entries.end(); ++it) {
-        it->free();
-    }
-    security_manager_policy_update_req_free(m_req);
-}
-
-void PolicyRequest::addEntry(PolicyEntry &entry,
-        lib_retcode expectedResult)
-{
-    int result = 0;
-
-    result = security_manager_policy_update_req_add_entry(m_req, entry.get());
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                     "adding policy entry to request returned wrong value."
-                          << " entry: " << entry << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-
-    m_entries.push_back(entry);
-}
-
-std::ostream& operator<<(std::ostream &os, const PolicyRequest &request)
-{
-    if (request.m_entries.size() != 0)
-    {
-        os << "PolicyRequest m_entries size: " << request.m_entries.size() << "; ";
-
-        for(unsigned int i = 0; i != request.m_entries.size(); i++) {
-           os << "entry " << i << ": " << request.m_entries[i] << "; ";
-       }
-    }
-
-    return os;
-}
-
-} // namespace SecurityManagerTest
diff --git a/src/security-manager-tests/common/sm_policy_request.h b/src/security-manager-tests/common/sm_policy_request.h
deleted file mode 100644 (file)
index 4c12102..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef SECURITY_MANAGER_TEST_POLICYREQUEST
-#define SECURITY_MANAGER_TEST_POLICYREQUEST
-
-#include <iostream>
-#include <sys/types.h>
-#include <utility>
-#include <vector>
-
-#include <security-manager.h>
-
-namespace SecurityManagerTest {
-
-class PolicyEntry
-{
-public:
-    PolicyEntry();
-
-    PolicyEntry(const std::string &appId,
-                const std::string &user,
-                const std::string &privilege
-                );
-    ~PolicyEntry();
-
-    PolicyEntry(policy_entry &entry);
-
-    policy_entry *get() const { return m_entry; }
-    std::string getUser() const         { return m_user.second; }
-    std::string getAppId() const        { return m_appId.second; }
-    std::string getPrivilege() const    { return m_privilege.second; }
-    std::string getCurrentLevel() const { return m_currentLevel.second; }
-    std::string getMaxLevel() const     { return m_maxLevel.second; }
-    void setLevel(const std::string &level);
-    void setMaxLevel(const std::string &level);
-    void free(void);
-
-    friend std::ostream& operator<<(std::ostream &, const PolicyEntry&);
-    bool operator==(const PolicyEntry &) const;
-    std::string toString() const;
-
-private:
-    policy_entry *m_entry;
-    std::pair<bool, std::string> m_appId;
-    std::pair<bool, std::string> m_user;
-    std::pair<bool, std::string> m_privilege;
-    std::pair<bool, std::string> m_currentLevel;
-    std::pair<bool, std::string> m_maxLevel;
-};
-
-std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PolicyEntry &request);
-
-class PolicyRequest
-{
-public:
-    PolicyRequest();
-    PolicyRequest(const PolicyRequest&) = delete;
-    PolicyRequest& operator=(const PolicyRequest&) = delete;
-    ~PolicyRequest();
-
-    void addEntry(PolicyEntry &entry, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-
-    policy_update_req *get() const { return m_req; }
-    friend std::ostream& operator<<(std::ostream &, const PolicyRequest&);
-
-private:
-    policy_update_req *m_req;
-    std::vector<PolicyEntry> m_entries;
-};
-
-std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PolicyRequest &request);
-
-} // namespace SecurityManagerTest
-
-namespace std {
-
-template<>
-struct hash<SecurityManagerTest::PolicyEntry> {
-    size_t operator()(const SecurityManagerTest::PolicyEntry &x) const { return hash<string>()(x.toString()); }
-};
-
-} // namespace std
-
-#endif // SECURITY_MANAGER_TEST_USERREQUEST
diff --git a/src/security-manager-tests/common/sm_request.cpp b/src/security-manager-tests/common/sm_request.cpp
deleted file mode 100644 (file)
index 6e06150..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2014-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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <sm_request.h>
-
-#include <dpl/test/test_runner.h>
-
-namespace SecurityManagerTest {
-
-void prepare_request(InstallRequest &request,
-                     const std::string &app_id,
-                     const std::string &pkg_id,
-                     app_install_path_type pathType,
-                     const std::string &path,
-                     uid_t uid)
-{
-    request.setAppId(app_id);
-    request.setPkgId(pkg_id);
-    request.addPath(path, pathType);
-
-    if (uid != 0)
-        request.setUid(uid);
-}
-
-InstallRequest::InstallRequest()
-    : m_req(nullptr)
-    , m_tizenVer("3.0")
-    , m_uid(false, 0)
-{
-    int result = security_manager_app_inst_req_new(&m_req);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new request failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
-}
-
-InstallRequest::~InstallRequest()
-{
-    security_manager_app_inst_req_free(m_req);
-}
-
-void InstallRequest::setAppTizenVersion(std::string tizenVer, lib_retcode expectedResult)
-{
-    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::move(tizenVer);
-}
-
-void InstallRequest::setAppId(std::string appId, lib_retcode expectedResult)
-{
-    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 = std::move(appId);
-}
-
-void InstallRequest::setPkgId(std::string pkgId, lib_retcode expectedResult)
-{
-    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 = std::move(pkgId);
-}
-
-void InstallRequest::addPrivilege(Privilege privilege, lib_retcode expectedResult)
-{
-    int result = security_manager_app_inst_req_add_client_privilege(m_req,
-                                                                    privilege,
-                                                                    privilege.getLicenseC());
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "adding privilege returned wrong value."
-                          << " Privilege: " << privilege.getName() << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    m_privileges.push_back(std::move(privilege));
-}
-
-void InstallRequest::addAppDefinedPrivilege(Privilege privilege, lib_retcode expectedResult)
-{
-    int result = security_manager_app_inst_req_add_app_defined_privilege(
-                    m_req,
-                    privilege,
-                    privilege.getSMType(),
-                    privilege.getLicenseC());
-
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "adding app defined privilege returned wrong value."
-                          << " Privilege: " << privilege.getName() << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    m_appDefinedPrivileges.push_back(std::move(privilege));
-}
-
-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.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.emplace_back(std::pair<std::string, app_install_path_type>(std::move(path), pathType));
-}
-
-void InstallRequest::setUid(const uid_t uid, lib_retcode expectedResult)
-{
-    int result = security_manager_app_inst_req_set_uid(m_req, uid);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "setting uid returned wrong value."
-                          << " Uid: " << uid << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    m_uid.first = true;
-    m_uid.second = uid;
-}
-
-void InstallRequest::setAuthorId(std::string authorId, lib_retcode expectedResult)
-{
-    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);
-}
-
-void InstallRequest::setInstallType(const enum app_install_type &type, lib_retcode expectedResult)
-{
-    int result = security_manager_app_inst_req_set_install_type(m_req, type);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "setting install type returned wrong value."
-                          << " Install type: " << type << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-void InstallRequest::setHybrid(lib_retcode expectedResult)
-{
-    int result = security_manager_app_inst_req_set_hybrid(m_req);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                       "setting security_manager_app_inst_req_set_hybrid returned wrong value."
-                       << " Result: " << result << ";"
-                       << " Expected result: " << expectedResult);
-}
-
-std::ostream& operator<<(std::ostream &os, const InstallRequest &request)
-{
-    if (!request.m_appId.empty())
-        os << "app id: " << request.m_appId << "; ";
-    if (!request.m_pkgId.empty())
-        os << "pkg id: " << request.m_pkgId << "; ";
-    if (!request.m_privileges.empty()) {
-        os << "privileges: [ "  << "< " << request.m_privileges[0].getName() << "; "
-                                        << request.m_privileges[0].getLicense() << " >";
-        for (size_t i = 1; i < request.m_privileges.size(); ++i) {
-            os << "; <" << request.m_privileges[i].getName() << "; "
-                        << request.m_privileges[i].getLicense() << " >";
-        }
-        os << " ]";
-    }
-    if (!request.m_appDefinedPrivileges.empty()) {
-        os << "app defined privileges: [ "  << "< "
-           << request.m_appDefinedPrivileges[0].getName() << "; "
-           << request.m_appDefinedPrivileges[0].getType() << "; "
-           << request.m_appDefinedPrivileges[0].getLicense() << " >";
-
-        for (size_t i = 1; i < request.m_appDefinedPrivileges.size(); ++i) {
-            os << "; <" << request.m_appDefinedPrivileges[i].getName() << "; "
-                        << request.m_appDefinedPrivileges[i].getType() << "; "
-                        << request.m_appDefinedPrivileges[i].getLicense() << " >";
-        }
-        os << " ]";
-    }
-
-    if (!request.m_paths.empty()) {
-        os << "paths: [ " << "< " << request.m_paths[0].first << "; "
-                                  << request.m_paths[0].second << " >";
-        for (size_t i=1; i < request.m_paths.size(); ++i) {
-            os << "; < " << request.m_paths[i].first << "; "
-                         << request.m_paths[i].second << " >";
-        }
-        os << " ]";
-    }
-    if (request.m_uid.first)
-        os << "uid: " << request.m_uid.second << "; ";
-    if (!request.m_authorId.empty()) {
-        os << "author id: " << request.m_authorId << "; ";
-    }
-    return os;
-}
-
-PathsRequest::PathsRequest()
-    : m_req(nullptr)
-    , m_uid(false, 0)
-{
-    int result = security_manager_path_req_new(&m_req);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new request failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
-}
-
-PathsRequest::~PathsRequest()
-{
-    security_manager_path_req_free(m_req);
-}
-
-void PathsRequest::setPkgId(std::string pkgId, lib_retcode expectedResult)
-{
-    int result = security_manager_path_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 = std::move(pkgId);
-}
-
-void PathsRequest::addPath(std::string path, app_install_path_type pathType, lib_retcode expectedResult)
-{
-    int result = security_manager_path_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.emplace_back(std::pair<std::string, app_install_path_type>(std::move(path), pathType));
-}
-
-void PathsRequest::setUid(const uid_t uid, lib_retcode expectedResult)
-{
-    int result = security_manager_path_req_set_uid(m_req, uid);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "setting uid returned wrong value."
-                          << " Uid: " << uid << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    m_uid.first = true;
-    m_uid.second = uid;
-}
-
-void PathsRequest::setInstallType(const enum app_install_type &type, lib_retcode expectedResult)
-{
-    int result = security_manager_path_req_set_install_type(m_req, type);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "setting install type returned wrong value."
-                          << " Install type: " << type << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-}
-
-std::ostream& operator<<(std::ostream &os, const PathsRequest &request)
-{
-    if (!request.m_pkgId.empty())
-        os << "pkg id: " << request.m_pkgId << "; ";
-    if (!request.m_paths.empty()) {
-        os << "paths: [ " << "< " << request.m_paths[0].first << "; "
-                                  << request.m_paths[0].second << " >";
-        for (size_t i=1; i < request.m_paths.size(); ++i) {
-            os << "; < " << request.m_paths[i].first << "; "
-                         << request.m_paths[i].second << " >";
-        }
-        os << " ]";
-    }
-    if (request.m_uid.first)
-        os << "uid: " << request.m_uid.second << "; ";
-    return os;
-}
-
-} // namespace SecurityManagerTest
diff --git a/src/security-manager-tests/common/sm_request.h b/src/security-manager-tests/common/sm_request.h
deleted file mode 100644 (file)
index 7d74f64..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2014-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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef SECURITY_MANAGER_TEST_INSTALLREQUEST
-#define SECURITY_MANAGER_TEST_INSTALLREQUEST
-
-#include <iostream>
-#include <string>
-#include <sys/types.h>
-#include <utility>
-#include <vector>
-
-#include <security-manager.h>
-#include <app_def_privilege.h>
-
-namespace SecurityManagerTest {
-class InstallRequest;
-void prepare_request(InstallRequest &request,
-                     const std::string &app_id,
-                     const std::string &pkg_id,
-                     app_install_path_type pathType,
-                     const std::string &path,
-                     uid_t uid);
-class InstallRequest
-{
-public:
-    InstallRequest();
-    InstallRequest(const InstallRequest&) = delete;
-    InstallRequest& operator=(const InstallRequest&) = delete;
-    InstallRequest(InstallRequest &&other)
-        : m_req(std::move(other.m_req)),
-          m_appId(std::move(other.m_appId)),
-          m_pkgId(std::move(other.m_pkgId)),
-          m_authorId(std::move(other.m_authorId)),
-          m_privileges(std::move(other.m_privileges)),
-          m_paths(std::move(other.m_paths)),
-          m_uid(std::move(other.m_uid))
-    {
-        other.m_req = nullptr;
-        other.m_uid.first = false;
-        other.m_uid.second = 0;
-    }
-    ~InstallRequest();
-
-    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(Privilege privilege, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
-    void addAppDefinedPrivilege(Privilege privilege, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-    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(std::string authorId, lib_retcode expectedResult= SECURITY_MANAGER_SUCCESS);
-    void setInstallType(const enum app_install_type &type, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-    void setHybrid(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&);
-
-private:
-    app_inst_req *m_req;
-
-    std::string m_tizenVer;
-    std::string m_appId;
-    std::string m_pkgId;
-    std::string m_authorId;
-    PrivilegeVector m_privileges;
-    PrivilegeVector m_appDefinedPrivileges;
-    std::vector<std::pair<std::string, app_install_path_type> > m_paths;
-    std::pair<bool, uid_t> m_uid;
-};
-
-std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::InstallRequest &request);
-
-class PathsRequest
-{
-public:
-    PathsRequest();
-    PathsRequest(const PathsRequest&) = delete;
-    PathsRequest& operator=(const PathsRequest&) = delete;
-    ~PathsRequest();
-
-    void setPkgId(std::string pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
-    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 setInstallType(const enum app_install_type &type, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-
-    //app_inst_req *get() { return m_req; }
-    const path_req *get() const { return m_req; }
-    friend std::ostream& operator<<(std::ostream &, const PathsRequest&);
-
-private:
-    path_req *m_req;
-
-    std::string m_pkgId;
-    std::vector<std::pair<std::string, app_install_path_type> > m_paths;
-    std::pair<bool, uid_t> m_uid;
-};
-
-std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PathsRequest &request);
-
-} // namespace SecurityManagerTest
-
-#endif // SECURITY_MANAGER_TEST_INSTALLREQUEST
diff --git a/src/security-manager-tests/common/sm_sharing_request.cpp b/src/security-manager-tests/common/sm_sharing_request.cpp
deleted file mode 100644 (file)
index 3e361ec..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2014-2016 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <sm_sharing_request.h>
-
-#include <dpl/test/test_runner.h>
-
-namespace SecurityManagerTest {
-
-SharingRequest::SharingRequest()
-    : m_req(nullptr)
-{
-    int result = security_manager_private_sharing_req_new(&m_req);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new request failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
-}
-
-SharingRequest::~SharingRequest()
-{
-    security_manager_private_sharing_req_free(m_req);
-}
-
-void SharingRequest::setOwnerAppId(const std::string &appId, lib_retcode expectedResult)
-{
-    int result = security_manager_private_sharing_req_set_owner_appid(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 = appId;
-}
-
-void SharingRequest::setTargetAppId(const std::string &appId, lib_retcode expectedResult)
-{
-    int result = security_manager_private_sharing_req_set_target_appid(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 = appId;
-}
-
-void SharingRequest::addPaths(const char **paths, size_t pathCount, lib_retcode expectedResult)
-{
-    int result = security_manager_private_sharing_req_add_paths(m_req, paths, pathCount);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                      "adding path returned wrong value."
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    for (size_t i = 0; i < pathCount; i++) {
-        m_paths.push_back(paths[i]);
-    }
-}
-
-std::ostream& operator<<(std::ostream &os, const SharingRequest &request)
-{
-
-    os << "app id: " << request.m_appId << "; ";
-    os << "pkg id: " << request.m_pkgId << "; ";
-
-    if (!request.m_paths.empty()) {
-        os << "paths: [ " << "< " << request.m_paths[0] << ">";
-        for (size_t i=1; i < request.m_paths.size(); ++i) {
-            os << "; < " << request.m_paths[i] << ">";
-        }
-        os << " ]";
-    }
-    return os;
-}
-
-} // namespace SecurityManagerTest
diff --git a/src/security-manager-tests/common/sm_sharing_request.h b/src/security-manager-tests/common/sm_sharing_request.h
deleted file mode 100644 (file)
index e7f4107..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2014-2016 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef SECURITY_MANAGER_TEST_SHARINGREQUEST
-#define SECURITY_MANAGER_TEST_SHARINGREQUEST
-
-#include <iostream>
-#include <string>
-#include <sys/types.h>
-#include <utility>
-#include <vector>
-
-#include <security-manager.h>
-
-namespace SecurityManagerTest {
-
-class SharingRequest
-{
-public:
-    SharingRequest();
-    SharingRequest(const SharingRequest&) = delete;
-    SharingRequest& operator=(const SharingRequest&) = delete;
-    ~SharingRequest();
-
-    void setOwnerAppId(const std::string &appId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
-    void setTargetAppId(const std::string &pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
-    void addPaths(const char **paths, size_t path_count,
-                 lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
-    const private_sharing_req *get() const { return m_req; }
-    friend std::ostream& operator<<(std::ostream &, const SharingRequest&);
-
-private:
-    private_sharing_req *m_req;
-
-    std::string m_appId;
-    std::string m_pkgId;
-    std::vector<std::string> m_paths;
-};
-
-std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::SharingRequest &request);
-
-} // namespace SecurityManagerTest
-
-#endif // SECURITY_MANAGER_TEST_SHARINGREQUEST
diff --git a/src/security-manager-tests/common/sm_user_request.cpp b/src/security-manager-tests/common/sm_user_request.cpp
deleted file mode 100644 (file)
index 4b176c3..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <sm_user_request.h>
-
-#include <dpl/test/test_runner.h>
-
-namespace SecurityManagerTest {
-
-UserRequest::UserRequest()
-    : m_req(nullptr)
-    , m_uid(false, 0)
-    , m_utype(false, static_cast<security_manager_user_type>(0))
-{
-    int result = security_manager_user_req_new(&m_req);
-    RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
-                      "creation of new request failed. Result: " << result);
-    RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
-}
-
-UserRequest::~UserRequest()
-{
-    security_manager_user_req_free(m_req);
-}
-
-void UserRequest::setUid(const uid_t uid, lib_retcode expectedResult)
-{
-    int result = security_manager_user_req_set_uid(m_req, uid);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                     "setting uid returned wrong value."
-                          << " Uid: " << uid << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    m_uid.first = true;
-    m_uid.second = uid;
-}
-
-void UserRequest::setUserType(const security_manager_user_type utype, lib_retcode expectedResult)
-{
-    int result = security_manager_user_req_set_user_type(m_req, utype);
-    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
-                     "setting user type returned wrong value."
-                          << " User type: " << utype << ";"
-                          << " Result: " << result << ";"
-                          << " Expected result: " << expectedResult);
-    m_utype.first = true;
-    m_utype.second = utype;
-}
-
-std::ostream& operator<<(std::ostream &os, const UserRequest &request)
-{
-    if (request.m_uid.first)
-        os << "uid: " << request.m_uid.second << "; ";
-
-    if (request.m_utype.first)
-        os << "utype: " << request.m_utype.second << "; ";
-
-    return os;
-}
-
-} // namespace SecurityManagerTest
diff --git a/src/security-manager-tests/common/sm_user_request.h b/src/security-manager-tests/common/sm_user_request.h
deleted file mode 100644 (file)
index 64da559..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef SECURITY_MANAGER_TEST_USERREQUEST
-#define SECURITY_MANAGER_TEST_USERREQUEST
-
-#include <iostream>
-#include <sys/types.h>
-#include <utility>
-
-#include <security-manager.h>
-
-namespace SecurityManagerTest {
-
-class UserRequest
-{
-public:
-    UserRequest();
-    UserRequest(const UserRequest&) = delete;
-    UserRequest& operator=(const UserRequest&) = delete;
-    ~UserRequest();
-
-    void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
-    void setUserType(const security_manager_user_type utype,
-                     lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
-
-    const user_req *get() const { return m_req; }
-    friend std::ostream& operator<<(std::ostream &, const UserRequest&);
-
-private:
-    user_req *m_req;
-
-    std::pair<bool, uid_t> m_uid;
-    std::pair<bool, security_manager_user_type> m_utype;
-};
-
-std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::UserRequest &request);
-
-} // namespace SecurityManagerTest
-
-#endif // SECURITY_MANAGER_TEST_USERREQUEST
diff --git a/src/security-manager-tests/common/tzplatform.cpp b/src/security-manager-tests/common/tzplatform.cpp
deleted file mode 100644 (file)
index 3d3dce7..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2016 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include <pwd.h>
-#include <sys/types.h>
-
-#include <dpl/test/test_runner.h>
-#include <memory.h>
-#include <temp_test_user.h>
-#include <tzplatform.h>
-
-namespace TzPlatformConfig {
-
-DEFINE_SMARTPTR(tzplatform_context_destroy, tzplatform_context, TzPlatformContextPtr);
-
-uid_t getGlobalUserId(void)
-{
-    return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
-}
-
-uid_t getGlobalGroupId(void)
-{
-    gid_t global_uid = getGlobalUserId();
-    errno = 0;
-    passwd* pw = getpwuid(global_uid);
-    RUNNER_ASSERT_ERRNO_MSG(pw, "getpwuid() failed.");
-    return pw->pw_gid;
-}
-
-const std::string appDirPath(const TemporaryTestUser &user, const std::string &appId,
-                             const std::string &pkgId)
-{
-    return appDirPath(user.getUid()) + pkgId + "/" + appId;
-}
-
-const std::string appDirPath(uid_t uid)
-{
-    struct tzplatform_context *tzCtxPtr = nullptr;
-
-    RUNNER_ASSERT(0 == tzplatform_context_create(&tzCtxPtr));
-    TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
-
-    RUNNER_ASSERT_MSG(0 == tzplatform_context_set_user(tzCtxPtr, uid),
-                      "Unable to set user with uid <" << uid << "> for tzplatform context");
-
-    const char *appDir = tzplatform_context_getenv(tzCtxPtr,
-                                getGlobalUserId() == uid ? TZ_SYS_RW_APP : TZ_USER_APP);
-    RUNNER_ASSERT_MSG(nullptr != appDir,
-                      "tzplatform_context_getenv failed"
-                          << "for getting sys rw app of user with uid<" << uid << ">");
-
-    return std::string(appDir) + "/";
-}
-
-const std::string globalAppDir()
-{
-    struct tzplatform_context *tzCtxPtr = nullptr;
-
-    RUNNER_ASSERT_MSG(0 == tzplatform_context_create(&tzCtxPtr), "Couldn't create tzplatform context");
-    TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
-
-    const char *appDir = tzplatform_context_getenv(tzCtxPtr, TZ_SYS_RW_APP);
-    RUNNER_ASSERT_MSG(nullptr != appDir,
-                      "tzplatform_context_getenv failed for getting sys rw app");
-    return appDir;
-}
-
-const std::string getPath(enum tzplatform_variable id) {
-    struct tzplatform_context *tzCtxPtr = nullptr;
-
-    RUNNER_ASSERT_MSG(0 == tzplatform_context_create(&tzCtxPtr), "Couldn't create tzplatform context");
-    TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
-
-    const char *path = tzplatform_context_getenv(tzCtxPtr, id);
-    RUNNER_ASSERT_MSG(nullptr != path,
-                          "tzplatform_context_getenv failed for getting " << static_cast<int>(id));
-    return path;
-}
-
-}
-
diff --git a/src/security-manager-tests/common/tzplatform.h b/src/security-manager-tests/common/tzplatform.h
deleted file mode 100644 (file)
index fff4f5e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2016 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#pragma once
-
-#include <string>
-
-#include <tzplatform_config.h>
-
-#include <temp_test_user.h>
-
-namespace TzPlatformConfig {
-
-const std::string getPath(enum tzplatform_variable id);
-
-uid_t getGlobalUserId(void);
-
-uid_t getGlobalGroupId(void);
-
-const std::string appDirPath(const TemporaryTestUser &user, const std::string &appId,
-                             const std::string &pkgId);
-
-const std::string globalAppDir();
-
-const std::string appDirPath(uid_t uid);
-}
-