SM: Fix group names 70/70970/3
authorZofia Abramowska <z.abramowska@samsung.com>
Mon, 23 May 2016 11:45:41 +0000 (13:45 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Tue, 24 May 2016 09:32:57 +0000 (11:32 +0200)
Change-Id: I0806acce5be77390c6ff57e95d35df8c66344ea5

src/security-manager-tests/security_manager_tests.cpp

index 1c4637b..6506b5a 100644 (file)
@@ -2457,6 +2457,63 @@ RUNNER_CHILD_TEST(security_manager_21_security_manager_admin_deny_user_priv)
     }
 }
 
+void setupPrivilegeGroups(const privileges_t &privileges, const std::vector<std::string> &groups)
+{
+    TestSecurityManagerDatabase db;
+    for (const auto &privilege : privileges) {
+        db.setup_privilege_groups(privilege, groups);
+    }
+}
+
+std::vector<std::string> readPrivilegeGroups()
+{
+    std::vector<std::string> groups;
+    const static std::string privilegeGroupMappingPath("/usr/share/security-manager/policy/privilege-group.list");
+    std::ifstream mappingFile(privilegeGroupMappingPath);
+
+    RUNNER_ASSERT_MSG(mappingFile.is_open(),
+        "Unable to read group mapping file " << privilegeGroupMappingPath);
+
+    std::string line;
+    std::regex r("^[^ #]+ +(.*)");
+    while (std::getline(mappingFile, line)) {
+        std::smatch m;
+        if (std::regex_search(line, m, r))
+            groups.push_back(m[1]);
+    }
+
+    return groups;
+}
+
+RUNNER_TEST(security_manager_22_groups_get)
+{
+    setupPrivilegeGroups(SM_ALLOWED_PRIVILEGES, SM_ALLOWED_GROUPS);
+
+    std::unordered_set<std::string> groups;
+    auto tmp = readPrivilegeGroups();
+    groups.insert(tmp.begin(), tmp.end());
+    groups.insert(SM_ALLOWED_GROUPS.begin(), SM_ALLOWED_GROUPS.end());
+
+    char ** c_groups;
+    size_t count = 0;
+
+    Api::getSecurityManagerGroups(&c_groups, &count);
+    RUNNER_ASSERT_MSG(count == groups.size(), "security_manager_groups_get should set count to: "
+                      << groups.size() << " but count is: " << count);
+
+    for (const auto &group : groups) {
+        bool found = false;
+        for (size_t i = 0; i < count; ++i) {
+            if (group == c_groups[i]) {
+                found = true;
+                break;
+            }
+        }
+        RUNNER_ASSERT_MSG(found, "PrivilegeGroup: " << group << " was not found");
+    }
+    security_manager_groups_free(c_groups, count);
+}
+
 namespace {
 const int sm_app_shared_test_id = 27;
 const char *const sm_app_shared_id = "sm_test_27_app_id_full";
@@ -2485,6 +2542,8 @@ void test_fail_worker(const std::string &appName, int test_num)
 }
 }
 
+RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_PUBLIC_SHARING)
+
 RUNNER_TEST(security_manager_27a_API2X_app_install)
 {
     std::string SM_RW_PATH = genRWPath(sm_app_shared_test_id);
@@ -2731,6 +2790,8 @@ void createFile(const std::string &filePath)
 
 }
 
+RUNNER_TEST_GROUP_INIT(SECURIT_MANAGER_PRIVATE_SHARING)
+
 RUNNER_TEST(security_manager_30a_send_incomplete_req1)
 {
     SharingRequest request;
@@ -3213,6 +3274,8 @@ RUNNER_TEST(security_manager_35_share_two_with_two)
     }
 }
 
+RUNNER_TEST_GROUP_INIT(SECURIT_MANAGER_TRUSTED_SHARING)
+
 RUNNER_TEST(security_manager_40_set_wrong_author_id)
 {
     InstallRequest requestInst;
@@ -3797,62 +3860,7 @@ RUNNER_CHILD_TEST(security_manager_53_app_has_privilege)
     Api::uninstall(requestUninst);
 }
 
-void setupPrivilegeGroups(const privileges_t &privileges, const std::vector<std::string> &groups)
-{
-    TestSecurityManagerDatabase db;
-    for (const auto &privilege : privileges) {
-        db.setup_privilege_groups(privilege, groups);
-    }
-}
-
-std::vector<std::string> readPrivilegeGroups()
-{
-    std::vector<std::string> groups;
-    const static std::string privilegeGroupMappingPath("/usr/share/security-manager/policy/privilege-group.list");
-    std::ifstream mappingFile(privilegeGroupMappingPath);
-
-    RUNNER_ASSERT_MSG(mappingFile.is_open(),
-        "Unable to read group mapping file " << privilegeGroupMappingPath);
-
-    std::string line;
-    std::regex r("^[^ #]+ +(.*)");
-    while (std::getline(mappingFile, line)) {
-        std::smatch m;
-        if (std::regex_search(line, m, r))
-            groups.push_back(m[1]);
-    }
-
-    return groups;
-}
-
-RUNNER_TEST(security_manager_48_groups_get)
-{
-    setupPrivilegeGroups(SM_ALLOWED_PRIVILEGES, SM_ALLOWED_GROUPS);
-
-    std::unordered_set<std::string> groups;
-    auto tmp = readPrivilegeGroups();
-    groups.insert(tmp.begin(), tmp.end());
-    groups.insert(SM_ALLOWED_GROUPS.begin(), SM_ALLOWED_GROUPS.end());
-
-    char ** c_groups;
-    size_t count = 0;
-
-    Api::getSecurityManagerGroups(&c_groups, &count);
-    RUNNER_ASSERT_MSG(count == groups.size(), "security_manager_groups_get should set count to: "
-                      << groups.size() << " but count is: " << count);
-
-    for (const auto &group : groups) {
-        bool found = false;
-        for (size_t i = 0; i < count; ++i) {
-            if (group == c_groups[i]) {
-                found = true;
-                break;
-            }
-        }
-        RUNNER_ASSERT_MSG(found, "PrivilegeGroup: " << group << " was not found");
-    }
-    security_manager_groups_free(c_groups, count);
-}
+RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_INSTALL_TYPE)
 
 RUNNER_TEST(security_manager_49a_global_user_set_install_type_global)
 {
@@ -4037,6 +4045,8 @@ RUNNER_CHILD_TEST(security_manager_49f_local_user_set_install_type_preloaded)
     Api::install(requestPrivateUser, (lib_retcode)SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED);
 }
 
+RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_REGISTER_PATH)
+
 RUNNER_TEST(security_manager_54_path_req_no_pkg)
 {
     const char *const sm_app_id = "sm_test_54_app_id";