1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-26 23:53:08 +00:00

Factor DM login process out of _graphical_wait_login

There are several other tests doing the same thing (but not as
safely, in some cases). To improve reliability and reduce
duplication, let's factor this out into utils.pm and reuse it
where appropriate.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2024-09-26 08:57:27 -07:00
parent 7657b8bb16
commit b870ec9bf3
5 changed files with 44 additions and 34 deletions

View File

@ -7,7 +7,7 @@ use Exporter;
use lockapi; use lockapi;
use testapi qw(is_serial_terminal :DEFAULT); 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 solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround/; 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 solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login/;
# We introduce this global variable to hold the list of applications that have # We introduce this global variable to hold the list of applications that have
@ -1777,4 +1777,36 @@ sub kde_doublek_workaround {
wait_still_screen 3; wait_still_screen 3;
} }
# handle login at a graphical DM once we have reached the initial
# DM screen. Factored out of _graphical_wait_login for reuse by
# tests that reboot and need to login afterwards
sub dm_perform_login {
my ($desktop, $password) = @_;
# GDM 3.24.1 dumps a cursor in the middle of the screen here...
mouse_hide;
if ($desktop eq 'gnome') {
# we have to hit enter to get the password dialog, and it
# doesn't always work for some reason so just try it three
# times
send_key_until_needlematch("graphical_login_input", "ret", 3, 5);
}
assert_screen "graphical_login_input";
# seems like we often double-type on aarch64 if we start right
# away
wait_still_screen(stilltime => 5, similarity_level => 38);
if (get_var("SWITCHED_LAYOUT")) {
# see _do_install_and_reboot; when layout is switched
# user password is doubled to contain both US and native
# chars
desktop_switch_layout 'ascii';
type_very_safely $password;
desktop_switch_layout 'native';
type_very_safely $password;
}
else {
type_very_safely $password;
}
send_key "ret";
}
1; 1;

View File

@ -126,13 +126,6 @@ sub check_stored {
} }
} }
sub perform_login {
my $password = shift;
send_key("ret") if ($desktop eq "gnome");
type_very_safely("$password\n");
check_desktop;
}
sub run { sub run {
my $self = shift; my $self = shift;
@ -142,7 +135,8 @@ sub run {
desktop_vt(); desktop_vt();
if (check_screen("login_screen", timeout => 30)) { if (check_screen("login_screen", timeout => 30)) {
perform_login($pass); dm_perform_login($desktop, $pass);
check_desktop;
} }
# Lets connect to localhost via SSH. This should result in # Lets connect to localhost via SSH. This should result in
@ -159,7 +153,8 @@ sub run {
# Boot to login screen and type in the password. # Boot to login screen and type in the password.
boot_to_login_screen(); boot_to_login_screen();
perform_login($pass); dm_perform_login($desktop, $pass);
check_desktop;
# Repeat the connection procedure, but skip the password # Repeat the connection procedure, but skip the password
# handling process as this will be done by the keyring. # handling process as this will be done by the keyring.

View File

@ -76,13 +76,6 @@ sub connect_localhost {
enter_cmd("exit"); enter_cmd("exit");
} }
sub perform_login {
my $password = shift;
send_key("ret") if ($desktop eq "gnome");
type_very_safely("$password\n");
check_desktop;
}
sub run { sub run {
my $self = shift; my $self = shift;
@ -99,7 +92,8 @@ sub run {
# If we arrive to a login screen, perform login # If we arrive to a login screen, perform login
if (check_screen("login_screen", timeout => 30)) { if (check_screen("login_screen", timeout => 30)) {
perform_login($pass); dm_perform_login($desktop, $pass);
check_desktop;
} }
# Use SSH to connect to the localhost. # Use SSH to connect to the localhost.
@ -110,7 +104,8 @@ sub run {
enter_cmd("reboot"); enter_cmd("reboot");
# Log in. # Log in.
boot_to_login_screen(); boot_to_login_screen();
perform_login($pass); dm_perform_login($desktop, $pass);
check_desktop;
# Reconnect without using password. We still should be # Reconnect without using password. We still should be
# able to log in. # able to log in.

View File

@ -20,10 +20,7 @@ sub run {
# "Login with a reader, but no enrolled prints" # "Login with a reader, but no enrolled prints"
type_string "reboot\n"; type_string "reboot\n";
assert_screen "graphical_login", 180; assert_screen "graphical_login", 180;
mouse_hide; dm_perform_login('gnome', 'weakpassword');
send_key_until_needlematch("graphical_login_input", "ret", 3, 5);
type_very_safely "weakpassword";
send_key "ret";
check_desktop(timeout => 60); check_desktop(timeout => 60);
wait_still_screen 10; wait_still_screen 10;
$self->root_console(tty => 5); $self->root_console(tty => 5);

View File

@ -77,19 +77,10 @@ sub run {
type_string "systemctl start graphical.target\n"; type_string "systemctl start graphical.target\n";
# we trust systemd to switch us to the right tty here # we trust systemd to switch us to the right tty here
if (get_var("BOOTFROM")) { if (get_var("BOOTFROM")) {
my $password = get_var("USER_PASSWORD", "weakpassword");
assert_screen 'graphical_login', 60; assert_screen 'graphical_login', 60;
wait_still_screen 10, 30; wait_still_screen 10, 30;
# GDM 3.24.1 dumps a cursor in the middle of the screen here... dm_perform_login($desktop, $password);
mouse_hide;
if ($desktop eq 'gnome') {
# we have to hit enter to get the password dialog, and it
# doesn't always work for some reason so just try it three
# times
send_key_until_needlematch("graphical_login_input", "ret", 3, 5);
}
assert_screen "graphical_login_input";
type_very_safely get_var("USER_PASSWORD", "weakpassword");
send_key 'ret';
} }
check_desktop(timeout => 90); check_desktop(timeout => 90);
# now, WE WAIT. this is just an unconditional wait - rather than # now, WE WAIT. this is just an unconditional wait - rather than