From 9ab8693839bb4697a8a2d998aaf615b65e53d874 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 19 Jun 2020 14:14:57 -0700 Subject: [PATCH] WIP: add Clevis test Signed-off-by: Adam Williamson --- templates.fif.json | 13 +++++++++++++ tests/iot_clevis.pm | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/iot_clevis.pm diff --git a/templates.fif.json b/templates.fif.json index 0601d507..01437f5b 100644 --- a/templates.fif.json +++ b/templates.fif.json @@ -1553,6 +1553,19 @@ "ROOT_PASSWORD": "weakpassword" } }, + "iot_clevis": { + "profiles": { + "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, + "fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 20 + }, + "settings": { + "ENCRYPT_PASSWORD": "weakpassword", + "POSTINSTALL": "iot_clevis", + "QEMUTPM": "instance", + "ROOT_PASSWORD": "weakpassword", + "WORKER_CLASS": "tpm" + } + }, "iot_greenboot": { "profiles": { "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, diff --git a/tests/iot_clevis.pm b/tests/iot_clevis.pm new file mode 100644 index 00000000..3f2295e9 --- /dev/null +++ b/tests/iot_clevis.pm @@ -0,0 +1,32 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +sub run { + my $self = shift; + # switch to TTY3 for both, graphical and console tests + $self->root_console(tty=>3); + # Verify decryption is working via TPM2 + assert_script_run "echo foo | clevis encrypt tpm2 '{}' | clevis decrypt"; + # Get the UUID of the encrypted device + assert_script_run 'UUID=$(lsblk | grep luks | sed "s/^.*luks-//" | cut -d" " -f1)'; + assert_script_run 'DEV=$(blkid --uuid $UUID)'; + # Check encryption details of the device + assert_script_run 'cryptsetup luksDump $DEV > /tmp/cryptsetup.log'; + upload_logs '/tmp/cryptsetup.log'; + # Setup Clevis to decrypt via TPM2 on boot + assert_script_run 'clevis luks bind -f -k- -d $DEV tpm2 "{}" <<< ' . get_var("ENCRYPT_PASSWORD"); + # Reboot the system and see if it is booted without user intervention + script_run "reboot", 0; + boot_to_login_screen; +} + + +sub test_flags { + return { fatal => 1 }; +} + +1; + +# vim: set sw=4 et: