From c9e712dabfb4a7d880d0f71880edc0e74d977ea8 Mon Sep 17 00:00:00 2001 From: Jan Cybulski Date: Thu, 18 Apr 2013 15:41:42 +0200 Subject: [PATCH] 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 --- tests/libprivilege-control-tests/test_cases.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); -- 2.7.4