File: task.yaml

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (58 lines) | stat: -rw-r--r-- 1,737 bytes parent folder | download | duplicates (2)
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
summary: Ensure network interface works.

details: |
    The network interface allows a snap to access the network as a client.

    A snap which defines the network plug must be shown in the interfaces list.
    The plug must 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 network
    services.

# amazon: uses nmap-netcat
# ubuntu-14.04: systemd-run not supported
systems: [-fedora-*, -opensuse-*, -amazon-*, -centos-*, -ubuntu-14.04*]

environment:
    SNAP_NAME: network-consumer
    PORT: 8081
    SERVICE_NAME: "test-service"

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

    echo "And a service is listening"
    # 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 connected by default"
    snap interfaces -i network | MATCH ":network .*$SNAP_NAME"

    echo "When the plug is disconnected"
    snap disconnect "$SNAP_NAME:network"

    echo "Then the plug can be connected again"
    snap connect "$SNAP_NAME:network"

    echo "Then the snap is able to access a network service"
    network-consumer http://127.0.0.1:"$PORT" | grep -Pqz 'ok\n'

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

    echo "When the plug is disconnected"
    snap disconnect "$SNAP_NAME:network"

    echo "Then snap can't access a network service"
    if network-consumer "http://127.0.0.1:$PORT"; then
        echo "Network shouldn't be accessible"
        exit 1
    fi