+RUNNER_CHILD_TEST_NOSMACK(tc16_security_server_get_gid_by_cookie_nosmack)
+{
+ int cookieSize = security_server_get_cookie_size();
+ RUNNER_ASSERT_MSG(cookieSize == 20, "Wrong cookie size");
+
+ std::vector<char> cookie(cookieSize);
+
+ gid_t realGid = getgid();
+ int retval = security_server_request_cookie(&cookie[0], cookieSize);
+ RUNNER_ASSERT_MSG(retval == SECURITY_SERVER_API_SUCCESS, "Unable to get cookie");
+
+ //drop privileges
+ RUNNER_ASSERT_MSG(setgid(5000) == 0, "Unable to drop privileges");
+ RUNNER_ASSERT_MSG(setuid(5000) == 0, "Unable to drop privileges");
+
+ //checking function
+ gid_t cookieGid;
+ retval = security_server_get_gid_by_cookie(&cookie[0], &cookieGid);
+ RUNNER_ASSERT_MSG(retval == SECURITY_SERVER_API_SUCCESS, "Unable to get GID from cookie");
+ RUNNER_ASSERT_MSG(realGid == cookieGid, "No match in received GID. ReadGid: " << realGid << " CookieGid: " << cookieGid);
+}
+
+RUNNER_CHILD_TEST_SMACK(tc17_security_server_get_gid_by_cookie_smack)