From: Simon McVittie Date: Tue, 16 Jan 2018 13:32:49 +0000 (+0000) Subject: loopback test: Display credentials received X-Git-Tag: dbus-1.13.4~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=005bded7a8b7c750280805faefb31f6b47bee780;p=thirdparty%2Fdbus.git loopback test: Display credentials received Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737 Reviewed-by: Philip Withnall --- diff --git a/test/loopback.c b/test/loopback.c index 59f4a28b6..6a1dbee70 100644 --- a/test/loopback.c +++ b/test/loopback.c @@ -31,6 +31,7 @@ #include #include +#include "dbus/dbus-connection-internal.h" #include #include @@ -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); }