diff --git a/lib/anaconda.pm b/lib/anaconda.pm index 1f0d2c8e..2d8da25b 100644 --- a/lib/anaconda.pm +++ b/lib/anaconda.pm @@ -9,7 +9,7 @@ use testapi; use utils; use bugzilla; -our @EXPORT = qw/select_disks custom_scheme_select custom_blivet_add_partition custom_blivet_format_partition custom_blivet_resize_partition custom_change_type custom_change_fs custom_change_device custom_delete_part webui_custom_start webui_custom_create_disklabel webui_custom_add_partition webui_custom_boot_partitions get_full_repo get_mirrorlist_url crash_anaconda_text report_bug_text/; +our @EXPORT = qw/select_disks custom_scheme_select custom_blivet_add_partition custom_blivet_format_partition custom_blivet_resize_partition custom_change_type custom_change_fs custom_change_device custom_delete_part webui_custom_start webui_custom_create_disklabel webui_custom_add_partition webui_custom_boot_partitions webui_create_user anaconda_create_user get_full_repo get_mirrorlist_url crash_anaconda_text report_bug_text/; sub select_disks { # Handles disk selection. Has one optional argument - number of @@ -384,6 +384,115 @@ sub webui_custom_boot_partitions { webui_custom_add_partition(size => 512, mountpoint => '/boot'); } +sub _type_user_password { + # convenience function used by anaconda_create_user, not meant + # for direct use + my $user_password = get_var("USER_PASSWORD") || "weakpassword"; + if (get_var("SWITCHED_LAYOUT")) { + # we double the password, the second time using the native + # layout, so the password has both ASCII and native characters + desktop_switch_layout "ascii", "anaconda"; + type_very_safely $user_password; + desktop_switch_layout "native", "anaconda"; + type_very_safely $user_password; + } + else { + type_very_safely $user_password; + } +} + +sub webui_create_user { + # Create a user in the WebUI interface where such screen appears, + # such as in the KDE installation. Currently, we only support + # English installations. + my %args = ( + timeout => 90, + @_ + ); + my $user_login = get_var("USER_LOGIN", "test"); + my $user_password = get_var("USER_PASSWORD", "weakpassword"); + my $geofield = get_var("USER_GECOS", $user_login); + # We click into the first field, because it seems that + # sometimes it is not focused. Then we will navigate + # between fields using the Tab key. + assert_and_click("anaconda_webui_createuser_name", timeout => $args{timeout}); + type_very_safely($geofield); + sleep(2); + send_key("tab"); + sleep(1); + type_very_safely($user_login); + sleep(2); + send_key("tab"); + sleep(1); + _type_user_password($user_password); + sleep(2); + for (1 .. 2) { + send_key("tab"); + sleep(1); + } + _type_user_password($user_password); +} + +sub anaconda_create_user { + # Create a user, in the anaconda interface. This is here because + # the same code works both during install and for initial-setup, + # which runs post-install, so we can share it. + my %args = ( + timeout => 90, + @_ + ); + # For some languages, i.e. Turkish, we want to use a complicated + # geo field to test that turkish letters will be displayed correctly + # and that the installer will be able to handle them and change them + # into the correct user name without special characters. + my $geofield = get_var("USER_GECOS"); + my $user_login = get_var("USER_LOGIN") || "test"; + unless ($geofield) { + # If geofield is not defined, let it be the same as login. + $geofield = $user_login; + } + assert_and_click("anaconda_install_user_creation", timeout => $args{timeout}); + assert_screen "anaconda_install_user_creation_screen"; + # wait out animation + wait_still_screen 2; + # We will type the $geofield as the user name. + type_very_safely $geofield; + # For Turkish, we especially want to check that correct characters + # are typed, so we will check it here. + if (get_var("LANGUAGE") eq "turkish") { + assert_screen("username_typed_correctly_turkish"); + } + send_key("tab"); + # Now set the login name. + type_very_safely($user_login); + # And fill the password stuff. + type_very_safely "\t\t\t"; + _type_user_password(); + wait_screen_change { send_key "tab"; }; + wait_still_screen 2; + _type_user_password(); + # even with all our slow typing this still *sometimes* seems to + # miss a character, so let's try again if we have a warning bar. + # But not if we're installing with a switched layout, as those + # will *always* result in a warning bar at this point (see below) + if (!get_var("SWITCHED_LAYOUT") && check_screen "anaconda_warning_bar", 3) { + wait_screen_change { send_key "shift-tab"; }; + wait_still_screen 2; + _type_user_password(); + wait_screen_change { send_key "tab"; }; + wait_still_screen 2; + _type_user_password(); + } + assert_and_click "anaconda_spoke_done"; + # since 20170105, we will get a warning here when the password + # contains non-ASCII characters. Assume only switched layouts + # produce non-ASCII characters, though this isn't strictly true + if (get_var('SWITCHED_LAYOUT') && check_screen "anaconda_warning_bar", 3) { + wait_still_screen 1; + assert_and_click "anaconda_spoke_done"; + } +} + sub get_full_repo { my ($repourl) = @_; # trivial thing we kept repeating: fill out an HTTP or HTTPS diff --git a/lib/utils.pm b/lib/utils.pm index d760fca5..bb0f4c4c 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -6,7 +6,7 @@ use base 'Exporter'; use Exporter; use lockapi; use testapi qw(is_serial_terminal :DEFAULT); -our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications desktop_launch_terminal solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login check_software_start/; +our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications desktop_launch_terminal solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login check_software_start/; # We introduce this global variable to hold the list of applications that have @@ -1015,83 +1015,6 @@ sub gnome_initial_setup { set_var("_SETUP_DONE", 1); } -sub _type_user_password { - # convenience function used by anaconda_create_user, not meant - # for direct use - my $user_password = get_var("USER_PASSWORD") || "weakpassword"; - if (get_var("SWITCHED_LAYOUT")) { - # we double the password, the second time using the native - # layout, so the password has both ASCII and native characters - desktop_switch_layout "ascii", "anaconda"; - type_very_safely $user_password; - desktop_switch_layout "native", "anaconda"; - type_very_safely $user_password; - } - else { - type_very_safely $user_password; - } -} - -sub anaconda_create_user { - # Create a user, in the anaconda interface. This is here because - # the same code works both during install and for initial-setup, - # which runs post-install, so we can share it. - my %args = ( - timeout => 90, - @_ - ); - # For some languages, i.e. Turkish, we want to use a complicated - # geo field to test that turkish letters will be displayed correctly - # and that the installer will be able to handle them and change them - # into the correct user name without special characters. - my $geofield = get_var("USER_GECOS"); - my $user_login = get_var("USER_LOGIN") || "test"; - unless ($geofield) { - # If geofield is not defined, let it be the same as login. - $geofield = $user_login; - } - assert_and_click("anaconda_install_user_creation", timeout => $args{timeout}); - assert_screen "anaconda_install_user_creation_screen"; - # wait out animation - wait_still_screen 2; - # We will type the $geofield as the user name. - type_very_safely $geofield; - # For Turkish, we especially want to check that correct characters - # are typed, so we will check it here. - if (get_var("LANGUAGE") eq "turkish") { - assert_screen("username_typed_correctly_turkish"); - } - send_key("tab"); - # Now set the login name. - type_very_safely($user_login); - # And fill the password stuff. - type_very_safely "\t\t\t"; - _type_user_password(); - wait_screen_change { send_key "tab"; }; - wait_still_screen 2; - _type_user_password(); - # even with all our slow typing this still *sometimes* seems to - # miss a character, so let's try again if we have a warning bar. - # But not if we're installing with a switched layout, as those - # will *always* result in a warning bar at this point (see below) - if (!get_var("SWITCHED_LAYOUT") && check_screen "anaconda_warning_bar", 3) { - wait_screen_change { send_key "shift-tab"; }; - wait_still_screen 2; - _type_user_password(); - wait_screen_change { send_key "tab"; }; - wait_still_screen 2; - _type_user_password(); - } - assert_and_click "anaconda_spoke_done"; - # since 20170105, we will get a warning here when the password - # contains non-ASCII characters. Assume only switched layouts - # produce non-ASCII characters, though this isn't strictly true - if (get_var('SWITCHED_LAYOUT') && check_screen "anaconda_warning_bar", 3) { - wait_still_screen 1; - assert_and_click "anaconda_spoke_done"; - } -} - sub check_desktop { # Check we're at a desktop. We do this by looking for the "apps" # menu button ("Activities" button on GNOME, kicker button on diff --git a/needles/anaconda/webui/anaconda_webui_allow_root-20250625.json b/needles/anaconda/webui/anaconda_webui_allow_root-20250625.json new file mode 100644 index 00000000..0fef5184 --- /dev/null +++ b/needles/anaconda/webui/anaconda_webui_allow_root-20250625.json @@ -0,0 +1,19 @@ +{ + "area": [ + { + "xpos": 267, + "ypos": 571, + "width": 161, + "height": 21, + "type": "match", + "click_point": { + "xpos": 14.5, + "ypos": 10.5 + } + } + ], + "properties": [], + "tags": [ + "anaconda_webui_allow_root" + ] +} \ No newline at end of file diff --git a/needles/anaconda/webui/anaconda_webui_allow_root-20250625.png b/needles/anaconda/webui/anaconda_webui_allow_root-20250625.png new file mode 100644 index 00000000..bc98ba5b Binary files /dev/null and b/needles/anaconda/webui/anaconda_webui_allow_root-20250625.png differ diff --git a/needles/anaconda/webui/anaconda_webui_createuser_name.json b/needles/anaconda/webui/anaconda_webui_createuser_name.json new file mode 100644 index 00000000..ceb899a1 --- /dev/null +++ b/needles/anaconda/webui/anaconda_webui_createuser_name.json @@ -0,0 +1,19 @@ +{ + "area": [ + { + "xpos": 269, + "ypos": 178, + "width": 241, + "height": 36, + "type": "match", + "click_point": { + "xpos": 193.5, + "ypos": 20 + } + } + ], + "properties": [], + "tags": [ + "anaconda_webui_createuser_name" + ] +} diff --git a/needles/anaconda/webui/anaconda_webui_createuser_name.png b/needles/anaconda/webui/anaconda_webui_createuser_name.png new file mode 100644 index 00000000..c0430312 Binary files /dev/null and b/needles/anaconda/webui/anaconda_webui_createuser_name.png differ diff --git a/tests/_boot_to_anaconda.pm b/tests/_boot_to_anaconda.pm index 4b1661bd..9cc6cc3a 100644 --- a/tests/_boot_to_anaconda.pm +++ b/tests/_boot_to_anaconda.pm @@ -205,12 +205,9 @@ sub run { } # we click to work around RHBZ #1566066 if it happens click_lastmatch; - my $language = get_var('LANGUAGE') || 'english'; - # Workaround the new Anaconda WebUI with two menus, where the - # language stuff is not visible. - # We will send the upper arrow to move the screen to its original position. - send_key_until_needlematch("anaconda_select_install_lang", "up", 30); - assert_and_click("anaconda_select_install_lang", timeout => 300); + # for webui, with the small window, just typing 'english' may + # not show the desired variant + my $language = get_var('LANGUAGE') || (get_var("_ANACONDA_WEBUI") ? 'united states' : 'english'); # Select install language wait_screen_change { assert_and_click "anaconda_select_install_lang_input"; }; diff --git a/tests/_do_install_and_reboot.pm b/tests/_do_install_and_reboot.pm index 264f1bc2..650ab71a 100644 --- a/tests/_do_install_and_reboot.pm +++ b/tests/_do_install_and_reboot.pm @@ -1,61 +1,85 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; use utils; sub _set_root_password { - # Set root password, unless we don't want to or can't # can also hit a transition animation wait_still_screen 2; - my $root_password = get_var("ROOT_PASSWORD") || "weakpassword"; - unless (get_var("INSTALLER_NO_ROOT")) { - assert_and_click "anaconda_install_root_password"; - # we have to click 'enable root account' before typing the - #password - assert_and_click "anaconda_install_root_password_screen"; - # wait out animation - wait_still_screen 2; - desktop_switch_layout("ascii", "anaconda") if (get_var("SWITCHED_LAYOUT")); - # these screens seems insanely subject to typing errors, so - # type super safely. This doesn't really slow the test down - # as we still get done before the install process is complete. - type_very_safely $root_password; - wait_screen_change { send_key "tab"; }; - type_very_safely $root_password; - # Another screen to test identification on - my $identification = get_var('IDENTIFICATION'); - if ($identification eq 'true') { - check_top_bar(); - # we don't check version or pre-release because here those - # texts appear on the banner which makes the needling - # complex and fragile (banner is different between variants, - # and has a gradient so for RTL languages the background color - # differs; pre-release text is also translated) - } - assert_and_click "anaconda_spoke_done"; - # exiting this screen can take a while, so check for the hub - assert_screen "anaconda_main_hub", 60; + my $root_password = get_var("ROOT_PASSWORD", "weakpassword"); + assert_and_click "anaconda_install_root_password"; + # we have to click 'enable root account' before typing the + #password + assert_and_click "anaconda_install_root_password_screen"; + # wait out animation + wait_still_screen 2; + desktop_switch_layout("ascii", "anaconda") if (get_var("SWITCHED_LAYOUT")); + # these screens seems insanely subject to typing errors, so + # type super safely. This doesn't really slow the test down + # as we still get done before the install process is complete. + type_very_safely $root_password; + wait_screen_change { send_key "tab"; }; + type_very_safely $root_password; + # Another screen to test identification on + my $identification = get_var('IDENTIFICATION'); + if ($identification eq 'true') { + check_top_bar(); + # we don't check version or pre-release because here those + # texts appear on the banner which makes the needling + # complex and fragile (banner is different between variants, + # and has a gradient so for RTL languages the background color + # differs; pre-release text is also translated) } + assert_and_click "anaconda_spoke_done"; + # exiting this screen can take a while, so check for the hub + assert_screen "anaconda_main_hub", 60; +} + +sub _set_root_password_webui { + my $root_password = get_var("ROOT_PASSWORD", "weakpassword"); + # Click the radio button, then get focus and fill the fields. + assert_and_click("anaconda_webui_allow_root"); + sleep(1); + type_very_safely($root_password); + for (1 .. 2) { + send_key("tab"); + sleep(1); + } + type_very_safely($root_password); } sub _do_root_and_user { - _set_root_password(); - # Set user details, unless the test is configured not to create one - unless (get_var("USER_LOGIN") eq 'false' || get_var("INSTALL_NO_USER")) { - # Wait out animation - wait_still_screen 8; - anaconda_create_user(); + my $nouser = (get_var("USER_LOGIN") eq 'false' || get_var("INSTALL_NO_USER")); + my $noroot = get_var("INSTALLER_NO_ROOT"); + return if ($nouser && $noroot); + if (get_var("_ANACONDA_WEBUI")) { + webui_create_user() unless ($nouser); + _set_root_password_webui() unless ($noroot); + assert_and_click("anaconda_webui_next"); + } + else { + _set_root_password() unless ($noroot); + # Set user details, unless the test is configured not to create one + unless ($nouser) { + # Wait out animation + wait_still_screen 8; + anaconda_create_user(); + } } # Check username (and hence keyboard layout) if non-English if (get_var('LANGUAGE')) { assert_screen "anaconda_install_user_created"; } + } sub run { my $self = shift; - my $webui = 0; + my $webui = get_var("_ANACONDA_WEBUI"); + my $desktop = get_var("DESKTOP"); + # From F31 onwards (after Fedora-Rawhide-20190722.n.1), user and # root password spokes are moved to main hub, so we must do those # before we run the install. @@ -67,8 +91,7 @@ sub run { assert_screen ["anaconda_main_hub_begin_installation", "anaconda_webui_begin_installation"], 90; wait_still_screen 5; assert_and_click ["anaconda_main_hub_begin_installation", "anaconda_webui_begin_installation"]; - if (match_has_tag "anaconda_webui_begin_installation") { - $webui = 1; + if ($webui) { click_lastmatch if (check_screen "anaconda_webui_confirm_installation", 10); } @@ -110,8 +133,10 @@ sub run { wait_still_screen 3; # if this is a live install, let's go ahead and quit the installer # in all cases, just to make sure quitting doesn't crash etc. - # not on web UI, as it immediately reboots - assert_and_click "anaconda_install_done" if (get_var('LIVE') && !$webui); + if (get_var('LIVE')) { + # not on Workstation with webUI, as it immediately reboots + assert_and_click "anaconda_install_done" unless ($webui && $desktop eq "gnome"); + } # there are various things we might have to do at a console here # before we actually reboot. let's figure them all out first... my @actions; @@ -129,10 +154,9 @@ sub run { push(@actions, 'checkefibootmgr') if (get_var("UEFI")); } # memcheck test doesn't need to reboot at all. Rebooting from GUI - # for no-webUI lives is unreliable (webUI lives reboot on "Quit" - # just like non-lives). And if we're already doing something + # for lives is unreliable. And if we're already doing something # else at a console, we may as well reboot from there too - push(@actions, 'reboot') if (!get_var("MEMCHECK") && ((get_var("LIVE") && !$webui) || @actions)); + push(@actions, 'reboot') if (!get_var("MEMCHECK") && (get_var("LIVE") || @actions)); # check whether install is affected by # https://bugzilla.redhat.com/show_bug.cgi?id=2268505 , # soft fail and work around it if so diff --git a/tests/_graphical_wait_login.pm b/tests/_graphical_wait_login.pm index 264150ed..e00682c0 100644 --- a/tests/_graphical_wait_login.pm +++ b/tests/_graphical_wait_login.pm @@ -1,6 +1,7 @@ use base "installedtest"; use strict; use testapi; +use anaconda; use utils; sub _enter_password {