forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.yaml
More file actions
74 lines (61 loc) · 3.23 KB
/
Copy pathtask.yaml
File metadata and controls
74 lines (61 loc) · 3.23 KB
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-file-ids desktop interface attribute works
details: |
Check that when the desktop-file-ids desktop interface attribute
is set, the names of the desktop files matching the ids are not
mangled (with the snap's desktop prefix).
# Disabled on Ubuntu Core because it doesn't provide the "desktop" slot.
# TODO: Enable for Ubuntu Core Desktop when it is available.
systems:
- -ubuntu-core-*
environment:
DIR: /var/lib/snapd/desktop/applications
prepare: |
cat > "$TESTSLIB"/snaps/test-snapd-desktop-file-ids/meta/gui/'bad. ,?**[]{}^\$#.desktop' << EOF
[Desktop Entry]
Name=test-snapd-desktop-file-ids.cmd
Comment=A desktop file for test-snapd-desktop-file-ids.cmd
Exec=test-snapd-desktop-file-ids.cmd
Terminal=true
Type=Application
EOF
"$TESTSTOOLS"/snaps-state install-local test-snapd-desktop-file-ids
touch "$DIR/test-confinement.desktop"
tests.session -u test prepare
restore: |
rm -f "$DIR/test-confinement.desktop"
tests.session -u test restore
execute: |
files="$DIR/org.example.desktop $DIR/org.example.Foo.desktop $DIR/org.example.Fallback.desktop $DIR/test-snapd-desktop-file-ids_arbitrary.desktop $DIR/test-snapd-desktop-file-ids_foo.desktop $DIR/test-snapd-desktop-file-ids_bar.desktop $DIR/test-snapd-desktop-file-ids_org.example.Bar.desktop $DIR/test-snapd-desktop-file-ids_bad._____________.desktop"
# Connect desktop-legacy interface to test generated desktop allow/deny rules
# only allows access to the snap's desktop files
snap connect test-snapd-desktop-file-ids:desktop-legacy
# Check that desktop files are installed with expected names and implicitly check
# that for confined systems the snap can access its own desktop files when
# desktop-legacy interface plug is connected
echo "Check that desktop files are installed as expected"
# shellcheck disable=SC2086
tests.session -u test exec test-snapd-desktop-file-ids.check-dirs $DIR
# shellcheck disable=SC2086
tests.session -u test exec test-snapd-desktop-file-ids.check-files $files
if [ "$(snap debug confinement)" == strict ]; then
# Check that snap cannot access other desktop files
not tests.session -u test exec test-snapd-desktop-file-ids.check-files "$DIR/test-confinement.desktop"
fi
echo "Just because a desktop file ID is declared does not mean it is created"
test ! -f "$DIR/org.example.NonexistentFile.desktop"
test ! -f "$DIR/org.example.MyCommonID.desktop"
echo "Check that common ID and desktop file ID is correct"
RESULT="$(snap debug api /v2/snaps/test-snapd-desktop-file-ids)"
echo "$RESULT" | MATCH '"status-code": 200'
APPS="$(echo "$RESULT" | gojq .result.apps)"
# Should have both common-id and desktop-file
echo "$APPS" | gojq '.[] | select(.name == "cmd")."common-id"' | MATCH "org.example.Foo"
echo "$APPS" | gojq '.[] | select(.name == "cmd")."desktop-file"' | MATCH "org.example.Foo.desktop"
snap remove --purge test-snapd-desktop-file-ids
echo "Check desktop files are removed"
for file in $files; do
not test -f "$file"
done
echo "But not other snaps' desktop files"
test -f "$DIR/test-confinement.desktop"
# TODO: Add check for parallel installs