Add tests for cynara-creds-gdbus
[platform/core/test/security-tests.git] / src / cynara-tests / common / cynara_test_helpers.cpp
index a86bead..da39c40 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <cynara-creds-dbus.h>
 #include <cynara-creds-socket.h>
+#include <cynara-creds-gdbus.h>
 
 #include "cynara_test_helpers.h"
 
@@ -84,4 +85,32 @@ pid_t dbusGetPid(DBusConnectionPtr connection, const char *uniqueName, int expec
     return pid;
 }
 
+char *gdbusGetClient(GDBusConnectionPtr connection, const char *uniqueName,
+                     cynara_client_creds method, int expectedResult) {
+    char *buff;
+    auto ret = cynara_creds_gdbus_get_client(connection.get(), uniqueName, method, &buff);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_gdbus_get_client failed, ret = " << ret
+                      << "; expected = " << expectedResult);
+    return buff;
+}
+
+char *gdbusGetUser(GDBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
+                   int expectedResult) {
+    char *buff;
+    auto ret = cynara_creds_gdbus_get_user(connection.get(), uniqueName, method, &buff);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_gdbus_get_user failed, ret = " << ret
+                      << "; expected = " << expectedResult);
+    return buff;
+}
+
+pid_t gdbusGetPid(GDBusConnectionPtr connection, const char *uniqueName) {
+    pid_t pid;
+    auto ret = cynara_creds_gdbus_get_pid(connection.get(), uniqueName, &pid);
+    RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS,
+                      "cynara_creds_gdbus_get_pid failed, ret = " << ret);
+    return pid;
+}
+
 } //namespace CynaraHelperCredentials