mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Enable tests and add a newly created user to run the tests. (#4796)
* enabled tests and added the new user to run the tests. * lint fix * adding a new user and add the user to hr group which will be used when deploying the apps. * Test commit * adding a new user and add the user to hr group which will be used when deploying the apps. * linting fixes * crc's moved the roles constants to identityService. * crc's moved the roles constants to identityService. * wrapped the createIdentityUser and assign Role calls into 1 method and used in the tests. * wrapped the createIdentityUser and assign Role calls into 1 method and used in the tests. * Added a method in identityService to pass the required roles to be added in a string array. * linting fixes * added the command line arguments to run the e2e tests -identity_admin_email and -identity_admin_password * added the command line arguments to run the e2e tests -identity_admin_email and -identity_admin_password * crc's, removed the step to add user to the hr group, as not needed in this test. * renamed the E2E travis variable to end with identity. * replaced the candidateuserapp with candidatebaseapp * replaced candidateuserapp with candidatebaseapp * replaced candidateuserapp with candidatebaseapp * replaced candidateuserapp with candidatebaseapp * timeout wait for the test to pass. * crc's
This commit is contained in:
committed by
Eugenio Romano
parent
3d73e94b5d
commit
e65e32e0cf
@@ -28,12 +28,21 @@ export class IdentityService {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
async createActivitiUserWithRole(apiService, role: string = 'ACTIVITI_USER') {
|
||||
roles = {
|
||||
aps_user: 'APS_USER',
|
||||
activiti_user: 'ACTIVITI_USER',
|
||||
aps_admin: 'APS_ADMIN',
|
||||
activiti_admin: 'ACTIVITI_ADMIN'
|
||||
};
|
||||
|
||||
async createIdentityUserWithRole(apiService: ApiService, roles: string[]) {
|
||||
const rolesService = new RolesService(apiService);
|
||||
const apsUser = await this.createIdentityUser();
|
||||
const apsUserRoleId = await rolesService.getRoleIdByRoleName(role);
|
||||
await this.assignRole(apsUser.idIdentityService, apsUserRoleId, role);
|
||||
return apsUser;
|
||||
const user = await this.createIdentityUser();
|
||||
for (let i = 0; i < roles.length; i++) {
|
||||
const roleId = await rolesService.getRoleIdByRoleName(roles[i]);
|
||||
await this.assignRole(user.idIdentityService, roleId, roles[i]);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
async createIdentityUser(user: UserModel = new UserModel()) {
|
||||
@@ -106,7 +115,7 @@ export class IdentityService {
|
||||
async getUserInfoByUsername(username) {
|
||||
const path = `/users`;
|
||||
const method = 'GET';
|
||||
const queryParams = { 'username': username }, postBody = {};
|
||||
const queryParams = {'username': username}, postBody = {};
|
||||
|
||||
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
|
||||
return data[0];
|
||||
@@ -116,16 +125,30 @@ export class IdentityService {
|
||||
const path = `/users/${id}/reset-password`;
|
||||
const method = 'PUT';
|
||||
const queryParams = {},
|
||||
postBody = { 'type': 'password', 'value': password, 'temporary': false };
|
||||
postBody = {'type': 'password', 'value': password, 'temporary': false};
|
||||
|
||||
return await this.api.performIdentityOperation(path, method, queryParams, postBody);
|
||||
}
|
||||
|
||||
async addUserToGroup(userId, groupId) {
|
||||
try {
|
||||
const path = `/users/${userId}/groups/${groupId}`;
|
||||
const method = 'PUT';
|
||||
const queryParams = {},
|
||||
postBody = {'realm': 'alfresco', 'userId': userId, 'groupId': groupId};
|
||||
|
||||
return await this.api.performIdentityOperation(path, method, queryParams, postBody);
|
||||
} catch (error) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log('Add User To Group - Service error, Response: ', JSON.parse(JSON.stringify(error)));
|
||||
}
|
||||
}
|
||||
|
||||
async assignRole(userId, roleId, roleName) {
|
||||
const path = `/users/${userId}/role-mappings/realm`;
|
||||
const method = 'POST';
|
||||
const queryParams = {},
|
||||
postBody = [{ 'id': roleId, 'name': roleName }];
|
||||
postBody = [{'id': roleId, 'name': roleName}];
|
||||
|
||||
return await this.api.performIdentityOperation(path, method, queryParams, postBody);
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ export class TasksService {
|
||||
return await this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||
} catch (error) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log('Create Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
|
||||
console.log('Create Task - Service error, Response: ', JSON.parse(JSON.stringify(error)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -44,4 +44,12 @@ export class ProcessDefinitionsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getProcessDefinitionByName(processDefinitionName: string, appName: string) {
|
||||
const processDefinitions = await this.getProcessDefinitions(appName);
|
||||
return processDefinitions.list.entries.find((el) => {
|
||||
if (el.entry.name === processDefinitionName) {
|
||||
return el;
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user