[ADF-3739] E2E test - login with SSO (#3949)

*  modify settings page and add test for login with SSO

* remove await

* added the HOST_SSO as parameter

* change setSilentLogin method, add new method, add new test

* remove comment

* optional parameters silentLogin and implicitFlow

* moved --host_sso "$E2E_HOST_SSO" to ./scripts/test-e2e-lib.sh script
This commit is contained in:
rgherghelas
2018-11-16 12:39:46 +02:00
committed by Eugenio Romano
parent 09a259bfa1
commit 604d401180
6 changed files with 181 additions and 4 deletions

View File

@@ -0,0 +1,51 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LoginAPSPage } from '../../../pages/adf/loginApsPage';
import { SettingsPage } from '../../../pages/adf/settingsPage';
import TestConfig = require('../../../test.config');
import { browser } from 'protractor';
import { NavigationBarPage } from '../../../pages/adf/NavigationBarPage';
describe('Login component - SSO', () => {
const settingsPage = new SettingsPage();
const loginApsPage = new LoginAPSPage();
const navigationBarPage = new NavigationBarPage();
const path = '/auth/realms/springboot';
let silentLogin;
afterEach(() => {
navigationBarPage.clickLogoutButton();
browser.executeScript('window.sessionStorage.clear();');
browser.executeScript('window.localStorage.clear();');
});
it('[C261050] Should be possible login in the PS with SSO', async () => {
silentLogin = false;
await settingsPage.setProviderBpmSso(TestConfig.adf.hostSso, TestConfig.adf.hostSso + path, silentLogin);
await loginApsPage.clickOnSSOButton();
browser.ignoreSynchronization = true;
await loginApsPage.loginAPS(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
});
it ('[C280667] Should be redirect directly to keycloak without show the login page with silent login', async () => {
await settingsPage.setProviderBpmSso(TestConfig.adf.hostSso, TestConfig.adf.hostSso + path);
browser.ignoreSynchronization = true;
await loginApsPage.loginAPS(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
});
});

View File

@@ -0,0 +1,56 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Util = require('../../util/util');
import { element, by } from 'protractor';
export class LoginAPSPage {
ssoButton = element(by.css(`[data-automation-id="login-button-sso"]`));
usernameField = element(by.id('username'));
passwordField = element(by.id('password'));
loginButton = element(by.id('kc-login'));
async loginAPS (username, password) {
await this.enterUsername(username);
await this.enterPassword(password);
await this.clickLoginButton();
}
async clickOnSSOButton () {
Util.waitUntilElementIsVisible(this.ssoButton);
await this.ssoButton.click();
}
async enterUsername (username) {
Util.waitUntilElementIsVisible(this.usernameField);
await this.usernameField.clear();
await this.usernameField.sendKeys(username);
}
async enterPassword (password) {
Util.waitUntilElementIsVisible(this.passwordField);
await this.passwordField.clear();
await this.passwordField.sendKeys(password);
}
async clickLoginButton () {
Util.waitUntilElementIsVisible(this.loginButton);
await this.loginButton.click();
}
}

View File

@@ -43,6 +43,11 @@ export class SettingsPage {
ecmText = element(by.css('input[data-automation-id*="ecmHost"]'));
bpmText = element(by.css('input[data-automation-id*="bpmHost"]'));
authHostText = element(by.css('input[id="oauthHost"]'));
ssoRadioButton = element(by.cssContainingText('[id*="mat-radio"]', 'SSO'));
silentLoginToggleLabel = element(by.css('mat-slide-toggle[name="silentLogin"] label'));
silentLoginToggleElement = element(by.css('mat-slide-toggle[name="silentLogin"]'));
implicitFlowLabel = element(by.css('mat-slide-toggle[name="implicitFlow"] label'));
implicitFlowElement = element(by.css('mat-slide-toggle[name="implicitFlow"]'));
applyButton = element(by.css('button[data-automation-id*="host-button"]'));
goToSettingsPage() {
@@ -96,9 +101,63 @@ export class SettingsPage {
return this;
}
clickApply() {
async clickSsoRadioButton () {
Util.waitUntilElementIsVisible(this.ssoRadioButton);
await this.ssoRadioButton.click();
}
async setProviderBpmSso (processServiceURL, authHost, silentLogin = true, implicitFlow = true ) {
this.goToSettingsPage();
this.setProvider(this.bpm.option, this.bpm.text);
Util.waitUntilElementIsVisible(this.bpmText);
Util.waitUntilElementIsNotOnPage(this.ecmText);
await this.clickSsoRadioButton();
await this.setProcessServicesURL(processServiceURL);
await this.setAuthHost(authHost);
await this.setSilentLogin(silentLogin);
await this.setImplicitFlow(implicitFlow);
await this.clickApply();
}
async setProcessServicesURL (processServiceURL) {
Util.waitUntilElementIsVisible(this.bpmText);
await this.bpmText.clear();
await this.bpmText.sendKeys(processServiceURL);
}
async setAuthHost (authHostURL) {
Util.waitUntilElementIsVisible(this.authHostText);
await this.authHostText.clear();
await this.authHostText.sendKeys(authHostURL);
}
async clickApply () {
Util.waitUntilElementIsVisible(this.applyButton);
this.applyButton.click();
await this.applyButton.click();
}
async setSilentLogin (enableToggle) {
await Util.waitUntilElementIsVisible(this.silentLoginToggleElement);
const isChecked = (await this.silentLoginToggleElement.getAttribute('class')).includes('mat-checked');
if (isChecked && !enableToggle || !isChecked && enableToggle) {
return this.silentLoginToggleLabel.click();
}
return Promise.resolve();
}
async setImplicitFlow (enableToggle) {
await Util.waitUntilElementIsVisible(this.implicitFlowElement);
const isChecked = (await this.implicitFlowElement.getAttribute('class')).includes('mat-checked');
if (isChecked && !enableToggle || !isChecked && enableToggle) {
return this.implicitFlowLabel.click();
}
return Promise.resolve();
}
checkProviderDropdownIsDisplayed() {

View File

@@ -4,6 +4,7 @@
*/
var HOST = process.env.URL_HOST_ADF;
const HOST_SSO = process.env.URL_HOST_SSO_ADF;
var USERNAME = process.env.USERNAME_ADF;
var PASSWORD = process.env.PASSWORD_ADF;
var EMAIL = process.env.EMAIL_ADF;
@@ -48,7 +49,10 @@ module.exports = {
/**
* main admin password
*/
adminPassword: PASSWORD
adminPassword: PASSWORD,
hostSso: "http://" + HOST_SSO
},
adf_acs: {