Fix libprivilege-control tests connected with perm_app_setup_path 01/18401/2
authorMarcin Lis <m.lis@samsung.com>
Mon, 24 Mar 2014 09:43:54 +0000 (10:43 +0100)
committerMarcin Lis <m.lis@samsung.com>
Mon, 24 Mar 2014 09:44:44 +0000 (10:44 +0100)
[Issue#]       N/A
[Feature]      Adapt tests to tizen.org and new three domain policy.
[Cause]        Tests failing due to lack of privileges in libprivilege database.
[Solution]     Add required permissions to database.

[Verification] Build, install, run tests.

               The following test cases should pass:
                        <<   WITH SMACK   >>
                - privilege_control17_appsettings_privilege
                - privilege_control22_app_installation_1x100
                - privilege_control23_app_installation2_10x10
                        <<  WITHOUT SMACK >>
                - privilege_control17_appsettings_privilege_nosmack

Change-Id: Iefb388d4dfca1b1681c55ee8db87eb35a9109f73
Signed-off-by: Marcin Lis <m.lis@samsung.com>
tests/libprivilege-control-tests/common/libprivilege-control_test_common.h
tests/libprivilege-control-tests/libprivilege-control_test_common.cpp
tests/libprivilege-control-tests/test_cases_stress.cpp

index be5d9b2..73df02c 100644 (file)
@@ -98,8 +98,9 @@ extern const char *PRIVS_WGT[];
 extern const char *PRIVS_OSP[];
 extern const char *PRIVS_EFL[];
 
-extern const char* PRIV_APPSETTING[];
 extern const char* PRIVS_AV[];
+extern const char *PRIV_APPSETTING[];
+extern const char *PRIV_APPSETTING_RULES[];
 
 typedef std::vector< std::vector<std::string> > rules_t;
 
index f453486..1f70d3d 100644 (file)
@@ -49,10 +49,12 @@ const char *PRIVS_WGT[] = { "test_privilege_control_rules_wgt", NULL };
 const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", NULL };
 const char *PRIVS_EFL[] = { "test_privilege_control_rules_efl", NULL };
 
-const char* PRIV_APPSETTING[] {"org.tizen.privilege.appsetting", NULL};
-
 const char* PRIVS_AV[] = { "org.tizen.privilege.antivirus", NULL };
 
+const char *PRIV_APPSETTING[] {"org.tizen.privilege.appsetting", NULL};
+const char *PRIV_APPSETTING_RULES[] = { "~APP~ ~SETTINGS_PATH~ rwx",
+                                        "~APP~ ~ALL_APPS~ rx",
+                                        NULL};
 /**
  * Check if every rule is true.
  * @return 1 if ALL rules in SMACK, 0 if ANY rule isn't, -1 on failure
@@ -610,6 +612,10 @@ void test_appsettings_privilege(bool smack)
     ret = perm_app_install(APP_TEST);
     RUNNER_ASSERT_MSG_BT(ret == PC_OPERATION_SUCCESS, "Error in perm_app_install.");
 
+    //register appsettings feature
+    ret = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+    RUNNER_ASSERT_MSG_BT(ret == PC_OPERATION_SUCCESS,
+        " Error registering api feature. Result: " << ret);
 
     ret = perm_app_enable_permissions(APP_TEST, APP_TYPE_OSP, PRIV_APPSETTING, true);
     RUNNER_ASSERT_MSG_BT(ret == PC_OPERATION_SUCCESS,
index 291bccf..8b86cf2 100644 (file)
@@ -126,6 +126,12 @@ RUNNER_TEST(privilege_control22_app_installation_1x100)
     result = perm_app_install(APP_TEST_SETTINGS_ASP1);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
                   "Error in perm_app_install. Result: " << result);
+
+    // Register appsettings feature
+    result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+                 " Error while registering api feature. Result: " << result);
+
     result = perm_app_enable_permissions(APP_TEST_SETTINGS_ASP1,
                                         APP_TYPE_OSP, PRIV_APPSETTING, true);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
@@ -444,6 +450,12 @@ RUNNER_TEST(privilege_control23_app_installation2_10x10)
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
                       "Error in perm_app_install."
                       << " Result: " << result);
+
+    // Register appsettings feature
+    result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
+                 " Error while registering api feature. Result: " << result);
+
     result = perm_app_enable_permissions(APP_TEST_SETTINGS_ASP1,
                                         APP_TYPE_OSP, PRIV_APPSETTING, true);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,