Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui-tests][full-ci] check keyring before starting client #12028

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from helpers.SyncHelper import close_socket_connection, clear_waited_after_sync
from helpers.SpaceHelper import delete_project_spaces
from helpers.api.provisioning import delete_created_groups, delete_created_users
from helpers.SetupClientHelper import wait_until_app_killed, unlock_keyring
from helpers.SetupClientHelper import wait_until_app_killed
from helpers.ConfigHelper import (
init_config,
get_config,
Expand Down Expand Up @@ -62,7 +62,6 @@ def hook(context):
# Order: 1
@OnScenarioStart
def hook(context):
unlock_keyring()
clear_scenario_config()


Expand Down
63 changes: 50 additions & 13 deletions test/gui/shared/scripts/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def get_current_user_sync_path():


def start_client():
check_keyring()

squish.startApplication(
'owncloud -s'
+ f' --logfile {get_config("clientLogFile")}'
Expand Down Expand Up @@ -230,10 +232,55 @@ def generate_uuidv4():


# sometimes the keyring is locked during the test execution, and we need to unlock it
def unlock_keyring():
def check_keyring():
if is_windows():
return

if is_keyring_locked():
test.log('[INFO] Keyring is locked or service is down. Unlocking...')
wait_until_keyring_unlocked()


def unlock_keyring() -> bool | None:
if is_windows():
return None

password = os.getenv('VNC_PW')
command = f'echo -n "{password}" | gnome-keyring-daemon -r --unlock'
stdout, stderr, returncode = run_sys_command(command, True)

output = ''
if stdout:
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')
test.log(f'[INFO] Keyring unlock output: {output}')
# wait for keyring to unlock
squish.snooze(1)

if returncode:
return False

return not is_keyring_locked()


def wait_until_keyring_unlocked():
if is_windows():
return

timeout = 10
unlocked = squish.waitFor(
lambda: unlock_keyring(), # pylint: disable=unnecessary-lambda
timeout * 1000,
)
if not unlocked:
test.fail(f'Timeout. Keyring was not unlocked within {timeout} seconds')


def is_keyring_locked() -> bool | None:
if is_windows():
return None

stdout, stderr, _ = run_sys_command(
[
'busctl',
Expand All @@ -250,18 +297,8 @@ def unlock_keyring():
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')

if not output.strip().endswith('false'):
test.log('Unlocking keyring...')
password = os.getenv('VNC_PW')
command = f'echo -n "{password}" | gnome-keyring-daemon -r -d --unlock'
stdout, stderr, returncode = run_sys_command(command, True)
if stdout:
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')
if returncode:
test.log(f'Failed to unlock keyring:\n{output}')
test.log(f'[INFO] Keyring locked status: {output}')
return not output.strip().endswith('false')


def run_sys_command(command=None, shell=False):
Expand Down
Loading