Commit 8fcc1f9a authored by Adrian Szyndela's avatar Adrian Szyndela

test: activation tests for send_destination_prefix

This adds a few tests for checking if activation is allowed
for names specified within send_destination_prefix namespaces.
Signed-off-by: Adrian Szyndela's avatarAdrian Szyndela <adrian.s@samsung.com>
Change-Id: I7a5a66f82fc08ce6cb46e37de2c3dfae24d9ea67
parent 7b7c5724
......@@ -688,6 +688,9 @@ static_data = \
data/systemd-activation/com.example.ReceiveDenied.service \
data/systemd-activation/com.example.SendDenied.service \
data/systemd-activation/com.example.SendDeniedByAppArmorName.service \
data/systemd-activation/com.example.SendPrefixDenied.service \
data/systemd-activation/com.example.SendPrefixDenied.internal.service \
data/systemd-activation/com.example.SendPrefixDenied.SendPrefixAllowed.internal.service \
data/systemd-activation/com.example.SystemdActivatable1.service \
data/systemd-activation/com.example.SystemdActivatable2.service \
data/systemd-activation/org.freedesktop.systemd1.service \
......
[D-BUS Service]
Name=com.example.SendPrefixDenied.SendPrefixAllowed.internal
Exec=/bin/false SendPrefixDenied.SendPrefixAllowed.internal
SystemdService=dbus-com.example.SendPrefixDenied.SendPrefixAllowed.internal.service
[D-BUS Service]
Name=com.example.SendPrefixDenied.internal
Exec=/bin/false SendPrefixDenied.internal
SystemdService=dbus-com.example.SendPrefixDenied.internal.service
[D-BUS Service]
Name=com.example.SendPrefixDenied
Exec=/bin/false SendPrefixDenied
SystemdService=dbus-com.example.SendPrefixDenied.service
......@@ -14,6 +14,8 @@
<policy context="mandatory">
<deny send_destination="com.example.SendDenied"/>
<deny send_destination_prefix="com.example.SendPrefixDenied"/>
<deny receive_interface="com.example.ReceiveDenied" receive_member="Call"/>
<allow send_destination_prefix="com.example.SendPrefixDenied.SendPrefixAllowed"/>
</policy>
</busconfig>
......@@ -516,6 +516,37 @@ test_activation (Fixture *f,
g_error ("OOM");
dbus_connection_send (f->systemd, m, NULL);
dbus_message_unref (m);
/* A fourth activation: for name from send_destination_prefix namespace */
m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal4");
if (!dbus_message_set_destination (m, "com.example.SendPrefixDenied.SendPrefixAllowed.internal"))
g_error ("OOM");
dbus_connection_send (f->caller, m, NULL);
dbus_message_unref (m);
/* systemd is already ready for it. */
while (f->systemd_message == NULL)
test_main_context_iterate (f->ctx, TRUE);
m = f->systemd_message;
f->systemd_message = NULL;
assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
"org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
"org.freedesktop.systemd1");
/* Check ActivationRequest for the required name. */
/* If it is correct, then it passed through policy checking, and the test is over. */
do
{
const char *name;
DBusError error;
dbus_error_init (&error);
dbus_message_get_args (m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
test_assert_no_error (&error);
g_assert_cmpstr (name, ==, "dbus-com.example.SendPrefixDenied.SendPrefixAllowed.internal.service");
} while (0);
dbus_message_unref (m);
}
static void
......@@ -1031,7 +1062,9 @@ static const Config deny_send_tests[] =
{ "com.example.SendDeniedByNonexistentAppArmorLabel" },
{ "com.example.SendDeniedByAppArmorName" },
#endif
{ "com.example.SendDenied" }
{ "com.example.SendDenied" },
{ "com.example.SendPrefixDenied" },
{ "com.example.SendPrefixDenied.internal" }
};
static const Config deny_receive_tests[] =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment