Cynara: Move Cynara helper credentials to global commons 52/88352/1
authorZofia Abramowska <z.abramowska@samsung.com>
Fri, 16 Sep 2016 10:16:43 +0000 (12:16 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Fri, 16 Sep 2016 10:39:55 +0000 (12:39 +0200)
Change-Id: If60a51afb801e75f300250f2e1244ad7f05b5098

src/common/CMakeLists.txt
src/common/cynara_helpers_creds.cpp [new file with mode: 0644]
src/common/cynara_helpers_creds.h [new file with mode: 0644]
src/common/cynara_helpers_dbus.h [new file with mode: 0644]
src/cynara-tests/CMakeLists.txt
src/cynara-tests/common/cynara_test_helpers.cpp [deleted file]
src/cynara-tests/common/cynara_test_helpers.h [deleted file]
src/cynara-tests/common/cynara_test_helpers_dbus.h [deleted file]
src/cynara-tests/test_cases_helpers.cpp

index 994fee1d5488dda076b21e5aecff38a16fc4d10d..4e1055fbdf2f8ea42b84d92695ec0f98e7e6f3e3 100644 (file)
@@ -8,6 +8,9 @@ PKG_CHECK_MODULES(COMMON_TARGET_DEP
     sqlite3
     libgum
     glib-2.0
+    cynara-creds-socket
+    cynara-creds-dbus
+    cynara-creds-gdbus
     REQUIRED
     )
 
@@ -28,6 +31,7 @@ SET(COMMON_TARGET_TEST_SOURCES
     ${PROJECT_SOURCE_DIR}/src/common/synchronization_pipe.cpp
     ${PROJECT_SOURCE_DIR}/src/common/timeout.cpp
     ${PROJECT_SOURCE_DIR}/src/common/temp_test_user.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/cynara_helpers_creds.cpp
     )
 
 #system and local includes
diff --git a/src/common/cynara_helpers_creds.cpp b/src/common/cynara_helpers_creds.cpp
new file mode 100644 (file)
index 0000000..dc1c904
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        cynara_helper_credentials.cpp
+ * @author      Aleksander Zdyb <a.zdyb@samsung.com>
+ * @version     1.0
+ * @brief       Helpers for cynara-helpers
+ */
+
+#include <dpl/test/test_runner.h>
+
+#include <cynara-creds-dbus.h>
+#include <cynara-creds-socket.h>
+#include <cynara-creds-gdbus.h>
+
+#include "cynara_helpers_creds.h"
+
+namespace CynaraHelperCredentials {
+
+char *socketGetClient(int sock, cynara_client_creds method, int expectedResult) {
+    char *buff = nullptr;
+    auto ret = cynara_creds_socket_get_client(sock, method, &buff);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_socket_get_client failed, ret = " << ret
+                      << "; expected = " << expectedResult);
+    return buff;
+}
+
+char *socketGetUser(int sock, cynara_user_creds method, int expectedResult) {
+    char *buff = nullptr;
+    auto ret = cynara_creds_socket_get_user(sock, method, &buff);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_socket_get_user failed, ret = " << ret
+                      << "; expected = " << expectedResult);
+    return buff;
+}
+
+pid_t socketGetPid(int sock, int expectedResult) {
+    pid_t pid = -1;
+    auto ret = cynara_creds_socket_get_pid(sock, &pid);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_socket_get_pid failed, ret = " << ret << "; expected = "
+                      << expectedResult);
+    return pid;
+}
+
+char *dbusGetClient(DBusConnectionPtr connection, const char *uniqueName,
+                    cynara_client_creds method, int expectedResult) {
+    char *buff = nullptr;
+    auto ret = cynara_creds_dbus_get_client(connection.get(), uniqueName, method, &buff);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_dbus_get_client failed, ret = " << ret
+                      << "; expected = " << expectedResult);
+    return buff;
+}
+
+char *dbusGetUser(DBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
+                  int expectedResult) {
+    char *buff = nullptr;
+    auto ret = cynara_creds_dbus_get_user(connection.get(), uniqueName, method, &buff);
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                      "cynara_creds_dbus_get_user failed, ret = " << ret
+                      << "; expected = " << expectedResult);
+    return buff;
+}
+
+pid_t dbusGetPid(DBusConnectionPtr connection, const char *uniqueName, int expectedResult) {
+    pid_t pid = -1;
+    auto ret = cynara_creds_dbus_get_pid(connection.get(), uniqueName, &pid);
+    RUNNER_ASSERT_MSG(ret == expectedResult, "cynara_creds_dbus_get_pid failed, ret = " << ret
+                                             << "; expected = " << expectedResult);
+    return pid;
+}
+
+char *gdbusGetClient(GDBusConnectionPtr connection, const char *uniqueName,
+                     cynara_client_creds method, int expectedResult) {
+    char *buff = nullptr;
+    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 = nullptr;
+    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 = -1;
+    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
diff --git a/src/common/cynara_helpers_creds.h b/src/common/cynara_helpers_creds.h
new file mode 100644 (file)
index 0000000..cafe423
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        cynara_helper_credentials.h
+ * @author      Aleksander Zdyb <a.zdyb@samsung.com>
+ * @version     1.0
+ * @brief       Helpers for cynara-helpers
+ */
+
+#ifndef CYNARA_TEST_HELPERS_H_
+#define CYNARA_TEST_HELPERS_H_
+
+#include <string>
+#include <sys/types.h>
+
+#include <cynara-creds-commons.h>
+#include <cynara-error.h>
+#include <cynara_helpers_dbus.h>
+
+namespace CynaraHelperCredentials {
+
+char *socketGetClient(int sock, cynara_client_creds method,
+                      int expectedResult = CYNARA_API_SUCCESS);
+
+char *socketGetUser(int sock, cynara_user_creds method,
+                    int expectedResult = CYNARA_API_SUCCESS);
+
+pid_t socketGetPid(int sock, int expectedResult = CYNARA_API_SUCCESS);
+
+DBusConnectionPtr createDBusConnection(const std::string &name);
+
+char *dbusGetClient(DBusConnectionPtr connection, const char *uniqueName,
+                    cynara_client_creds method, int expectedResult = CYNARA_API_SUCCESS);
+
+
+char *dbusGetUser(DBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
+                  int expectedResult = CYNARA_API_SUCCESS);
+
+pid_t dbusGetPid(DBusConnectionPtr connection, const char *uniqueName,
+                 int expectedResult = CYNARA_API_SUCCESS);
+
+char *gdbusGetClient(GDBusConnectionPtr connection, const char *uniqueName,
+                     cynara_client_creds method, int expectedResult = CYNARA_API_SUCCESS);
+
+
+char *gdbusGetUser(GDBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
+                   int expectedResult = CYNARA_API_SUCCESS);
+
+pid_t gdbusGetPid(GDBusConnectionPtr connection, const char *uniqueName);
+
+} // namespace CynaraHelperCredentials
+
+#endif // CYNARA_TEST_HELPERS_H_
diff --git a/src/common/cynara_helpers_dbus.h b/src/common/cynara_helpers_dbus.h
new file mode 100644 (file)
index 0000000..19c1b24
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        cynara_helpers_dbus.h
+ * @author      Aleksander Zdyb <a.zdyb@samsung.com>
+ * @version     1.0
+ */
+#ifndef CYNARA_TEST_HELPERS_DBUS_H_
+#define CYNARA_TEST_HELPERS_DBUS_H_
+
+#include <dbus/dbus.h>
+#include <functional>
+#include <gio/gio.h>
+#include <memory>
+
+typedef std::function<void(DBusConnection *)> DBusConnectionCloseAndUnref;
+typedef std::function<void(GDBusConnection *)> GDBusConnectionCloseAndUnref;
+typedef std::unique_ptr<DBusConnection, DBusConnectionCloseAndUnref> DBusConnectionPtr;
+typedef std::unique_ptr<GDBusConnection, GDBusConnectionCloseAndUnref> GDBusConnectionPtr;
+
+
+#endif // CYNARA_TEST_HELPERS_DBUS_H_
index 6fa7aa5800c81afa8bba7798ddaba917ecc75ea4..7a42d65653825432fcc0f2186546880e77e936ae 100644 (file)
@@ -47,7 +47,6 @@ SET(CYNARA_TARGET_TEST_SOURCES
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_cynara_mask.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_env.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_file_operations.cpp
-    ${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_helpers.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/plugins/plugins.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/cynara-test.cpp
     ${PROJECT_SOURCE_DIR}/src/cynara-tests/test_cases.cpp
diff --git a/src/cynara-tests/common/cynara_test_helpers.cpp b/src/cynara-tests/common/cynara_test_helpers.cpp
deleted file mode 100644 (file)
index ffb9628..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file        cynara_test_helpers.cpp
- * @author      Aleksander Zdyb <a.zdyb@samsung.com>
- * @version     1.0
- * @brief       Helpers for cynara-helpers
- */
-
-#include <dpl/test/test_runner.h>
-
-#include <cynara-creds-dbus.h>
-#include <cynara-creds-socket.h>
-#include <cynara-creds-gdbus.h>
-
-#include "cynara_test_helpers.h"
-
-namespace CynaraHelperCredentials {
-
-char *socketGetClient(int sock, cynara_client_creds method, int expectedResult) {
-    char *buff = nullptr;
-    auto ret = cynara_creds_socket_get_client(sock, method, &buff);
-    RUNNER_ASSERT_MSG(ret == expectedResult,
-                      "cynara_creds_socket_get_client failed, ret = " << ret
-                      << "; expected = " << expectedResult);
-    return buff;
-}
-
-char *socketGetUser(int sock, cynara_user_creds method, int expectedResult) {
-    char *buff = nullptr;
-    auto ret = cynara_creds_socket_get_user(sock, method, &buff);
-    RUNNER_ASSERT_MSG(ret == expectedResult,
-                      "cynara_creds_socket_get_user failed, ret = " << ret
-                      << "; expected = " << expectedResult);
-    return buff;
-}
-
-pid_t socketGetPid(int sock, int expectedResult) {
-    pid_t pid = -1;
-    auto ret = cynara_creds_socket_get_pid(sock, &pid);
-    RUNNER_ASSERT_MSG(ret == expectedResult,
-                      "cynara_creds_socket_get_pid failed, ret = " << ret << "; expected = "
-                      << expectedResult);
-    return pid;
-}
-
-char *dbusGetClient(DBusConnectionPtr connection, const char *uniqueName,
-                    cynara_client_creds method, int expectedResult) {
-    char *buff = nullptr;
-    auto ret = cynara_creds_dbus_get_client(connection.get(), uniqueName, method, &buff);
-    RUNNER_ASSERT_MSG(ret == expectedResult,
-                      "cynara_creds_dbus_get_client failed, ret = " << ret
-                      << "; expected = " << expectedResult);
-    return buff;
-}
-
-char *dbusGetUser(DBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
-                  int expectedResult) {
-    char *buff = nullptr;
-    auto ret = cynara_creds_dbus_get_user(connection.get(), uniqueName, method, &buff);
-    RUNNER_ASSERT_MSG(ret == expectedResult,
-                      "cynara_creds_dbus_get_user failed, ret = " << ret
-                      << "; expected = " << expectedResult);
-    return buff;
-}
-
-pid_t dbusGetPid(DBusConnectionPtr connection, const char *uniqueName, int expectedResult) {
-    pid_t pid = -1;
-    auto ret = cynara_creds_dbus_get_pid(connection.get(), uniqueName, &pid);
-    RUNNER_ASSERT_MSG(ret == expectedResult, "cynara_creds_dbus_get_pid failed, ret = " << ret
-                                             << "; expected = " << expectedResult);
-    return pid;
-}
-
-char *gdbusGetClient(GDBusConnectionPtr connection, const char *uniqueName,
-                     cynara_client_creds method, int expectedResult) {
-    char *buff = nullptr;
-    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 = nullptr;
-    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 = -1;
-    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
diff --git a/src/cynara-tests/common/cynara_test_helpers.h b/src/cynara-tests/common/cynara_test_helpers.h
deleted file mode 100644 (file)
index d790fe3..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file        cynara_test_helpers.h
- * @author      Aleksander Zdyb <a.zdyb@samsung.com>
- * @version     1.0
- * @brief       Helpers for cynara-helpers
- */
-
-#ifndef CYNARA_TEST_HELPERS_H_
-#define CYNARA_TEST_HELPERS_H_
-
-#include <string>
-#include <sys/types.h>
-
-#include <cynara-creds-commons.h>
-#include <cynara-error.h>
-#include <cynara_test_helpers_dbus.h>
-
-namespace CynaraHelperCredentials {
-
-char *socketGetClient(int sock, cynara_client_creds method,
-                      int expectedResult = CYNARA_API_SUCCESS);
-
-char *socketGetUser(int sock, cynara_user_creds method,
-                    int expectedResult = CYNARA_API_SUCCESS);
-
-pid_t socketGetPid(int sock, int expectedResult = CYNARA_API_SUCCESS);
-
-DBusConnectionPtr createDBusConnection(const std::string &name);
-
-char *dbusGetClient(DBusConnectionPtr connection, const char *uniqueName,
-                    cynara_client_creds method, int expectedResult = CYNARA_API_SUCCESS);
-
-
-char *dbusGetUser(DBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
-                  int expectedResult = CYNARA_API_SUCCESS);
-
-pid_t dbusGetPid(DBusConnectionPtr connection, const char *uniqueName,
-                 int expectedResult = CYNARA_API_SUCCESS);
-
-char *gdbusGetClient(GDBusConnectionPtr connection, const char *uniqueName,
-                     cynara_client_creds method, int expectedResult = CYNARA_API_SUCCESS);
-
-
-char *gdbusGetUser(GDBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
-                   int expectedResult = CYNARA_API_SUCCESS);
-
-pid_t gdbusGetPid(GDBusConnectionPtr connection, const char *uniqueName);
-
-} // namespace CynaraHelperCredentials
-
-#endif // CYNARA_TEST_HELPERS_H_
diff --git a/src/cynara-tests/common/cynara_test_helpers_dbus.h b/src/cynara-tests/common/cynara_test_helpers_dbus.h
deleted file mode 100644 (file)
index 46c827e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file        cynara_test_helpers_dbus.h
- * @author      Aleksander Zdyb <a.zdyb@samsung.com>
- * @version     1.0
- */
-#ifndef CYNARA_TEST_HELPERS_DBUS_H_
-#define CYNARA_TEST_HELPERS_DBUS_H_
-
-#include <dbus/dbus.h>
-#include <functional>
-#include <gio/gio.h>
-#include <memory>
-
-typedef std::function<void(DBusConnection *)> DBusConnectionCloseAndUnref;
-typedef std::function<void(GDBusConnection *)> GDBusConnectionCloseAndUnref;
-typedef std::unique_ptr<DBusConnection, DBusConnectionCloseAndUnref> DBusConnectionPtr;
-typedef std::unique_ptr<GDBusConnection, GDBusConnectionCloseAndUnref> GDBusConnectionPtr;
-
-
-#endif // CYNARA_TEST_HELPERS_DBUS_H_
index 5e0f1cd3f62b87ee1fd39d6e4d9fd09c66d2b468..06aa14da700d435bbaf0a2a4c5a87d7b6205c954 100644 (file)
@@ -40,9 +40,9 @@
 #include <tests_common.h>
 #include <uds.h>
 #include <passwd_access.h>
+#include <cynara_helpers_creds.h>
+#include <cynara_helpers_dbus.h>
 
-#include <cynara_test_helpers.h>
-#include <cynara_test_helpers_dbus.h>
 #include <cynara-creds-gdbus.h>
 #include <cynara-creds-self.h>