From aacd01ea8b4eb617853938be99a8268ead8a74bf Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 8 Jul 2016 08:56:57 -0700 Subject: [PATCH] add encrypted workstation upgrade tests (current and previous) Summary: This requires us to handle decryption each time we reboot in the upgrade process, so factor that little block out into the base class so we don't have to keep pasting it. It's also a bit tricky to integrate into the 'catch a boot loop' code we have to deal with #1349721, but I think this should work. There is a matching openqa_fedora_tools diff to generate the disk image. Test Plan: Run the tests, check that they work, run the other upgrade and encrypted install tests and check they still work properly too. Reviewers: garretraziel Reviewed By: garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D922 --- lib/fedorabase.pm | 9 ++++ .../boot_enter_passphrase-20160705.json | 15 ++++++ .../boot_enter_passphrase-20160705.png | Bin 0 -> 1654 bytes .../boot_enter_passphrase-graphical.json | 15 ++++++ .../boot_enter_passphrase-graphical.png | Bin 0 -> 5835 bytes templates | 48 ++++++++++++++++++ tests/_graphical_wait_login.pm | 4 +- tests/disk_guided_encrypted_postinstall.pm | 9 ++-- tests/upgrade_preinstall.pm | 9 ++++ tests/upgrade_run.pm | 17 ++++++- 10 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 needles/console/boot_enter_passphrase-20160705.json create mode 100644 needles/console/boot_enter_passphrase-20160705.png create mode 100644 needles/console/boot_enter_passphrase-graphical.json create mode 100644 needles/console/boot_enter_passphrase-graphical.png diff --git a/lib/fedorabase.pm b/lib/fedorabase.pm index 029ecf30..a5a07971 100644 --- a/lib/fedorabase.pm +++ b/lib/fedorabase.pm @@ -224,6 +224,15 @@ sub get_host_dns { return @forwards; } +sub boot_decrypt { + # decrypt storage during boot; arg is timeout (in seconds) + my $self = shift; + my $timeout = shift || 60; + assert_screen "boot_enter_passphrase", $timeout; # + type_string get_var("ENCRYPT_PASSWORD"); + send_key "ret"; +} + 1; # vim: set sw=4 et: diff --git a/needles/console/boot_enter_passphrase-20160705.json b/needles/console/boot_enter_passphrase-20160705.json new file mode 100644 index 00000000..1bb61338 --- /dev/null +++ b/needles/console/boot_enter_passphrase-20160705.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "width": 207, + "xpos": 0, + "ypos": 169, + "type": "match", + "height": 31 + } + ], + "tags": [ + "boot_enter_passphrase" + ], + "properties": [] +} \ No newline at end of file diff --git a/needles/console/boot_enter_passphrase-20160705.png b/needles/console/boot_enter_passphrase-20160705.png new file mode 100644 index 0000000000000000000000000000000000000000..cfa77e7362f4b2a98d957cb68f11bd8d68239228 GIT binary patch literal 1654 zcmeAS@N?(olHy`uVBq!ia0y~yU;#3j8JL)X)bT5S=K(3s0G|+7AYD;W@&EsS=GJ7O z9Gixxi(^Q|t+&^G`=m8R7!pFf{S3WBzMri1iu)yUVztonIo}VIEx&9#EAohE|EH^q zq=Wy|9XPD_wEjoU?@oV4pm9SV{CLT*IRCFR|MBB~uRp$AzT(dF`(K}5ye6so?T?LD z?G;J)m(|aXTs|$?X&4=8sl8G5anJPXJ-5OhPPAOQWjf=QFgu2v`3!r`XP>tcPB8uG zGv%$+(`uewdB^|dD6GhS=CeF(`)Nb(>+Y8)t_akQbJMzY_E4bOZOzB48UK7`3$SC{ zv4^q8yx|wa3dRY#-^zWLUlTO4XPCko5YI8edhMIN^NJVW`z80gc=xdlw|35*xcR$B zjB>jDE6eg6?XPQgZZn-`TJ&p9&Dx1Gtp96NGq}u*xH4(0nuB-KoV?c;-<93bWztNa zcX=PH!-k%vqP%_$EB;wE*sd(r*}HXD+s&jaw+oNCyo%X)qh)K}_A@hADvK{kJ!ivR z%Ui>E=h~s~9&gg8%w&Flv&i9F-0d%?k0kr$`jxv)D%|;G-HXDeV}em@-?_W>t@w9H zVghr&NAZ?T{W3?GPFz%TSeLi%yH#&>-f5oL+_?|uc=ddba5rIe6YG2Wp?*E2VHeVDtPtdxR6_K9g|j zu~+)V)bTP+M!URW=c}D%&%ZNNI__bQNX(IaUA5kfaZ|U?lU?VlpG4U1XFM|PMe)yi zMu(UG84BVjvj*H!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XM@fLq*L#VG;i^7kdlVb#>TZx_&5Z3biO{#p zZGT$pTB!4FZpvab`o4V6ebJ!-E7i=Pq37SbXs@AxO97Qi?Z<}CK1)zCH8t(OzD;4k zu`Y0#%ihKLPHYOifuzlrxrnRvOc$Kc%cG zH&Ylj)Kz>2G|yh8rvmD0#)0In26*$BM>C7kU9{zYp7SVn0C>(~cBc%GAT2Gey6smz zww=XZI)^X2B1JNHK1vAaJ+D7dgE~IHt5F6I_Krqq)QTC{N@LFLp^b~7y_RIdjPFH8 z`n@)vcD$e}4}ZDh`7fc27bb~|te7_)rN*eKvy`5>h*DaE34iU~OT7*Oa0g($@ht(W zL@B3=W)$D`?jIv1TU@UTe&$6a=IHaMF5JMx_a+42zD5NAhBNN^Ot z>pYOB>Q7Wf37#qWua}ioMMictP&R`VesXupL}wv`j3etUt%Hk@yoabBr$ZSWUB6hlB3%K!fi=X3<|iZNSPF&H^A3$<=ZuN$I))n;I-Qi2xvZb0?>d5 z15gLSJK@LN)zR=Y5ir1#`WR<5Fb(AXuYW$Q?7XrC4M%z}^J>47;P`5Aq|XS`D(HU) zTZFRlqqxVzb^Z|?4gYwLJ~jC52dP-uf`@(n2>Yk=|AhmrpkZoOCV6Gc%5A)|MGa2& zo_6mEgNCQAoOxx-hcmyI@FRr(%rN0$Mpl6d4bT6?JmKLS|65FMsRC7bc~ol2De*7i O=;q(p94 { name => "upgrade_kde_64bit" }, }, + { + machine => { name => "64bit" }, + prio => 30, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "universal", + version => "*", + }, + test_suite => { name => "upgrade_desktop_encrypted_64bit" }, + }, { machine => { name => "64bit" }, prio => 50, @@ -853,6 +864,17 @@ }, test_suite => { name => "upgrade_2_kde_64bit" }, }, + { + machine => { name => "64bit" }, + prio => 50, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "universal", + version => "*", + }, + test_suite => { name => "upgrade_2_desktop_encrypted_64bit" }, + }, { machine => { name => "64bit" }, prio => 40, @@ -1577,6 +1599,19 @@ { key => "DESKTOP", value => "kde" }, ], }, + { + name => "upgrade_desktop_encrypted_64bit", + settings => [ + { key => "ROOT_PASSWORD", value => "weakpassword" }, + { key => "USER_LOGIN", value => "test" }, + { key => "USER_PASSWORD", value => "weakpassword" }, + { key => "BOOTFROM", value => "c" }, + { key => "HDD_1", value => "disk_f%CURRREL%_desktopencrypt_x86_64.img" }, + { key => "UPGRADE", value => "1" }, + { key => "DESKTOP", value => "gnome" }, + { key => "ENCRYPT_PASSWORD", value => "weakpassword" }, + ], + }, { name => "upgrade_2_minimal_64bit", settings => [ @@ -1623,6 +1658,19 @@ { key => "DESKTOP", value => "kde" }, ], }, + { + name => "upgrade_2_desktop_encrypted_64bit", + settings => [ + { key => "ROOT_PASSWORD", value => "weakpassword" }, + { key => "USER_LOGIN", value => "test" }, + { key => "USER_PASSWORD", value => "weakpassword" }, + { key => "BOOTFROM", value => "c" }, + { key => "HDD_1", value => "disk_f%PREVREL%_desktopencrypt_x86_64.img" }, + { key => "UPGRADE", value => "1" }, + { key => "DESKTOP", value => "gnome" }, + { key => "ENCRYPT_PASSWORD", value => "weakpassword" }, + ], + }, { name => "upgrade_desktop_32bit", settings => [ diff --git a/tests/_graphical_wait_login.pm b/tests/_graphical_wait_login.pm index d94ac133..fab943e8 100644 --- a/tests/_graphical_wait_login.pm +++ b/tests/_graphical_wait_login.pm @@ -5,9 +5,11 @@ use testapi; sub run { # If KICKSTART is set, then the wait_time needs to consider the # install time. if UPGRADE, we have to wait for the entire upgrade + # unless ENCRYPT_PASSWORD is set (in which case the postinstall + # test does the waiting) my $wait_time = 300; $wait_time = 1800 if (get_var("KICKSTART")); - $wait_time = 6000 if (get_var("UPGRADE")); + $wait_time = 6000 if (get_var("UPGRADE") && !get_var("ENCRYPT_PASSWORD")); # Wait for the login screen assert_screen "graphical_login", $wait_time; diff --git a/tests/disk_guided_encrypted_postinstall.pm b/tests/disk_guided_encrypted_postinstall.pm index 29a76274..0c8cc70b 100644 --- a/tests/disk_guided_encrypted_postinstall.pm +++ b/tests/disk_guided_encrypted_postinstall.pm @@ -3,10 +3,13 @@ use strict; use testapi; sub run { + my $self = shift; + my $wait_time = 300; + # if we're running an upgrade, we must wait for the entire upgrade + # process to run + $wait_time = 6000 if (get_var("UPGRADE")); # decrypt disks during boot - assert_screen "boot_enter_passphrase", 300; # - type_string get_var("ENCRYPT_PASSWORD"); - send_key "ret"; + $self->boot_decrypt($wait_time); } sub test_flags { diff --git a/tests/upgrade_preinstall.pm b/tests/upgrade_preinstall.pm index a86926e9..91936753 100644 --- a/tests/upgrade_preinstall.pm +++ b/tests/upgrade_preinstall.pm @@ -4,6 +4,10 @@ use testapi; sub run { my $self = shift; + # decrypt disks during boot if necessary + if (get_var("ENCRYPT_PASSWORD")) { + $self->boot_decrypt(60); + } # wait for either graphical or text login if (get_var('DESKTOP')) { @@ -22,6 +26,11 @@ sub run { script_run "reboot"; + # decrypt if necessary + if (get_var("ENCRYPT_PASSWORD")) { + $self->boot_decrypt(60); + } + if (get_var('DESKTOP')) { $self->boot_to_login_screen("graphical_login", 30, 90); # DM takes time to load } else { diff --git a/tests/upgrade_run.pm b/tests/upgrade_run.pm index 7ac0b3cf..62a2bc9d 100644 --- a/tests/upgrade_run.pm +++ b/tests/upgrade_run.pm @@ -23,16 +23,31 @@ sub run { script_run "dnf system-upgrade reboot"; # fail immediately if we see a DNF error message - die "DNF reported failure" if (check_screen "upgrade_fail"); + die "DNF reported failure" if (check_screen "upgrade_fail", 15); + if (get_var("ENCRYPT_PASSWORD")) { + $self->boot_decrypt(60); + } # try and catch if we hit RHBZ #1349721 and work around it if (check_screen "bootloader") { # wait some secs for the screen to clear sleep 10; + if (get_var("ENCRYPT_PASSWORD")) { + $self->boot_decrypt(60); + } if (check_screen "bootloader") { record_soft_failure; $self->do_bootloader(postinstall=>1, params=>"enforcing=0"); + if (get_var("ENCRYPT_PASSWORD")) { + $self->boot_decrypt(60); + } } } + # in encrypted case we need to wait a bit so postinstall test + # doesn't bogus match on the encryption prompt we just completed + # before it disappears from view + if (get_var("ENCRYPT_PASSWORD")) { + sleep 5; + } }