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
|
summary: Test the customized device registration through a gadget hook
details: |
Check that device initialisation and registration can be customized
with the prepare-device gadget hook
# TODO:UC20: enable for UC20, it assumes /var/lib/snapd/seed/assertions/model
# which we don't have currently
systems: [ubuntu-core-1*]
prepare: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
systemctl stop snapd.service snapd.socket
clean_snapd_lib
# Configure the pc snap
unpack_pc_snap
mkdir -p squashfs-root/meta/hooks
cp prepare-device squashfs-root/meta/hooks
pack_pc_snap
# Generic setup for test account
prepare_core_model
# shellcheck disable=SC2119
prepare_and_manip_seed
prepare_test_account developer1
prepare_test_model developer1-pc
prepare_testrootorg_store
# start fake device svc
systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029
# kick first boot again
systemctl start snapd.service snapd.socket
# wait for first boot to be done
wait_for_first_boot_change
restore: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
systemctl stop snapd.service snapd.socket fakedevicesvc
clean_snapd_lib
# Restore pc snap configuration
restore_pc_snap
# Generic restore for test account
restore_updated_seed
restore_test_account developer1
restore_test_model developer1-pc
restore_testrootorg_store
restore_core_model
# kick first boot again
systemctl start snapd.service snapd.socket
# wait for first boot to be done
wait_for_first_boot_change
execute: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
echo "We have a model assertion"
snap model --verbose|MATCH "model:\s* my-model"
echo "Wait for device initialisation to be done"
wait_for_device_initialized_change
echo "Check we have a serial"
snap model --serial --assertion|MATCH "authority-id: developer1"
snap model --serial --assertion|MATCH "brand-id: developer1"
snap model --serial --assertion|MATCH "model: my-model"
snap model --serial --assertion|MATCH "serial: 7777"
|