Test privilege_control05_set_app_privilege_wgt, privilege_control05_set_app_privilege...
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 8 May 2013 12:46:02 +0000 (14:46 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 13:43:50 +0000 (14:43 +0100)
[Issue#]        SDWSSP-202
[Bug/Feature]   Additional test cases for set_app_privilege() for widgets
[Cause]         N/A
[Solution]      N/A
[Verification]  N/A

Change-Id: Id4734deb3667306f1af017fef59e7e4fbaf91daa

packaging/security-tests.spec
tests/libprivilege-control-tests/CMakeLists.txt
tests/libprivilege-control-tests/MisiuPysiu123Partner.wgt [new file with mode: 0644]
tests/libprivilege-control-tests/MisiuPysiu123Platform.wgt [new file with mode: 0644]
tests/libprivilege-control-tests/TestMisiuPysiu123.wgt [new file with mode: 0644]
tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.dac [new file with mode: 0644]
tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.smack [new file with mode: 0644]
tests/libprivilege-control-tests/test_cases.cpp

index 1a9c3a1..55d78c2 100644 (file)
@@ -40,9 +40,15 @@ rm -rf %{buildroot}
 
 %post
 find /etc/smack/test_privilege_control_DIR/ -type f -name exec -exec chmod 0755 {} +
+wrt-installer --install /usr/bin/TestMisiuPysiu123.wgt
+wrt-installer --install /usr/bin/MisiuPysiu123Partner.wgt
+wrt-installer --install /usr/bin/MisiuPysiu123Platform.wgt
 echo "security-tests postinst done ..."
 
 %postun
+wrt-installer --uninstall-name QwCqJ0ttyS
+wrt-installer --uninstall-name 7btsV1Y0sX
+wrt-installer --uninstall-name G4DE3U2vmW
 
 %files
 %defattr(-, root, root, -)
@@ -66,3 +72,6 @@ echo "security-tests postinst done ..."
 /etc/smack/test_smack_rules_lnk
 /usr/share/privilege-control/*
 /etc/smack/test_privilege_control_DIR/*
+/usr/bin/TestMisiuPysiu123.wgt
+/usr/bin/MisiuPysiu123Partner.wgt
+/usr/bin/MisiuPysiu123Platform.wgt
index 542d80f..5e8e8f6 100644 (file)
@@ -99,3 +99,28 @@ INSTALL(DIRECTORY
     ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/test_privilege_control_DIR
     DESTINATION /etc/smack/
 )
+
+INSTALL(FILES
+    ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/TestMisiuPysiu123.wgt
+    DESTINATION /usr/bin/
+  )
+
+INSTALL(FILES
+    ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/MisiuPysiu123Partner.wgt
+    DESTINATION /usr/bin/
+  )
+
+INSTALL(FILES
+    ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/MisiuPysiu123Platform.wgt
+    DESTINATION /usr/bin/
+  )
+
+INSTALL(FILES
+    ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.smack
+    DESTINATION /usr/share/privilege-control/
+  )
+
+INSTALL(FILES
+    ${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.dac
+    DESTINATION /usr/share/privilege-control/
+  )
diff --git a/tests/libprivilege-control-tests/MisiuPysiu123Partner.wgt b/tests/libprivilege-control-tests/MisiuPysiu123Partner.wgt
new file mode 100644 (file)
index 0000000..4116238
Binary files /dev/null and b/tests/libprivilege-control-tests/MisiuPysiu123Partner.wgt differ
diff --git a/tests/libprivilege-control-tests/MisiuPysiu123Platform.wgt b/tests/libprivilege-control-tests/MisiuPysiu123Platform.wgt
new file mode 100644 (file)
index 0000000..d41fcd6
Binary files /dev/null and b/tests/libprivilege-control-tests/MisiuPysiu123Platform.wgt differ
diff --git a/tests/libprivilege-control-tests/TestMisiuPysiu123.wgt b/tests/libprivilege-control-tests/TestMisiuPysiu123.wgt
new file mode 100644 (file)
index 0000000..d30020e
Binary files /dev/null and b/tests/libprivilege-control-tests/TestMisiuPysiu123.wgt differ
diff --git a/tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.dac b/tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.dac
new file mode 100644 (file)
index 0000000..3d1b597
--- /dev/null
@@ -0,0 +1,2 @@
+34567
+45678
diff --git a/tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.smack b/tests/libprivilege-control-tests/WRT_test_privilege_control_rules_wgt.smack
new file mode 100644 (file)
index 0000000..858f5b1
--- /dev/null
@@ -0,0 +1,16 @@
+~APP~ test_book_8 r
+~APP~ test_book_9 w
+~APP~ test_book_10 x
+~APP~ test_book_11 rw
+~APP~ test_book_12 rx
+~APP~ test_book_13 wx
+~APP~ test_book_14 rwx
+~APP~ test_book_15 rwxat
+test_subject_8 ~APP~ r
+test_subject_9 ~APP~ w
+test_subject_10 ~APP~ x
+test_subject_11 ~APP~ rw
+test_subject_12 ~APP~ rx
+test_subject_13 ~APP~ wx
+test_subject_14 ~APP~ rwx
+test_subject_15 ~APP~ rwxat
index d840b24..f846a4e 100644 (file)
 #define APP_SET_PRIV_PATH "/etc/smack/test_privilege_control_DIR/test_set_app_privilege/test_APP"
 #define APP_SET_PRIV_PATH_REAL "/etc/smack/test_privilege_control_DIR/test_set_app_privilege/test_APP_REAL"
 
+#define WGT_APP_LABEL "wgt_QwCqJ0ttyS"
+#define WGT_PARTNER_APP_LABEL "wgt_partner_7btsV1Y0sX"
+#define WGT_PLATFORM_APP_LABEL "wgt_platform_G4DE3U2vmW"
+#define WGT_APP_ID "QwCqJ0ttyS"
+#define WGT_PARTNER_APP_ID "7btsV1Y0sX"
+#define WGT_PLATFORM_APP_ID "G4DE3U2vmW"
+#define WGT_APP_PATH "/opt/usr/apps/QwCqJ0ttyS/bin/QwCqJ0ttyS.TestMisiuPysiu123"
+#define WGT_PARTNER_APP_PATH "/opt/usr/apps/7btsV1Y0sX/bin/7btsV1Y0sX.MisiuPysiu123Partner"
+#define WGT_PLATFORM_APP_PATH "/opt/usr/apps/G4DE3U2vmW/bin/G4DE3U2vmW.MisiuPysiu123Platform"
+
 const char *PRIVS[] = { "WRT", "test_privilege_control_rules", NULL };
 const char *PRIVS2[] = { "test_privilege_control_rules2", NULL };
 const char *PRIVS2_NO_R[] = { "test_privilege_control_rules2_no_r", NULL };
 const char *PRIVS2_R[] = { "test_privilege_control_rules2_r", NULL };
 const char *PRIVS2_R_AND_NO_R[] = { "test_privilege_control_rules2_r", "test_privilege_control_rules2_no_r", NULL };
-
+const char *PRIVS_WGT[] = { "WRT", "test_privilege_control_rules_wgt", NULL };
+const char *PRIVS_WGT_PARTNER[] = { "WRT_partner", "test_privilege_control_rules_wgt", NULL };
+const char *PRIVS_WGT_PLATFORM[] = { "WRT_platform", "test_privilege_control_rules_wgt", NULL };
 
 #define LIBPRIVILEGE_APP_GROUP_LIST "/usr/share/privilege-control/app_group_list"
 #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 APP_TEST_APP_1 "test-application1"
 #define APP_TEST_APP_2 "test-application_2"
 #define APP_TEST_APP_3 "test-app-3"
@@ -157,6 +171,62 @@ const std::vector< std::vector<std::string> > rules2_r = {
         { "test_subject_14", APP_ID, "r" },
         { "test_subject_15", APP_ID, "r" }};
 
+// Rules from test_privilege_control_rules_wgt.smack for wgt
+const std::vector< std::vector<std::string> > rules_wgt = {
+        { WGT_APP_LABEL, "test_book_8", "r" },
+        { WGT_APP_LABEL, "test_book_9", "w" },
+        { WGT_APP_LABEL, "test_book_10", "x" },
+        { WGT_APP_LABEL, "test_book_11", "rw" },
+        { WGT_APP_LABEL, "test_book_12", "rx" },
+        { WGT_APP_LABEL, "test_book_13", "wx" },
+        { WGT_APP_LABEL, "test_book_14", "rwx" },
+        { WGT_APP_LABEL, "test_book_15", "rwxat" },
+        { "test_subject_8", WGT_APP_LABEL, "r" },
+        { "test_subject_9", WGT_APP_LABEL, "w" },
+        { "test_subject_10", WGT_APP_LABEL, "x" },
+        { "test_subject_11", WGT_APP_LABEL, "rw" },
+        { "test_subject_12", WGT_APP_LABEL, "rx" },
+        { "test_subject_13", WGT_APP_LABEL, "wx" },
+        { "test_subject_14", WGT_APP_LABEL, "rwx" },
+        { "test_subject_15", WGT_APP_LABEL, "rwxat" }};
+
+// Rules from test_privilege_control_rules_wgt.smack for wgt_partner
+const std::vector< std::vector<std::string> > rules_wgt_partner = {
+        { WGT_PARTNER_APP_LABEL, "test_book_8", "r" },
+        { WGT_PARTNER_APP_LABEL, "test_book_9", "w" },
+        { WGT_PARTNER_APP_LABEL, "test_book_10", "x" },
+        { WGT_PARTNER_APP_LABEL, "test_book_11", "rw" },
+        { WGT_PARTNER_APP_LABEL, "test_book_12", "rx" },
+        { WGT_PARTNER_APP_LABEL, "test_book_13", "wx" },
+        { WGT_PARTNER_APP_LABEL, "test_book_14", "rwx" },
+        { WGT_PARTNER_APP_LABEL, "test_book_15", "rwxat" },
+        { "test_subject_8", WGT_PARTNER_APP_LABEL, "r" },
+        { "test_subject_9", WGT_PARTNER_APP_LABEL, "w" },
+        { "test_subject_10", WGT_PARTNER_APP_LABEL, "x" },
+        { "test_subject_11", WGT_PARTNER_APP_LABEL, "rw" },
+        { "test_subject_12", WGT_PARTNER_APP_LABEL, "rx" },
+        { "test_subject_13", WGT_PARTNER_APP_LABEL, "wx" },
+        { "test_subject_14", WGT_PARTNER_APP_LABEL, "rwx" },
+        { "test_subject_15", WGT_PARTNER_APP_LABEL, "rwxat" }};
+
+// Rules from test_privilege_control_rules_wgt.smack for wgt_platform
+const std::vector< std::vector<std::string> > rules_wgt_platform = {
+        { WGT_PLATFORM_APP_LABEL, "test_book_8", "r" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_9", "w" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_10", "x" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_11", "rw" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_12", "rx" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_13", "wx" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_14", "rwx" },
+        { WGT_PLATFORM_APP_LABEL, "test_book_15", "rwxat" },
+        { "test_subject_8", WGT_PLATFORM_APP_LABEL, "r" },
+        { "test_subject_9", WGT_PLATFORM_APP_LABEL, "w" },
+        { "test_subject_10", WGT_PLATFORM_APP_LABEL, "x" },
+        { "test_subject_11", WGT_PLATFORM_APP_LABEL, "rw" },
+        { "test_subject_12", WGT_PLATFORM_APP_LABEL, "rx" },
+        { "test_subject_13", WGT_PLATFORM_APP_LABEL, "wx" },
+        { "test_subject_14", WGT_PLATFORM_APP_LABEL, "rwx" },
+        { "test_subject_15", WGT_PLATFORM_APP_LABEL, "rwxat" }};
 
 namespace {
 
@@ -489,15 +559,32 @@ RUNNER_TEST(privilege_control04_add_permissions)
 RUNNER_CHILD_TEST(privilege_control06_revoke_permissions)
 {
     int result;
+    int fd;
 
     // Revoke permissions
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
             "Error revoking app permissions. Result: " << result);
 
+    result = app_revoke_permissions(WGT_APP_LABEL);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
+       "Error revoking app permissions. Result: " << result);
+    result = app_revoke_permissions(WGT_PARTNER_APP_LABEL);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
+       "Error revoking app permissions. Result: " << result);
+    result = app_revoke_permissions(WGT_PLATFORM_APP_LABEL);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
+       "Error revoking app permissions. Result: " << result);
+
     // Are all the permissions revoked?
     result = test_have_any_accesses(rules);
     RUNNER_ASSERT_MSG(result!=1, "Not all permisions revoked.");
+    result = test_have_any_accesses(rules_wgt);
+    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    result = test_have_any_accesses(rules_wgt_partner);
+    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    result = test_have_any_accesses(rules_wgt_platform);
+    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
 
     //// File exists?
     FILE *pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
@@ -506,6 +593,22 @@ RUNNER_CHILD_TEST(privilege_control06_revoke_permissions)
         RUNNER_ASSERT_MSG(false,
             "SMACK file exists after revoke!");
     }
+
+    fd = open(SMACK_RULES_DIR WGT_APP_ID, O_RDONLY);
+    RUNNER_ASSERT_MSG(fd >= 0, "SMACK file deleted after app_revoke_permissions");
+    RUNNER_ASSERT_MSG(lseek(fd, 0, SEEK_END) == 0, "SMACK file not empty after app_revoke_permissions");
+    close(fd);
+
+    fd = open(SMACK_RULES_DIR WGT_PARTNER_APP_ID, O_RDONLY);
+    RUNNER_ASSERT_MSG(fd >= 0, "SMACK file deleted after app_revoke_permissions");
+    RUNNER_ASSERT_MSG(lseek(fd, 0, SEEK_END) == 0, "SMACK file not empty after app_revoke_permissions");
+    close(fd);
+
+    fd = open(SMACK_RULES_DIR WGT_PLATFORM_APP_ID, O_RDONLY);
+    RUNNER_ASSERT_MSG(fd >= 0, "SMACK file deleted after app_revoke_permissions");
+    RUNNER_ASSERT_MSG(lseek(fd, 0, SEEK_END) == 0, "SMACK file not empty after app_revoke_permissions");
+    close(fd);
+
 }
 
 static void read_gids(std::set<unsigned> &set, const char* file_path)
@@ -699,6 +802,176 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege)
     RUNNER_ASSERT_MSG(groups_check.empty(), "Application doesn't belong to some required groups: " << groups_left);
 }
 
+/**
+ * Set APP privileges. wgt.
+ */
+RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt)
+{
+    int result;
+
+    result = set_app_privilege(WGT_APP_ID, "wgt", WGT_APP_PATH);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
+
+    // Check if SMACK label really set
+    char * label;
+    result = smack_new_label_from_self(&label);
+    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
+    result = strcmp(WGT_APP_LABEL, label);
+    RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
+
+    std::set<unsigned> groups_check;
+    read_gids(groups_check, LIBPRIVILEGE_APP_GROUP_LIST);
+    read_gids(groups_check, LIBPRIVILEGE_TEST_DAC_FILE_WGT);
+
+    int groups_cnt = getgroups(0, NULL);
+    RUNNER_ASSERT_MSG(groups_cnt > 0, "Wrong number of supplementary groupsCnt");
+    gid_t *groups_list = (gid_t *) calloc(groups_cnt, sizeof(gid_t));
+    RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed");
+    getgroups(groups_cnt, groups_list);
+
+    for (int i = 0; i < groups_cnt; ++i) {
+        if (groups_check.erase(groups_list[i]) == 0) {
+            // getgroups() may also return process' main group
+            if (groups_list[i] != getgid())
+                RUNNER_ASSERT_MSG(false, "Application belongs to unknown group (GID=" << groups_list[i] << ")");
+        }
+    }
+    std::string groups_left;
+    for (std::set<unsigned>::iterator it = groups_check.begin(); it != groups_check.end(); it++) {
+        groups_left.append(std::to_string(*it)).append(" ");
+    }
+    RUNNER_ASSERT_MSG(groups_check.empty(), "Application doesn't belong to some required groups: " << groups_left);
+
+
+    result = app_enable_permissions(APP_ID, APP_TYPE_WGT, PRIVS_WGT, 1);
+    RUNNER_ASSERT_MSG(result != PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << result);
+
+    result = test_have_any_accesses(rules_wgt);
+    RUNNER_ASSERT_MSG(result==0, "Permissions exist.");
+
+    result = app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS_WGT, 1);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << result);
+
+    result = test_have_all_accesses(rules_wgt);
+    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+}
+
+/**
+ * Set APP privileges. wgt_partner.
+ */
+RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt_partner)
+{
+    int result;
+
+    result = set_app_privilege(WGT_PARTNER_APP_ID, "wgt_partner", WGT_PARTNER_APP_PATH);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
+
+    // Check if SMACK label really set
+    char * label;
+    result = smack_new_label_from_self(&label);
+    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
+    result = strcmp(WGT_PARTNER_APP_LABEL, label);
+    RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
+
+    std::set<unsigned> groups_check;
+    read_gids(groups_check, LIBPRIVILEGE_APP_GROUP_LIST);
+    read_gids(groups_check, LIBPRIVILEGE_TEST_DAC_FILE_WGT);
+
+    int groups_cnt = getgroups(0, NULL);
+    RUNNER_ASSERT_MSG(groups_cnt > 0, "Wrong number of supplementary groupsCnt");
+    gid_t *groups_list = (gid_t *) calloc(groups_cnt, sizeof(gid_t));
+    RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed");
+    getgroups(groups_cnt, groups_list);
+
+    for (int i = 0; i < groups_cnt; ++i) {
+        if (groups_check.erase(groups_list[i]) == 0) {
+            // getgroups() may also return process' main group
+            if (groups_list[i] != getgid())
+                RUNNER_ASSERT_MSG(false, "Application belongs to unknown group (GID=" << groups_list[i] << ")");
+        }
+    }
+    std::string groups_left;
+    for (std::set<unsigned>::iterator it = groups_check.begin(); it != groups_check.end(); it++) {
+        groups_left.append(std::to_string(*it)).append(" ");
+    }
+    RUNNER_ASSERT_MSG(groups_check.empty(), "Application doesn't belong to some required groups: " << groups_left);
+
+    result = app_enable_permissions(APP_ID, APP_TYPE_WGT_PARTNER, PRIVS_WGT_PARTNER, 1);
+    RUNNER_ASSERT_MSG(result != PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << result);
+
+    result = test_have_any_accesses(rules_wgt_partner);
+    RUNNER_ASSERT_MSG(result==0, "Permissions exist.");
+
+    result = app_enable_permissions(WGT_PARTNER_APP_ID, APP_TYPE_WGT_PARTNER, PRIVS_WGT_PARTNER, 1);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << result);
+
+    result = test_have_all_accesses(rules_wgt_partner);
+    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+}
+
+/**
+ * Set APP privileges. wgt_platform.
+ */
+RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt_platform)
+{
+    int result;
+
+    result = set_app_privilege(WGT_PLATFORM_APP_ID, "wgt_platform", WGT_PLATFORM_APP_PATH);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
+
+    // Check if SMACK label really set
+    char * label;
+    result = smack_new_label_from_self(&label);
+    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
+    result = strcmp(WGT_PLATFORM_APP_LABEL, label);
+    RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
+
+    std::set<unsigned> groups_check;
+    read_gids(groups_check, LIBPRIVILEGE_APP_GROUP_LIST);
+    read_gids(groups_check, LIBPRIVILEGE_TEST_DAC_FILE_WGT);
+
+    int groups_cnt = getgroups(0, NULL);
+    RUNNER_ASSERT_MSG(groups_cnt > 0, "Wrong number of supplementary groupsCnt");
+    gid_t *groups_list = (gid_t *) calloc(groups_cnt, sizeof(gid_t));
+    RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed");
+    getgroups(groups_cnt, groups_list);
+
+    for (int i = 0; i < groups_cnt; ++i) {
+        if (groups_check.erase(groups_list[i]) == 0) {
+            // getgroups() may also return process' main group
+            if (groups_list[i] != getgid())
+                RUNNER_ASSERT_MSG(false, "Application belongs to unknown group (GID=" << groups_list[i] << ")");
+        }
+    }
+    std::string groups_left;
+    for (std::set<unsigned>::iterator it = groups_check.begin(); it != groups_check.end(); it++) {
+        groups_left.append(std::to_string(*it)).append(" ");
+    }
+    RUNNER_ASSERT_MSG(groups_check.empty(), "Application doesn't belong to some required groups: " << groups_left);
+
+
+    result = app_enable_permissions(APP_ID, APP_TYPE_WGT_PLATFORM, PRIVS_WGT_PLATFORM, 1);
+    RUNNER_ASSERT_MSG(result != PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << result);
+
+    result = test_have_any_accesses(rules_wgt_platform);
+    RUNNER_ASSERT_MSG(result==0, "Permissions exist.");
+
+    result = app_enable_permissions(WGT_PLATFORM_APP_ID, APP_TYPE_WGT_PLATFORM, PRIVS_WGT_PLATFORM, 1);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << result);
+
+    result = test_have_all_accesses(rules_wgt_platform);
+    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+}
+
 RUNNER_TEST(privilege_control08_app_give_access)
 {
     const char *subject = "lkjq345v34sfa";