Fixed tests for app_shared_dir_add_readers()
authorJan Cybulski <j.cybulski@samsung.com>
Thu, 18 Apr 2013 13:41:42 +0000 (15:41 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 13:19:16 +0000 (14:19 +0100)
        [Issue#] SSDWSSP-196
        [Feature/Bug] app_shared_dir_add_readers() has to accept NULL in an argument list 'app_list'. Also added test to check what happens if the label in 'app_list' is not correct SMACK label
        [Problem] N/A
        [Cause] N/A
        [Solution] As above mentioned.
        [Verification] libprivilege-control-test --output=text

Change-Id: If53fc929d4900cefda345b240fce8d8d26250505

tests/libprivilege-control-tests/test_cases.cpp

index ac76a5a..241077f 100644 (file)
@@ -492,12 +492,27 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
     int i;
     int fd = -1;
     char *path;
-    const char *app_labels[] = {"TEST_raz", "TEST_dwa", "TEST_trzy", ""};
+
+    const char *app_labels_wrong[] = {"-TEST_raz", NULL};
+    const char *app_labels[] = {"TEST_raz", "TEST_dwa", "TEST_trzy", NULL};
     const int READ_BUF_SIZE = 1000;
     char buf[READ_BUF_SIZE];
     FILE *file = NULL;
     struct smack_accesses * rules = NULL;
 
+    //test what happens when the label is not correct SMACK label
+    result = smack_accesses_new(&rules);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new. Error: " << result);
+
+    result = add_shared_dir_readers(TEST_OBJ,app_labels_wrong);
+    RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "add_shared_dir_readers should fail here");
+
+    result = smack_have_access(app_labels_wrong[0],TEST_OBJ,"rx");
+    RUNNER_ASSERT_MSG(result != 1, "add_shared_dir_readers should not grant permission here");
+
+    smack_accesses_free(rules);
+
+    //ok, now the correct list of apps
     result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new. Error: " << result);