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 (98 lines) | stat: -rw-r--r-- 3,319 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
summary: Ensure that the locale-control interface works.

details: |
    The locale-control interface allows a snap to access the locale
    configuration.

    A snap which defines the locale-control 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 the
    /etc/default/locale file both for reading and writing. This path doesn't
    exist on the excluded distributions.

systems: [-fedora-*, -opensuse-*, -arch-*, -amazon-*, -centos-*]

prepare: |
    if os.query is-core; then
        if snap interfaces | MATCH locale-control; then
            echo "locale-control should be only available on core"
            exit 1
        else
            exit 0
        fi
    fi

    echo "Given a snap declaring a plug on the locale-control interface is installed"
    "$TESTSTOOLS"/snaps-state install-local locale-control-consumer

    "$TESTSTOOLS"/fs-state mock-file /etc/default/locale
    cat > /etc/default/locale <<EOF
    LANG="$LANG"
    LANGUAGE="$LANGUAGE"
    EOF

restore: |
    if os.query is-core; then
        if snap interfaces | MATCH locale-control; then
            echo "locale-control should be only available on core"
            exit 1
        else
            exit 0
        fi
    fi

    "$TESTSTOOLS"/fs-state restore-file /etc/default/locale

execute: |
    if os.query is-core; then
        if snap interfaces | MATCH locale-control; then
            echo "locale-control should be only available on core"
            exit 1
        else
            exit 0
        fi
    fi

    echo "The interface is not connected by default"
    snap interfaces -i locale-control | MATCH '^- +locale-control-consumer:locale-control'

    echo "When the plug is connected"
    snap connect locale-control-consumer:locale-control

    echo "Then the snap is able to read the locale configuration"
    test "$(su -l -c 'locale-control-consumer.get LANG' test)" = "$LANG"

    if [ "$(snap debug confinement)" = strict ] ; then
        echo "When the plug is disconnected"
        snap disconnect locale-control-consumer:locale-control

        echo "Then the snap is not able to read the locale configuration"
        if su -l -c "locale-control-consumer.get LANG" test 2> locale-read.error; then
            echo "Expected permission error accessing locale configuration with disconnected plug"
            exit 1
        fi
        grep -q "Permission denied" locale-read.error
    fi

    echo "When the plug is connected"
    snap connect locale-control-consumer:locale-control

    echo "Then the snap is able to write the locale configuration"
    locale-control-consumer.set LANG mylang
    MATCH 'LANG=\"mylang\"' < /etc/default/locale

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

    echo "When the plug is disconnected"
    snap disconnect locale-control-consumer:locale-control

    echo "Then the snap is not able to read the locale configuration"
    if locale-control-consumer.set LANG mysecondlang 2> locale-write.error; then
        echo "Expected permission error accessing locale configuration with disconnected plug"
        exit 1
    fi
    MATCH "Permission denied" < locale-write.error