@@ -754,6 +754,88 @@ try:
754754
755755 verify_config ()
756756
757+ # Shutdown VM
758+ shutdownVM (c , log , 'Shutdown VM for non-TPM backed test' )
759+
760+ # Clear swtpm
761+ from glob import glob
762+ for f in glob (f'{ tpm_folder } /*' ):
763+ os .remove (f )
764+
765+ # Shutdown kills swtpm
766+ tpm_process .join ()
767+ tpm_process .close ()
768+ tpm_process = None
769+
770+ # Booting back into VM
771+ log .info ('Booting system without TPM' )
772+ cmd = get_qemu_cmd (qemu_name , args .uefi , args .disk , raid = diskname_raid , tpm = False , vnc_enabled = args .vnc )
773+ log .debug (f'Executing command: { cmd } ' )
774+ c = pexpect .spawn (cmd , logfile = stl )
775+
776+ try :
777+ c .expect ('The highlighted entry will be executed automatically in' , timeout = 10 )
778+ c .sendline ('' )
779+ except pexpect .TIMEOUT :
780+ log .warning ('Did not find GRUB countdown window, ignoring' )
781+
782+ loginVM (c , log )
783+
784+ # New recovery key
785+ test_recovery_key = '' .join (choices (string .ascii_uppercase + string .digits , k = 32 ))
786+
787+ log .info ('Encrypting config' )
788+ c .sendline ('encryption enable' )
789+ c .expect ('Are you sure you want to proceed\?.*' )
790+ c .sendline ('y' )
791+ c .expect ('Enter key: ' )
792+ c .sendline (test_recovery_key )
793+ c .expect ('Enter size of encrypted config partition.*' , timeout = 30 )
794+ c .sendline ('32' )
795+ c .expect ('Encrypted config volume has been enabled' , timeout = tpm_timeout )
796+ c .expect ('Backup the key in a safe place!' )
797+ c .expect (f'Key: { test_recovery_key } ' )
798+ c .expect (op_mode_prompt )
799+
800+ verify_mount ()
801+
802+ shutdownVM (c , log , 'Shutdown VM for non-TPM config load' )
803+
804+ # Booting back into VM
805+ log .info ('Booting system without TPM' )
806+ cmd = get_qemu_cmd (qemu_name , args .uefi , args .disk , raid = diskname_raid , tpm = False , vnc_enabled = args .vnc )
807+ log .debug (f'Executing command: { cmd } ' )
808+ c = pexpect .spawn (cmd , logfile = stl )
809+
810+ try :
811+ c .expect ('The highlighted entry will be executed automatically in' , timeout = 10 )
812+ c .sendline ('' )
813+ except pexpect .TIMEOUT :
814+ log .warning ('Did not find GRUB countdown window, ignoring' )
815+
816+ c .expect ('.*Encrypted config volume has not been mounted' , timeout = 120 )
817+
818+ loginVM (c , log )
819+
820+ # Test loading config with recovery key
821+ c .sendline ('encryption load' )
822+ c .expect ('Enter key: ' )
823+ c .sendline (test_recovery_key )
824+ c .expect ('Encrypted config volume has been mounted' , timeout = 120 )
825+ c .expect (op_mode_prompt )
826+
827+ verify_mount ()
828+
829+ log .info ('Loading encrypted config.boot' )
830+ c .sendline ('configure' )
831+ c .expect (cfg_mode_prompt )
832+ c .sendline ('load /config/config.boot' )
833+ c .expect (cfg_mode_prompt )
834+ c .sendline ('commit' )
835+ c .expect (cfg_mode_prompt )
836+ c .sendline ('exit' )
837+ c .expect (op_mode_prompt )
838+
757839 elif args .raid :
758840 # Verify RAID subsystem - by deleting a disk and re-create the array
759841 # from scratch
0 commit comments