tests/daemon: Daemon test failues for p2p-dbus fixed.
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Sat, 11 May 2013 10:02:30 +0000 (13:02 +0300)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Thu, 16 May 2013 11:28:13 +0000 (14:28 +0300)
GTestBusServer is limited only for 'session' bus.

configure.ac
test/daemon/Makefile.am
test/daemon/daemon-test.c
test/daemon/test-daemon-setup.sh

index 7b8a7e3..4e12bee 100644 (file)
@@ -38,12 +38,6 @@ PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
 AC_SUBST(CHECK_CFLAGS)
 AC_SUBST(CHECK_LIBS)
 
-PKG_CHECK_MODULES(GTestDBus, glib-2.0 >= 2.34, [gtestdbus=yes], [gtestdbus=no])
-AM_CONDITIONAL(HAVE_GTESTDBUS, [test x$gtestdbus = xyes])
-if test "x$gtestdbus" = xyes; then
-    AC_DEFINE(HAVE_GTESTDBUS, [1], [Define if GTestDBus exists.])
-fi
-
 PKG_CHECK_MODULES([LIBSMACK], libsmack >= 1.0, [libsmack=yes], [libsmack=no])
 AM_CONDITIONAL(HAVE_LIBSMACK, [test x$libsmack = xyes])
 if test "x$libsmack" = xyes; then
@@ -73,11 +67,18 @@ if test "x$enable_dbus_type" = "xp2p" ; then
 elif test "x$enable_dbus_type" = "xsession" ; then
     AC_DEFINE(GSIGNOND_BUS_TYPE, [G_BUS_TYPE_SESSION], [Use session bus])
     DBUS_SERVICES_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
+    
+    PKG_CHECK_MODULES(GTestDBus, gio-2.0 >= 2.34, [gtestdbus=yes], [gtestdbus=no])
+    if test "x$gtestdbus" = xyes; then
+       AC_DEFINE(HAVE_GTESTDBUS, [1], [Define if GTestDBus exists.])
+    fi
 elif test "x$enable_dbus_type" = "xsystem" ; then
     AC_DEFINE(GSIGNOND_BUS_TYPE, [G_BUS_TYPE_SYSTEM], [Use system bus])
     DBUS_SERVICES_DIR="`pkg-config --variable system_bus_services_dir dbus-1`"
 fi
 
+AM_CONDITIONAL(USE_GTESTDBUS, [test x$gtestdbus = xyes])
+
 AC_SUBST(DBUS_SERVICES_DIR)
 DBUS_INTERFACES_DIR="`pkg-config --variable interfaces_dir dbus-1`"
 AC_SUBST(DBUS_INTERFACES_DIR)
@@ -118,6 +119,11 @@ test/Makefile
 test/common/Makefile
 test/db/Makefile
 test/daemon/Makefile
-test/daemon/services/com.google.code.AccountsSSO.gSingleSignOn.service
 test/plugins/Makefile
 ])
+
+if test x$gtestdbus = xyes; then
+    AC_OUTPUT([
+    test/daemon/services/com.google.code.AccountsSSO.gSingleSignOn.service
+    ])
+fi
index 1ba25fe..71f6044 100644 (file)
@@ -1,4 +1,4 @@
-if HAVE_GTESTDBUS
+if USE_GTESTDBUS
 TESTS = daemontest
 else
 TESTS = test-daemon-setup.sh
@@ -18,10 +18,14 @@ daemontest_CFLAGS = \
     $(CHECK_CFLAGS) \
     -U G_LOG_DOMAIN \
     -DG_LOG_DOMAIN=\"gsignond-test-server\" \
-    -DGSIGNOND_TEST_DBUS_SERVICE_DIR=\""$(abs_top_builddir)/test/daemon/services"\" \
     -I$(top_srcdir) \
     -I$(top_srcdir)/src/ \
-    -I$(top_srcdir)/include/ 
+    -I$(top_srcdir)/include/
+
+if USE_GTESTDBUS
+daemontest_CFLAGS += \
+    -DGSIGNOND_TEST_DBUS_SERVICE_DIR=\""$(abs_top_builddir)/test/daemon/services"\"
+endif
 
 daemontest_LDADD = \
     $(top_builddir)/src/common/libgsignond-common.la \
index 9e57b4c..c1e0034 100644 (file)
@@ -23,7 +23,7 @@
  * 02110-1301 USA
  */
 
-#include <config.h>
+#include "config.h"
 #include <check.h>
 #include <stdlib.h>
 #include <gio/gio.h>
 #include <gsignond/gsignond-identity-info.h>
 #include <gsignond/gsignond-log.h>
 
+#ifdef USE_P2P
+#  ifdef GSIGNOND_SERVICE
+#    undef GSIGNOND_SERVICE
+#  endif
+#  define GSIGNOND_SERVICE NULL
+#endif
+
 struct IdentityData {
     gchar *key;
     gchar *type;
@@ -97,21 +104,39 @@ gboolean validate_identity_info (GVariant *identity_info)
     return TRUE;
 }
 
