From: Jan Cybulski Date: Thu, 18 Apr 2013 13:41:42 +0000 (+0200) Subject: Fixed tests for app_shared_dir_add_readers() X-Git-Tag: security-manager_5.5_testing~429 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9e712dabfb4a7d880d0f71880edc0e74d977ea8;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Fixed tests for app_shared_dir_add_readers() [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 --- diff --git a/tests/libprivilege-control-tests/test_cases.cpp b/tests/libprivilege-control-tests/test_cases.cpp index ac76a5a..241077f 100644 --- a/tests/libprivilege-control-tests/test_cases.cpp +++ b/tests/libprivilege-control-tests/test_cases.cpp @@ -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);