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 70 71 72 73 74
|
summary: Ensure that the desktop-launch interface works.
details: |
The desktop-launch interface allows a snap to launch other snaps via
the desktop files they provide to the host system.
systems: [-ubuntu-core-*]
prepare: |
if ! tests.session has-session-systemd-and-dbus; then
exit 0
fi
snap remove --purge api-client || true
tests.session -u test prepare
tests.session -u test exec systemctl --user \
set-environment XDG_DATA_DIRS=/usr/share:/var/lib/snapd/desktop
restore: |
if ! tests.session has-session-systemd-and-dbus; then
exit 0
fi
tests.session -u test restore
rm -f ~test/snap/test-app/current/launch-data.txt
execute: |
if ! tests.session has-session-systemd-and-dbus; then
exit 0
fi
"$TESTSTOOLS"/snaps-state install-local api-client
tests.cleanup defer snap remove --purge api-client
echo "Install the application snap"
"$TESTSTOOLS"/snaps-state install-local test-app
echo "The snap installs a desktop file"
[ -f /var/lib/snapd/desktop/applications/test-app_test-app.desktop ]
echo "Install the launcher snap"
"$TESTSTOOLS"/snaps-state install-local test-launcher
echo "The desktop-launch plug is initially disconnected"
snap connections test-launcher | MATCH "desktop-launch +test-launcher:desktop-launch +- +-"
echo "The plug can be connected"
snap connect test-launcher:desktop-launch
snap connections test-launcher | MATCH "desktop-launch +test-launcher:desktop-launch +:desktop-launch +manual"
echo "The launcher snap can launch other snaps via userd"
tests.session -u test exec test-launcher \
test-app_test-app.desktop
echo "The app snap records that it has been launched"
launch_data=~test/snap/test-app/current/launch-data.txt
retry -n 5 --wait 1 test -s "$launch_data"
echo "The app was invoked with the arguments in the desktop file"
MATCH "^args=arg-before arg-after$" < "$launch_data"
echo "Without the plug connection, the app cannot access endpoints"
api-client --socket /run/snapd-snap.socket "/v2/icons/api-client/icon" | gojq '."status-code"' | MATCH '^403$'
api-client --socket /run/snapd-snap.socket "/v2/snaps/snapd" | gojq '."status-code"' | MATCH '^403$'
api-client --socket /run/snapd-snap.socket "/v2/snaps" | gojq '."status-code"' | MATCH '^403$'
echo "Connect the api-client desktop-launch plug"
snap connect api-client:desktop-launch
echo "Check that snap can access icons info via /v2/icons and gets 404 if icon is not found"
api-client --socket /run/snapd-snap.socket "/v2/icons/api-client/icon" | gojq '."status-code"' | MATCH '^404$'
echo "Check that snap can access /v2/snaps/{name}"
api-client --socket /run/snapd-snap.socket "/v2/snaps/snapd" | gojq '."status-code"' | MATCH '^200$'
echo "Check that snap can access /v2/snaps"
api-client --socket /run/snapd-snap.socket "/v2/snaps" | gojq '."status-code"' | MATCH '^200$'
|