]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
loopback test: Display credentials received
authorSimon McVittie <smcv@collabora.com>
Tue, 16 Jan 2018 13:32:49 +0000 (13:32 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 2 Mar 2018 14:51:54 +0000 (14:51 +0000)
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
Reviewed-by: Philip Withnall <withnall@endlessm.com>
test/loopback.c

index 59f4a28b60970d5c835763a80d082dcaa233950d..6a1dbee705c7dbd9fe453b49eb9cb813fd404845 100644 (file)
@@ -31,6 +31,7 @@
 #include <glib/gstdio.h>
 
 #include <dbus/dbus.h>
+#include "dbus/dbus-connection-internal.h"
 
 #include <errno.h>
 #include <string.h>
@@ -163,6 +164,8 @@ test_connect (Fixture *f,
   const char *listening_address = addr;
   char *address;
   DBusAddressEntry **entries;
+  DBusCredentials *creds;
+  DBusString cred_string;
   int n_entries;
   dbus_bool_t ok;
 
@@ -258,6 +261,31 @@ test_connect (Fixture *f,
       test_main_context_iterate (f->ctx, TRUE);
     }
 
+  /* Wait for the server to have credentials, check that their string
+   * form is non-NULL and log them. We don't make any further assertions,
+   * because we don't really know what to expect. */
+
+  creds = _dbus_connection_get_credentials (f->server_conn);
+
+  while (creds == NULL)
+    {
+      test_progress ('.');
+      test_main_context_iterate (f->ctx, TRUE);
+      creds = _dbus_connection_get_credentials (f->server_conn);
+    }
+
+  g_assert_nonnull (creds);
+
+  if (!_dbus_string_init (&cred_string) ||
+      !_dbus_credentials_to_string_append (creds, &cred_string))
+    g_error ("OOM");
+
+  g_test_message ("Credentials: %s",
+                  _dbus_string_get_const_data (&cred_string));
+  g_assert_cmpstr (_dbus_string_get_const_data (&cred_string), !=, NULL);
+  _dbus_string_free (&cred_string);
+  _dbus_clear_credentials (&creds);
+
   dbus_free (address);
 }