Skip to content

Commit

Permalink
fix for ocis
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Nov 7, 2023
1 parent 8b8dcfb commit c8e8cb0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
42 changes: 37 additions & 5 deletions test/gui/shared/scripts/pageObjects/EnterPassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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",
Expand All @@ -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(
Expand All @@ -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))
9 changes: 5 additions & 4 deletions test/gui/shared/steps/account_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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))
Expand All @@ -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')
Expand Down

0 comments on commit c8e8cb0

Please sign in to comment.