From 6add956c2affcd93d8490f8bcd30a3c786a98c54 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Jan 2018 13:32:49 +0000 Subject: [PATCH 07/11] loopback test: Display credentials received Reviewed-by: Philip Withnall [smcv: Add a comment as requested] Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737 --- Add the comment Philip asked for --- test/loopback.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/loopback.c b/test/loopback.c index 59f4a28b..6a1dbee7 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); } -- 2.16.1