Fix groups issue in tests using perm_app_set_privilege api.
[platform/core/test/security-tests.git] / tests / libprivilege-control-tests / test_cases_nosmack.cpp
index 972d8e9..cf84205 100644 (file)
@@ -26,6 +26,7 @@
 #include <memory>
 #include <functional>
 #include <fstream>
+#include <set>
 
 #include <string.h>
 #include <errno.h>
@@ -214,6 +215,9 @@ void test_set_app_privilege_nosmack(
     RUNNER_ASSERT_MSG_BT(result == -1,
             " Permissions shouldn't be added. Result: " << result);
 
+    std::set<unsigned> groups_before;
+    read_user_gids(groups_before, APP_UID);
+
     result = perm_app_set_privilege(app_id, type, app_path);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
             " Error in perm_app_set_privilege. Error: " << result);
@@ -226,7 +230,7 @@ void test_set_app_privilege_nosmack(
     RUNNER_ASSERT_MSG_BT(label == NULL,
             " new_label_from_self shouldn't allocate memory for label.");
 
-    check_groups(dac_file);
+    check_groups(groups_before, dac_file);
 }
 
 /**
@@ -249,6 +253,9 @@ RUNNER_CHILD_TEST_NOSMACK(privilege_control05_set_app_privilege_nosmack)
     perm_app_uninstall(APP_ID);
     DB_END
 
+    std::set<unsigned> groups_before;
+    read_user_gids(groups_before, APP_UID);
+
     //Set app privileges
     result = perm_app_set_privilege(APP_ID, NULL, APP_SET_PRIV_PATH);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
@@ -271,7 +278,7 @@ RUNNER_CHILD_TEST_NOSMACK(privilege_control05_set_app_privilege_nosmack)
     result = strcmp(getenv("USER"), APP_USER_NAME);
     RUNNER_ASSERT_MSG_BT(result == 0, "Wrong user USER NAME. Result: " << result);
 
-    check_groups(LIBPRIVILEGE_TEST_DAC_FILE);
+    check_groups(groups_before, NULL);
 }
 
 /**