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 (64 lines) | stat: -rw-r--r-- 2,846 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
summary: Ensure that the DBus interface works

details: |
    The DBus interface allows owning a name on DBus public bus.

    The test uses two snaps, a provider declaring a DBus slot and a consumer
    with a plug with the same attributes as the slot. The provider requests
    a DBus name and, when the plug is connected, the consumer can call the
    method exposed by the provider.

systems:
    - -ubuntu-14.04-*  # no tests.session support
    - -ubuntu-core-*  # dbus interface disallows unconfined access on core,
                      # in addition, up until core20 session bus was not supported
    - -amazon-linux-2-* # session bus is not supported

prepare: |
    echo "Give a snap declaring a dbus slot in installed"
    snap install --beta test-snapd-dbus-provider

    echo "And a snap declaring a matching dbus plug is installed"
    snap install --beta test-snapd-dbus-consumer

    tests.session -u test prepare

    # XXX: The pair of snaps in this test communicate over the session bus but
    # are normal applications that require starting. Instead of using
    # run-in-the-background hack, use systemd-run to start a session service
    # wrapping the application. This ensures it has access to the session bus
    # and that if it forks off any unexpected processes, those are cleaned up
    # on shutdown.
    echo "And the provider dbus loop is started"
    tests.session -u test exec systemd-run --user --unit dbus-provider.service test-snapd-dbus-provider.provider

restore: |
    tests.session -u test exec systemctl --user stop dbus-provider.service
    tests.session -u test restore

execute: |
    echo "Then the dbus name is properly reserved by the provider and the method is accessible"
    retry -n 5 --wait 1 sh -c 'tests.session -u test exec dbus-send --print-reply --dest=com.dbustest.HelloWorld /com/dbustest/HelloWorld com.dbustest.HelloWorld.SayHello | MATCH "hello world"'

    echo "And plug is disconnected by default"
    snap interfaces -i dbus | MATCH '^- +test-snapd-dbus-consumer:dbus-test'

    echo "When the plug is connected"
    snap connect test-snapd-dbus-consumer:dbus-test test-snapd-dbus-provider:dbus-test

    echo "Then the consumer is able to call the provided method"
    tests.session -u test exec test-snapd-dbus-consumer.dbus-consumer | MATCH "hello world"

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

    echo "When the plug is disconnected"
    snap disconnect test-snapd-dbus-consumer:dbus-test test-snapd-dbus-provider:dbus-test

    echo "The consumer is not able to access the provided method"
    if tests.session -u test exec test-snapd-dbus-consumer.dbus-consumer 2> call.error; then
        echo "Expected permission error calling dbus method with disconnected plug"
        exit 1
    fi
    MATCH "Permission denied" < call.error