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 57 58 59 60 61 62 63 64 65 66 67 68 69
|
summary: Ensure that the location-control interface works.
details: |
The location-control interface allows a snap to operate as the location
service.
A snap which defines the location-control plug must be shown in the
interfaces list. The plug must not be auto-connected on install and, as
usual, must be able to be reconnected.
The snap is also declaring a plug on this interface must be able to ask for
its properties.
# s390x does not support locationd
systems:
- -amazon-linux-2-* # no session services
- -ubuntu-*-s390x # no support for locationd
- -ubuntu-14.04-* # no tests.session support
- -ubuntu-core-* # no session services (except for core20+)
prepare: |
echo "Given a snap declaring a plug on the location-control interface is installed"
snap install test-snapd-location-control-provider
echo "And the provider dbus loop is started"
# XXX: The provider is not a service so we have to start it manually. It
# attaches to the system bus so it just goes into a systemd service and not
# via tests.session.
systemd-run --unit test-snapd-location-control-provider.service test-snapd-location-control-provider.provider
tests.session -u test prepare
restore: |
systemctl stop test-snapd-location-control-provider.service
# provider.py was started from a snap by the test-snapd-location-control-provider.service unit,
# normally it should be enough to kill the whole unit, however since that process
# was started from a snap, it got moved to a separate snap-specific transient
# scope, thus it is no longer part of the unit's cgroup
pkill -f provider.py || true
tests.session -u test restore
execute: |
echo "The interface is not connected by default"
snap interfaces -i location-control | MATCH "^- +test-snapd-location-control-provider:location-control$"
echo "The interface can be connected"
snap connect test-snapd-location-control-provider:location-control test-snapd-location-control-provider:location-control-test
echo "Then wait until the dbus name is properly reserved"
retry -n 10 --wait 1 sh -c 'tests.session -u test exec test-snapd-location-control-provider.consumer Get | MATCH "location-provider-added"'
echo "Check the location-control is working from the consumer app in the snap"
tests.session -u test exec test-snapd-location-control-provider.consumer Get | MATCH "location-provider-added"
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plug is disconnected"
snap disconnect test-snapd-location-control-provider:location-control test-snapd-location-control-provider:location-control-test
echo "And the location provider props cannot be accessed"
if tests.session -u test exec test-snapd-location-control-provider.consumer Get 2> getprop.error; then
echo "Expected permission error trying to get props with disconnected plug"
exit 1
fi
MATCH "Permission denied" < getprop.error
echo "And the plug can be re-connected"
snap connect test-snapd-location-control-provider:location-control test-snapd-location-control-provider:location-control-test
|