2020-04-04 19:06:49 -03:00
|
|
|
summary: Run a smoke test on UC20 with encryption enabled
|
2020-03-23 14:43:45 -03:00
|
|
|
|
2021-03-04 10:35:57 -03:00
|
|
|
details: |
|
2020-04-16 15:01:37 -03:00
|
|
|
This test checks basic snapd commands on UC20 with secure boot and encryption enabled
|
2020-03-23 14:43:45 -03:00
|
|
|
|
2023-05-09 04:21:16 -03:00
|
|
|
systems: [ubuntu-20.04-64, ubuntu-20.04-arm-64]
|
2021-04-08 18:01:32 -03:00
|
|
|
|
2020-03-23 14:43:45 -03:00
|
|
|
execute: |
|
2021-03-04 13:45:58 -03:00
|
|
|
echo "Wait for the system to be seeded first"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "sudo snap wait system seed.loaded"
|
2020-06-24 05:19:14 -05:00
|
|
|
|
2022-05-10 13:55:25 +02:00
|
|
|
echo "Wait for device initialisation to be done"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "retry --wait 5 -n 10 sh -c 'snap changes | MATCH \"Done.*Initialize device\"'"
|
2022-05-10 13:55:25 +02:00
|
|
|
|
2020-04-16 14:25:19 -03:00
|
|
|
echo "Ensure 'snap install' works"
|
|
|
|
|
# The install command could cause a ssh break, so || true is used
|
|
|
|
|
# and then we check the installation was completed successfully
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "sudo snap install test-snapd-sh" || true
|
2020-04-16 14:25:19 -03:00
|
|
|
|
2020-04-16 15:01:37 -03:00
|
|
|
echo "Ensure 'snap list' works and test-snapd-sh snap is installed"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "snap list" | MATCH test-snapd-sh
|
2020-04-16 14:25:19 -03:00
|
|
|
|
|
|
|
|
echo "Ensure 'snap find' works"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "snap find test-snapd-sh" | MATCH ^test-snapd-sh
|
2020-04-16 14:25:19 -03:00
|
|
|
|
|
|
|
|
echo "Ensure 'snap info' works"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "snap info test-snapd-sh" | MATCH '^name:\ +test-snapd-sh'
|
2020-04-16 14:25:19 -03:00
|
|
|
|
|
|
|
|
echo "Ensure 'snap remove' works"
|
|
|
|
|
# The install command could cause a ssh break, so || true is used
|
|
|
|
|
# and then we check the removal was completed successfully
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "sudo snap remove test-snapd-sh" || true
|
2020-04-16 14:25:19 -03:00
|
|
|
|
2020-04-16 15:01:37 -03:00
|
|
|
echo "Ensure 'snap list' works and test-snapd-sh snap is removed"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "! snap list test-snapd-sh"
|
2020-11-17 09:50:02 +01:00
|
|
|
|
2022-05-10 13:55:25 +02:00
|
|
|
echo "Ensure that recovery keys are not present in fresh install"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "test ! -f /var/lib/snapd/device/fde/recovery.key"
|
|
|
|
|
remote.exec "test ! -f /var/lib/snapd/device/fde/reinstall.key"
|
2022-05-10 13:55:25 +02:00
|
|
|
|
2023-05-09 04:21:16 -03:00
|
|
|
if os.query is-arm; then
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2022-05-10 13:55:25 +02:00
|
|
|
# single key for ubuntu-data and ubuntu-save
|
2022-09-13 17:14:55 -03:00
|
|
|
test "$(remote.exec "sudo cryptsetup luksDump /dev/vda4 |grep Key:" | wc -l)" = "1"
|
|
|
|
|
test "$(remote.exec "sudo cryptsetup luksDump /dev/vda5 |grep Key:" | wc -l)" = "1"
|
2022-05-10 13:55:25 +02:00
|
|
|
|
|
|
|
|
echo "Ensure 'snap debug show-keys' works as root"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "sudo snap recovery --show-keys" > show-keys.out
|
2022-05-10 13:55:25 +02:00
|
|
|
MATCH 'recovery:\s+[0-9]{5}-[0-9]{5}-[0-9]{5}-[0-9]{5}-[0-9]{5}-[0-9]{5}-[0-9]{5}-[0-9]{5}' < show-keys.out
|
|
|
|
|
# reinstall key is not generated anymore
|
|
|
|
|
# show-keys should be idempotent, so let's call it multiple times
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "sudo snap recovery --show-keys" > show-keys-again.out
|
2022-05-10 13:55:25 +02:00
|
|
|
# outputs are identical
|
|
|
|
|
diff -u show-keys.out show-keys-again.out
|
|
|
|
|
|
|
|
|
|
# key files are present
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "test -f /var/lib/snapd/device/fde/recovery.key"
|
|
|
|
|
remote.exec "test ! -f /var/lib/snapd/device/fde/reinstall.key"
|
2022-05-10 13:55:25 +02:00
|
|
|
# and each partition has 2 keys now
|
2022-09-13 17:14:55 -03:00
|
|
|
test "$(remote.exec "sudo cryptsetup luksDump /dev/vda4 |grep Key:" | wc -l)" = "2"
|
|
|
|
|
test "$(remote.exec "sudo cryptsetup luksDump /dev/vda5 |grep Key:" | wc -l)" = "2"
|
2022-04-28 15:45:44 +02:00
|
|
|
|
2020-10-23 18:45:14 +02:00
|
|
|
echo "But not as user (normal file permissions prevent this)"
|
2022-09-13 17:14:55 -03:00
|
|
|
if remote.exec "snap recovery --show-keys"; then
|
2022-05-10 13:55:25 +02:00
|
|
|
echo "snap recovery --show-keys should not work as a user"
|
2020-10-23 18:45:14 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2020-12-02 21:03:55 +01:00
|
|
|
|
2022-05-10 13:55:25 +02:00
|
|
|
# the remove API isn't exposed by snap recovery yet
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "sudo snap install --devmode --edge test-snapd-curl"
|
|
|
|
|
remote.exec "sudo test-snapd-curl.curl --unix-socket /run/snapd.socket -D- -d '{\"action\":\"remove\"}' http://localhost/v2/system-recovery-keys"
|
2022-05-10 13:55:25 +02:00
|
|
|
|
|
|
|
|
# keys were removed
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "test ! -f /var/lib/snapd/device/fde/recovery.key"
|
|
|
|
|
remote.exec "test ! -f /var/lib/snapd/device/fde/reinstall.key"
|
2022-05-10 13:55:25 +02:00
|
|
|
# back to having just one key
|
2022-09-13 17:14:55 -03:00
|
|
|
test "$(remote.exec "sudo cryptsetup luksDump /dev/vda4 |grep Key:" | wc -l)" = "1"
|
|
|
|
|
test "$(remote.exec "sudo cryptsetup luksDump /dev/vda5 |grep Key:" | wc -l)" = "1"
|
2020-12-02 21:03:55 +01:00
|
|
|
|
|
|
|
|
echo "Check that the serial backed up to save is as expected"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec 'cat /var/lib/snapd/save/device/asserts-v0/serial/'"$(tests.nested get model-authority)"'/pc/*/active' >serial.saved
|
|
|
|
|
remote.exec snap model --serial --assertion >serial
|
2020-12-02 21:03:55 +01:00
|
|
|
cmp serial serial.saved
|
2021-01-07 19:58:43 +01:00
|
|
|
|
2021-03-04 13:45:58 -03:00
|
|
|
echo "Check that we go the install log after the transition to run mode"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "test -e /var/log/install-mode.log.gz"
|
2021-03-04 13:45:58 -03:00
|
|
|
|
|
|
|
|
echo "Transparently verify that the format is gzip"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "zcat /var/log/install-mode.log.gz" | MATCH 'installing a new system'
|
2021-07-13 22:41:32 +02:00
|
|
|
|
|
|
|
|
echo "Check that we go the timings after the transition to run mode"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "test -e /var/log/install-timings.txt.gz"
|
|
|
|
|
remote.exec "zcat /var/log/install-timings.txt.gz" > install-timings.txt
|
2021-07-13 22:41:32 +02:00
|
|
|
MATCH "Install the system" < install-timings.txt
|
|
|
|
|
MATCH "^seed" < install-timings.txt
|
|
|
|
|
MATCH "Mark system seeded" < install-timings.txt
|
|
|
|
|
MATCH "Setup system for run mode" < install-timings.txt
|
2021-08-05 10:01:12 +02:00
|
|
|
MATCH "ensure=install-system" < install-timings.txt
|
2022-05-23 15:25:17 +02:00
|
|
|
|
|
|
|
|
echo "Check seeding info"
|
2022-09-13 17:14:55 -03:00
|
|
|
remote.exec "snap debug seeding" | MATCH "^seeded: +true"
|
|
|
|
|
remote.exec "snap debug seeding" | MATCH "^preseeded: +false"
|