File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (56 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download | duplicates (3)
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
summary: Ensure that the network-observe interface works

details: |
    The network-observe interface allows a snap to query the network status
    information, using a dedicated unprivileged interface.

    A snap which defines the network-observe plug must be shown in the
    interfaces list. The plug must not be auto-connected on install and, as
    usual, must be able to be reconnected.

    A snap declaring a plug on this interface must be able to access read the
    network status, the test sets up a network service to establish a known
    state in the network to be queried.

# ubuntu-14.04: systemd-run not supported
systems: [-fedora-*, -opensuse-*, -ubuntu-14.04*]

environment:
    PORT: 8081
    SERVICE_NAME: "test-service"

prepare: |
    echo "Given a snap declaring a plug on the network-observe interface is installed"
    "$TESTSTOOLS"/snaps-state install-local network-observe-consumer

    echo "And a network service is up"
    # shellcheck source=tests/lib/network.sh
    . "$TESTSLIB"/network.sh
    make_network_service "$SERVICE_NAME" "$PORT"

restore: |
    systemctl stop "$SERVICE_NAME"

execute: |
    echo "The interface is disconnected by default"
    snap interfaces -i network-observe | MATCH -- '^- +network-observe-consumer:network-observe'

    echo "When the plug is connected"
    snap connect network-observe-consumer:network-observe

    echo "Then the snap command can query network status information"
    network-observe-consumer | MATCH "LISTEN.*:$PORT"

    if [ "$(snap debug confinement)" = partial ] ; then
        exit 0
    fi

    echo "When the plug is disconnected"
    snap disconnect network-observe-consumer:network-observe

    echo "Then the snap command can not query network status information"
    if network-observe-consumer 2> net-query.output; then
        echo "Expected error caling command with disconnected plug"
    fi
    MATCH "Permission denied" < net-query.output