Fix libprivilege-control tests
[platform/core/test/security-tests.git] / src / libprivilege-control-tests / test_cases_stress.cpp
index fd4242a..31d9162 100644 (file)
@@ -230,16 +230,18 @@ void privilege_control22_app_installation_1x100(bool smack)
 
             // Verify that all permissions to public dir have been added
             // correctly, also to other app
-            result = smack_have_access(APP_ID, shared_dir_auto_label.c_str(), "rwxatl");
+            result = smack_have_access(GENERATED_APP_ID, shared_dir_auto_label.c_str(), "rwxatl");
 
             RUNNER_ASSERT_MSG(result == expected_smack_result,
                    "Not all accesses to Public RO dir are granted. Loop index: "
                    << i);
 
-            result = smack_have_access(TEST_OSP_FEATURE_APP_ID, shared_dir_auto_label.c_str(), "rx" );
+            /* all apps are getting the label "User" at the moment. Calling smack_have_access with
+               "User" as an argument is no different from previous call */
+            /*result = smack_have_access(TEST_OSP_FEATURE_APP_ID, shared_dir_auto_label.c_str(), "rx" );
             RUNNER_ASSERT_MSG(result == expected_smack_result,
                    "Not all accesses to Public RO dir are granted. Loop index: "
-                   << i);
+                   << i);*/
 
             break;
         }
@@ -275,27 +277,29 @@ void privilege_control22_app_installation_1x100(bool smack)
 
             // Verify that setting app has rwx permission to app dir
             // and rx permissions to app
-            result = smack_have_access(APP_ID, shared_dir_auto_label.c_str(), "rwxatl");
+            result = smack_have_access(GENERATED_APP_ID, shared_dir_auto_label.c_str(), "rwxatl");
             RUNNER_ASSERT_MSG(result == expected_smack_result,
                  "Not all accesses to App-Setting dir are granted. "
                  << APP_ID << " "<< shared_dir_auto_label << " rwxatl "
                  << "Loop index: " << i);
 
-            result = smack_have_access(APP_TEST_SETTINGS_ASP1, shared_dir_auto_label.c_str(), "rwx");
+            /* all apps are getting the label "User" at the moment. Calling smack_have_access with
+               "User" as an argument is no different from previous call */
+            /*result = smack_have_access(APP_TEST_SETTINGS_ASP1, shared_dir_auto_label.c_str(), "rwx");
             RUNNER_ASSERT_MSG(result == expected_smack_result,
                  "Not all accesses to App-Setting dir are granted. "
                  << APP_TEST_SETTINGS_ASP1 << " " << shared_dir_auto_label << " rwx. "
                  << "Loop index: " << i);
 
-            result = smack_have_access(APP_TEST_SETTINGS_ASP1, APP_ID, "rx");
+            result = smack_have_access(APP_TEST_SETTINGS_ASP1, GENERATED_APP_ID, "rx");
             RUNNER_ASSERT_MSG(result == expected_smack_result,
                  "Not all accesses to App-Setting dir are granted. "
-                 << APP_TEST_SETTINGS_ASP1 << " " <<  APP_ID <<  " rx"
-                 << "Loop index: " << i);
+                 << APP_TEST_SETTINGS_ASP1 << " " <<  GENERATED_APP_ID <<  " rx"
+                 << "Loop index: " << i);*/
 
             // Verify that all permissions to public dir have been added
             // correctly, also to other app
-            result = smack_have_access(APP_ID, LABEL_FOR_PUBLIC_SHARED_DIRS, "rwxatl");
+            result = smack_have_access(GENERATED_APP_ID, LABEL_FOR_PUBLIC_SHARED_DIRS, "rwxatl");
             RUNNER_ASSERT_MSG(result == expected_smack_result,
                  "Not all accesses to Group RW dir are granted. Loop index: "
                   << i);
@@ -307,14 +311,14 @@ void privilege_control22_app_installation_1x100(bool smack)
         // check if api-features permissions are added properly
         result = check_all_accesses(smack,
                                     (const rules_t) {
-                                     { APP_ID, TEST_OSP_FEATURE_APP_ID, "rxl" },
-                                     { APP_ID, TEST_WGT_FEATURE_APP_ID, "rwxl" } } );
+                                     { GENERATED_APP_ID, TEST_OSP_FEATURE_APP_ID, "rxl" },
+                                     { GENERATED_APP_ID, TEST_WGT_FEATURE_APP_ID, "rwxl" } } );
         RUNNER_ASSERT_MSG(result == 1,
                       "Not all permisions from api features added. Loop index: "
                       << i);
 
         // revoke permissions
-        result = perm_app_revoke_permissions(APP_ID);
+        result = perm_app_revoke_permissions(GENERATED_APP_ID);
         RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                      "Error in perm_app_revoke_permissions. Loop index: " << i
                      << ". Result: " << result);
@@ -406,7 +410,9 @@ void privilege_control23_app_installation2_10x10(bool smack)
     // generate app ids: test_APP0, test_APP1, test_APP2 etc.:
     for (int i = 0; i < app_count; ++i)
     {
-        result = sprintf(app_ids[i], APP_ID "%d", i);
+        /* Libprivilege-control assigns "User" label to all apps. Replace it when individual labels
+           are supported. */
+        result = sprintf(app_ids[i], GENERATED_APP_ID);
         RUNNER_ASSERT_MSG(result > 0, "Cannot generate name for app nr: " << i);
     }
 
@@ -571,9 +577,10 @@ void privilege_control23_app_installation2_10x10(bool smack)
 
         DB_END
 
