Skip to content

Commit

Permalink
add step implementation for oauth2 login
Browse files Browse the repository at this point in the history
  • Loading branch information
Salipa-Gurung committed Nov 6, 2023
1 parent c1a383b commit b3cace6
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 15 deletions.
3 changes: 2 additions & 1 deletion test/gui/shared/scripts/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
o_folderList_ownCloud_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "ownCloud", "type": "QModelIndex"}
contentWidget_contentWidget_QStackedWidget = {"container": setupWizardWindow_contentWidget_QStackedWidget, "name": "contentWidget", "type": "QStackedWidget", "visible": 1}
o_folderList_Personal_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "Personal", "type": "QModelIndex"}
add_Folder_Sync_Connection_tableView_QTableView = {"name": "tableView","type": "QTableView","visible": 1,"window": add_Folder_Sync_Connection_OCC_FolderWizard}
add_Folder_Sync_Connection_tableView_QTableView = {"name": "tableView","type": "QTableView","visible": 1,"window": add_Folder_Sync_Connection_OCC_FolderWizard}
quit_ownCloud_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Quit ownCloud"}
10 changes: 10 additions & 0 deletions test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
createUserSyncPath,
getTempResourcePath,
setCurrentUserSyncPath,
getClientDetails,
)
import test

Expand Down Expand Up @@ -351,3 +352,12 @@ def isSyncEverythingOptionChecked():
).checked
== True
)

@staticmethod
def addAccountWithOauth2(context):
account_details = getClientDetails(context)
AccountConnectionWizard.addServer(account_details['server'])
AccountConnectionWizard.oauthLogin(
account_details['user'], account_details['password']
)
AccountConnectionWizard.nextStep()
11 changes: 11 additions & 0 deletions test/gui/shared/scripts/pageObjects/AccountSetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class AccountSetting:
"visible": 1,
"window": names.loginRequiredDialog_OCC_LoginRequiredDialog,
}
LOGIN_REQUIRED_DIALOG = {
"name": "LoginRequiredDialog",
"type": "OCC::LoginRequiredDialog",
"visible": 1,
}

@staticmethod
def accountAction(action):
Expand Down Expand Up @@ -157,3 +162,9 @@ def isLogDialogVisible():
except:
pass
return visible

@staticmethod
def is_login_required_dialog_visible():
if squish.waitForObjectExists(AccountSetting.LOGIN_REQUIRED_DIALOG):
return True
return False
4 changes: 2 additions & 2 deletions test/gui/shared/scripts/pageObjects/EnterPassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def enterPassword(password):
squish.clickButton(squish.waitForObject(EnterPassword.LOGIN_BUTTON))

@staticmethod
def oidcReLogin(username, password):
def oidcReLogin(username, password, login_type='oidc'):
# wait 500ms for copy button to fully load
squish.snooze(1 / 2)
squish.clickButton(
squish.waitForObject(EnterPassword.COPY_URL_TO_CLIPBOARD_BUTTON)
)
authorize_via_webui(username, password)
authorize_via_webui(username, password, login_type)

@staticmethod
def reLogin(username, password):
Expand Down
16 changes: 16 additions & 0 deletions test/gui/shared/scripts/pageObjects/Toolbar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import squish
import names


class Toolbar:
QUIT_OWNCLOUD_YES_QPUSHBUTTON = {
"text": "Yes",
"type": "QPushButton",
"unnamed": 1,
"visible": 1,
"window": names.quit_ownCloud_QMessageBox,
}

@staticmethod
def getItemSelector(item_name):
return {
Expand Down Expand Up @@ -31,3 +40,10 @@ def getDisplayedAccountText(displayname, host):
Toolbar.getItemSelector(displayname + "@" + host)
).text
)

@staticmethod
def quitOwncloud():
squish.clickButton(
squish.waitForObject(Toolbar.getItemSelector("Quit ownCloud"))
)
squish.clickButton(squish.waitForObject(Toolbar.QUIT_OWNCLOUD_YES_QPUSHBUTTON))
46 changes: 40 additions & 6 deletions test/gui/shared/steps/account_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,29 @@ def step(context):
AccountConnectionWizard.addAccount(account_details)


@When('the user starts the client')
def step(context):
squish.snooze(2)
startClient()


@When(r'^the user adds (the first|another) account with$', regexp=True)
def step(context, accountType):
if accountType == 'another':
Toolbar.openNewAccountSetup()


@Given('the user has entered the following account information:')
def step(context):
account_details = getClientDetails(context)
AccountConnectionWizard.addAccountInformation(account_details)


@Given('the user "|any|" has logged out of the client-UI')
def step(context, username):
AccountSetting.logout()


@When('the user "|any|" logs out of the client-UI')
def step(context, username):
AccountSetting.logout()
Expand Down Expand Up @@ -230,14 +247,15 @@ def step(context):
test.compare(True, AccountSetting.isLogDialogVisible(), "Log dialog is opened")


@Given('the user has added the following account with oauth2 enabled:')
def step(context):
AccountConnectionWizard.addAccountWithOauth2(context)
# squish.snooze(1)


@When('the user adds the following account with oauth2 enabled:')
def step(context):
account_details = getClientDetails(context)
AccountConnectionWizard.addServer(account_details['server'])
AccountConnectionWizard.oauthLogin(
account_details['user'], account_details['password']
)
AccountConnectionWizard.nextStep()
AccountConnectionWizard.addAccountWithOauth2(context)


@When('the user cancels the sync connection wizard')
Expand All @@ -253,3 +271,19 @@ def step(context):
@When('user "|any|" logs out from the login required dialog')
def step(context, username):
AccountSetting.logoutFromLoginRequiredDialog()


@When('user "|any|" logs in with oauth2 to the client-UI')
def step(context, username):
AccountSetting.login()
if AccountSetting.is_login_required_dialog_visible():
EnterPassword.oidcReLogin(
username, getPasswordForUser(username), login_type='oauth'
)
else:
raise Exception("oidc re-login failed")


@Given("the user has quitted the client")
def step(context):
Toolbar.quitOwncloud()
12 changes: 6 additions & 6 deletions test/gui/tst_loginLogout/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ Feature: Logout users
Scenario: login after loggin out with oauth2 enabled
Given app "oauth2" has been "enabled" in the server
And the user has started the client
And the user adds the following account with oauth2 enabled:
And the user has added the following account with oauth2 enabled:
| server | %local_server% |
| user | Alice |
| password | 1234 |
When user "Alice" has logged out of the client-UI
And user "Alice" logs in with oauth2 to the client-UI
And the user "Alice" has logged out of the client-UI
When user "Alice" logs in with oauth2 to the client-UI
Then user "Alice" should be connect to the client-UI

@skipOnOCIS
Scenario: the client re-auths after restarting
Given app "oauth2" has been "enabled" in the server
And the user has started the client
And the user adds the following account with oauth2 enabled:
And the user has added the following account with oauth2 enabled:
| server | %local_server% |
| user | Alice |
| password | 1234 |
When user quits the client
And user starts the client
And the user has quitted the client
When the user starts the client
Then user "Alice" should be connect to the client-UI

0 comments on commit b3cace6

Please sign in to comment.