diff --git a/lib/cockpit.pm b/lib/cockpit.pm index 55907db3..7d82a4d9 100644 --- a/lib/cockpit.pm +++ b/lib/cockpit.pm @@ -13,8 +13,12 @@ our @EXPORT = qw(start_cockpit select_cockpit_update check_updates); sub start_cockpit { # Starting from a console, get to a browser with Cockpit (running - # on localhost) shown. If $login is truth-y, also log in. Assumes + # on localhost) shown. If login is truth-y, also log in. If login + # and admin are both truthy, also gain admin privileges. Assumes # X and Firefox are installed. + my %args = @_; + $args{login} //= 0; + $args{admin} //= 1; my $login = shift || 0; # https://bugzilla.redhat.com/show_bug.cgi?id=1439429 assert_script_run "sed -i -e 's,enable_xauth=1,enable_xauth=0,g' /usr/bin/startx"; @@ -25,11 +29,17 @@ sub start_cockpit { # this happened on early Modular Server composes... record_soft_failure "Unbranded Cockpit" if (match_has_tag "cockpit_login_unbranded"); wait_still_screen(stilltime => 5, similarity_level => 45); - if ($login) { + if ($args{login}) { type_safely "test"; wait_screen_change { send_key "tab"; }; type_safely get_var("USER_PASSWORD", "weakpassword"); send_key "ret"; + if ($args{admin}) { + assert_and_click "cockpit_admin_enable"; + assert_screen "cockpit_admin_password"; + type_safely get_var("USER_PASSWORD", "weakpassword"); + send_key "ret"; + } assert_screen "cockpit_main"; # wait for any animation or other weirdness # can't use wait_still_screen because of that damn graph diff --git a/needles/cockpit/rocky-cockpit_admin_enable-20231122.json b/needles/cockpit/rocky-cockpit_admin_enable-20231122.json new file mode 100644 index 00000000..824b0249 --- /dev/null +++ b/needles/cockpit/rocky-cockpit_admin_enable-20231122.json @@ -0,0 +1,16 @@ +{ + "area": [ + { + "xpos": 294, + "ypos": 242, + "width": 102, + "height": 16, + "type": "match" + } + ], + "properties": [], + "tags": [ + "ENV-DISTRI-rocky", + "cockpit_admin_enable" + ] +} diff --git a/needles/cockpit/rocky-cockpit_admin_enable-20231122.png b/needles/cockpit/rocky-cockpit_admin_enable-20231122.png new file mode 100644 index 00000000..2e782b88 Binary files /dev/null and b/needles/cockpit/rocky-cockpit_admin_enable-20231122.png differ diff --git a/needles/cockpit/rocky-cockpit_admin_password-20231122.json b/needles/cockpit/rocky-cockpit_admin_password-20231122.json new file mode 100644 index 00000000..dfb9e066 --- /dev/null +++ b/needles/cockpit/rocky-cockpit_admin_password-20231122.json @@ -0,0 +1,16 @@ +{ + "area": [ + { + "xpos": 255, + "ypos": 394, + "width": 122, + "height": 18, + "type": "match" + } + ], + "properties": [], + "tags": [ + "ENV-DISTRI-rocky", + "cockpit_admin_password" + ] +} diff --git a/needles/cockpit/rocky-cockpit_admin_password-20231122.png b/needles/cockpit/rocky-cockpit_admin_password-20231122.png new file mode 100644 index 00000000..48658d44 Binary files /dev/null and b/needles/cockpit/rocky-cockpit_admin_password-20231122.png differ diff --git a/needles/cockpit/rocky-cockpit_main-20231122.json b/needles/cockpit/rocky-cockpit_main-20231122.json new file mode 100644 index 00000000..6d6e1213 --- /dev/null +++ b/needles/cockpit/rocky-cockpit_main-20231122.json @@ -0,0 +1,16 @@ +{ + "area": [ + { + "xpos": 257, + "height": 40, + "ypos": 517, + "type": "match", + "width": 230 + } + ], + "properties": [], + "tags": [ + "ENV-DISTRI-rocky", + "cockpit_main" + ] +} diff --git a/needles/cockpit/rocky-cockpit_main-20231122.png b/needles/cockpit/rocky-cockpit_main-20231122.png new file mode 100644 index 00000000..b59cd1a6 Binary files /dev/null and b/needles/cockpit/rocky-cockpit_main-20231122.png differ diff --git a/tests/realmd_join_cockpit.pm b/tests/realmd_join_cockpit.pm index 6c319799..1392255c 100644 --- a/tests/realmd_join_cockpit.pm +++ b/tests/realmd_join_cockpit.pm @@ -31,7 +31,7 @@ sub run { # note: we can't use wait_screen_change, wait_still_screen or # check_type_string in cockpit because of that fucking constantly # scrolling graph - start_cockpit(1); + start_cockpit(login => 1); # we may have to scroll down before the button is visible if (check_screen "cockpit_join_domain_button", 5) { click_lastmatch; diff --git a/tests/server_cockpit_autoupdate.pm b/tests/server_cockpit_autoupdate.pm index 73646e6a..890abd7d 100644 --- a/tests/server_cockpit_autoupdate.pm +++ b/tests/server_cockpit_autoupdate.pm @@ -9,7 +9,7 @@ sub run { my $self = shift; # Start Cockpit - start_cockpit(1); + start_cockpit(login => 1); # Navigate to the Update screen select_cockpit_update(); diff --git a/tests/server_cockpit_basic.pm b/tests/server_cockpit_basic.pm index 783b5105..85d6239e 100644 --- a/tests/server_cockpit_basic.pm +++ b/tests/server_cockpit_basic.pm @@ -7,7 +7,7 @@ use cockpit; sub run { my $self = shift; # run firefox and login to cockpit - start_cockpit(1); + start_cockpit(login => 1); # go to the logs screen assert_and_click "cockpit_logs"; # the date dropdown changes and messes with the button locations, so wait diff --git a/tests/server_cockpit_default.pm b/tests/server_cockpit_default.pm index 91d6a9d5..0b0530b6 100644 --- a/tests/server_cockpit_default.pm +++ b/tests/server_cockpit_default.pm @@ -13,7 +13,7 @@ sub run { assert_script_run 'systemctl is-active cockpit.socket'; assert_script_run 'firewall-cmd --query-service cockpit'; # test cockpit web UI start - start_cockpit(0); + start_cockpit(login => 0); # quit firefox (return to console) quit_firefox; # we don't get back to a prompt instantly and keystrokes while X diff --git a/tests/server_cockpit_updates.pm b/tests/server_cockpit_updates.pm index b40e9607..81e34b38 100644 --- a/tests/server_cockpit_updates.pm +++ b/tests/server_cockpit_updates.pm @@ -16,7 +16,7 @@ sub run { verify_installed_packages; # Start Cockpit - start_cockpit(1); + start_cockpit(login => 1); # Navigate to update screen select_cockpit_update(); @@ -74,13 +74,14 @@ sub run { # When Cockpit packages are also included in the updates # the user is forced to reconnect, i.e. to restart the Web Application # and relog for further interaction. We will check if reconnection is - # needed and if so, we will restart Firefox and login again. + # needed and if so, we will restart Firefox and login again. We do + # *not* need to gain admin privs again, trying to do so will fail. # last if (check_screen("cockpit_updates_updated")); if (check_screen("cockpit_updates_reconnect", 1)) { quit_firefox; sleep 5; - start_cockpit(1); + start_cockpit(login => 1, admin => 0); select_cockpit_update(); last;