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 75
|
summary: Check that snap connect works
details: |
This test verifies multiple ways to invoke "snap connect". It
checks proper errors are reported. It makes sure slot in some
contexts can be implicit. Calls are idempotent. It tests
connections to snapd as well as other snaps.
prepare: |
echo "Install a test snap"
"$TESTSTOOLS"/snaps-state install-local home-consumer
# the home interface is not autoconnected on all-snap systems
if not os.query is-core16; then
snap disconnect home-consumer:home
fi
execute: |
echo "Connect and disconnect provides meaningful error if plug or slot snap is not installed"
snap connect home-consumer:home foo:home 2>&1 | MATCH 'error: snap "foo" is not installed'
snap connect foo:home 2>&1 | MATCH 'error: snap "foo" is not installed'
snap disconnect foo:home 2>&1 | MATCH 'error: snap "foo" is not installed'
snap disconnect home-consumer:home foo:home 2>&1 | MATCH 'error: snap "foo" is not installed'
CONNECTED_PATTERN=':home .*home-consumer'
echo "The plug can be connected to a matching slot of OS snap without snap:slot argument"
snap connect home-consumer:home
snap interfaces | MATCH "$CONNECTED_PATTERN"
snap disconnect home-consumer:home
echo "The plug can be connected to a matching slot with slot name omitted"
snap connect home-consumer:home
snap interfaces | MATCH "$CONNECTED_PATTERN"
echo "Connecting already connected interface does nothing"
snap connect home-consumer:home system:home
OUTPUT=$(snap change --last=connect)
if [ "$(echo "$OUTPUT" | wc -l)" -ne 1 ]; then
echo "Expected no tasks, got: $OUTPUT"
exit 1
fi
snap disconnect home-consumer:home
snap tasks --last=disconnect| MATCH "Disconnect .* from (core|snapd):home"
echo "The plug can be connected to a slot on the core snap using abbreviated syntax"
snap connect home-consumer:home :home
snap interfaces | MATCH "$CONNECTED_PATTERN"
snap tasks --last=connect| MATCH "Connect home-consumer:home to (core|snapd):home"
# NOTE: Those only work when installed from the store as otherwise we don't
# have snap declaration assertion and cannot check if a given connection
# should be allowed.
CONTENT_CONNECTED_PATTERN='test-snapd-content-slot:shared-content-slot +test-snapd-content-plug:shared-content-plug'
echo "The plug side auto-connects when content is installed"
snap install --edge test-snapd-content-slot
snap install --edge test-snapd-content-plug
snap tasks --last=install| MATCH "Mount snap \"test-snapd-content-plug\""
snap interfaces | MATCH "$CONTENT_CONNECTED_PATTERN"
# Remove the content snaps so that we can reinstall them the other way around
snap remove --purge test-snapd-content-plug
snap remove --purge test-snapd-content-slot
echo "The slot side auto-connects when content snap is installed"
snap install --edge test-snapd-content-plug
snap install --edge test-snapd-content-slot
snap interfaces | MATCH "$CONTENT_CONNECTED_PATTERN"
|