mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-06-19 04:58:27 +02:00
dbus-daemon test: exercise maximum match rules per connection
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86442 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
This commit is contained in:
parent
b32f7360b7
commit
951fd317ca
3 changed files with 54 additions and 0 deletions
|
|
@ -349,6 +349,7 @@ in_data = \
|
|||
data/valid-config-files/incoming-limit.conf.in \
|
||||
data/valid-config-files/max-completed-connections.conf.in \
|
||||
data/valid-config-files/max-connections-per-user.conf.in \
|
||||
data/valid-config-files/max-match-rules-per-connection.conf.in \
|
||||
data/valid-config-files/max-replies-per-connection.conf.in \
|
||||
data/valid-config-files/multi-user.conf.in \
|
||||
data/valid-config-files/systemd-activation.conf.in \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<!-- Our well-known bus type, don't change this -->
|
||||
<type>session</type>
|
||||
<listen>@TEST_LISTEN@</listen>
|
||||
|
||||
<policy context="default">
|
||||
<!-- Allow everything to be sent -->
|
||||
<allow send_destination="*" eavesdrop="true"/>
|
||||
<!-- Allow everything to be received -->
|
||||
<allow eavesdrop="true"/>
|
||||
<!-- Allow anyone to own anything -->
|
||||
<allow own="*"/>
|
||||
</policy>
|
||||
|
||||
<limit name="max_match_rules_per_connection">3</limit>
|
||||
</busconfig>
|
||||
|
|
@ -847,6 +847,33 @@ test_max_replies_per_connection (Fixture *f,
|
|||
g_queue_clear (&errors);
|
||||
}
|
||||
|
||||
static void
|
||||
test_max_match_rules_per_connection (Fixture *f,
|
||||
gconstpointer context)
|
||||
{
|
||||
DBusError error = DBUS_ERROR_INIT;
|
||||
|
||||
if (f->skip)
|
||||
return;
|
||||
|
||||
dbus_bus_add_match (f->left_conn, "sender='com.example.C1'", &error);
|
||||
test_assert_no_error (&error);
|
||||
dbus_bus_add_match (f->left_conn, "sender='com.example.C2'", &error);
|
||||
test_assert_no_error (&error);
|
||||
dbus_bus_add_match (f->left_conn, "sender='com.example.C3'", &error);
|
||||
test_assert_no_error (&error);
|
||||
|
||||
dbus_bus_add_match (f->left_conn, "sender='com.example.C4'", &error);
|
||||
g_assert_cmpstr (error.name, ==, DBUS_ERROR_LIMITS_EXCEEDED);
|
||||
dbus_error_free (&error);
|
||||
|
||||
dbus_bus_remove_match (f->left_conn, "sender='com.example.C3'", &error);
|
||||
test_assert_no_error (&error);
|
||||
|
||||
dbus_bus_add_match (f->left_conn, "sender='com.example.C4'", &error);
|
||||
test_assert_no_error (&error);
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (Fixture *f,
|
||||
gconstpointer context G_GNUC_UNUSED)
|
||||
|
|
@ -946,6 +973,11 @@ static Config max_replies_per_connection_config = {
|
|||
SPECIFY_ADDRESS
|
||||
};
|
||||
|
||||
static Config max_match_rules_per_connection_config = {
|
||||
NULL, 1, "valid-config-files/max-match-rules-per-connection.conf",
|
||||
SPECIFY_ADDRESS
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
|
|
@ -972,6 +1004,9 @@ main (int argc,
|
|||
g_test_add ("/limits/max-replies-per-connection", Fixture,
|
||||
&max_replies_per_connection_config,
|
||||
setup, test_max_replies_per_connection, teardown);
|
||||
g_test_add ("/limits/max-match-rules-per-connection", Fixture,
|
||||
&max_match_rules_per_connection_config,
|
||||
setup, test_max_match_rules_per_connection, teardown);
|
||||
#ifdef DBUS_UNIX
|
||||
/* We can't test this in loopback.c with the rest of unix:runtime=yes,
|
||||
* because dbus_bus_get[_private] is the only way to use the default,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue