From c4f542f049ca965c6cee129a77e3140cfa849a2c Mon Sep 17 00:00:00 2001 From: Dipak Acharya Date: Tue, 22 Dec 2020 11:02:05 +0545 Subject: [PATCH] [Tests-Only] Add ui test for checking the browser session of deleted user --- .../features/webUILogin/login.feature | 19 +++++++++++++ .../acceptance/pageObjects/loginErrorPage.js | 27 +++++++++++++++++++ .../stepDefinitions/generalContext.js | 10 +++++++ .../stepDefinitions/loginContext.js | 8 ++++++ .../stepDefinitions/provisioningContext.js | 4 +++ 5 files changed, 68 insertions(+) create mode 100644 tests/acceptance/pageObjects/loginErrorPage.js diff --git a/tests/acceptance/features/webUILogin/login.feature b/tests/acceptance/features/webUILogin/login.feature index 579530fdb9f..b11c69c8c5c 100644 --- a/tests/acceptance/features/webUILogin/login.feature +++ b/tests/acceptance/features/webUILogin/login.feature @@ -56,3 +56,22 @@ Feature: login users Then the files table should be displayed # Then the warning 'Logon failed. Please verify your credentials and try again.' should be displayed on the login page + @issue-1129 + Scenario: the user session of a deleted user is cleared properly + Given these users have been created with default attributes: + | username | + | user1 | + And user "user1" has logged in using the webUI + And the user has browsed to the files page + And user "user1" has been deleted + # When the user uploads file "new-lorem.txt" using the webUI + # Then the error message with header 'File upload failed…' should be displayed on the webUI + When the user reloads the current page of the webUI + # Then an alert box with title "sign in" must be displayed on the webUI + When the user dismisses the alert + # When the user logs out of the webUI + Then the user should be redirected to the login error page + When the user exits the login error page + # Uncomment this line once the issue is fixed + # Then the user should be redirected to the login page + Then the user should be redirected to the login error page \ No newline at end of file diff --git a/tests/acceptance/pageObjects/loginErrorPage.js b/tests/acceptance/pageObjects/loginErrorPage.js new file mode 100644 index 00000000000..e2aad250ec0 --- /dev/null +++ b/tests/acceptance/pageObjects/loginErrorPage.js @@ -0,0 +1,27 @@ +import { join } from '../helpers/path' + +module.exports = { + url: function() { + return join(this.api.launchUrl, '/#/access-denied') + }, + elements: { + body: 'body', + loginErrorMessage: { + locateStrategy: 'xpath', + selector: '//span[@data-msgid="Login Error"]' + }, + exitButton: { + selector: '#exitAnchor' + } + }, + commands: { + waitTillLoaded: function() { + const element = this.elements.loginErrorMessage + return this.useStrategy(element).waitForElementVisible(element) + }, + exit: function() { + const exitBtn = this.elements.exitButton + return this.waitForElementVisible(exitBtn).click(exitBtn) + } + } +} diff --git a/tests/acceptance/stepDefinitions/generalContext.js b/tests/acceptance/stepDefinitions/generalContext.js index eac3484d458..c27801985f4 100644 --- a/tests/acceptance/stepDefinitions/generalContext.js +++ b/tests/acceptance/stepDefinitions/generalContext.js @@ -302,3 +302,13 @@ Given('default expiration date for users is set to {int} day/days', function(day return this }) + +Then('an alert box with title {string} must be displayed on the webUI', async function(title) { + await client.getAlertText(text => { + console.log(text) + }) +}) + +When('the user dismisses the alert', async function() { + await client.dismissAlert() +}) diff --git a/tests/acceptance/stepDefinitions/loginContext.js b/tests/acceptance/stepDefinitions/loginContext.js index e531f80fd3b..80529aa4aa3 100644 --- a/tests/acceptance/stepDefinitions/loginContext.js +++ b/tests/acceptance/stepDefinitions/loginContext.js @@ -109,3 +109,11 @@ Then('the user should be redirected to the IdP login page', function() { return client.page.ownCloudAuthorizePage().waitForPage() }) + +Then('the user should be redirected to the login error page', function() { + return client.page.loginErrorPage().waitTillLoaded() +}) + +When('the user exits the login error page', function() { + return client.page.loginErrorPage().exit() +}) diff --git a/tests/acceptance/stepDefinitions/provisioningContext.js b/tests/acceptance/stepDefinitions/provisioningContext.js index 417a30b50f0..a54bdf8420a 100644 --- a/tests/acceptance/stepDefinitions/provisioningContext.js +++ b/tests/acceptance/stepDefinitions/provisioningContext.js @@ -155,6 +155,10 @@ Given('user {string} has been created with default attributes', async function(u await initUser(userId) }) +Given('user {string} has been deleted', function(userId) { + return deleteUser(userId) +}) + Given('user {string} has been created with default attributes on remote server', function(userId) { return backendHelper.runOnRemoteBackend(async function() { await deleteUser()