Test to: Implemet data control solution for OSP apps.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Mon, 22 Apr 2013 16:23:37 +0000 (18:23 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 13:19:16 +0000 (14:19 +0100)
[Issue#]   SSDWSSP-177
[Bug]      N/A
[Cause]    OPS application need to share memory.
[Solution] Add cross rules between OSP application.

Change-Id: I29b24d3fa8410b0f444f494d45e1c283605ce2af

tests/security-server-tests/security_server_tests_server.cpp

index 355aca6..b2e5e66 100644 (file)
@@ -372,6 +372,7 @@ RUNNER_CHILD_TEST(tc01a_security_server_app_give_access)
 {
     const char *subject = "abc345v34sfa";
     const char *object = "efg678x2lkjz";
+    const char *server_api = "security-server::api-data-share";
     smack_accesses *tmp = NULL;
 
     RUNNER_ASSERT(0 == smack_accesses_new(&tmp));
@@ -380,6 +381,7 @@ RUNNER_CHILD_TEST(tc01a_security_server_app_give_access)
         smack(tmp, smack_accesses_free);
 
     RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), subject, object, "-----"));
+    RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), object, server_api, "rw"));
     RUNNER_ASSERT(0 == smack_accesses_apply(smack.get()));
 
     smack_set_label_for_self(object);
@@ -405,6 +407,26 @@ RUNNER_TEST(tc01b_security_server_app_give_access)
     RUNNER_ASSERT(0 == smack_have_access(subject, object, "----t"));
 }
 
+RUNNER_CHILD_TEST(tc01c_security_server_app_give_access_no_access)
+{
+    const char *subject = "xxx45v34sfa";
+    const char *object = "yyy78x2lkjz";
+    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, "-----"));
+    RUNNER_ASSERT(0 == smack_accesses_apply(smack.get()));
+
+    smack_set_label_for_self(object);
+    RUNNER_ASSERT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == security_server_app_give_access(subject, getpid()));
+
+    RUNNER_ASSERT(0 == smack_have_access(subject, object, "r"));
+}
+
 RUNNER_TEST(tc02_check_privilege_by_pid)
 {
     int ret;