From: Bartlomiej Grzelewski Date: Wed, 10 Apr 2013 14:32:50 +0000 (+0200) Subject: Test for app_give_access, app_revoke_access function. X-Git-Tag: security-manager_5.5_testing~441 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=518315be08edd334479a566fd1b415296aa01339;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Test for app_give_access, app_revoke_access function. [Issue#] SSDWSSP-177 [Bug] N/A [Cause] N/A [Solution] N/A [Verification] Build. Run libprivilege-control tests. New test has been added and it should pass. Change-Id: I5877111a60f2b95d871df45095eaf00da6e4f3f5 --- diff --git a/tests/libprivilege-control-tests/test_cases.cpp b/tests/libprivilege-control-tests/test_cases.cpp index d16d0d52..62589144 100644 --- a/tests/libprivilege-control-tests/test_cases.cpp +++ b/tests/libprivilege-control-tests/test_cases.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -361,7 +362,7 @@ RUNNER_TEST(privilege_control04_revoke_permissions) /** * Set APP privileges. */ -RUNNER_TEST(privilege_control05_set_app_privilege) +RUNNER_CHILD_TEST(privilege_control05_set_app_privilege) { int result; char* labelApp = "test_pc_label"; @@ -394,3 +395,32 @@ RUNNER_TEST(privilege_control05_set_app_privilege) RUNNER_ASSERT_MSG(result == 0, "Wrong user USER NAME"); } +RUNNER_TEST(privilege_control06_app_give_access) +{ + const char *subject = "lkjq345v34sfa"; + const char *object = "lk9290f92lkjz"; + smack_accesses *tmp = NULL; + + RUNNER_ASSERT(0 == smack_accesses_new(&tmp)); + + std::unique_ptr> + smack(tmp, smack_accesses_free); + + RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), subject, object, "r--a-")); + RUNNER_ASSERT(0 == smack_accesses_apply(smack.get())); + + app_give_access(subject, object, "wt"); + + RUNNER_ASSERT(1 == smack_have_access(subject, object, "rwat")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "x")); + + app_revoke_access(subject, object); + + RUNNER_ASSERT(1 == smack_have_access(subject, object, "ra")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "w")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "x")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "t")); + + RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), subject, object, "-")); + RUNNER_ASSERT(0 == smack_accesses_apply(smack.get())); +}