2019-09-10 12:59:57 +00:00
|
|
|
package cockpit;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use base 'Exporter';
|
|
|
|
use Exporter;
|
|
|
|
use lockapi;
|
|
|
|
use testapi;
|
|
|
|
use utils;
|
|
|
|
|
|
|
|
our @EXPORT = qw(start_cockpit select_cockpit_update check_updates);
|
|
|
|
|
|
|
|
|
|
|
|
sub start_cockpit {
|
|
|
|
# Starting from a console, get to a browser with Cockpit (running
|
2022-11-25 19:24:52 +00:00
|
|
|
# on localhost) shown. If login is truth-y, also log in. If login
|
|
|
|
# and admin are both truthy, also gain admin privileges. Assumes
|
2019-09-10 12:59:57 +00:00
|
|
|
# X and Firefox are installed.
|
2022-11-25 19:24:52 +00:00
|
|
|
my %args = @_;
|
|
|
|
$args{login} //= 0;
|
|
|
|
$args{admin} //= 1;
|
2019-09-10 12:59:57 +00:00
|
|
|
my $login = shift || 0;
|
|
|
|
# run firefox directly in X as root. never do this, kids!
|
|
|
|
type_string "startx /usr/bin/firefox -width 1024 -height 768 http://localhost:9090\n";
|
2020-01-22 09:40:46 +00:00
|
|
|
assert_screen "cockpit_login", 60;
|
2022-07-28 20:32:57 +00:00
|
|
|
wait_still_screen(stilltime => 5, similarity_level => 45);
|
2022-11-25 19:24:52 +00:00
|
|
|
if ($args{login}) {
|
2022-11-19 00:34:55 +00:00
|
|
|
type_safely "test";
|
2019-09-10 12:59:57 +00:00
|
|
|
wait_screen_change { send_key "tab"; };
|
2022-11-19 00:34:55 +00:00
|
|
|
type_safely get_var("USER_PASSWORD", "weakpassword");
|
2019-09-10 12:59:57 +00:00
|
|
|
send_key "ret";
|
2022-11-25 19:24:52 +00:00
|
|
|
if ($args{admin}) {
|
|
|
|
assert_and_click "cockpit_admin_enable";
|
|
|
|
assert_screen "cockpit_admin_password";
|
|
|
|
type_safely get_var("USER_PASSWORD", "weakpassword");
|
|
|
|
send_key "ret";
|
|
|
|
}
|
2019-09-10 12:59:57 +00:00
|
|
|
assert_screen "cockpit_main";
|
|
|
|
# wait for any animation or other weirdness
|
|
|
|
# can't use wait_still_screen because of that damn graph
|
|
|
|
sleep 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub select_cockpit_update {
|
|
|
|
# This method navigates to to the updates screen
|
2022-05-03 20:15:02 +00:00
|
|
|
# From Firefox 100 on, we get 'adaptive scrollbars', which means
|
|
|
|
# the scrollbar is just invisible unless you moved the mouse
|
|
|
|
# recently. So we click in the search box and hit 'up' to scroll
|
|
|
|
# the sidebar to the bottom if necessary
|
|
|
|
assert_screen ["cockpit_software_updates", "cockpit_search"], 120;
|
2020-05-30 16:33:06 +00:00
|
|
|
click_lastmatch;
|
2022-05-03 20:15:02 +00:00
|
|
|
if (match_has_tag "cockpit_search") {
|
|
|
|
send_key "up";
|
2022-05-05 00:02:05 +00:00
|
|
|
wait_still_screen 2;
|
2022-05-03 20:15:02 +00:00
|
|
|
assert_and_click "cockpit_software_updates";
|
|
|
|
}
|
2019-09-10 12:59:57 +00:00
|
|
|
# wait for the updates to download
|
|
|
|
assert_screen 'cockpit_updates_check', 300;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub check_updates {
|
|
|
|
my $logfile = shift;
|
|
|
|
sleep 2;
|
|
|
|
my $checkresult = script_run "dnf check-update > $logfile";
|
2022-07-28 20:32:57 +00:00
|
|
|
upload_logs "$logfile", failok => 1;
|
|
|
|
return ($checkresult);
|
2019-09-10 12:59:57 +00:00
|
|
|
}
|