From c8e8cb001cb4927024712c5b21ede6a364ee20fb Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 2 Nov 2023 10:37:34 +0545 Subject: [PATCH] fix for ocis --- .../scripts/pageObjects/EnterPassword.py | 42 ++++++++++++++++--- test/gui/shared/steps/account_context.py | 9 ++-- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/test/gui/shared/scripts/pageObjects/EnterPassword.py b/test/gui/shared/scripts/pageObjects/EnterPassword.py index 454ad37c21b..5df02ebc88d 100644 --- a/test/gui/shared/scripts/pageObjects/EnterPassword.py +++ b/test/gui/shared/scripts/pageObjects/EnterPassword.py @@ -2,7 +2,7 @@ import squish from helpers.WebUIHelper import authorize_via_webui from helpers.ConfigHelper import get_config -from pageObjects.AccountConnectionWizard import AccountConnectionWizard +from helpers.UserHelper import getDisplaynameForUser, getPasswordForUser class EnterPassword: @@ -11,6 +11,12 @@ class EnterPassword: "type": "OCC::LoginRequiredDialog", "visible": 1, } + LOGIN_USER_LABEL = { + "name": "topLabel", + "type": "QLabel", + "visible": 1, + "window": LOGIN_DIALOG, + } USERNAME_BOX = { "name": "usernameLineEdit", "type": "QLineEdit", @@ -36,13 +42,32 @@ class EnterPassword: "visible": 1, "window": LOGIN_DIALOG, } + TLS_CERT_WINDOW = { + "name": "OCC__TlsErrorDialog", + "type": "OCC::TlsErrorDialog", + "visible": 1, + } + ACCEPT_CERTIFICATE_YES = { + "text": "Yes", + "type": "QPushButton", + "visible": 1, + "window": TLS_CERT_WINDOW, + } def __init__(self, occurrence=1): - if occurrence > 1: + if occurrence > 1 and not get_config('ocis'): self.LOGIN_DIALOG.update({"occurrence": occurrence}) + elif occurrence > 1 and get_config('ocis'): + self.TLS_CERT_WINDOW.update({"occurrence": occurrence}) def get_username(self): - return str(squish.waitForObjectExists(self.USERNAME_BOX).text) + # Parse username from following label: + # Please enter your password to log in to the account Alice Hansen@localhost. + # The account Alice Hansen@localhost:9200 is currently logged out. + label = str(squish.waitForObjectExists(self.LOGIN_USER_LABEL).text) + label = label.split("@", maxsplit=1)[0].split(" ") + label.reverse() + return label[1].capitalize() def enterPassword(self, password): squish.waitForObjectExists( @@ -66,9 +91,16 @@ def reLogin(self, username, password): else: self.enterPassword(password) - def loginAfterSetup(self, username, password): + def loginAfterSetup(self, username=None, password=None): + if get_config('ocis'): + self.accept_certificate() + if not username: + username = self.get_username() + password = getPasswordForUser(username) if get_config('ocis'): - AccountConnectionWizard.acceptCertificate() self.oidcReLogin(username, password) else: self.enterPassword(password) + + def accept_certificate(self): + squish.clickButton(squish.waitForObject(self.ACCEPT_CERTIFICATE_YES)) diff --git a/test/gui/shared/steps/account_context.py b/test/gui/shared/steps/account_context.py index a1d89810755..b56c4d0d1c2 100644 --- a/test/gui/shared/steps/account_context.py +++ b/test/gui/shared/steps/account_context.py @@ -68,8 +68,7 @@ def step(context): listenSyncStatusForItem(sync_path) # login from last dialog enter_password = EnterPassword(len(sync_paths) - idx) - username = enter_password.get_username().capitalize() - enter_password.loginAfterSetup(username, getPasswordForUser(username)) + enter_password.loginAfterSetup() # wait for files to sync waitForInitialSyncToComplete(sync_path) @@ -125,7 +124,8 @@ def step(context, username): def step(context, username): AccountSetting.login() password = getPasswordForUser(username) - EnterPassword.reLogin(username, password) + enter_password = EnterPassword() + enter_password.reLogin(username, password) # wait for files to sync waitForInitialSyncToComplete(getResourcePath('/', username)) @@ -138,7 +138,8 @@ def step(context, username): @When('user "|any|" enters the password "|any|"') def step(context, username, password): - EnterPassword.reLogin(username, password) + enter_password = EnterPassword() + enter_password.reLogin(username, password) @Then('user "|any|" should be connect to the client-UI')