+GDBusConnection * _get_bus_connection (GError **error)
+{
+#if USE_P2P
+    return g_dbus_connection_new_for_address_sync (
+        GSIGNOND_DBUS_ADDRESS,
+        G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+        NULL,
+        NULL,
+        error);
+#else
+    return g_bus_get_sync (GSIGNOND_BUS_TYPE, NULL, error);
+#endif
+}
+
 START_TEST (test_register_new_identity)
 {
     GError *error = 0;
     gboolean res;
+    GDBusConnection *connection = NULL;
     GSignondDbusAuthService *auth_service = 0;
     gchar *identity_path = 0;
-    auth_service = gsignond_dbus_auth_service_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+
+    connection = _get_bus_connection (&error);
+    fail_if (connection == NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+
+    auth_service = gsignond_dbus_auth_service_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         GSIGNOND_DAEMON_OBJECTPATH,
         NULL, &error);
 
-    fail_if (auth_service == NULL);
+    fail_if (auth_service == NULL, "failed to get auth_service : %s", error ? error->message : "");
 
     res = gsignond_dbus_auth_service_call_register_new_identity_sync (
         auth_service,
@@ -122,7 +147,7 @@ START_TEST (test_register_new_identity)
 
     g_object_unref (auth_service);
 
-    fail_if (res == FALSE, "Failed to register identity");
+    fail_if (res == FALSE, "Failed to register identity : %s", error ? error->message : "");
     fail_if (identity_path == NULL);
     g_free (identity_path);
 }
@@ -134,9 +159,12 @@ START_TEST (test_register_new_identity_with_no_app_context)
     gboolean res;
     GSignondDbusAuthService *auth_service = 0;
     gchar *identity_path = NULL;
+    GDBusConnection *connection = _get_bus_connection (&error);
+    fail_if (connection == NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+    fail_if (error != NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
  
-    auth_service = gsignond_dbus_auth_service_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    auth_service = gsignond_dbus_auth_service_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         GSIGNOND_DAEMON_OBJECTPATH,
@@ -171,8 +199,12 @@ START_TEST (test_identity_store)
     int i;
     gchar* mechanisms [] = {"password", NULL};
 
-    auth_service = gsignond_dbus_auth_service_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    GDBusConnection *connection = _get_bus_connection (&error);
+    fail_if (connection == NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+    fail_if (error != NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+
+    auth_service = gsignond_dbus_auth_service_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         GSIGNOND_DAEMON_OBJECTPATH,
@@ -204,8 +236,8 @@ START_TEST (test_identity_store)
 
     fail_if (identity_info == NULL);
 
-    identity = gsignond_dbus_identity_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    identity = gsignond_dbus_identity_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         identity_path,
@@ -234,9 +266,12 @@ START_TEST(test_identity_get_identity)
     gint id = 1 ; /* identity id created in test_identity_store */
     GVariant *identity_info = NULL;
     gchar *identity_path = 0;
+    GDBusConnection *connection = _get_bus_connection (&error);
+    fail_if (connection == NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+    fail_if (error != NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
 
-    auth_service = gsignond_dbus_auth_service_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    auth_service = gsignond_dbus_auth_service_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         GSIGNOND_DAEMON_OBJECTPATH,
@@ -266,9 +301,12 @@ START_TEST(test_clear_database)
     GError *error = 0;
     gboolean res, ret;
     GSignondDbusAuthService *auth_service = 0;
+    GDBusConnection *connection = _get_bus_connection (&error);
+    fail_if (connection == NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+    fail_if (error != NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
  
-    auth_service = gsignond_dbus_auth_service_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    auth_service = gsignond_dbus_auth_service_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         GSIGNOND_DAEMON_OBJECTPATH,
@@ -308,7 +346,6 @@ static void _on_identity_updated (GSignondDbusIdentity *identity, gint change_ty
 static void _on_sign_out_reply (GSignondDbusIdentity *sender, GAsyncResult *reply, gpointer data)
 {
     GError *error = NULL;
-    g_warning ("_on_sign_out_reply");
 
     gboolean res = FALSE, ret = FALSE;
     
@@ -337,11 +374,14 @@ START_TEST(test_identity_signout)
     gboolean identity_signed_out = FALSE;
     gboolean session_unregistered = FALSE;
     GMainLoop *loop = NULL;
+    GDBusConnection *connection = _get_bus_connection (&error);
+    fail_if (connection == NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
+    fail_if (error != NULL, "failed to get bus connection : %s", error ? error->message : "(null)");
 
     loop = g_main_loop_new (NULL, FALSE);
 
-    auth_service = gsignond_dbus_auth_service_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    auth_service = gsignond_dbus_auth_service_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         GSIGNOND_DAEMON_OBJECTPATH,
@@ -373,8 +413,8 @@ START_TEST(test_identity_signout)
 
     fail_if (identity_info == NULL);
 
-    identity = gsignond_dbus_identity_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    identity = gsignond_dbus_identity_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         identity_path,
@@ -399,8 +439,8 @@ START_TEST(test_identity_signout)
         error ? error->message : "");
     fail_if (session_path == NULL, "(null) session_path");
 
-    auth_session = gsignond_dbus_auth_session_proxy_new_for_bus_sync (
-        G_BUS_TYPE_SESSION,
+    auth_session = gsignond_dbus_auth_session_proxy_new_sync (
+        connection,
         G_DBUS_PROXY_FLAGS_NONE,
         GSIGNOND_SERVICE,
         session_path,
@@ -465,4 +505,3 @@ int main (void)
 
     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-  
index 86abf31..1dabd9a 100755 (executable)
@@ -3,6 +3,7 @@
 export G_MESSAGES_DEBUG=all
 export SSO_IDENTITY_TIMEOUT=5
 export SSO_STORAGE_PATH=/tmp/gsignond
+export SSO_SECRET_PATH=/tmp/gsignond
 
 rm -rf "$SSO_STORAGE_PATH"