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
|
summary: Ensure that the udisks2 interface works.
details: |
The udisks2 interface allows operating as or interacting with the UDisks2 service
# Interfaces not defined for ubuntu core systems
systems: [-ubuntu-core-*]
environment:
FS_PATH: "$(pwd)/dev0-fake0"
prepare: |
snap install test-snapd-udisks2
restore: |
device="$(losetup -j "$FS_PATH" | cut -d: -f1)"
if [ -n "$device" ]; then
udisksctl loop-delete -b "$device"
fi
execute: |
echo "The interface is not connected by default"
snap interfaces -i udisks2 | MATCH -- "- +test-snapd-udisks2:udisks2"
echo "When the interface is connected"
snap connect test-snapd-udisks2:udisks2
echo "Check it is possible to see the udisks2 stauts"
test-snapd-udisks2.udisksctl status | MATCH "MODEL"
echo "Check it is possible to dump all the udisks objects info"
test-snapd-udisks2.udisksctl dump | MATCH "org.freedesktop.UDisks2.Manager"
echo "Check we can mount/unmount a block device using the snap"
# create a 10M filesystem in pwd
dd if=/dev/zero of="$FS_PATH" bs=1M count=10
mkfs.ext4 -F "$FS_PATH"
# create the loopback block device
udisksctl loop-setup -f "$FS_PATH"
device="$(losetup -j "$FS_PATH" | cut -d: -f1)"
# We retry because there is a race with the device becoming
# registered by udisks2. The issue can be easily reproduced on ubuntu-20.04
retry -n 15 --wait 1 sh -c "test-snapd-udisks2.udisksctl mount -b \"$device\" -t ext4 | MATCH 'Mounted /dev/'"
test-snapd-udisks2.udisksctl unmount -b "$device" | MATCH "Unmounted /dev/"
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plug is disconnected"
snap disconnect test-snapd-udisks2:udisks2
echo "Then the snap is not able to check udisks2 status"
if test-snapd-udisks2.udisksctl status 2> call.error; then
echo "Expected permission error calling udisksctl status with disconnected plug"
exit 1
fi
MATCH "Permission denied" < call.error
|