1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
summary: Ensure that the dbus interface works on the system bus.
details: |
Check that the dbus interface can be used to access the system
bus for specific methods and that they cannot be accessed if the
interface is disconnected.
prepare: |
echo "Install dbus system test snaps"
snap install --edge test-snapd-dbus-provider
snap install --edge test-snapd-dbus-consumer
# we can only talk from an unconfied dbus-send to the service on classic,
# on ubuntu-core devices *all* dbus calls are mediated.
echo "Ensure the dbus service is up"
if os.query is-classic; then
dbus-send --system --print-reply --dest=com.dbustest.HelloWorld /com/dbustest/HelloWorld com.dbustest.HelloWorld.SayHello | MATCH "hello world"
fi
restore: |
snap remove --purge test-snapd-dbus-consumer || true
snap remove --purge test-snapd-dbus-provider || true
execute: |
echo "The dbus consumer plug is disconnected by default"
snap interfaces -i dbus | MATCH '^- +test-snapd-dbus-consumer:dbus-system-test'
echo "When the plug is connected"
snap connect test-snapd-dbus-consumer:dbus-system-test test-snapd-dbus-provider:dbus-system-test
echo "Then the consumer is able to call the provided method"
test-snapd-dbus-consumer.dbus-system-consumer | MATCH "hello world"
echo "Also check if dbus works if plug/slot come from the same snap"
echo "When the plug is connected (same snap)"
snap connect test-snapd-dbus-provider:dbus-system-test-plug test-snapd-dbus-provider:dbus-system-test
echo "Then the consumer (same snap) is able to call the provided method"
test-snapd-dbus-provider.system-consumer | MATCH "hello world"
echo "And the connection to the other snap still works"
test-snapd-dbus-consumer.dbus-system-consumer | MATCH "hello world"
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plugs are disconnected"
snap disconnect test-snapd-dbus-consumer:dbus-system-test
snap disconnect test-snapd-dbus-provider:dbus-system-test-plug
echo "And the consumer is not able to access the provided method"
not test-snapd-dbus-consumer.dbus-system-consumer 2> call.error
MATCH "Permission denied" < call.error
echo "And the provider is not able to access the provided method (same snap)"
not test-snapd-dbus-provider.system-consumer 2> call.error
MATCH "Permission denied" < call.error
|