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 (67 lines) | stat: -rw-r--r-- 2,336 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
summary: Check that `snap auto-import` works as expected

details: |
    The auto-import command searches available mounted devices looking for
    assertions that are signed by trusted authorities, and potentially
    performs system changes based on them.

    Assertions to be imported must be made available in the auto-import.assert file
    in the root of the filesystem.

    This test verifies that if snapd is not running, the `snap auto-import` command
    spools assertions into /run/snapd/auto-import, and then when snapd is started
    `snap auto-import` command reads the assertions from the auto-import dir.

systems: [ubuntu-core-*-64]

prepare: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi
    echo "Ensure the testrootorg-store.account-key is not already added"
    output=$(snap known account-key | grep -c "name: test-store" || true)
    if [ "$output" != "0" ]; then
            echo " testrootorg-store.account-key is already added"
            exit 1
    fi
    echo "Create a ramdisk with the testrootorg-store.account-key assertion"
    #shellcheck source=tests/lib/ramdisk.sh
    . "$TESTSLIB/ramdisk.sh"
    setup_ramdisk
    mkfs.ext3 /dev/ram0
    mount /dev/ram0 /mnt
    cp "$TESTSLIB"/assertions/testrootorg-store.account-key /mnt/auto-import.assert
    sync

restore: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi
    rm -rf /var/lib/snapd/auto-import/*

execute: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi
    echo "Simulate a not running snapd (happens on e.g. early boot)"
    systemctl stop snapd.service snapd.socket

    echo "'snap auto-import' spooled assertions if it can not talk to snapd"
    snap auto-import
    ls /run/snapd/auto-import
    umount /mnt
    systemctl start snapd.service snapd.socket

    echo "'snap auto-import' reads from the auto-import dir"
    snap auto-import
    snap known account-key | MATCH "name: test-store"

    nr=$(find /run/snapd/auto-import -maxdepth 1 -mindepth 1 |wc -l)
    if [ "$nr" != "0" ]; then
        echo "Expected an empty /run/snapd/auto-import got:"
        ls /run/snapd/auto-import
        exit 1
    fi