+        // All apps have the same label "User" so this check makes no sense.
         // Verify that some previously installed app does not have
         // any acces to app 0 and app 5 PRIVATE folders
-        for (int j = 0; j < app_count; ++j)
+        /*for (int j = 0; j < app_count; ++j)
         {
             // Apps 1-9 should not have any access to app 0
             if (j != 0)
@@ -598,7 +605,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
                        ") has access to private label of: " << app_ids[5] <<
                        ". It may not be shared. Loop index: " << i << ".");
             }
-        } // End for Verify PRIVATE
+        }*/ // End for Verify PRIVATE
 
         // Verify that apps 1, 2 and 6 have all accesses to GROUP_RW folders
         result = check_all_accesses(smack,
@@ -648,8 +655,9 @@ void privilege_control23_app_installation2_10x10(bool smack)
                 RUNNER_ASSERT_MSG(result == 1,
                  "Not all accesses to owned Public RO dir are granted. App id: "
                  << app_ids[j] << "  Loop index: " << i);
+                // All apps have the same label "User" so this check makes no sense.
                 // Verify that there are no extra permissions to public dirs
-                result = check_no_accesses(smack,
+                /*result = check_no_accesses(smack,
                                (const rules_t) {
                                 { app_ids[j], shared_dir7_auto_label.c_str(), "w" },
                                 { app_ids[j], shared_dir7_auto_label.c_str(), "t" },
@@ -657,7 +665,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
                                 { app_ids[j], shared_dir8_auto_label.c_str(), "t" } } );
                 RUNNER_ASSERT_MSG(result == 1,
                      "Unexpected extra permissions added for app:" << app_ids[j]
-                     << ". Loop index: " << i);
+                     << ". Loop index: " << i);*/
             }
             if (j == 7)
             {
@@ -667,8 +675,9 @@ void privilege_control23_app_installation2_10x10(bool smack)
                 RUNNER_ASSERT_MSG(result == 1,
                  "Not all accesses to owned Public RO dir are granted. App id: "
                  << app_ids[j] << " Loop index: " << i);
+                // All apps have the same label "User" so this check makes no sense.
                 // Verify that there are no extra permissions to public dirs
-                result = check_no_accesses(smack,
+                /*result = check_no_accesses(smack,
                                (const rules_t) {
                                 { app_ids[j], shared_dir3_auto_label.c_str(), "w" },
                                 { app_ids[j], shared_dir3_auto_label.c_str(), "t" },
@@ -676,7 +685,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
                                 { app_ids[j], shared_dir8_auto_label.c_str(), "t" } } );
                 RUNNER_ASSERT_MSG(result == 1,
                      "Unexpected extra permissions added for app:" << app_ids[j]
-                     << ". Loop index: " << i);
+                     << ". Loop index: " << i);*/
             }
             if (j == 8)
             {
@@ -686,8 +695,9 @@ void privilege_control23_app_installation2_10x10(bool smack)
                 RUNNER_ASSERT_MSG(result == 1,
                  "Not all accesses to owned Public RO dir are granted. App id: "
                  << app_ids[j] << "  Loop index: " << i);
+                // All apps have the same label "User" so this check makes no sense.
                 // Verify that there are no extra permissions to other public dirs
-                result = check_no_accesses(smack,
+                /*result = check_no_accesses(smack,
                                (const rules_t) {
                                 { app_ids[j], shared_dir3_auto_label.c_str(), "w" },
                                 { app_ids[j], shared_dir3_auto_label.c_str(), "t" },
@@ -695,7 +705,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
                                 { app_ids[j], shared_dir7_auto_label.c_str(), "t" } } );
                 RUNNER_ASSERT_MSG(result == 1,
                      "Unexpected extra permissions added for app:" << app_ids[j]
-                     << ". Loop index: " << i);
+                     << ". Loop index: " << i);*/
             }
 
             result = check_all_accesses(smack,
@@ -738,7 +748,8 @@ void privilege_control23_app_installation2_10x10(bool smack)
                  "Not all accesses to App-Setting dir are granted."
                  << app_ids[9] << " " << setting_dir9_auto_label
                  << " Loop index: " << i);
-        result = smack_have_access(APP_TEST_SETTINGS_ASP1, app_ids[4], "rx");
+        // All apps have the same label "User" so this check makes no sense.
+        /*result = smack_have_access(APP_TEST_SETTINGS_ASP1, app_ids[4], "rx");
         RUNNER_ASSERT_MSG(result == expected_smack_result,
                  "Not all accesses to App-Setting dir are granted."
                  << APP_TEST_SETTINGS_ASP1 << " " << app_ids[4]
@@ -757,7 +768,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
         RUNNER_ASSERT_MSG(result == expected_smack_result,
                  "Not all accesses to App-Setting dir are granted."
                  << APP_TEST_SETTINGS_ASP1 << " " << setting_dir9_auto_label
-                 << " Loop index: " << i);
+                 << " Loop index: " << i);*/
 
 
 
@@ -802,8 +813,9 @@ void privilege_control23_app_installation2_10x10(bool smack)
 
         DB_END
 
+        // All apps have the same label "User" so this check makes no sense.
         // Check if permissions are removed properly
-        for (int j = 0; j < app_count; ++j)
+        /*for (int j = 0; j < app_count; ++j)
         {
             // To all other apps
             for (int k = 0; k < app_count; ++k)
@@ -816,7 +828,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
                           "Not all permisions revoked. Subject: " << app_ids[j]
                           << " Object: " << app_ids[k] << " Loop index: " << i);
             }
-        }
+        }*/
 
         DB_BEGIN