#include <stdio.h>
#include <vector>
#include <errno.h>
+#include <memory>
#include <ftw.h>
#include <dpl/test/test_runner.h>
#include <dpl/test/test_runner_child.h>
/**
* 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";
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_accesses,std::function<void(smack_accesses*)>>
+ 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()));
+}