}
}
+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";
}
}
+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);
}
+RUNNER_TEST_GROUP_INIT(SECURIT_MANAGER_PRIVATE_SHARING)
+
RUNNER_TEST(security_manager_30a_send_incomplete_req1)
{
SharingRequest request;
}
}
+RUNNER_TEST_GROUP_INIT(SECURIT_MANAGER_TRUSTED_SHARING)
+
RUNNER_TEST(security_manager_40_set_wrong_author_id)
{
InstallRequest requestInst;
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)
{
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";