Add a regression test for being a new-style monitor
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 2 Feb 2015 20:02:56 +0000 (20:02 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 4 Feb 2015 17:15:24 +0000 (17:15 +0000)
commita650bd055f98a37c99c1b90e2b7872d609a291f2
treed27359bbf33b9a29a643e899a915772556f27a05
parent1acedfdde7a3b704ed53b58033fd15c6f6b34a3d
Add a regression test for being a new-style monitor

This includes most of the situations I could think of:

* method call on dbus-daemon and response
* NameOwnerChanged
* NameAcquired, NameLost (although I'm not 100% sure these should
  get captured, since they're redundant with NameOwnerChanged)
* unicast message is allowed through
* unicast message is rejected by no-sending or no-receiving policy
* broadcast is allowed through
* broadcast is rejected by no-sending policy (the error reply
  is also captured)
* broadcast is rejected by no-receiving policy (there is no error
  reply)
* message causing service activation, and the message telling systemd
  to do the actual activation
* systemd reporting that activation failed

It does not cover:

* sending a message to dbus-daemon, then provoking a reply, then
  dbus-daemon does not allow itself to send the reply due to its
  own security policy

This is such an obscure corner case that I'm not even convinced it's
testable without dropping down into lower-level socket manipulation:
dbus-daemon's replies are always assumed to be requested replies,
and replies contain so little other metadata that I think we can
only forbid them by forbidding all method replies. If we do that,
the reply to Hello() won't arrive and the client-side connection will
not become active.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
test/Makefile.am
test/data/valid-config-files/forbidding.conf.in [new file with mode: 0644]
test/monitor.c [new file with mode: 0644]