Remove tests that use deprecated libprivilege-control API. 10/19210/2
authorMarcin Lis <m.lis@samsung.com>
Tue, 8 Apr 2014 15:33:35 +0000 (17:33 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 14 Apr 2014 14:14:54 +0000 (07:14 -0700)
[Feature]      Adapt tests to tizen.org
[Cause]        Libprivilege contained a lot of API that was marked deprecated
               for a long time. This API is removed in the following commit:
                   https://review.tizen.org/gerrit/#/c/19194/
[Solution]     Remove tests, macros, variables associated with old API:
               - app_register_av
               - app_add_friend
[Verification] Build, install and run tests on smack and non-smack environment.
               Ensure that libprivilege-control rpm built from the commit linked
               above is installed on the target.
               Removed tests should not be present.

Change-Id: I59ef71c5684a29a4fb6ba6a8f6a4a667e3f99ab0
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.cpp
tests/libprivilege-control-tests/test_cases_incorrect_params.cpp
tests/libprivilege-control-tests/test_cases_nosmack.cpp

index 5e52603bb2424619b841e4f31d7fa1458ddaebda..979188f469df1161a40070096c3d8c726fbea4e0 100644 (file)
 
 #define EFL_APP_ID             "hello-tizen"
 
-#define APP_FRIEND_1 "app_friend_1"
-#define APP_FRIEND_2 "app_friend_2"
-
 #define LIBPRIVILEGE_TEST_DAC_FILE     "/usr/share/privilege-control/test_privilege_control_rules.dac"
 #define LIBPRIVILEGE_TEST_DAC_FILE_WGT "/usr/share/privilege-control/WRT_test_privilege_control_rules_wgt.dac"
 #define LIBPRIVILEGE_TEST_DAC_FILE_OSP "/usr/share/privilege-control/OSP_test_privilege_control_rules_osp.dac"
 #define LIBPRIVILEGE_TEST_DAC_FILE_EFL "/usr/share/privilege-control/EFL_test_privilege_control_rules_efl.dac"
 
-#define APP_TEST_APP_1 "test-application1"
-#define APP_TEST_APP_2 "test-application_2"
-#define APP_TEST_APP_3 "test-app-3"
-#define APP_TEST_AV_1  "test-antivirus1"
-#define APP_TEST_AV_2  "test-antivirus_2"
-
 #define OSP_APP_ID            "uqNfgEjqc7"
 
 #define WGT_APP_PATH          "/opt/usr/apps/QwCqJ0ttyS/bin/QwCqJ0ttyS.TestMisiuPysiu123"
@@ -238,9 +229,6 @@ int nftw_set_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
 int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
                                   int /*typeflag*/, struct FTW* /*ftwbuf*/);
 
-void checkOnlyAvAccess(const char *av_id, const char *app_id, const char *comment);
-void checkOnlyAvAccessNosmack(const char *av_id, const char *app_id, const char *comment);
-
 void test_revoke_permissions(int line_no, const char* app_id, const rules_t &rules, bool smack);
 void test_app_enable_permissions_efl(bool smack);
 void test_app_disable_permissions_efl(bool smack);
index ac3e0c7d400fa4294724950acb7f1541f859734e..117331b12b0f42eabf9e42002b4b27e02ab59100 100644 (file)
@@ -276,45 +276,6 @@ int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
     return 0;
 }
 
-void checkOnlyAvAccess(const char *av_id, const char *app_id, const char *comment)
-{
-    int result;
-    result = smack_have_access(av_id, app_id, "rwx");
-    RUNNER_ASSERT_MSG_BT(result == 1,
-        "Error while checking " << av_id << " rwx access to "
-        << app_id << " " << comment << " Result: " << result);
-    result = smack_have_access(av_id, app_id, "a");
-    RUNNER_ASSERT_MSG_BT(result == 0,
-        "Error while checking " << av_id << " a access to "
-        << app_id << " " << comment << " Result: " << result);
-    result = smack_have_access(av_id, app_id, "t");
-    RUNNER_ASSERT_MSG_BT(result == 0,
-        "Error while checking " << av_id << " t access to "
-        << app_id << " " << comment << " Result: " << result);
-}
-
-/**
- * NOSMACK version of checkOnlyAvAccess function.
- *
- * Expects error instead of access granted/forbidden from smack_have_access.
- */
-void checkOnlyAvAccessNosmack(const char *av_id, const char *app_id, const char *comment)
-{
-    int result;
-    result = smack_have_access(av_id, app_id, "rwx");
-    RUNNER_ASSERT_MSG_BT(result == -1,
-            "smack_have_access should return error (SMACK is off). Result: " << result
-            << " when testing " << comment);
-    result = smack_have_access(av_id, app_id, "a");
-    RUNNER_ASSERT_MSG_BT(result == -1,
-            "smack_have_access should return error (SMACK is off). Result: " << result
-            << " when testing " << comment);
-    result = smack_have_access(av_id, app_id, "t");
-    RUNNER_ASSERT_MSG_BT(result == -1,
-            "smack_have_access should return error (SMACK is off). Result: " << result
-            << " when testing " << comment);
-}
-
 void test_revoke_permissions(int line_no, const char* app_id, const rules_t &rules, bool smack)
 {
     int result;
index 9f3bb539e51123890e431fc6677d8a6eb7d9da6b..c4875c877cdec927b41ae6c24bd3c24b0753d63a 100644 (file)
@@ -536,69 +536,6 @@ RUNNER_TEST(privilege_control07_app_rollback_2)
     TestLibPrivilegeControlDatabase db_test;
     db_test.test_db_after__perm_app_install(APP_ID);
 }
-/*
- * Check app_register_av function
- * Notice that this test case may have no sense if previous would fail (privilege_control06_app_install)
- */
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-RUNNER_TEST_SMACK(privilege_control10_app_register_av)
-{
-    RUNNER_IGNORED_MSG("app_register_av is deprecated");
-    int result;
-
-    // cleaning
-    smack_revoke_subject(APP_TEST_AV_1);
-    smack_revoke_subject(APP_TEST_AV_2);
-
-    DB_BEGIN
-
-    // Adding two apps before antivir
-    result = perm_app_install(APP_TEST_APP_1);
-    RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno));
-
-    result = perm_app_install(APP_TEST_APP_2);
-    RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno));
-
-    // Adding antivir
-    result = app_register_av(APP_TEST_AV_1);
-    RUNNER_ASSERT_MSG_BT(result == 0, "app_register_av returned " << result << ". Errno: " << strerror(errno));
-
-    DB_END
-
-    // Checking added apps accesses
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_1)");
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_2, "app_register_av(APP_TEST_AV_1)");
-
-    DB_BEGIN
-
-    // Adding third app
-    result = perm_app_install(APP_TEST_APP_3);
-    RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno));
-
-    DB_END
-
-    // Checking app accesses
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_1, "perm_app_install(APP_TEST_APP_3)");
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_2, "perm_app_install(APP_TEST_APP_3)");
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_3, "perm_app_install(APP_TEST_APP_3)");
-
-    // Adding second antivir
-    result = app_register_av(APP_TEST_AV_2);
-    RUNNER_ASSERT_MSG_BT(result == 0, "app_register_av returned " << result << ". Errno: " << strerror(errno));
-
-    // Checking app accesses
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_2, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_3, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccess(APP_TEST_AV_2, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccess(APP_TEST_AV_2, APP_TEST_APP_2, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccess(APP_TEST_AV_2, APP_TEST_APP_3, "app_register_av(APP_TEST_AV_2)");
-
-    // cleaning
-    smack_revoke_subject(APP_TEST_AV_1);
-    smack_revoke_subject(APP_TEST_AV_2);
-}
-#pragma GCC diagnostic warning "-Wdeprecated-declarations"
 
 /**
  * Grant SMACK permissions based on permissions list.
@@ -844,195 +781,6 @@ RUNNER_TEST_SMACK(privilege_control13_app_reset_permissions)
     DB_END
 }
 
-/**
- * Make two applications "friends", by giving them both full permissions on
- * each other.
- */
-RUNNER_TEST_SMACK(privilege_control14_app_add_friend)
-{
-    RUNNER_IGNORED_MSG("perm_app_add_friend is not implemented");
-
-    int result;
-
-/**
- * Test - making friends with no permissions on each other
- */
-
-    DB_BEGIN
-
-    result = perm_app_revoke_permissions(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-    result = perm_app_revoke_permissions(APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-
-    perm_app_uninstall(APP_FRIEND_1);
-    perm_app_uninstall(APP_FRIEND_2);
-
-    // Installing friends to be
-    result = perm_app_install(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error installing first app. Result: " << result);
-    result = perm_app_install(APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error installing second app. Result: " << result);
-
-    // Making friends
-    result = perm_app_add_friend(APP_FRIEND_1, APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error making friends. Errno: " << result);
-
-    DB_END
-
-    // Checking if friends were made
-    result = smack_have_access(APP_FRIEND_1, APP_FRIEND_2, "wrxat");
-    RUNNER_ASSERT_MSG_BT(result == 1,
-        " Error first one sided friednship failed. Result: " << result);
-    result = smack_have_access(APP_FRIEND_2, APP_FRIEND_1, "wrxat");
-    RUNNER_ASSERT_MSG_BT(result == 1,
-        " Error second one sided friednship failed. Result: " << result);
-
-    DB_BEGIN
-
-    // Clean up
-    result = perm_app_revoke_permissions(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-    result = perm_app_revoke_permissions(APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-
-    perm_app_uninstall(APP_FRIEND_1);
-    perm_app_uninstall(APP_FRIEND_2);
-
-    DB_END
-
-/**
- * Test - making friends with nonexistent friend
- */
-
-    DB_BEGIN
-
-    // Installing one friend
-    result = perm_app_install(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error installing first app. Errno: " << result);
-
-    // Adding imaginary friend as second
-    result = perm_app_add_friend(APP_FRIEND_1, APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error making friends (first) with imaginairy friend failed. Result: "
-        << result);
-    // Adding imaginary friend as first
-    result = perm_app_add_friend(APP_FRIEND_2, APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error making friends (second) with imaginairy friend failed. Result: "
-        << result);
-    // Clean up
-    result = perm_app_revoke_permissions(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-    result = perm_app_revoke_permissions(APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-
-    perm_app_uninstall(APP_FRIEND_1);
-    perm_app_uninstall(APP_FRIEND_2);
-
-    DB_END
-
-/**
- * Test - making friends with some permissions already added
- */
-    unsigned int i;
-    unsigned int j;
-
-    struct smack_accesses *rulesFriend = NULL;
-
-    std::vector<std::string> accessesFriend =
-    { "r", "w", "x", "rw", "rx", "wx", "rwx", "rwxat" };
-
-    DB_BEGIN
-
-    // Installing friends to be
-    result = perm_app_install(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error installing first app. Result: " << result);
-    result = perm_app_install(APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        " Error installing second app. Result: " << result);
-
-    DB_END
-
-    for (i = 0; i < accessesFriend.size(); ++i)
-    {
-        for (j = 0; j < accessesFriend.size(); ++j)
-        {
-            // Adding rules before making friends
-            result = smack_accesses_new(&rulesFriend);
-            RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-                "Error in smack_accesses_new. Result: " << result);
-
-            result = smack_accesses_add(rulesFriend,
-                APP_FRIEND_1, APP_FRIEND_2, accessesFriend[i].c_str());
-            RUNNER_ASSERT_MSG_BT(result == 0,
-                "Unable to add modify rulesFirend (first). Result: " << result);
-            result = smack_accesses_add(rulesFriend, APP_FRIEND_2,
-                APP_FRIEND_1, accessesFriend[j].c_str());
-            RUNNER_ASSERT_MSG_BT(result == 0,
-                "Unable to add modify rulesFirend (second). Result: " << result);
-
-            result = smack_accesses_apply(rulesFriend);
-            RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-                "Error in smack_accesses_apply. Result: " << result);
-
-            DB_BEGIN
-
-            // Adding friends
-            result = perm_app_add_friend(APP_FRIEND_1, APP_FRIEND_2);
-            RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-                " Error making friends. Result: " << result);
-
-            DB_END
-
-            // Checking if friends were made
-            result = smack_have_access(APP_FRIEND_1, APP_FRIEND_2, "wrxat");
-            RUNNER_ASSERT_MSG_BT(result == 1,
-                " Error first one sided friednship failed. Result: " << result);
-            result = smack_have_access(APP_FRIEND_2, APP_FRIEND_1, "wrxat");
-            RUNNER_ASSERT_MSG_BT(result == 1,
-                " Error second one sided friednship failed. Result: " << result);
-
-            // Deleting all rules between friends
-            smack_accesses_add_modify(rulesFriend,
-                APP_FRIEND_1, APP_FRIEND_2,"","rwxat");
-            smack_accesses_add_modify(rulesFriend,
-                APP_FRIEND_2, APP_FRIEND_1,"","rwxat");
-
-            result = smack_accesses_apply(rulesFriend);
-
-            smack_accesses_free(rulesFriend);
-            rulesFriend = NULL;
-        }
-    }
-
-    DB_BEGIN
-
-    // Clean up
-    result = perm_app_revoke_permissions(APP_FRIEND_1);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-    result = perm_app_revoke_permissions(APP_FRIEND_2);
-    RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
-        "Error revoking app permissions. Result: " << result);
-
-    perm_app_uninstall(APP_FRIEND_1);
-    perm_app_uninstall(APP_FRIEND_2);
-
-    DB_END
-}
-
 static void smack_set_random_label_based_on_pid_on_self(void)
 {
     int result;
index d23d272c04f9c309419510ee4dc3f90d2c2f4315..31cdc8c282f0678995ba258fa9cd851c04a91975 100644 (file)
@@ -103,24 +103,6 @@ RUNNER_TEST(privilege_control21i_incorrect_params_app_setup_path)
             "perm_app_setup_path didn't check if pkg_id is valid.");
 }
 
-RUNNER_TEST(privilege_control21j_incorrect_params_app_add_friend)
-{
-    RUNNER_IGNORED_MSG("perm_app_add_friend is not implemented");
-
-    RUNNER_ASSERT_MSG_BT(perm_app_add_friend(NULL, APP_FRIEND_2) == PC_ERR_INVALID_PARAM,
-            "perm_app_add_friend didin't check if pkg_id1 isn't NULL.");
-    RUNNER_ASSERT_MSG_BT(perm_app_add_friend("", APP_FRIEND_2) == PC_ERR_INVALID_PARAM,
-            "perm_app_add_friend didin't check if pkg_id1 isn't empty.");
-    RUNNER_ASSERT_MSG_BT(perm_app_add_friend(APP_FRIEND_1, NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_add_friend didin't check if pkg_id2 isn't NULL.");
-    RUNNER_ASSERT_MSG_BT(perm_app_add_friend(APP_FRIEND_1, "") == PC_ERR_INVALID_PARAM,
-            "perm_app_add_friend didin't check if pkg_id2 isn't empty.");
-    RUNNER_ASSERT_MSG_BT(perm_app_add_friend("~APP~", APP_FRIEND_2) == PC_ERR_INVALID_PARAM,
-            "perm_app_add_friend didin't check if pkg_id1 is valid.");
-    RUNNER_ASSERT_MSG_BT(perm_app_add_friend(APP_FRIEND_1, "~APP~") == PC_ERR_INVALID_PARAM,
-            "perm_app_add_friend didin't check if pkg_id2 is valid.");
-}
-
 RUNNER_TEST(privilege_control21k_incorrect_params_add_api_feature)
 {
     RUNNER_ASSERT_MSG_BT(perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0) == PC_ERR_INVALID_PARAM,
index 165d14fedf05d9c26df95ba409beff10318bb142..972d8e99b52ea6f779f925ce20a3ee365ac9a1b4 100644 (file)
@@ -319,77 +319,6 @@ RUNNER_CHILD_TEST_NOSMACK(privilege_control06_revoke_permissions_osp_nosmack)
     test_revoke_permissions(__LINE__, OSP_APP_ID, rules_osp, false);
 }
 
-/*
- * NOSMACK version of privilege_control10_app_register_av test.
- *
- * Uses NOSMACK version of checkOnlyAvAccess (mentioned above), rest of the test is identical to
- * it's SMACK version.
- */
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-RUNNER_TEST_NOSMACK(privilege_control10_app_register_av_nosmack)
-{
-    RUNNER_IGNORED_MSG("app_register_av is deprecated");
-    int result;
-
-    // cleaning
-    smack_revoke_subject(APP_TEST_AV_1);
-    smack_revoke_subject(APP_TEST_AV_2);
-
-    DB_BEGIN
-
-    // Adding two apps before antivir
-    result = perm_app_install(APP_TEST_APP_1);
-    RUNNER_ASSERT_MSG_BT(result == 0,
-            "perm_app_install returned " << result << ". Errno: " << strerror(errno));
-
-    result = perm_app_install(APP_TEST_APP_2);
-    RUNNER_ASSERT_MSG_BT(result == 0,
-            "perm_app_install returned " << result << ". Errno: " << strerror(errno));
-
-    DB_END
-
-    // Adding antivir
-    result = app_register_av(APP_TEST_AV_1);
-    RUNNER_ASSERT_MSG_BT(result == 0,
-            "app_register_av returned " << result << ". Errno: " << strerror(errno));
-
-    // Checking added apps accesses
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_1)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_2, "app_register_av(APP_TEST_AV_1)");
-
-    DB_BEGIN
-
-    // Adding third app
-    result = perm_app_install(APP_TEST_APP_3);
-    RUNNER_ASSERT_MSG_BT(result == 0,
-            "perm_app_install returned " << result << ". Errno: " << strerror(errno));
-
-    DB_END
-
-    // Checking app accesses
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_1, "perm_app_install(APP_TEST_APP_3)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_2, "perm_app_install(APP_TEST_APP_3)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_3, "perm_app_install(APP_TEST_APP_3)");
-
-    // Adding second antivir
-    result = app_register_av(APP_TEST_AV_2);
-    RUNNER_ASSERT_MSG_BT(result == 0,
-            "app_register_av returned " << result << ". Errno: " << strerror(errno));
-
-    // Checking app accesses
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_2, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_1, APP_TEST_APP_3, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_2, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_2, APP_TEST_APP_2, "app_register_av(APP_TEST_AV_2)");
-    checkOnlyAvAccessNosmack(APP_TEST_AV_2, APP_TEST_APP_3, "app_register_av(APP_TEST_AV_2)");
-
-    // cleaning
-    smack_revoke_subject(APP_TEST_AV_1);
-    smack_revoke_subject(APP_TEST_AV_2);
-}
-#pragma GCC diagnostic warning "-Wdeprecated-declarations"
-
 /**
  * NOSMACK version of privilege_control11_app_enable_permissions test.
  *