mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3666] User info sso e2e tests (#4057)
* user info sso tests * remove async await
This commit is contained in:
committed by
Eugenio Romano
parent
ced1901c89
commit
c32d331a9b
106
e2e/actions/APS-cloud/identity.ts
Normal file
106
e2e/actions/APS-cloud/identity.ts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { ApiService } from '../APS-cloud/apiservice';
|
||||||
|
import { Util } from '../../util/util';
|
||||||
|
|
||||||
|
export class Identity {
|
||||||
|
|
||||||
|
api: ApiService = new ApiService();
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(username, password) {
|
||||||
|
await this.api.login(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
async createIdentityUser(username = Util.generateRandomString(5), password = Util.generateRandomString(5)) {
|
||||||
|
await this.createUser(username);
|
||||||
|
const user = await this.getUserInfoByUsername(username);
|
||||||
|
await this.resetPassword(user[0].id, password);
|
||||||
|
user[0].password = password;
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteIdentityUser(userId) {
|
||||||
|
await this.deleteUser(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
async createUser(username) {
|
||||||
|
const path = '/auth/admin/realms/springboot/users';
|
||||||
|
const method = 'POST';
|
||||||
|
const queryParams = {}, postBody = {
|
||||||
|
'username': username,
|
||||||
|
'firstName': username,
|
||||||
|
'lastName': 'LastName',
|
||||||
|
'enabled': true,
|
||||||
|
'email': username + '@alfresco.com'
|
||||||
|
};
|
||||||
|
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteUser(userId) {
|
||||||
|
const path = `/auth/admin/realms/springboot/users/${userId}`;
|
||||||
|
const method = 'DELETE';
|
||||||
|
const queryParams = {}, postBody = {
|
||||||
|
};
|
||||||
|
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getUserInfoByUsername(username) {
|
||||||
|
const path = `/auth/admin/realms/springboot/users`;
|
||||||
|
const method = 'GET';
|
||||||
|
const queryParams = { 'username' : username }, postBody = {};
|
||||||
|
|
||||||
|
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async resetPassword(id, password) {
|
||||||
|
const path = `/auth/admin/realms/springboot/users/${id}/reset-password`;
|
||||||
|
const method = 'PUT';
|
||||||
|
const queryParams = {},
|
||||||
|
postBody = {'type': 'password', 'value': password, 'temporary': false};
|
||||||
|
|
||||||
|
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getRoleByName(roleName) {
|
||||||
|
const path = `/auth/admin/realms/springboot/roles/${roleName}`;
|
||||||
|
const method = 'GET';
|
||||||
|
const queryParams = {},
|
||||||
|
postBody = {};
|
||||||
|
|
||||||
|
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async assignRole(userId, roleId, roleName) {
|
||||||
|
const path = `/auth/admin/realms/springboot/users/${userId}/role-mappings/realm`;
|
||||||
|
const method = 'POST';
|
||||||
|
const queryParams = {},
|
||||||
|
postBody = [{'id': roleId, 'name': roleName}];
|
||||||
|
|
||||||
|
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
61
e2e/core/user_info_component_cloud.e2e.ts
Normal file
61
e2e/core/user_info_component_cloud.e2e.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { LoginSSOPage } from '../pages/adf/loginSSOPage';
|
||||||
|
import { SettingsPage } from '../pages/adf/settingsPage';
|
||||||
|
import TestConfig = require('../test.config');
|
||||||
|
import { browser } from 'protractor';
|
||||||
|
import { NavigationBarPage } from '../pages/adf/NavigationBarPage';
|
||||||
|
import { UserInfoDialog } from '../pages/adf/dialog/userInfoDialog';
|
||||||
|
import { Identity } from '../actions/APS-cloud/identity';
|
||||||
|
|
||||||
|
describe('User Info - SSO', () => {
|
||||||
|
|
||||||
|
const settingsPage = new SettingsPage();
|
||||||
|
const loginSSOPage = new LoginSSOPage();
|
||||||
|
const navigationBarPage = new NavigationBarPage();
|
||||||
|
const userInfoDialog = new UserInfoDialog();
|
||||||
|
const identityService: Identity = new Identity();
|
||||||
|
const path = '/auth/realms/springboot';
|
||||||
|
let silentLogin, identityUser;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await identityService.init(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
|
||||||
|
identityUser = await identityService.createIdentityUser();
|
||||||
|
silentLogin = false;
|
||||||
|
settingsPage.setProviderBpmSso(TestConfig.adf.hostSso, TestConfig.adf.hostSso + path, silentLogin);
|
||||||
|
loginSSOPage.clickOnSSOButton();
|
||||||
|
browser.ignoreSynchronization = true;
|
||||||
|
loginSSOPage.loginAPS(identityUser['0'].username, identityUser['0'].password);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll (() => {
|
||||||
|
identityService.deleteIdentityUser(identityUser[0].id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('[C290066] Should display UserInfo when login using SSO', () => {
|
||||||
|
|
||||||
|
navigationBarPage.navigateToProcessServicesCloudPage();
|
||||||
|
navigationBarPage.clickUserProfile();
|
||||||
|
expect(userInfoDialog.getSsoHeaderTitle()).toEqual(identityUser['0'].firstName + ' ' + identityUser['0'].lastName);
|
||||||
|
expect(userInfoDialog.getSsoTitle()).toEqual(identityUser['0'].firstName + ' ' + identityUser['0'].lastName);
|
||||||
|
expect(userInfoDialog.getSsoEmail()).toEqual(identityUser['0'].email);
|
||||||
|
userInfoDialog.closeUserProfile();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -34,6 +34,9 @@ export class UserInfoDialog {
|
|||||||
apsImage = element(by.css('img[id="bpm-user-detail-image"]'));
|
apsImage = element(by.css('img[id="bpm-user-detail-image"]'));
|
||||||
acsImage = element(by.css('img[id="ecm-user-detail-image"]'));
|
acsImage = element(by.css('img[id="ecm-user-detail-image"]'));
|
||||||
initialImage = element.all(by.css('div[id="user-initials-image"]')).first();
|
initialImage = element.all(by.css('div[id="user-initials-image"]')).first();
|
||||||
|
userInfoSsoHeaderTitle = this.dialog.element(by.css('div[id="identity-username"]'));
|
||||||
|
userInfoSsoTitle = element(by.css('.adf-userinfo__detail-title'));
|
||||||
|
ssoEmail = element(by.id('identity-email'));
|
||||||
|
|
||||||
dialogIsDisplayed() {
|
dialogIsDisplayed() {
|
||||||
Util.waitUntilElementIsVisible(this.dialog);
|
Util.waitUntilElementIsVisible(this.dialog);
|
||||||
@@ -103,6 +106,21 @@ export class UserInfoDialog {
|
|||||||
return this.processTenant.getText();
|
return this.processTenant.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSsoHeaderTitle () {
|
||||||
|
Util.waitUntilElementIsVisible(this.userInfoSsoHeaderTitle);
|
||||||
|
return this.userInfoSsoHeaderTitle.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
getSsoTitle() {
|
||||||
|
Util.waitUntilElementIsVisible(this.userInfoSsoTitle);
|
||||||
|
return this.userInfoSsoTitle.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
getSsoEmail() {
|
||||||
|
Util.waitUntilElementIsVisible(this.ssoEmail);
|
||||||
|
return this.ssoEmail.getText();
|
||||||
|
}
|
||||||
|
|
||||||
closeUserProfile() {
|
closeUserProfile() {
|
||||||
Util.waitUntilElementIsVisible(this.dialog);
|
Util.waitUntilElementIsVisible(this.dialog);
|
||||||
browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
|
browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
|
||||||
|
Reference in New Issue
Block a user