2 * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file cynara_test_helpers.cpp
18 * @author Aleksander Zdyb <a.zdyb@samsung.com>
20 * @brief Helpers for cynara-helpers
23 #include <dpl/test/test_runner.h>
25 #include <cynara-creds-dbus.h>
26 #include <cynara-creds-socket.h>
28 #include "cynara_test_helpers.h"
30 namespace CynaraHelperCredentials {
32 char *socketGetClient(int sock, cynara_client_creds method, int expectedResult) {
34 auto ret = cynara_creds_socket_get_client(sock, method, &buff);
35 RUNNER_ASSERT_MSG(ret == expectedResult,
36 "cynara_creds_socket_get_client failed, ret = " << ret
37 << "; expected = " << expectedResult);
41 char *socketGetUser(int sock, cynara_user_creds method, int expectedResult) {
43 auto ret = cynara_creds_socket_get_user(sock, method, &buff);
44 RUNNER_ASSERT_MSG(ret == expectedResult,
45 "cynara_creds_socket_get_user failed, ret = " << ret
46 << "; expected = " << expectedResult);
50 pid_t socketGetPid(int sock, int expectedResult) {
52 auto ret = cynara_creds_socket_get_pid(sock, &pid);
53 RUNNER_ASSERT_MSG(ret == expectedResult,
54 "cynara_creds_socket_get_pid failed, ret = " << ret << "; expected = "
59 char *dbusGetClient(DBusConnectionPtr connection, const char *uniqueName,
60 cynara_client_creds method, int expectedResult) {
62 auto ret = cynara_creds_dbus_get_client(connection.get(), uniqueName, method, &buff);
63 RUNNER_ASSERT_MSG(ret == expectedResult,
64 "cynara_creds_dbus_get_client failed, ret = " << ret
65 << "; expected = " << expectedResult);
69 char *dbusGetUser(DBusConnectionPtr connection, const char *uniqueName, cynara_user_creds method,
72 auto ret = cynara_creds_dbus_get_user(connection.get(), uniqueName, method, &buff);
73 RUNNER_ASSERT_MSG(ret == expectedResult,
74 "cynara_creds_dbus_get_user failed, ret = " << ret
75 << "; expected = " << expectedResult);
79 pid_t dbusGetPid(DBusConnectionPtr connection, const char *uniqueName, int expectedResult) {
81 auto ret = cynara_creds_dbus_get_pid(connection.get(), uniqueName, &pid);
82 RUNNER_ASSERT_MSG(ret == expectedResult, "cynara_creds_dbus_get_pid failed, ret = " << ret
83 << "; expected = " << expectedResult);
87 } //namespace CynaraHelperCredentials