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
|
summary: Ensure that the network-setup-observe interface works.
details: |
The network setup observe interface allows to access the different netplan
configuration files.
prepare: |
"$TESTSTOOLS"/snaps-state install-local test-snapd-sh
execute: |
dirs="/etc/netplan /etc/network"
echo "The interface is disconnected by default"
snap interfaces -i network-setup-observe| MATCH -- '^- +test-snapd-sh:network-setup-observe'
echo "When the interface is connected"
snap connect test-snapd-sh:network-setup-observe
echo "Then the snap is able to read the network and netplan directories"
for dir in $dirs; do
if [ -d "$dir" ]; then
test-snapd-sh.with-network-setup-observe-plug -c "ls $dir"
fi
done
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plug is disconnected"
snap disconnect test-snapd-sh:network-setup-observe
echo "Then the snap is not able to read the network and netplan directories"
for dir in $dirs; do
if [ -d "$dir" ]; then
if test-snapd-sh.with-network-setup-observe-plug -c "ls $dir" 2>call.error; then
echo "Expected permission error reading network directory with disconnected plug"
exit 1
fi
MATCH "Permission denied" < call.error
fi
done
echo "Then the interface can be connected again"
snap connect test-snapd-sh:network-setup-observe
|