SM: remove app paths before uninstall 83/65183/3
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 7 Apr 2016 15:58:51 +0000 (17:58 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 23 Jun 2016 10:00:04 +0000 (12:00 +0200)
Change-Id: Iaa994be25d48cdf51d745f5803ff7779d7fad057

src/security-manager-tests/common/app_install_helper.h
src/security-manager-tests/security_manager_tests.cpp

index 7bcca734e6daaa9ac5c496d9a0e7e0c44748508c..a0c69625c6c417dc56349e929c6b5c349bca17cc 100644 (file)
@@ -95,14 +95,20 @@ struct AppInstallHelper {
         return "User::Pkg::" + getPkgId();
     }
 
-    virtual ~AppInstallHelper() {
-        // TODO we should also remove trusted dirs created with custom params
+    void removePaths() {
         for (const auto &dir : m_dirs) {
             rmdir(dir.c_str());
         }
+        m_dirs.clear();
         for (const auto &file : m_files) {
             unlink(file.c_str());
         }
+        m_files.clear();
+    }
+
+    virtual ~AppInstallHelper() {
+        // TODO we should also remove trusted dirs created with custom params
+        removePaths();
     }
 
 protected:
index 799278dfe411bc674f5d594d564788e965a47e11..ac9c95054ad523747b6ddc3e63842b448206c7c2 100644 (file)
@@ -3364,6 +3364,7 @@ RUNNER_TEST(security_manager_35_share_uninstall_owner) {
     check_target_access(owner.generatePkgLabel(), target.generateAppLabel(), pathLabel1);
     check_path_label(sharedPath, pathLabel1);
 
+    owner.removePaths();
     Api::uninstall(ownerReq);
 
     check_system_access(pathLabel1, false);
@@ -3416,6 +3417,7 @@ RUNNER_TEST(security_manager_36_share_pkg_owner_uninstall) {
     check_target_access(owner.generatePkgLabel(), target.generateAppLabel(), pathLabel1);
     check_path_label(sharedPath, pathLabel1);
 
+    owner.removePaths();
     Api::uninstall(ownerReq);
 
     check_system_access(pathLabel1, false);
@@ -3653,6 +3655,7 @@ RUNNER_TEST(security_manager_37_pkg_double_share_owner_uninstall) {
     check_target_access(owner.generatePkgLabel(), target.generateAppLabel(), pathLabel1);
     check_path_label(sharedPath, pathLabel1);
 
+    owner.removePaths();
     Api::uninstall(ownerReq);
 
     check_system_access(pathLabel1, false);
@@ -3793,6 +3796,7 @@ RUNNER_TEST(security_manager_38_share_one_with_two_uninstall_owner)
     check_target_access(owner.generatePkgLabel(), target2.generateAppLabel(), pathLabel);
     check_path_label(sharedPath, pathLabel);
 
+    owner.removePaths();
     Api::uninstall(ownerReq);
     check_system_access(pathLabel, false);
     check_owner_access(owner.generateAppLabel(), pathLabel,false);