1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-21 13:33:08 +00:00

Create test suite for Desktop Keyring

This adds both the Gnome and the KDE tests to test the
Desktop Keyring. After a discussion with the Brno team,
how this could be tested without the need to rely on
external servers to log into, we set up a local FTP server,
we will log into it and remember the credentials and verify
that the credentials will be stored in the keyring correctly.
This commit is contained in:
Lukas Ruzicka 2024-04-04 18:44:06 +02:00 committed by Adam Williamson
parent 206ffc2a7e
commit 992e51f5c5
70 changed files with 851 additions and 0 deletions

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 271,
"ypos": 113,
"width": 142,
"height": 24,
"type": "match"
}
],
"properties": [],
"tags": [
"apps_run_seahorse"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 226,
"ypos": 271,
"width": 164,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_askpass_password"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 543,
"ypos": 236,
"width": 170,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_askpass_yesno"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 442,
"ypos": 261,
"width": 126,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_seahorse_details_shown"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 35,
"ypos": 121,
"width": 38,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_seahorse_login"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 33,
"ypos": 121,
"width": 40,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_seahorse_login"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 338,
"ypos": 111,
"width": 169,
"height": 26,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_seahorse_login_details"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 440,
"ypos": 262,
"width": 111,
"height": 22,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_seahorse_password_shown"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 615,
"ypos": 260,
"width": 27,
"height": 26,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_seahorse_show_password"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 292,
"height": 37,
"xpos": 183,
"type": "match",
"width": 42
}
],
"properties": [],
"tags": [
"keyring_sftp_logged"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 382,
"ypos": 434,
"width": 136,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_autounlock_password"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"type": "match",
"height": 21,
"xpos": 360,
"width": 141,
"ypos": 104
}
],
"properties": [],
"tags": [
"nautilus_connection_established"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 361,
"ypos": 104,
"width": 141,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_connection_established"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 260,
"ypos": 608,
"width": 138,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_enter_address"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"type": "match",
"height": 20,
"xpos": 260,
"width": 136,
"ypos": 611
}
],
"properties": [],
"tags": [
"nautilus_enter_address"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 258,
"ypos": 610,
"width": 140,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_enter_address"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 559,
"width": 109,
"xpos": 109,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_other_locations"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 109,
"ypos": 559,
"width": 109,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_other_locations"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 381,
"ypos": 434,
"width": 142,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_remember_password"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"height": 17,
"ypos": 495,
"width": 52,
"type": "match",
"xpos": 587
}
],
"properties": [],
"tags": [
"nautilus_unlock"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 587,
"ypos": 495,
"width": 52,
"height": 17,
"type": "match"
}
],
"properties": [],
"tags": [
"nautilus_unlock"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 554,
"ypos": 444,
"width": 49,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_askpass_confirm"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 379,
"ypos": 322,
"width": 167,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_askpass_password"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 381,
"ypos": 414,
"width": 92,
"height": 16,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_askpass_remember"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 265,
"width": 118,
"height": 19,
"type": "match",
"xpos": 380
}
],
"properties": [],
"tags": [
"keyring_askpass_yesno"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

View File

@ -0,0 +1,16 @@
{
"area": [
{
"type": "match",
"xpos": 453,
"height": 19,
"ypos": 347,
"width": 138,
"match": 90
}
],
"properties": [],
"tags": [
"keyring_askpass_yesno"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 59,
"ypos": 382,
"width": 42,
"height": 37,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_sftp_logged"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 450,
"ypos": 284,
"width": 103,
"height": 17,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_wallet_password"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 62,
"ypos": 308,
"width": 94,
"height": 16,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_wallet_password_details"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 456,
"ypos": 245,
"width": 91,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_wallet_password_reveal"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 26,
"ypos": 284,
"width": 86,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_wallet_password_stored"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 23,
"ypos": 258,
"width": 117,
"height": 18,
"type": "match"
}
],
"properties": [],
"tags": [
"keyring_wallet_passwords_unfold"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 459,
"ypos": 96,
"width": 104,
"height": 23,
"type": "match"
}
],
"properties": [],
"tags": [
"kwalletmanager_runs"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 KiB

View File

@ -1357,6 +1357,20 @@
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"desktop_keyring": {
"profiles": {
"fedora-Workstation-live-iso-ppc64le-*-ppc64le": 20,
"fedora-Workstation-live-iso-x86_64-*-64bit": 20,
"fedora-KDE-live-iso-x86_64-*-64bit": 30,
"fedora-Workstation-raw_xz-raw.xz-aarch64-*-aarch64": 22
},
"settings": {
"BOOTFROM": "c",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"POSTINSTALL_PATH": "tests/applications/keyring",
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"desktop_update_graphical": {
"profiles": {
"fedora-KDE-live-iso-x86_64-*-64bit": 32,

View File

@ -0,0 +1,42 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This script will do the following:
# - install Seahorse when on Gnome
# - enable the sshd.service
# - create an SSH key for the installed user (~ test)
# - set up the SSH key password for that key
# - it will set a milestone
sub run {
my $self = shift;
my $desktop = get_var("DESKTOP");
my $user = get_var("USER") || "test";
# Switch to console to perform several setting tasks.
$self->root_console(tty => 3);
# Install Seahorse on Gnome.
# On KDE, similar application is already installed in the system.
if ($desktop eq "gnome") {
assert_script_run("dnf -y install seahorse");
}
# Enable and start sshd.service and check that is is running.
assert_script_run("systemctl enable sshd.service --now");
assert_script_run("systemctl status sshd.service --no-pager");
# Create the SSH keys with password for the regular user.
# Switch to that user's account.
assert_script_run("su $user -c 'ssh-keygen -N sshpassword -f /home/$user/.ssh/id_ed25519'");
}
sub test_flags {
return {fatal => 1, milestone => 1};
}
1;
# vim: set sw=4 et:

View File

@ -0,0 +1,174 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This script will do the following:
# - it will establish a connection to the system via sftp
# - it will ask for password to the system and store that password
# - it will check that the password was stored in the keyring
# - it will reboot the system
# - it will re-establish the connection without asking for the password
my $user = get_var("USER_LOGIN", "test");
my $pass = get_var("USER_PASSWORD", "weakpassword");
my $desktop = get_var("DESKTOP", "gnome");
# On KDE, it is possible that Konsole interacts with keyring when
# certain variables are set in the system. This subroutine sets up
# those variables.
sub export_kde_vars {
enter_cmd('export SSH_ASKPASS=/usr/bin/ksshaskpass');
sleep 2;
enter_cmd('export SSH_ASKPASS_REQUIRE=prefer');
sleep 2;
}
# This will handle the connection to the localhost. The process is different
# for KDE and Gnome, as currently Gnome does not save passwords to keyring
# from terminal and the KDE has a bug KNetAttach that prevents Dolphin from
# establishing the connection like Nautilus does.
sub connect_localhost {
my $type = shift;
# For Gnome, we will use Nautilus to establish an SFTP
# connection to the localhost.
if (get_var("DESKTOP") eq "gnome") {
# Start Nautilus.
menu_launch_type("nautilus");
assert_screen("apps_run_files");
# Add a new network connection.
assert_and_click("nautilus_other_locations");
assert_and_click("nautilus_enter_address");
my $connection = "ssh://$user" . '@localhost';
type_very_safely("$connection\n");
# When we connect for the first time, a password
# dialogue should appear in which we need to type
# in the password. We will also try to remember the
# password and confirm the connection.
if ($type ne "reconnect") {
wait_still_screen(3);
type_very_safely($pass);
assert_and_click("nautilus_remember_password");
assert_and_click("nautilus_unlock");
}
# When the connection has been established,
# a new connection icon will appear.
assert_screen("nautilus_connection_established");
}
else {
# On KDE, Dolphin has a bug that prevents the application
# from connecting easily (as in Gnome). Manually, this is
# not a big deal, as one could react accordingly, but with
# automation, this approach is basically useless.
# Therefore, we will use a different approach - we will enable
# CLI keyring integration and perform an SFTP connection
# in Konsole.
menu_launch_type("konsole");
assert_screen("konsole_runs");
# Export the environmental variables, this is needed for the process
# to work correctly.
export_kde_vars();
# Connect the sftp.
my $command = "sftp $user" . '@localhost';
enter_cmd($command);
# If performed for the first time, also deal with the
# password storing which is a little painful on KDE.
if ($type ne "reconnect") {
# First, we check that the yes no dialogue is present
# and type "yes" into it.
assert_screen("keyring_askpass_yesno");
type_very_safely("yes\n");
# Then similarly to Gnome, the password dialogue will appear
# and we type in the password. Also, we click on Remember
# and confirm with the OK button.
assert_screen("keyring_askpass_password");
type_very_safely("$pass");
assert_and_click("keyring_askpass_remember");
assert_and_click("keyring_askpass_confirm");
}
# Check that we have logged in and exit the application.
assert_and_click("keyring_sftp_logged");
type_very_safely("bye\n");
}
}
sub check_stored {
# This subroutine will run the keyring application on either
# desktop and check that the password has been stored there.
# On KDE, we will use the KWalletManager.
if (get_var("DESKTOP") eq "kde") {
menu_launch_type("kwalletmanager");
assert_screen("kwalletmanager_runs");
send_key("super-pgup");
# Navigate to the stored entry and check
# that the credentials are stored there.
assert_and_dclick("keyring_wallet_passwords_unfold");
assert_and_dclick("keyring_wallet_password_stored");
assert_and_click("keyring_wallet_password_details");
assert_and_click("keyring_wallet_password_reveal");
assert_screen("keyring_wallet_password");
}
else {
# Start the Seahorse application and maximize it.
menu_launch_type("seahorse");
assert_screen("apps_run_seahorse");
send_key("super-up");
# Navigate to the stored entry and check
# that the credentials are stored there.
assert_and_click("keyring_seahorse_login");
assert_and_dclick("keyring_seahorse_login_details");
assert_screen("keyring_seahorse_details_shown");
assert_and_click("keyring_seahorse_show_password");
assert_screen("keyring_seahorse_password_shown");
}
}
sub perform_login {
my $password = shift;
send_key("ret") if ($desktop eq "gnome");
type_very_safely("$password\n");
wait_still_screen(3);
send_key("esc");
}
sub run {
my $self = shift;
# We are still at the root console, but for the following steps,
# there is nothing we should be doing there, so we switch back
# to the graphical desktop.
desktop_vt();
if (check_screen("login_screen", timeout => 30)) {
perform_login($pass);
}
# Lets connect to localhost via SSH. This should result in
# asking for a password and storing the credentials for later use.
# The following routine uses different approaches on different
# desktops.
connect_localhost("connect");
# Check that the password has been stored.
check_stored();
# Reboot the machine, log onto the session again.
$self->root_console(tty => 3);
enter_cmd("reboot");
# Boot to login screen and type in the password.
boot_to_login_screen();
perform_login($pass);
# Repeat the connection procedure, but skip the password
# handling process as this will be done by the keyring.
connect_localhost("reconnect");
}
sub test_flags {
return {fatal => 0, always_rollback => 1};
}
1;
# vim: set sw=4 et:

View File

@ -0,0 +1,125 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This script will do the following:
# - set up the system for paswordless connection using
# the SSH authorized keys.
# - open the ssh key and establish the connection
# - store that password in the keyring
# - reboot the system
# - re-establish the connection, this time without the need to open the password
my $desktop = get_var("DESKTOP");
my $user = get_var("USER_LOGIN", "test");
my $pass = get_var("USER_PASSWORD", "weakpassword");
sub export_kde_vars {
# On KDE, it is possible to update and reuse the keyring
# on Konsole if correct environmental variables are set.
# Set them now.
enter_cmd('export SSH_ASKPASS=/usr/bin/ksshaskpass');
sleep 2;
enter_cmd('export SSH_ASKPASS_REQUIRE=prefer');
sleep 2;
}
sub connect_localhost {
my $type = shift;
# Start the terminal application. On KDE also export the variables.
if (get_var("DESKTOP") eq "gnome") {
menu_launch_type("terminal");
assert_screen("apps_run_terminal");
}
else {
menu_launch_type("konsole");
assert_screen("konsole_runs");
export_kde_vars();
}
# Establish the SFTP connection to the localhost.
# A dialogue should appear to collect credentials to open
# the SSH key.
my $command = "sftp $user" . '@localhost';
enter_cmd($command);
sleep 2;
# When connecting for the first time, we will remember
# the key password and store it in the keyring.
if ($type ne "reconnect") {
if ($desktop eq "gnome") {
type_very_safely("yes\n");
wait_still_screen(2);
type_very_safely("sshpassword");
assert_and_click("nautilus_autounlock_password");
assert_and_click("nautilus_unlock");
}
else {
type_very_safely("yes\n");
wait_still_screen(2);
type_very_safely("sshpassword");
assert_and_click("keyring_askpass_remember");
assert_and_click("keyring_askpass_confirm");
}
}
# The connection should have been established if everything has worked
# so far.
assert_screen("keyring_sftp_logged");
# Finish the connection.
enter_cmd("bye");
# Exit the terminal app.
enter_cmd("exit");
}
sub perform_login {
my $password = shift;
send_key("ret") if ($desktop eq "gnome");
type_very_safely("$password\n");
wait_still_screen(3);
send_key("esc");
}
sub run {
my $self = shift;
# We are still at the root console and for the following steps,
# Set up the SSH daemon
# Authorize the SSH key.
enter_cmd("su -l $user");
enter_cmd('echo $(cat ~/.ssh/id_ed25519.pub) > ~/.ssh/authorized_keys');
enter_cmd("exit");
# Return to desktop
desktop_vt();
# If we arrive to a login screen, perform login
if (check_screen("login_screen", timeout => 30)) {
perform_login($pass);
}
# Use SSH to connect to the localhost.
connect_localhost("connect");
# Reboot the machine.
$self->root_console(tty => 3);
enter_cmd("reboot");
# Log in.
boot_to_login_screen();
perform_login($pass);
# Reconnect without using password. We still should be
# able to log in.
connect_localhost("reconnect");
}
sub test_flags {
return {fatal => 0, always_rollback => 1};
}
1;
# vim: set sw=4 et: