Fix error messages for access denial tests 90/18490/2
authorZofia Abramowska <z.abramowska@samsung.com>
Fri, 21 Mar 2014 17:00:37 +0000 (18:00 +0100)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 26 Mar 2014 15:25:35 +0000 (08:25 -0700)
Error messages stated that function failed instead of saying
that access should not have been granted.

Change-Id: Ifcd1bca4f5b6b12c5d907b0301afdc727e73739a

tests/security-server-tests/cookie_api.cpp
tests/security-server-tests/server.cpp

index cc1530a..5145174 100644 (file)
@@ -217,7 +217,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_03_02_security_server_check_privilege)
 
     int ret = security_server_check_privilege(cookie.data(), 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
-                      "Error in security_server_check_privilege(): " << ret);
+                      "security_server_check_privilege() should return access denied: " << ret);
 }
 
 //privileges drop and added smack rule
@@ -301,7 +301,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_05_02_security_server_get_cookie_pid)
 
     int ret = security_server_get_cookie_pid(cookie.data());
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
-                      "Error in security_server_get_cookie_pid(): " << ret);
+                      "security_server_get_cookie_pid() should return access denied: " << ret);
 }
 
 //privileges drop and added smack rule
@@ -411,19 +411,28 @@ RUNNER_CHILD_TEST(tc_unit_09_02_cookie_API_access_deny)
     Cookie cookie = getCookieFromSS();
 
     int ret = security_server_check_privilege(cookie.data(), DB_ALARM_GID);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_check_privilege should return access denied, "
+            "ret: " << ret);
 
     ret = security_server_get_gid(ROOT_USER);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_get_gid should return access denied, "
+            "ret: " << ret);
 
     ret = security_server_get_cookie_pid(cookie.data());
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_get_cookie_pid should return access denied, "
+            "ret: " << ret);
 
     UniquePtrCstring ss_label(security_server_get_smacklabel_cookie(cookie.data()), free);
-    RUNNER_ASSERT_MSG_BT(ss_label.get() == NULL, "ss_label: " << ss_label.get());
+    RUNNER_ASSERT_MSG_BT(ss_label.get() == NULL,
+            "access should be denied so label should be NULL: " << ss_label.get());
 
     ret = security_server_check_privilege_by_pid(getpid(), "_", "rx");
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_check_privilege_by_pid should return access denied, "
+            "ret: " << ret);
 }
 
 // NOSMACK version of the test above
index c6cb455..189f052 100644 (file)
@@ -161,7 +161,8 @@ RUNNER_CHILD_TEST_SMACK(tc01c_security_server_app_give_access_no_access)
 
     RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid());
 
-    RUNNER_ASSERT_BT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == security_server_app_give_access(subject, getpid()));
+    RUNNER_ASSERT_BT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED ==
+            security_server_app_give_access(subject, getpid()));
 
     RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "r"));
 }
@@ -252,27 +253,40 @@ RUNNER_CHILD_TEST(tc04_check_API_passwd_denied)
      */
 
     ret = security_server_set_pwd_validity(10);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_set_pwd_validity should return access denied,"
+            " ret: " << ret);
 
     ret = security_server_set_pwd_max_challenge(5);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_set_pwd_max_challenge should return access denied,"
+            " ret: " << ret);
 
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_is_pwd_valid should return access denied,"
+            " ret: " << ret);
 
     usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd("12345", "12346", 0, 0);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_set_pwd should return access denied,"
+            " ret: " << ret);
 
     ret = security_server_reset_pwd("12346",0, 0);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
-
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_reset_pwd should return access denied,"
+            " ret: " << ret);
     usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd("12346", &attempt, &max_attempt, &expire_sec);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_chk_pwd should return access denied,"
+            " ret: " << ret);
 
     ret = security_server_set_pwd_history(10);
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_set_pwd_history should return access denied,"
+            " ret: " << ret);
 }
 
 RUNNER_CHILD_TEST_SMACK(tc07_check_API_data_share_allow)
@@ -292,7 +306,9 @@ RUNNER_CHILD_TEST_SMACK(tc08_check_API_data_share_denied)
     provider.applyAndSwithToUser(APP_UID, APP_GID);
 
     int ret = security_server_app_give_access(TEST08_SUBJECT, getpid());
-    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
+    RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED,
+            "security_server_app_give_access should return access denied,"
+            " ret: " << ret);
 }
 
 //////////////////////////////////////////