From 170ace9d872747dbd87d96c45517b14325b4d431 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Feb 2015 14:45:40 +0000 Subject: [PATCH 7/8] monitor test: check that we log a fake reply to forbidden broadcasts --- test/monitor.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/monitor.c b/test/monitor.c index 38f66d2..c43ecc5 100644 --- a/test/monitor.c +++ b/test/monitor.c @@ -689,6 +689,9 @@ test_broadcast (Fixture *f, if (f->address == NULL) return; + dbus_bus_add_match (f->recipient, "type='signal'", &f->e); + test_assert_no_error (&f->e); + become_monitor (f); m = dbus_message_new_signal ("/foo", "com.example.bar", "BroadcastSignal1"); @@ -734,6 +737,9 @@ test_forbidden_broadcast (Fixture *f, if (f->address == NULL) return; + dbus_bus_add_match (f->recipient, "type='signal'", &f->e); + test_assert_no_error (&f->e); + become_monitor (f); m = dbus_message_new_signal ("/foo", "com.example.CannotSend", @@ -751,7 +757,7 @@ test_forbidden_broadcast (Fixture *f, dbus_connection_send (f->sender, m, NULL); dbus_message_unref (m); - while (g_queue_get_length (&f->monitored) < 3) + while (g_queue_get_length (&f->monitored) < 6) test_main_context_iterate (f->ctx, TRUE); m = g_queue_pop_head (&f->monitored); @@ -759,8 +765,10 @@ test_forbidden_broadcast (Fixture *f, "BroadcastSignal1", "", NULL); dbus_message_unref (m); - /* FIXME: dbus-daemon does not fake a denial message for the monitor's - * benefit; should it? */ + m = g_queue_pop_head (&f->monitored); + assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name, + DBUS_ERROR_ACCESS_DENIED); + dbus_message_unref (m); m = g_queue_pop_head (&f->monitored); assert_signal (m, f->sender_name, "/foo", "com.example.CannotReceive", @@ -768,11 +776,21 @@ test_forbidden_broadcast (Fixture *f, dbus_message_unref (m); m = g_queue_pop_head (&f->monitored); + assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name, + DBUS_ERROR_ACCESS_DENIED); + dbus_message_unref (m); + + m = g_queue_pop_head (&f->monitored); assert_signal (m, f->sender_name, "/foo", "com.example.CannotSend", "BroadcastSignal3", "", NULL); dbus_message_unref (m); m = g_queue_pop_head (&f->monitored); + assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name, + DBUS_ERROR_ACCESS_DENIED); + dbus_message_unref (m); + + m = g_queue_pop_head (&f->monitored); g_assert (m == NULL); } -- 2.1.4